From ce0352eff41877c9a47559b0f22394da3184d444 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Fri, 13 Aug 2021 21:38:12 +0200 Subject: [PATCH] Disable std::regex use for older gcc versions --- src/common/conf_post.h | 7 +++++++ src/query/plaintorich.cpp | 7 +++++++ src/rcldb/rclabsfromtext.cpp | 7 +++++++ src/utils/pathut.cpp | 2 ++ 4 files changed, 23 insertions(+) diff --git a/src/common/conf_post.h b/src/common/conf_post.h index fcdc688e..eac832c0 100644 --- a/src/common/conf_post.h +++ b/src/common/conf_post.h @@ -67,4 +67,11 @@ typedef int ssize_t; # define PRETEND_USE(expr) ((void)(expr)) #endif /* PRETEND_USE */ +#ifdef __GNUC__ +#include +#if ! __GNUC_PREREQ(6,0) +#define NO_STD_REGEX 1 +#endif +#endif + #endif /* INCLUDED */ diff --git a/src/query/plaintorich.cpp b/src/query/plaintorich.cpp index 86352b4a..85810e41 100644 --- a/src/query/plaintorich.cpp +++ b/src/query/plaintorich.cpp @@ -154,6 +154,7 @@ bool TextSplitPTR::matchGroups() return true; } +#ifndef NO_STD_REGEX // Replace HTTP(s) urls in text/plain with proper HTML anchors so that // they become clickable in the preview. We don't make a lot of effort // for validating, or catching things which are probably urls but miss @@ -165,6 +166,12 @@ static string activate_urls(const string& in) { return std::regex_replace(in, url_re, urlRep); } +#else +static string activate_urls(const string& in) +{ + return in; +} +#endif // Fix result text for display inside the gui text window. // diff --git a/src/rcldb/rclabsfromtext.cpp b/src/rcldb/rclabsfromtext.cpp index cb578c3e..32783b1f 100644 --- a/src/rcldb/rclabsfromtext.cpp +++ b/src/rcldb/rclabsfromtext.cpp @@ -52,6 +52,7 @@ using namespace std; namespace Rcl { +#ifndef NO_STD_REGEX //// Fragment cleanup // Chars we turn to spaces in the Snippets static const string cstr_nc("\n\r\x0c\\"); @@ -65,6 +66,12 @@ static string fixfrag(const string& infrag) { return std::regex_replace(neutchars(infrag, cstr_nc), fixfrag_re, punctRep); } +#else +static string fixfrag(const string& infrag) +{ + return infrag; +} +#endif // Fragment descriptor. A fragment is a text area with one or several diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp index 80e502b1..2f81649a 100644 --- a/src/utils/pathut.cpp +++ b/src/utils/pathut.cpp @@ -1210,6 +1210,7 @@ bool urlisfileurl(const string& url) return url.find("file://") == 0; } +#ifndef NO_STD_REGEX static std::regex re_uriparse("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?", std::regex::extended); @@ -1299,6 +1300,7 @@ ParsedUri::ParsedUri(std::string uri) fragment = mr[9].str(); } } +#endif // NO_STD_REGEX /// Directory reading interface. UTF-8 on Windows. class PathDirContents::Internal {