summaryrefslogtreecommitdiff
path: root/m4/regex.m4
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2021-01-20 21:52:54 +0100
committerAndy Wingo <wingo@pobox.com>2021-01-20 23:03:56 +0100
commita91b95cca2d397c84f8b9bbd602d40209a7092ce (patch)
tree2c286a291f5a2b812d6e216be10936f2709d59cf /m4/regex.m4
parent758b31994cff582c7e8785b4cc2240dbf3573837 (diff)
downloadguile-a91b95cca2d397c84f8b9bbd602d40209a7092ce.tar.gz
Update Gnulib to v0.1-4379-g2ef5a9b4b
Also bump required autoconf version to 2.64, as required by Gnulib.
Diffstat (limited to 'm4/regex.m4')
-rw-r--r--m4/regex.m4131
1 files changed, 99 insertions, 32 deletions
diff --git a/m4/regex.m4 b/m4/regex.m4
index 61ff09872..850c57222 100644
--- a/m4/regex.m4
+++ b/m4/regex.m4
@@ -1,6 +1,6 @@
-# serial 66
+# serial 71
-# Copyright (C) 1996-2001, 2003-2017 Free Software Foundation, Inc.
+# Copyright (C) 1996-2001, 2003-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -13,6 +13,7 @@ AC_PREREQ([2.50])
AC_DEFUN([gl_REGEX],
[
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_ARG_WITH([included-regex],
[AS_HELP_STRING([--without-included-regex],
[don't compile regex; this is the default on systems
@@ -75,7 +76,7 @@ AC_DEFUN([gl_REGEX],
if (setlocale (LC_ALL, "en_US.UTF-8"))
{
{
- /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html
+ /* https://sourceware.org/ml/libc-hacker/2006-09/msg00008.html
This test needs valgrind to catch the bug on Debian
GNU/Linux 3.1 x86, but it might catch the bug better
on other platforms and it shouldn't hurt to try the
@@ -89,17 +90,20 @@ AC_DEFUN([gl_REGEX],
s = re_compile_pattern (pat, sizeof pat - 1, &regex);
if (s)
result |= 1;
- else if (re_search (&regex, data, sizeof data - 1,
- 0, sizeof data - 1, &regs)
- != -1)
- result |= 1;
- regfree (&regex);
+ else
+ {
+ if (re_search (&regex, data, sizeof data - 1,
+ 0, sizeof data - 1, &regs)
+ != -1)
+ result |= 1;
+ regfree (&regex);
+ }
}
{
/* This test is from glibc bug 15078.
The test case is from Andreas Schwab in
- <http://www.sourceware.org/ml/libc-alpha/2013-01/msg00967.html>.
+ <https://sourceware.org/ml/libc-alpha/2013-01/msg00967.html>.
*/
static char const pat[] = "[^x]x";
static char const data[] =
@@ -124,8 +128,8 @@ AC_DEFUN([gl_REGEX],
0, sizeof data - 1, 0);
if (i != 0 && i != 21)
result |= 1;
+ regfree (&regex);
}
- regfree (&regex);
}
if (! setlocale (LC_ALL, "C"))
@@ -138,9 +142,13 @@ AC_DEFUN([gl_REGEX],
s = re_compile_pattern ("a[^x]b", 6, &regex);
if (s)
result |= 2;
- /* This should fail, but succeeds for glibc-2.5. */
- else if (re_search (&regex, "a\nb", 3, 0, 3, &regs) != -1)
- result |= 2;
+ else
+ {
+ /* This should fail, but succeeds for glibc-2.5. */
+ if (re_search (&regex, "a\nb", 3, 0, 3, &regs) != -1)
+ result |= 2;
+ regfree (&regex);
+ }
/* This regular expression is from Spencer ere test number 75
in grep-2.3. */
@@ -152,7 +160,10 @@ AC_DEFUN([gl_REGEX],
s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, &regex);
/* This should fail with _Invalid character class name_ error. */
if (!s)
- result |= 4;
+ {
+ result |= 4;
+ regfree (&regex);
+ }
/* Ensure that [b-a] is diagnosed as invalid, when
using RE_NO_EMPTY_RANGES. */
@@ -160,13 +171,18 @@ AC_DEFUN([gl_REGEX],
memset (&regex, 0, sizeof regex);
s = re_compile_pattern ("a[b-a]", 6, &regex);
if (s == 0)
- result |= 8;
+ {
+ result |= 8;
+ regfree (&regex);
+ }
/* This should succeed, but does not for glibc-2.1.3. */
memset (&regex, 0, sizeof regex);
s = re_compile_pattern ("{1", 2, &regex);
if (s)
result |= 8;
+ else
+ regfree (&regex);
/* The following example is derived from a problem report
against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */
@@ -174,17 +190,35 @@ AC_DEFUN([gl_REGEX],
s = re_compile_pattern ("[an\371]*n", 7, &regex);
if (s)
result |= 8;
- /* This should match, but does not for glibc-2.2.1. */
- else if (re_match (&regex, "an", 2, 0, &regs) != 2)
- result |= 8;
+ else
+ {
+ /* This should match, but does not for glibc-2.2.1. */
+ if (re_match (&regex, "an", 2, 0, &regs) != 2)
+ result |= 8;
+ else
+ {
+ free (regs.start);
+ free (regs.end);
+ }
+ regfree (&regex);
+ }
memset (&regex, 0, sizeof regex);
s = re_compile_pattern ("x", 1, &regex);
if (s)
result |= 8;
- /* glibc-2.2.93 does not work with a negative RANGE argument. */
- else if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
- result |= 8;
+ else
+ {
+ /* glibc-2.2.93 does not work with a negative RANGE argument. */
+ if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
+ result |= 8;
+ else
+ {
+ free (regs.start);
+ free (regs.end);
+ }
+ regfree (&regex);
+ }
/* The version of regex.c in older versions of gnulib
ignored RE_ICASE. Detect that problem too. */
@@ -193,11 +227,20 @@ AC_DEFUN([gl_REGEX],
s = re_compile_pattern ("x", 1, &regex);
if (s)
result |= 16;
- else if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)
- result |= 16;
+ else
+ {
+ if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)
+ result |= 16;
+ else
+ {
+ free (regs.start);
+ free (regs.end);
+ }
+ regfree (&regex);
+ }
/* Catch a bug reported by Vin Shelton in
- http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html
+ https://lists.gnu.org/r/bug-coreutils/2007-06/msg00089.html
*/
re_set_syntax (RE_SYNTAX_POSIX_BASIC
& ~RE_CONTEXT_INVALID_DUP
@@ -206,12 +249,31 @@ AC_DEFUN([gl_REGEX],
s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, &regex);
if (s)
result |= 32;
+ else
+ regfree (&regex);
/* REG_STARTEND was added to glibc on 2004-01-15.
Reject older versions. */
if (! REG_STARTEND)
result |= 64;
+ /* Matching with the compiled form of this regexp would provoke
+ an assertion failure prior to glibc-2.28:
+ regexec.c:1375: pop_fail_stack: Assertion 'num >= 0' failed
+ With glibc-2.28, compilation fails and reports the invalid
+ back reference. */
+ re_set_syntax (RE_SYNTAX_POSIX_EGREP);
+ memset (&regex, 0, sizeof regex);
+ s = re_compile_pattern ("0|()0|\\1|0", 10, &regex);
+ if (!s)
+ result |= 64;
+ else
+ {
+ if (strcmp (s, "Invalid back reference"))
+ result |= 64;
+ regfree (&regex);
+ }
+
#if 0
/* It would be nice to reject hosts whose regoff_t values are too
narrow (including glibc on hosts with 64-bit ptrdiff_t and
@@ -226,13 +288,19 @@ AC_DEFUN([gl_REGEX],
return result;
]])],
- [gl_cv_func_re_compile_pattern_working=yes],
- [gl_cv_func_re_compile_pattern_working=no],
- dnl When crosscompiling, assume it is not working.
- [gl_cv_func_re_compile_pattern_working=no])])
- case $gl_cv_func_re_compile_pattern_working in #(
- yes) ac_use_included_regex=no;; #(
- no) ac_use_included_regex=yes;;
+ [gl_cv_func_re_compile_pattern_working=yes],
+ [gl_cv_func_re_compile_pattern_working=no],
+ [case "$host_os" in
+ # Guess no on native Windows.
+ mingw*) gl_cv_func_re_compile_pattern_working="guessing no" ;;
+ # Otherwise obey --enable-cross-guesses.
+ *) gl_cv_func_re_compile_pattern_working="$gl_cross_guess_normal" ;;
+ esac
+ ])
+ ])
+ case "$gl_cv_func_re_compile_pattern_working" in #(
+ *yes) ac_use_included_regex=no;; #(
+ *no) ac_use_included_regex=yes;;
esac
;;
*) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex])
@@ -286,7 +354,6 @@ AC_DEFUN([gl_PREREQ_REGEX],
AC_REQUIRE([AC_C_RESTRICT])
AC_REQUIRE([AC_TYPE_MBSTATE_T])
AC_REQUIRE([gl_EEMALLOC])
- AC_REQUIRE([gl_GLIBC21])
AC_CHECK_HEADERS([libintl.h])
AC_CHECK_FUNCS_ONCE([isblank iswctype])
AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]])