Disable std::regex use for older gcc versions

This commit is contained in:
Jean-Francois Dockes 2021-08-13 21:38:12 +02:00
parent f91185fd53
commit ce0352eff4
4 changed files with 23 additions and 0 deletions

View File

@ -67,4 +67,11 @@ typedef int ssize_t;
# define PRETEND_USE(expr) ((void)(expr))
#endif /* PRETEND_USE */
#ifdef __GNUC__
#include <features.h>
#if ! __GNUC_PREREQ(6,0)
#define NO_STD_REGEX 1
#endif
#endif
#endif /* INCLUDED */

View File

@ -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.
//

View File

@ -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

View File

@ -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 {