From 394e1bf99c7dc9ab2912665a441a11b6e947bdd7 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sun, 28 Dec 2014 18:08:18 +0100 Subject: [PATCH] Use std::regex if possible It works with gcc >= 4.9.0 and clang (with libc++ or gcc libstdc++ from gcc >= 4.9.0). The MSVC parg is missing, because I cannot test it, and the autotools build still link against boost::regex even if it is not needed, but I don't know how to fix that. --- CMakeLists.txt | 6 ++---- configure.ac | 11 +++++------ src/support/regex.h | 2 ++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5409746276..294dbe4c1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,12 +246,11 @@ set(LYX_GCC11_MODE) if(UNIX OR MINGW) execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) message(STATUS "Using GCC version ${GCC_VERSION}") -# disabled because of missing match_partial -# if(GCC_VERSION VERSION_LESS 4.9) + if(GCC_VERSION VERSION_LESS 4.9) # in gcc is unusable in versions less than 4.9.0 # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631 set(LYX_USE_STD_REGEX 0) -# endif() + endif() if (LYX_ENABLE_CXX11) find_package(CXX11Compiler) if(NOT CXX11COMPILER_FOUND) @@ -260,7 +259,6 @@ if(UNIX OR MINGW) set(LYX_GCC11_MODE "${CXX11_FLAG}") endif() else() -# disabled because of missing match_partial set(LYX_USE_STD_REGEX 0) # if(MSVC10) # set(LYX_USE_STD_REGEX 1) #TODO should we use it in ECMAScript mode? diff --git a/configure.ac b/configure.ac index 6a735b1a5c..77fe598f8b 100644 --- a/configure.ac +++ b/configure.ac @@ -287,12 +287,11 @@ char * strerror(int n); // in gcc is unusable in versions less than 4.9.0 // see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631 // clang defines __GNUC__ but how do the versions match? -// disabled because of missing match_partial -//#ifndef LYX_USE_STD_REGEX -//# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __GNUC__ > 4 || defined(USE_LLVM_LIBCPP) -//# define LYX_USE_STD_REGEX -//# endif -//#endif +#ifndef LYX_USE_STD_REGEX +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __GNUC__ > 4 || defined(USE_LLVM_LIBCPP) +# define LYX_USE_STD_REGEX +# endif +#endif #ifdef __CYGWIN__ # define NOMINMAX diff --git a/src/support/regex.h b/src/support/regex.h index 04f93cac5a..7c64caf432 100644 --- a/src/support/regex.h +++ b/src/support/regex.h @@ -18,6 +18,8 @@ namespace lyx { // inheriting 'private' to see which functions are used and if there are // other ECMAScrip defaults + // FIXME: Is this really needed? + // If yes, then the MSVC regex implementation is not standard-conforming. class regex : private std::regex { public: -- 2.39.2