mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Always use std::regex
Since now minimum supported GCC is 4.9.
This commit is contained in:
parent
b4b2d01ea7
commit
f3ec89cfa1
3
3rdparty/Makefile.am
vendored
3
3rdparty/Makefile.am
vendored
@ -3,11 +3,8 @@ include $(top_srcdir)/config/common.am
|
|||||||
DIST_SUBDIRS = boost dtl hunspell mythes libiconv zlib
|
DIST_SUBDIRS = boost dtl hunspell mythes libiconv zlib
|
||||||
|
|
||||||
if USE_INCLUDED_BOOST
|
if USE_INCLUDED_BOOST
|
||||||
if LYX_USE_STD_REGEX
|
|
||||||
else
|
|
||||||
BOOST = boost
|
BOOST = boost
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
|
|
||||||
if USE_INCLUDED_HUNSPELL
|
if USE_INCLUDED_HUNSPELL
|
||||||
HUNSPELL = hunspell
|
HUNSPELL = hunspell
|
||||||
|
8
3rdparty/boost/libs/CMakeLists.txt
vendored
8
3rdparty/boost/libs/CMakeLists.txt
vendored
@ -6,10 +6,4 @@
|
|||||||
|
|
||||||
project(boost)
|
project(boost)
|
||||||
|
|
||||||
|
message(STATUS "Using std regex")
|
||||||
if(LYX_USE_STD_REGEX)
|
|
||||||
message(STATUS "Using std regex")
|
|
||||||
else()
|
|
||||||
add_subdirectory(regex)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
@ -380,13 +380,7 @@ unset(LYX_GCC11_MODE)
|
|||||||
if(UNIX OR MINGW)
|
if(UNIX OR MINGW)
|
||||||
if (CMAKE_CXX_COMPILER_ID MATCHES "^([cC]lang|AppleClang)$")
|
if (CMAKE_CXX_COMPILER_ID MATCHES "^([cC]lang|AppleClang)$")
|
||||||
# ignore the GCC_VERSION for clang
|
# ignore the GCC_VERSION for clang
|
||||||
# and use the resulting CXX11_STD_REGEX found in FindCXX11Compiler.cmake
|
|
||||||
message(STATUS "Using clang")
|
message(STATUS "Using clang")
|
||||||
if(CXX11_STD_REGEX)
|
|
||||||
set(LYX_USE_STD_REGEX 1)
|
|
||||||
else()
|
|
||||||
set(LYX_USE_STD_REGEX 0)
|
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpfullversion OUTPUT_VARIABLE GCC_VERSION ERROR_VARIABLE _error RESULT_VARIABLE _err OUTPUT_STRIP_TRAILING_WHITESPACE)
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpfullversion OUTPUT_VARIABLE GCC_VERSION ERROR_VARIABLE _error RESULT_VARIABLE _err OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
#message(STATUS "dumpfullversion: error = ${_error}, result = ${_err}")
|
#message(STATUS "dumpfullversion: error = ${_error}, result = ${_err}")
|
||||||
@ -399,7 +393,6 @@ if(UNIX OR MINGW)
|
|||||||
if(GCC_VERSION VERSION_LESS 4.9)
|
if(GCC_VERSION VERSION_LESS 4.9)
|
||||||
message(FATAL_ERROR "gcc >= 4.9 is required.")
|
message(FATAL_ERROR "gcc >= 4.9 is required.")
|
||||||
endif()
|
endif()
|
||||||
set(LYX_USE_STD_REGEX 1)
|
|
||||||
endif()
|
endif()
|
||||||
set(LYX_GCC11_MODE "${CXX11_FLAG}")
|
set(LYX_GCC11_MODE "${CXX11_FLAG}")
|
||||||
else()
|
else()
|
||||||
@ -407,7 +400,6 @@ else()
|
|||||||
# Drop support for msvc versions prior to 1900 (Visual Studio 2015)
|
# Drop support for msvc versions prior to 1900 (Visual Studio 2015)
|
||||||
message(FATAL_ERROR "Visual Studio >= 2015 is required.")
|
message(FATAL_ERROR "Visual Studio >= 2015 is required.")
|
||||||
endif()
|
endif()
|
||||||
set(LYX_USE_STD_REGEX 1)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LYX_3RDPARTY_BUILD)
|
if(LYX_3RDPARTY_BUILD)
|
||||||
@ -941,40 +933,12 @@ if(NOT LYX_EXTERNAL_DTL)
|
|||||||
add_subdirectory(3rdparty/dtl)
|
add_subdirectory(3rdparty/dtl)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LYX_USE_STD_REGEX)
|
# Set only include path.
|
||||||
# Set only include path.
|
# Use internal boost, which is known to exist
|
||||||
# Use internal boost, which is known to exist
|
# we don't need any libraries
|
||||||
# we don't need any libraries
|
set(Lyx_Boost_Libraries)
|
||||||
set(Lyx_Boost_Libraries)
|
add_definitions(-DBOOST_USER_CONFIG=<config.h>)
|
||||||
add_definitions(-DBOOST_USER_CONFIG=<config.h>)
|
include_directories(${TOP_SRC_DIR}/3rdparty/boost)
|
||||||
include_directories(${TOP_SRC_DIR}/3rdparty/boost)
|
|
||||||
else()
|
|
||||||
# Using boost-regex
|
|
||||||
if(LYX_EXTERNAL_BOOST)
|
|
||||||
message(STATUS "Searching for external boost")
|
|
||||||
find_package(Boost COMPONENTS regex)
|
|
||||||
if(Boost_FOUND)
|
|
||||||
message(STATUS "Boost found")
|
|
||||||
message(STATUS "Boost-libs = ${Boost_LIBRARIES}")
|
|
||||||
set(Lyx_Boost_Libraries ${Boost_LIBRARIES})
|
|
||||||
if (LYX_STDLIB_DEBUG OR LYX_DEBUG_GLIBC OR LYX_DEBUG_GLIBC_PEDANTIC)
|
|
||||||
# Comment from Jean-Marc Lasgouttes:
|
|
||||||
# In general, system boost libraries are incompatible with
|
|
||||||
# the use of stdlib-debug in libstdc++. See ticket #9736 for
|
|
||||||
# details.
|
|
||||||
message(FATAL_ERROR "Compiling LyX with stdlib-debug and system boost libraries may lead to crashes. Consider using '-DLYX_STDLIB_DEBUG=OFF -DLYX_DEBUG_GLIBC=OFF -DLYX_DEBUG_GLIBC_PEDANTIC=OFF' or using '-DLYX_EXTERNAL_BOOST=OFF'")
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Boost not found" ${Boost_ERROR_REASON})
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
# Using included boost
|
|
||||||
set(Lyx_Boost_Libraries boost_regex)
|
|
||||||
add_definitions(-DBOOST_USER_CONFIG=<config.h>)
|
|
||||||
include_directories(${TOP_SRC_DIR}/3rdparty/boost)
|
|
||||||
add_subdirectory(3rdparty/boost "${TOP_BINARY_DIR}/3rdparty/boost")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
if(LYX_CONSOLE)
|
if(LYX_CONSOLE)
|
||||||
@ -1175,10 +1139,6 @@ if(QTVERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*")
|
|||||||
MATH(EXPR QT4_VERSION "(${CMAKE_MATCH_1}<<16)|(${CMAKE_MATCH_2}<<8)|${CMAKE_MATCH_3}")
|
MATH(EXPR QT4_VERSION "(${CMAKE_MATCH_1}<<16)|(${CMAKE_MATCH_2}<<8)|${CMAKE_MATCH_3}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT HAVE_REGEX)
|
|
||||||
set(LYX_USE_STD_REGEX 0)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
set (cmd ${CMAKE_CTEST_COMMAND})
|
set (cmd ${CMAKE_CTEST_COMMAND})
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
|
@ -213,46 +213,6 @@ AC_DEFUN([LYX_CXX_CXX11_FLAGS],
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
dnl Usage: LYX_CXX_USE_REGEX
|
|
||||||
dnl decide whether we want to use std::regex and set the
|
|
||||||
dnl LYX_USE_STD_REGEX macro and conditional accordingly.
|
|
||||||
AC_DEFUN([LYX_CXX_USE_REGEX],
|
|
||||||
[AC_ARG_ENABLE(std-regex,
|
|
||||||
AS_HELP_STRING([--enable-std-regex],[use std::regex instead of boost::regex (default is autodetected)]),
|
|
||||||
[lyx_std_regex=$enableval],
|
|
||||||
[AC_MSG_CHECKING([for correct regex implementation])
|
|
||||||
save_CPPFLAGS=$CPPFLAGS
|
|
||||||
CPPFLAGS="$AM_CPPFLAGS $CPPFLAGS"
|
|
||||||
save_CXXFLAGS=$CXXFLAGS
|
|
||||||
CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
|
|
||||||
# The following code snippet has been taken taken from example in
|
|
||||||
# http://stackoverflow.com/questions/8561850/compile-stdregex-iterator-with-gcc
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
#include <regex>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
typedef std::regex_iterator<const char *> Myiter;
|
|
||||||
]], [[
|
|
||||||
const char *pat = "axayaz";
|
|
||||||
Myiter::regex_type rx("a");
|
|
||||||
Myiter next(pat, pat + strlen(pat), rx);
|
|
||||||
Myiter end;
|
|
||||||
]])],[lyx_std_regex=yes],[lyx_std_regex=no])
|
|
||||||
CXXFLAGS=$save_CXXFLAGS
|
|
||||||
CPPFLAGS=$save_CPPFLAGS
|
|
||||||
AC_MSG_RESULT([$lyx_std_regex])
|
|
||||||
])
|
|
||||||
|
|
||||||
if test $lyx_std_regex = yes ; then
|
|
||||||
lyx_flags="$lyx_flags std-regex"
|
|
||||||
AC_DEFINE([LYX_USE_STD_REGEX], 1, [define to 1 if std::regex should be preferred to boost::regex])
|
|
||||||
fi
|
|
||||||
AM_CONDITIONAL([LYX_USE_STD_REGEX], test $lyx_std_regex = yes)
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
dnl Usage: LYX_CXX_USE_CALL_ONCE
|
dnl Usage: LYX_CXX_USE_CALL_ONCE
|
||||||
dnl check whether we can use std::call_once and set the
|
dnl check whether we can use std::call_once and set the
|
||||||
dnl LYX_USE_STD_CALL_ONCE macro and conditional accordingly.
|
dnl LYX_USE_STD_CALL_ONCE macro and conditional accordingly.
|
||||||
@ -319,7 +279,6 @@ LYX_PROG_CLANG
|
|||||||
LYX_CXX_CXX11_FLAGS($enable_cxx_mode)
|
LYX_CXX_CXX11_FLAGS($enable_cxx_mode)
|
||||||
LYX_LIB_STDCXX
|
LYX_LIB_STDCXX
|
||||||
LYX_LIB_STDCXX_CXX11_ABI
|
LYX_LIB_STDCXX_CXX11_ABI
|
||||||
LYX_CXX_USE_REGEX
|
|
||||||
LYX_CXX_USE_CALL_ONCE
|
LYX_CXX_USE_CALL_ONCE
|
||||||
AC_LANG_POP(C++)
|
AC_LANG_POP(C++)
|
||||||
|
|
||||||
|
@ -50,8 +50,6 @@
|
|||||||
|
|
||||||
#cmakedefine LYX_MERGE_FILES 1
|
#cmakedefine LYX_MERGE_FILES 1
|
||||||
|
|
||||||
#cmakedefine LYX_USE_STD_REGEX 1
|
|
||||||
|
|
||||||
// Define if callstack can be printed
|
// Define if callstack can be printed
|
||||||
#cmakedefine LYX_CALLSTACK_PRINTING 1
|
#cmakedefine LYX_CALLSTACK_PRINTING 1
|
||||||
|
|
||||||
|
@ -991,19 +991,10 @@ static docstring escape_special_chars(docstring const & expr)
|
|||||||
|
|
||||||
// $& is an ECMAScript format expression that expands to all
|
// $& is an ECMAScript format expression that expands to all
|
||||||
// of the current match
|
// of the current match
|
||||||
#ifdef LYX_USE_STD_REGEX
|
|
||||||
// To prefix a matched expression with a single literal backslash, we
|
// To prefix a matched expression with a single literal backslash, we
|
||||||
// need to escape it for the C++ compiler and use:
|
// need to escape it for the C++ compiler and use:
|
||||||
// FIXME: UNICODE
|
// FIXME: UNICODE
|
||||||
return from_utf8(lyx::regex_replace(to_utf8(expr), reg, string("\\$&")));
|
return from_utf8(lyx::regex_replace(to_utf8(expr), reg, string("\\$&")));
|
||||||
#else
|
|
||||||
// A backslash in the format string starts an escape sequence in boost.
|
|
||||||
// Thus, to prefix a matched expression with a single literal backslash,
|
|
||||||
// we need to give two backslashes to the regex engine, and escape both
|
|
||||||
// for the C++ compiler and use:
|
|
||||||
// FIXME: UNICODE
|
|
||||||
return from_utf8(lyx::regex_replace(to_utf8(expr), reg, string("\\\\$&")));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,17 +20,9 @@ string const escape_special_chars(string const & expr)
|
|||||||
|
|
||||||
// $& is a ECMAScript format expression that expands to all
|
// $& is a ECMAScript format expression that expands to all
|
||||||
// of the current match
|
// of the current match
|
||||||
#ifdef LYX_USE_STD_REGEX
|
|
||||||
// To prefix a matched expression with a single literal backslash, we
|
// To prefix a matched expression with a single literal backslash, we
|
||||||
// need to escape it for the C++ compiler and use:
|
// need to escape it for the C++ compiler and use:
|
||||||
return lyx::regex_replace(expr, reg, "\\$&");
|
return lyx::regex_replace(expr, reg, "\\$&");
|
||||||
#else
|
|
||||||
// A backslash in the format string starts an escape sequence in boost.
|
|
||||||
// Thus, to prefix a matched expression with a single literal backslash,
|
|
||||||
// we need to give two backslashes to the regex engine, and escape both
|
|
||||||
// for the C++ compiler and use:
|
|
||||||
return lyx::regex_replace(expr, reg, "\\\\$&");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,45 +12,32 @@
|
|||||||
#ifndef LYX_REGEXP_H
|
#ifndef LYX_REGEXP_H
|
||||||
#define LYX_REGEXP_H
|
#define LYX_REGEXP_H
|
||||||
|
|
||||||
#ifdef LYX_USE_STD_REGEX
|
#include <regex>
|
||||||
# include <regex>
|
|
||||||
// <regex> in gcc is unusable in versions less than 4.9.0
|
|
||||||
// see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
|
|
||||||
# define LR_NS std
|
|
||||||
#else
|
|
||||||
# include <boost/regex.hpp>
|
|
||||||
# define LR_NS boost
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
using LR_NS::regex;
|
|
||||||
using LR_NS::regex_match;
|
using std::regex;
|
||||||
using LR_NS::regex_replace;
|
using std::regex_match;
|
||||||
using LR_NS::regex_search;
|
using std::regex_replace;
|
||||||
using LR_NS::sregex_iterator;
|
using std::regex_search;
|
||||||
using LR_NS::smatch;
|
using std::sregex_iterator;
|
||||||
using LR_NS::basic_regex;
|
using std::smatch;
|
||||||
using LR_NS::regex_error;
|
using std::basic_regex;
|
||||||
using LR_NS::match_results;
|
using std::regex_error;
|
||||||
|
using std::match_results;
|
||||||
|
|
||||||
namespace regex_constants
|
namespace regex_constants
|
||||||
{
|
{
|
||||||
using namespace LR_NS::regex_constants;
|
|
||||||
using LR_NS::regex_constants::match_flag_type;
|
using namespace std::regex_constants;
|
||||||
|
using std::regex_constants::match_flag_type;
|
||||||
|
|
||||||
} // namespace regex_constants
|
} // namespace regex_constants
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
#undef LR_NS
|
|
||||||
|
|
||||||
#ifdef LYX_USE_STD_REGEX
|
|
||||||
// Match Begin and End of String when using ECMAScript (default std::regex)
|
// Match Begin and End of String when using ECMAScript (default std::regex)
|
||||||
#define REGEX_BOS "^"
|
#define REGEX_BOS "^"
|
||||||
#define REGEX_EOS "$"
|
#define REGEX_EOS "$"
|
||||||
#else
|
|
||||||
// Match Begin and End of String when using Perl RE (default boost::regex)
|
|
||||||
#define REGEX_BOS "\\`"
|
|
||||||
#define REGEX_EOS "\\'"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif // LYX_REGEXP_H
|
||||||
|
Loading…
Reference in New Issue
Block a user