]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Avoid \] in regular expressions
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 May 2026 15:38:21 +0000 (08:38 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 May 2026 20:23:08 +0000 (13:23 -0700)
POSIX did not require support for \] in regular expressions
until POSIX.1-2024, so avoid it to be portable to strict
earlier implementations.
* lib/autoconf/types.m4 (_AC_CHECK_TYPE_MAYBE_TYPE_P):
* lib/freeze.mk (ETAGS_FOR_M4, ETAGS_FOR_M4SUGAR, ETAGS_FOR_AUTOCONF):
Also avoid \] here, though this is more for consistency
as GNU m4 always uses GNU regexp.
* tests/torture.at (AC_OUTPUT with one argument)
(AC_OUTPUT with three arguments):
Avoid \] in regular expressions, as support for it is
required only by POSIX.1-2024 and later.

doc/autoconf.texi
lib/autoconf/types.m4
lib/freeze.mk
tests/torture.at

index ad5e148c8dd4a1e4253d25764bb94cf072d1c433..34d7d27694fab6f67fe96b4902207820913255f9 100644 (file)
@@ -19338,6 +19338,8 @@ not work on long input lines.  To work around these problems, invoke
 Portable extended regular expressions should use @samp{\} only to escape
 characters in the string @samp{$()*+.?[\^@{|}.  For example, @samp{\@}}
 is not portable, even though it typically matches @samp{@}}.
+In particular, even though POSIX.1-2024 says @samp{\]} matches @samp{]},
+earlier editions of POSIX say that the meaning of @samp{\]} is undefined.
 
 The empty alternative is not portable.  Use @samp{?} instead.  For
 instance with Digital Unix v5.0:
@@ -19609,6 +19611,8 @@ portable scripts.  Solaris and HP-UX @command{grep} do not support it.
 Similarly, the following escape sequences should also be avoided:
 @samp{\<}, @samp{\>}, @samp{\+}, @samp{\?}, @samp{\`}, @samp{\'},
 @samp{\B}, @samp{\b}, @samp{\S}, @samp{\s}, @samp{\W}, and @samp{\w}.
+Also, even though POSIX.1-2024 says @samp{\]} matches @samp{]},
+earlier editions of POSIX say that the meaning of @samp{\]} is undefined.
 For more information about what can appear in portable regular expressions,
 @pxref{Problematic Expressions,,, grep, GNU Grep}.
 
index be0fac5f73deb84b9ed01684d3ebea3c414c4342..3897f350bb530370dd5f33ec7a275c9b6a42682e 100644 (file)
@@ -213,7 +213,7 @@ m4_define([_AC_CHECK_TYPE_REPLACEMENT_TYPE_P],
 # -----------------------------------
 # Return '1' if STRING looks like a C/C++ type.
 m4_define([_AC_CHECK_TYPE_MAYBE_TYPE_P],
-[m4_bmatch([$1], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$],
+[m4_bmatch([$1], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|]\)*$],
          1, 0)dnl
 ])# _AC_CHECK_TYPE_MAYBE_TYPE_P
 
index 81905e9c274501a5f51bde82e20d7b9a16ea89ef..81aeda74f1222b24c4dfa7d76e20c5e2336ba42a 100644 (file)
@@ -104,16 +104,16 @@ autoconf_m4f_dependencies =                       \
 
 ETAGS_FOR_M4 = \
   --lang=none \
-  --regex='/\(m4_define\|define\)(\[\([^]]*\)\]/\2/'
+  --regex='/\(m4_define\|define\)(\[\([^]]*\)]/\2/'
 
 ETAGS_FOR_M4SUGAR = \
   $(ETAGS_FOR_M4) \
-  --regex='/m4_defun(\[\([^]]*\)\]/\1/'
+  --regex='/m4_defun(\[\([^]]*\)]/\1/'
 
 ETAGS_FOR_AUTOCONF = \
   $(ETAGS_FOR_M4SUGAR) \
-  --regex='/\(A[CU]_DEFUN\|AU_ALIAS\)(\[\([^]]*\)\]/\2/' \
-  --regex='/AN_\(FUNCTION\|HEADER\|IDENTIFIER\|LIBRARY\|MAKEVAR\|PROGRAM\)(\[\([^]]*\)\]/\2/'
+  --regex='/\(A[CU]_DEFUN\|AU_ALIAS\)(\[\([^]]*\)]/\2/' \
+  --regex='/AN_\(FUNCTION\|HEADER\|IDENTIFIER\|LIBRARY\|MAKEVAR\|PROGRAM\)(\[\([^]]*\)]/\2/'
 
 
 ## -------------------------------- ##
index d0e568e5a3cba19bc8e772eee91811a98a2f6d77..6d1b06a094dc88facf12845616cb9e917d03c4a4 100644 (file)
@@ -434,7 +434,7 @@ AT_CHECK_AUTOUPDATE
 
 AT_CHECK([[$EGREP '^AC_OUTPUT$' configure.ac]],
          [0], [ignore])
-AT_CHECK([[$EGREP '^AC_CONFIG_FILES\(\[Makefile\]\)$' configure.ac]],
+AT_CHECK([[$EGREP '^AC_CONFIG_FILES\(\[Makefile]\)$' configure.ac]],
          [0], [ignore])
 
 AT_CLEANUP
@@ -478,9 +478,9 @@ AT_CHECK_AUTOUPDATE
 
 AT_CHECK([[$EGREP '^AC_''OUTPUT$' configure.ac]],
          [0], [ignore])
-AT_CHECK([[$EGREP '^AC_''CONFIG_FILES\(\[Makefile\]\)$' configure.ac]],
+AT_CHECK([[$EGREP '^AC_''CONFIG_FILES\(\[Makefile]\)$' configure.ac]],
          [0], [ignore])
-AT_CHECK([[$EGREP '^AC_''CONFIG_COMMANDS\(\[default\]' configure.ac]],
+AT_CHECK([[$EGREP '^AC_''CONFIG_COMMANDS\(\[default]' configure.ac]],
          [0], [ignore])
 
 AT_CLEANUP