]> git.lyx.org Git - lyx.git/commitdiff
Use std::regex if possible
authorGeorg Baum <baum@lyx.org>
Sun, 28 Dec 2014 17:08:18 +0000 (18:08 +0100)
committerGeorg Baum <baum@lyx.org>
Sun, 28 Dec 2014 17:08:18 +0000 (18:08 +0100)
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
configure.ac
src/support/regex.h

index 5409746276c38fa259d8480ca71a5958dfe7059e..294dbe4c1e3bce58226f0ca9acc317f3ebb4fc3c 100644 (file)
@@ -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)
                # <regex> 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?
index 6a735b1a5ccf5e4be97b1b6cd1f9edff8cbb3f6a..77fe598f8b113bde5cb0955bb75b7e4ca644490d 100644 (file)
@@ -287,12 +287,11 @@ char * strerror(int n);
 // <regex> 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
index 04f93cac5a05ab881733a2dba156d71fd6fbd7a7..7c64caf43210a5c93437ba3d9438e2a95397baff 100644 (file)
@@ -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: