Avoid \] in BREs and EREs

* bootstrap (PACKAGE_NAME, PACKAGE_BUGREPORT):
* lib/autoconf/status.m4 (AC_OUTPUT_MAKE_DEFS):
* maint.mk (longopt_re, gpg_key_ID):
* tests/m4sugar.at (m4_dumpdef):
Avoid \] in POSIX-specified regular expressions, as POSIX says \]
produces undefined results in BREs and EREs.
This commit is contained in:
Paul Eggert 2022-06-28 17:26:07 -05:00
parent 6e3282fe38
commit 9c3f25710d
4 changed files with 6 additions and 8 deletions

View File

@ -149,9 +149,9 @@ VERSION=$(build-aux/git-version-gen .tarball-version)
# get copied into the generated configure script, so we need to get them
# right. Caution: there is a hard tab in one of the regexes below.
PACKAGE_NAME=$(sed -n < configure.ac \
-e 's/^m4_define(\[autoconf_PACKAGE_NAME\], \[\([^]]*\)\])$/\1/p')
-e 's/^m4_define(\[autoconf_PACKAGE_NAME], \[\([^]]*\)])$/\1/p')
PACKAGE_BUGREPORT=$(sed -n < configure.ac \
-e 's/^m4_define(\[autoconf_PACKAGE_BUGREPORT\], \[\([^]]*\)\])$/\1/p')
-e 's/^m4_define(\[autoconf_PACKAGE_BUGREPORT], \[\([^]]*\)])$/\1/p')
if [ -z "$RELEASE_YEAR" ]; then
echo "$me: error: could not extract RELEASE_YEAR from configure.ac" >&2

View File

@ -1772,9 +1772,7 @@ s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g
t quote
b any
:quote
s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g
s/\[/\\&/g
s/\]/\\&/g
s/[][ `~#$^&*(){}\\|;'\''"<>?]/\\&/g
s/\$/$$/g
H
:any

View File

@ -826,7 +826,7 @@ sc_trailing_blank:
# Match lines like the following, but where there is only one space
# between the options and the description:
# -D, --all-repeated[=delimit-method] print all duplicate lines\n
longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*]?)?
sc_two_space_separator_in_usage:
@prohibit='^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
halt='help2man requires at least two spaces between an option and its description'\
@ -1393,7 +1393,7 @@ gpg_key_ID ?= \
$$(cd $(srcdir) \
&& git cat-file tag v$(VERSION) \
| $(gpgv) --status-fd 1 --keyring /dev/null - - 2>/dev/null \
| $(AWK) '/^\[GNUPG:\] ERRSIG / {print $$3; exit}')
| $(AWK) '/^\[GNUPG:] ERRSIG / {print $$3; exit}')
translation_project_ ?= coordinator@translationproject.org

View File

@ -196,7 +196,7 @@ m4_dumpdef([good], [oops])
]])
AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
AT_CHECK([grep '^good: \[[yep\]]$' stderr], [0], [ignore])
AT_CHECK([grep '^good: \[[yep]]$' stderr], [0], [ignore])
AT_CHECK([grep 'm4@&t@_dumpdef: undefined.*oops' stderr], [0], [ignore])
# Check that pushdef stacks can be dumped.