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.
This commit is contained in:
Georg Baum 2014-12-28 18:08:18 +01:00
parent dae8555234
commit 394e1bf99c
3 changed files with 9 additions and 10 deletions

View File

@ -246,12 +246,11 @@ set(LYX_GCC11_MODE)
if(UNIX OR MINGW) if(UNIX OR MINGW)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
message(STATUS "Using GCC version ${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 # <regex> in gcc is unusable in versions less than 4.9.0
# see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631 # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
set(LYX_USE_STD_REGEX 0) set(LYX_USE_STD_REGEX 0)
# endif() endif()
if (LYX_ENABLE_CXX11) if (LYX_ENABLE_CXX11)
find_package(CXX11Compiler) find_package(CXX11Compiler)
if(NOT CXX11COMPILER_FOUND) if(NOT CXX11COMPILER_FOUND)
@ -260,7 +259,6 @@ if(UNIX OR MINGW)
set(LYX_GCC11_MODE "${CXX11_FLAG}") set(LYX_GCC11_MODE "${CXX11_FLAG}")
endif() endif()
else() else()
# disabled because of missing match_partial
set(LYX_USE_STD_REGEX 0) set(LYX_USE_STD_REGEX 0)
# if(MSVC10) # if(MSVC10)
# set(LYX_USE_STD_REGEX 1) #TODO should we use it in ECMAScript mode? # set(LYX_USE_STD_REGEX 1) #TODO should we use it in ECMAScript mode?

View File

@ -287,12 +287,11 @@ char * strerror(int n);
// <regex> in gcc is unusable in versions less than 4.9.0 // <regex> in gcc is unusable in versions less than 4.9.0
// see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631 // see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
// clang defines __GNUC__ but how do the versions match? // clang defines __GNUC__ but how do the versions match?
// disabled because of missing match_partial #ifndef LYX_USE_STD_REGEX
//#ifndef LYX_USE_STD_REGEX # if (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __GNUC__ > 4 || defined(USE_LLVM_LIBCPP)
//# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __GNUC__ > 4 || defined(USE_LLVM_LIBCPP) # define LYX_USE_STD_REGEX
//# define LYX_USE_STD_REGEX # endif
//# endif #endif
//#endif
#ifdef __CYGWIN__ #ifdef __CYGWIN__
# define NOMINMAX # define NOMINMAX

View File

@ -18,6 +18,8 @@
namespace lyx { namespace lyx {
// inheriting 'private' to see which functions are used and if there are // inheriting 'private' to see which functions are used and if there are
// other ECMAScrip defaults // other ECMAScrip defaults
// FIXME: Is this really needed?
// If yes, then the MSVC regex implementation is not standard-conforming.
class regex : private std::regex class regex : private std::regex
{ {
public: public: