From 3d17bca4196670183ad45c0af369acf4acdc7d7e Mon Sep 17 00:00:00 2001 From: "Zane U. Ji" Date: Tue, 4 Oct 2022 19:04:08 +0800 Subject: [PATCH] Migrate to PCRE2 (Miriam Ruiz) --- ChangeLog | 3 ++ Makefile.in | 2 + configure | 100 +++++++++++++++++++++++++++++++++++++++--- configure.ac | 3 +- data/Makefile.in | 2 + m4/Makefile.in | 2 + src/.cproject | 28 ++++++------ src/Makefile.am | 5 ++- src/Makefile.in | 10 +++-- src/rule.cpp | 7 ++- src/rule.h | 3 +- src/wrapregex.cpp | 95 ++++++++++++++++++++------------------- src/wrapregex.h | 16 ++++--- src/xmlcopyeditor.iss | 2 +- 14 files changed, 193 insertions(+), 85 deletions(-) diff --git a/ChangeLog b/ChangeLog index b7320e0..8d7376c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ # Version number followed by the release date +1.3.1.0 + * Migrate to PCRE2 (Miriam Ruiz) + 1.3.0.0 2020/08/15 * Link against wxWidgets 3.0 * SSE2 compatible CPUs are required (xerces-c++) diff --git a/Makefile.in b/Makefile.in index 949054b..0483d0f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -286,6 +286,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PCRE2_CFLAGS = @PCRE2_CFLAGS@ +PCRE2_LIBS = @PCRE2_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ diff --git a/configure b/configure index 491f99d..023da25 100755 --- a/configure +++ b/configure @@ -666,6 +666,8 @@ GTK_CFLAGS ASPELL_LIBS ENCHANT_LIBS ENCHANT_CFLAGS +PCRE2_LIBS +PCRE2_CFLAGS XSLT_LIBS XSLT_CFLAGS XML2_LIBS @@ -872,6 +874,8 @@ XML2_CFLAGS XML2_LIBS XSLT_CFLAGS XSLT_LIBS +PCRE2_CFLAGS +PCRE2_LIBS ENCHANT_CFLAGS ENCHANT_LIBS GTK_CFLAGS @@ -1556,6 +1560,9 @@ Some influential environment variables: XML2_LIBS linker flags for XML2, overriding pkg-config XSLT_CFLAGS C compiler flags for XSLT, overriding pkg-config XSLT_LIBS linker flags for XSLT, overriding pkg-config + PCRE2_CFLAGS + C compiler flags for PCRE2, overriding pkg-config + PCRE2_LIBS linker flags for PCRE2, overriding pkg-config ENCHANT_CFLAGS C compiler flags for ENCHANT, overriding pkg-config ENCHANT_LIBS @@ -17801,15 +17808,98 @@ fi # Check pcre is available -ac_fn_c_check_header_compile "$LINENO" "pcre.h" "ac_cv_header_pcre_h" "$ac_includes_default" -if test "x$ac_cv_header_pcre_h" = xyes -then : -else $as_nop - as_fn_error $? "PCRE headers not found" "$LINENO" 5 +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libpcre2-8" >&5 +printf %s "checking for libpcre2-8... " >&6; } + +if test -n "$PCRE2_CFLAGS"; then + pkg_cv_PCRE2_CFLAGS="$PCRE2_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre2-8\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libpcre2-8") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PCRE2_CFLAGS=`$PKG_CONFIG --cflags "libpcre2-8" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$PCRE2_LIBS"; then + pkg_cv_PCRE2_LIBS="$PCRE2_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre2-8\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libpcre2-8") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PCRE2_LIBS=`$PKG_CONFIG --libs "libpcre2-8" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried fi + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + PCRE2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libpcre2-8" 2>&1` + else + PCRE2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libpcre2-8" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PCRE2_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (libpcre2-8) were not met: + +$PCRE2_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables PCRE2_CFLAGS +and PCRE2_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables PCRE2_CFLAGS +and PCRE2_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + PCRE2_CFLAGS=$pkg_cv_PCRE2_CFLAGS + PCRE2_LIBS=$pkg_cv_PCRE2_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + +fi + # Check boost::shared_ptr is available ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' diff --git a/configure.ac b/configure.ac index d0ab3af..1c1f0dd 100755 --- a/configure.ac +++ b/configure.ac @@ -72,8 +72,7 @@ AC_ARG_ENABLE(debug, ]) # Check pcre is available -AC_CHECK_HEADER(pcre.h, , - AC_MSG_ERROR([PCRE headers not found])) +PKG_CHECK_MODULES([PCRE2], [libpcre2-8]) # Check boost::shared_ptr is available AC_LANG(C++) diff --git a/data/Makefile.in b/data/Makefile.in index a5a6d83..ef623ce 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -239,6 +239,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PCRE2_CFLAGS = @PCRE2_CFLAGS@ +PCRE2_LIBS = @PCRE2_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ diff --git a/m4/Makefile.in b/m4/Makefile.in index eb92c2d..4db797e 100644 --- a/m4/Makefile.in +++ b/m4/Makefile.in @@ -205,6 +205,8 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PCRE2_CFLAGS = @PCRE2_CFLAGS@ +PCRE2_LIBS = @PCRE2_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ diff --git a/src/.cproject b/src/.cproject index 69b886e..da78fde 100644 --- a/src/.cproject +++ b/src/.cproject @@ -34,7 +34,7 @@ - + @@ -297,7 +297,7 @@ - + @@ -412,7 +412,7 @@ - + @@ -526,7 +526,7 @@ - + @@ -605,10 +605,9 @@