Use PCRE as built-in regex library

Replace the use of Henry Spencer's regex library with PCRE at the build
level and enable wxUSE_PCRE in wxRegEx code to switch to PCRE-based
implementation there.

Note that this has to be done unconditionally because there is no simple
way to select between the previously used regex library and PCRE at the
makefiles level.

We could still keep the possibility to use the system regex library
under Unix, but this doesn't seem to be worth doing, as we don't support
Unicode REs properly when using it (and never did), so drop support for
this too.
This commit is contained in:
Vadim Zeitlin
2021-07-17 14:23:23 +02:00
parent 966e9cefb5
commit 3d8438619d
61 changed files with 2464 additions and 1556 deletions

379
configure vendored
View File

@@ -989,6 +989,9 @@ subdirs
wxCFLAGS_C99
LIBTIFF_LIBS
LIBTIFF_CFLAGS
wxPCRE2_CODE_UNIT_WIDTH
LIBPCRE_LIBS
LIBPCRE_CFLAGS
PKG_CONFIG
AR
HAVE_CXX17
@@ -1388,6 +1391,8 @@ CXX
CXXFLAGS
CCC
PKG_CONFIG
LIBPCRE_CFLAGS
LIBPCRE_LIBS
LIBTIFF_CFLAGS
LIBTIFF_LIBS
LIBCURL_CFLAGS
@@ -2402,6 +2407,10 @@ Some influential environment variables:
CXX C++ compiler command
CXXFLAGS C++ compiler flags
PKG_CONFIG path to pkg-config utility
LIBPCRE_CFLAGS
C compiler flags for LIBPCRE, overriding pkg-config
LIBPCRE_LIBS
linker flags for LIBPCRE, overriding pkg-config
LIBTIFF_CFLAGS
C compiler flags for LIBTIFF, overriding pkg-config
LIBTIFF_LIBS
@@ -21584,45 +21593,247 @@ if test "$wxUSE_REGEX" != "no"; then
$as_echo "#define wxUSE_REGEX 1" >>confdefs.h
if test "$wxUSE_UNICODE" = "yes" -a "$wxUSE_REGEX" = "yes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Defaulting to the builtin regex library for Unicode build." >&5
$as_echo "$as_me: WARNING: Defaulting to the builtin regex library for Unicode build." >&2;}
wxUSE_REGEX=builtin
if test "$wxUSE_UNICODE" = "yes"; then
if test "$wxUSE_UNICODE_UTF8" = "yes"; then
pcre_suffix=8
else
if test "$ac_cv_sizeof_wchar_t" = 2; then
pcre_suffix=16
elif test "$ac_cv_sizeof_wchar_t" = 4; then
pcre_suffix=32
else
as_fn_error $? "unknown sizeof(wchar_t)" "$LINENO" 5
fi
fi
else
pcre_suffix=8
fi
if test "$wxUSE_REGEX" = "sys" -o "$wxUSE_REGEX" = "yes" ; then
ac_fn_c_check_header_compile "$LINENO" "regex.h" "ac_cv_header_regex_h" "
"
if test "x$ac_cv_header_regex_h" = xyes; then :
for ac_func in regcomp re_search
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
if test "$wxUSE_REGEX" != "builtin"; then
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBPCRE" >&5
$as_echo_n "checking for LIBPCRE... " >&6; }
if test -n "$PKG_CONFIG"; then
if test -n "$LIBPCRE_CFLAGS"; then
pkg_cv_LIBPCRE_CFLAGS="$LIBPCRE_CFLAGS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre2-\$pcre_suffix\""; } >&5
($PKG_CONFIG --exists --print-errors "libpcre2-$pcre_suffix") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_LIBPCRE_CFLAGS=`$PKG_CONFIG --cflags "libpcre2-$pcre_suffix" 2>/dev/null`
else
pkg_failed=yes
fi
done
fi
else
pkg_failed=untried
fi
if test -n "$PKG_CONFIG"; then
if test -n "$LIBPCRE_LIBS"; then
pkg_cv_LIBPCRE_LIBS="$LIBPCRE_LIBS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre2-\$pcre_suffix\""; } >&5
($PKG_CONFIG --exists --print-errors "libpcre2-$pcre_suffix") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_LIBPCRE_LIBS=`$PKG_CONFIG --libs "libpcre2-$pcre_suffix" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi
if test "x$ac_cv_func_regcomp" != "xyes"; then
if test "$wxUSE_REGEX" = "sys" ; then
as_fn_error $? "system regex library not found! Use --with-regex to use built-in version" "$LINENO" 5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: system regex library not found, will use built-in instead" >&5
$as_echo "$as_me: WARNING: system regex library not found, will use built-in instead" >&2;}
wxUSE_REGEX=builtin
fi
if test $pkg_failed = yes; then
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
LIBPCRE_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libpcre2-$pcre_suffix"`
else
wxUSE_REGEX=sys
$as_echo "#define WX_NO_REGEX_ADVANCED 1" >>confdefs.h
LIBPCRE_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libpcre2-$pcre_suffix"`
fi
# Put the nasty error message in config.log where it belongs
echo "$LIBPCRE_PKG_ERRORS" >&5
wxUSE_REGEX=builtin
elif test $pkg_failed = untried; then
wxUSE_REGEX=builtin
else
LIBPCRE_CFLAGS=$pkg_cv_LIBPCRE_CFLAGS
LIBPCRE_LIBS=$pkg_cv_LIBPCRE_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
PCRE_LINK=$LIBPCRE_LIBS
CXXFLAGS="$LIBPCRE_CFLAGS $CXXFLAGS"
wxUSE_REGEX=sys
fi
fi
if test "$wxUSE_REGEX" = "builtin"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pcre submodule exists" >&5
$as_echo_n "checking whether pcre submodule exists... " >&6; }
if ! test -f "$ac_confdir/3rdparty/pcre/pcre2-config.in" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
as_fn_error $? "
Configured to use built-in PCRE library, but the file
$ac_confdir/3rdparty/pcre/pcre2-config.in couldn't be found.
You might need to run:
git submodule update --init 3rdparty/pcre
to fix this." "$LINENO" 5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
fi
if test $pcre_suffix != 8; then
pcre_config_disable="--disable-pcre2-8"
pcre_config_enable="--enable-pcre2-$pcre_suffix"
fi
wxPCRE2_CODE_UNIT_WIDTH=$pcre_suffix
# Various preliminary checks.
ax_dir="3rdparty/pcre"
# Do not complain, so a configure script can configure whichever parts of a
# large source tree are present.
if test -d "$srcdir/$ax_dir"; then
ac_builddir=.
case "$ax_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ax_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
# Remove --cache-file, --srcdir, and --disable-option-checking arguments
# so they do not pile up.
ax_args=
ax_prev=
eval "set x $ac_configure_args"
shift
for ax_arg; do
if test -n "$ax_prev"; then
ax_prev=
continue
fi
case $ax_arg in
-cache-file | --cache-file | --cache-fil | --cache-fi | --cache-f \
| --cache- | --cache | --cach | --cac | --ca | --c)
ax_prev=cache_file ;;
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
| --c=*)
;;
--config-cache | -C)
;;
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
ax_prev=srcdir ;;
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
;;
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
ax_prev=prefix ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* \
| --p=*)
;;
--disable-option-checking)
;;
*) case $ax_arg in
*\'*) ax_arg=$($as_echo "$ax_arg" | sed "s/'/'\\\\\\\\''/g");;
esac
as_fn_append ax_args " '$ax_arg'" ;;
esac
done
# Always prepend --disable-option-checking to silence warnings, since
# different subdirs can have different --enable and --with options.
ax_args="--disable-option-checking $ax_args"
# Options that must be added as they are provided.
as_fn_append ax_args " '$pcre_config_disable'"
as_fn_append ax_args " '$pcre_config_enable'"
# New options that may need to be merged with existing options.
# New options that must replace existing options.
# Options that must be removed.
as_fn_append ax_args " '--srcdir=$ac_srcdir'"
# Add the subdirectory to the list of target subdirectories.
ax_subconfigures="$ax_subconfigures $ax_dir"
# Save the argument list for this subdirectory.
ax_var=$(printf "$ax_dir" | tr -c "0-9a-zA-Z_" "_")
eval "ax_sub_configure_args_$ax_var=\"$ax_args\""
eval "ax_sub_configure_$ax_var=\"yes\""
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find source tree for $ax_dir" >&5
$as_echo "$as_me: WARNING: could not find source tree for $ax_dir" >&2;}
fi
fi
fi
@@ -22436,8 +22647,6 @@ $as_echo "yes" >&6; }
# Various preliminary checks.
@@ -38454,7 +38663,7 @@ if test "$SHARED" = 1; then
fi
LIBS=`echo $LIBS`
EXTRALIBS="$LDFLAGS $LDFLAGS_VERSIONING $LIBS $DMALLOC_LIBS"
EXTRALIBS="$LDFLAGS $LDFLAGS_VERSIONING $LIBS $PCRE_LINK $DMALLOC_LIBS"
EXTRALIBS_XML="$EXPAT_LINK"
EXTRALIBS_HTML="$MSPACK_LINK"
EXTRALIBS_MEDIA="$GST_LIBS"
@@ -38495,9 +38704,14 @@ if test "$wxUSE_GUI" = "yes"; then
;;
esac
fi
if test "$wxUSE_REGEX" = "builtin" ; then
wxconfig_3rdparty="regex${lib_unicode_suffix} $wxconfig_3rdparty"
fi
case "wxUSE_REGEX" in
builtin)
wxconfig_3rdparty="pcre $wxconfig_3rdparty"
;;
sys)
WXCONFIG_LIBS="$PCRE_LINK $WXCONFIG_LIBS"
;;
esac
if test "$wxUSE_STC" = "yes" ; then
wxconfig_3rdparty="scintilla $wxconfig_3rdparty"
fi
@@ -41259,6 +41473,101 @@ LIBOBJS=$ac_libobjs
LTLIBOBJS=$ac_ltlibobjs
ax_dir="3rdparty/pcre"
# Convert the path to the subdirectory into a shell variable name.
ax_var=$(printf "$ax_dir" | tr -c "0-9a-zA-Z_" "_")
ax_configure_ax_var=$(eval "echo \"\$ax_sub_configure_$ax_var\"")
if test "$no_recursion" != "yes" -a "x$ax_configure_ax_var" = "xyes"; then
subdirs_extra="$subdirs_extra $ax_dir"
ax_msg="=== configuring in $ax_dir ($(pwd)/$ax_dir)"
$as_echo "$as_me:${as_lineno-$LINENO}: $ax_msg" >&5
$as_echo "$ax_msg" >&6
as_dir="$ax_dir"; as_fn_mkdir_p
ac_builddir=.
case "$ax_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ax_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
ax_popdir=$(pwd)
cd "$ax_dir"
# Check for guested configure; otherwise get Cygnus style configure.
if test -f "$ac_srcdir/configure.gnu"; then
ax_sub_configure=$ac_srcdir/configure.gnu
elif test -f "$ac_srcdir/configure"; then
ax_sub_configure=$ac_srcdir/configure
elif test -f "$ac_srcdir/configure.in"; then
# This should be Cygnus configure.
ax_sub_configure=$ac_aux_dir/configure
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: no configuration information is in $ax_dir" >&5
$as_echo "$as_me: WARNING: no configuration information is in $ax_dir" >&2;}
ax_sub_configure=
fi
if test -n "$ax_sub_configure"; then
# Get the configure arguments for the current configure.
eval "ax_sub_configure_args=\"\$ax_sub_configure_args_${ax_var}\""
# Always prepend --prefix to ensure using the same prefix
# in subdir configurations.
ax_arg="--prefix=$prefix"
case $ax_arg in
*\'*) ax_arg=$($as_echo "$ax_arg" | sed "s/'/'\\\\\\\\''/g");;
esac
ax_sub_configure_args="'$ax_arg' $ax_sub_configure_args"
if test "$silent" = yes; then
ax_sub_configure_args="--silent $ax_sub_configure_args"
fi
# Make the cache file name correct relative to the subdirectory.
case $cache_file in
[\\/]* | ?:[\\/]* )
ax_sub_cache_file=$cache_file ;;
*) # Relative name.
ax_sub_cache_file=$ac_top_build_prefix$cache_file ;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: running $SHELL $ax_sub_configure $ax_sub_configure_args --cache-file=$ac_sub_cache_file" >&5
$as_echo "$as_me: running $SHELL $ax_sub_configure $ax_sub_configure_args --cache-file=$ac_sub_cache_file" >&6;}
eval "\$SHELL \"$ax_sub_configure\" $ax_sub_configure_args --cache-file=\"$ax_sub_cache_file\"" \
|| as_fn_error $? "$ax_sub_configure failed for $ax_dir" "$LINENO" 5
fi
cd "$ax_popdir"
fi
ax_dir="src/tiff"
# Convert the path to the subdirectory into a shell variable name.