]> git.lyx.org Git - lyx.git/commitdiff
Always use std::regex
authorYuriy Skalko <yuriy.skalko@gmail.com>
Sat, 21 Nov 2020 18:11:23 +0000 (20:11 +0200)
committerYuriy Skalko <yuriy.skalko@gmail.com>
Fri, 27 Nov 2020 10:39:59 +0000 (12:39 +0200)
Since now minimum supported GCC is 4.9.

3rdparty/Makefile.am
3rdparty/boost/libs/CMakeLists.txt
CMakeLists.txt
config/lyxinclude.m4
development/cmake/config.h.cmake
src/frontends/qt/GuiCitation.cpp
src/frontends/tests/biblio.cpp
src/support/regex.h

index e21e1cbc01c79a55abb8ae6ac10409b8656ea4da..ec12adb8831245140c00011b9256aa66621437f5 100644 (file)
@@ -3,11 +3,8 @@ include $(top_srcdir)/config/common.am
 DIST_SUBDIRS = boost dtl hunspell mythes libiconv zlib
 
 if USE_INCLUDED_BOOST
-if LYX_USE_STD_REGEX
-else
 BOOST = boost
 endif
-endif
 
 if USE_INCLUDED_HUNSPELL
 HUNSPELL = hunspell
index d2fdd7f64449210e015474b6d24bb35d3da7cdc9..84da81e65e1392b494498e7ae611107413e53ec0 100644 (file)
@@ -6,10 +6,4 @@
 
 project(boost)
 
-
-if(LYX_USE_STD_REGEX)
-       message(STATUS "Using std regex")
-else()
-       add_subdirectory(regex) 
-endif()
-
+message(STATUS "Using std regex")
index b35f2f5f8bb37ab1eba31f767bdf878b2f649322..02a1b3000db773d74ea4fdf8114472b846107f4f 100644 (file)
@@ -380,13 +380,7 @@ unset(LYX_GCC11_MODE)
 if(UNIX OR MINGW)
        if (CMAKE_CXX_COMPILER_ID MATCHES "^([cC]lang|AppleClang)$")
          # ignore the GCC_VERSION for clang
-         # and use the resulting CXX11_STD_REGEX found in FindCXX11Compiler.cmake
          message(STATUS "Using clang")
-         if(CXX11_STD_REGEX)
-           set(LYX_USE_STD_REGEX 1)
-         else()
-           set(LYX_USE_STD_REGEX 0)
-         endif()
        else()
          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}")
@@ -399,7 +393,6 @@ if(UNIX OR MINGW)
          if(GCC_VERSION VERSION_LESS 4.9)
                message(FATAL_ERROR "gcc >= 4.9 is required.")
          endif()
-         set(LYX_USE_STD_REGEX 1)
        endif()
        set(LYX_GCC11_MODE "${CXX11_FLAG}")
 else()
@@ -407,7 +400,6 @@ else()
                # Drop support for msvc versions prior to 1900 (Visual Studio 2015)
                message(FATAL_ERROR "Visual Studio >= 2015 is required.")
        endif()
-       set(LYX_USE_STD_REGEX 1)
 endif()
 
 if(LYX_3RDPARTY_BUILD)
@@ -941,40 +933,12 @@ if(NOT LYX_EXTERNAL_DTL)
   add_subdirectory(3rdparty/dtl)
 endif()
 
-if(LYX_USE_STD_REGEX)
-  # Set only include path.
-  # Use internal boost, which is known to exist
-  # we don't need any libraries
-  set(Lyx_Boost_Libraries)
-  add_definitions(-DBOOST_USER_CONFIG=<config.h>)
-  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()
+# Set only include path.
+# Use internal boost, which is known to exist
+# we don't need any libraries
+set(Lyx_Boost_Libraries)
+add_definitions(-DBOOST_USER_CONFIG=<config.h>)
+include_directories(${TOP_SRC_DIR}/3rdparty/boost)
 
 if(WIN32)
        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}")
 endif()
 
-if (NOT HAVE_REGEX)
-       set(LYX_USE_STD_REGEX 0)
-endif()
-
 
 set (cmd ${CMAKE_CTEST_COMMAND})
 if (MSVC)
index 268c501dea4cd973e691d0bc123501bd2e96aa6b..46b56171e41e56ce27695f87ebef36f0863b9a92 100644 (file)
@@ -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 check whether we can use std::call_once and set the
 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_LIB_STDCXX
 LYX_LIB_STDCXX_CXX11_ABI
-LYX_CXX_USE_REGEX
 LYX_CXX_USE_CALL_ONCE
 AC_LANG_POP(C++)
 
index 35124161fde9ce37dc5d645e6efa4c5cc03235a8..15bceaac46e728ff0c71069360d1627d65cf4920 100644 (file)
@@ -50,8 +50,6 @@
 
 #cmakedefine LYX_MERGE_FILES 1
 
-#cmakedefine LYX_USE_STD_REGEX 1
-
 // Define if callstack can be printed
 #cmakedefine LYX_CALLSTACK_PRINTING 1
 
index c66a6d372ce686a1166fe470c248d5e6f13448de..7a402ed9752e26a823fbe745bae276e4ff137591 100644 (file)
@@ -991,19 +991,10 @@ static docstring escape_special_chars(docstring const & expr)
 
        // $& is an ECMAScript format expression that expands to all
        // of the current match
-#ifdef LYX_USE_STD_REGEX
        // To prefix a matched expression with a single literal backslash, we
        // need to escape it for the C++ compiler and use:
        // FIXME: UNICODE
        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
 }
 
 
index 97ae4a9eb7ed0b1734ea67528da25096d592c748..3696598a3f4c7c130560af2e25f8c5a25d1fb124 100644 (file)
@@ -20,17 +20,9 @@ string const escape_special_chars(string const & expr)
 
        // $& is a ECMAScript format expression that expands to all
        // of the current match
-#ifdef LYX_USE_STD_REGEX
        // To prefix a matched expression with a single literal backslash, we
        // need to escape it for the C++ compiler and use:
        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
 }
 
 
index 96498708fcee8047a44ab9ada5c369bfbb7c2f53..491044ca1f857f353e1843506aee00a85b75fc83 100644 (file)
 #ifndef LYX_REGEXP_H
 #define LYX_REGEXP_H
 
-#ifdef LYX_USE_STD_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
+#include <regex>
 
 namespace lyx {
-using LR_NS::regex;
-using LR_NS::regex_match;
-using LR_NS::regex_replace;
-using LR_NS::regex_search;
-using LR_NS::sregex_iterator;
-using LR_NS::smatch;
-using LR_NS::basic_regex;
-using LR_NS::regex_error;
-using LR_NS::match_results;
+
+using std::regex;
+using std::regex_match;
+using std::regex_replace;
+using std::regex_search;
+using std::sregex_iterator;
+using std::smatch;
+using std::basic_regex;
+using std::regex_error;
+using std::match_results;
 
 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 lyx
 
-#undef LR_NS
-
-#ifdef LYX_USE_STD_REGEX
 // Match Begin and End of String when using ECMAScript (default std::regex)
 #define REGEX_BOS "^"
 #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