Fix AC_DEFINE_UNQUOTED regexp

Problem reported by Eric Blake in:
https://savannah.gnu.org/support/?111221
* lib/autoconf/general.m4 (_AC_DEFINE_UNQUOTED): Fix typo that
caused us to not use a here-document in some cases when we should.
* tests/torture.at (Substitute and define special characters):
Test for the bug.
This commit is contained in:
Paul Eggert 2025-04-07 11:01:59 -07:00
parent 2f64dcd048
commit 79ab6ccf4f
3 changed files with 7 additions and 2 deletions

3
NEWS
View File

@ -32,6 +32,9 @@ GNU Autoconf NEWS - User visible changes.
** Notable bug fixes
*** AC_DEFINE_UNQUOTED no longer mishandles double-quotes inside $(...)
and ${...}.
*** AC_FUNC_STRNLEN now detects Android 5.0's broken strnlen.
*** AC_PROG_OBJC now finds the GNU Objective-C compiler, as packaged in

View File

@ -2385,7 +2385,7 @@ m4_define([AC_DEFINE_UNQUOTED], [_AC_DEFINE_Q([_$0], $@)])
# avoid AS_ECHO if "#" is present to avoid confusing m4 with comments,
# but quadrigraphs are fine in that case.
m4_define([_AC_DEFINE_UNQUOTED],
[m4_if(m4_bregexp([$1], [#\|\\\|`\|\(\$\|@S|@\)\((|{|@{:@\)]), [-1],
[m4_if(m4_bregexp([$1], [#\|\\\|`\|\(\$\|@S|@\)\((\|{\|@{:@\)]), [-1],
[AS_ECHO(["AS_ESCAPE([$1], [""])"]) >>confdefs.h],
[cat >>confdefs.h <<_ACEOF
[$1]

View File

@ -988,12 +988,13 @@ AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a "' b'`}"], [unquoted, test 5])
AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
AC_DEFINE_UNQUOTED([unq7], ['\\"'], [unquoted, test 7])
AC_DEFINE_UNQUOTED([unq8], ["${baz+$(echo "a "' b')}"], [unquoted, test 8])
AC_PROG_AWK
AC_CONFIG_FILES([Foo Zardoz])]])
AT_CHECK_AUTOCONF
AT_CHECK_AUTOHEADER([],
[foo fooq bar barq unq1 unq2 unq2 unq3 unq4 unq5 unq6 unq7])
[foo fooq bar barq unq1 unq2 unq2 unq3 unq4 unq5 unq6 unq7 unq8])
# Check both awk and the result of AC_PROG_AWK
# Quote the first word in the for list for Solaris sh.
for awk_arg in "FOO=" AWK=awk; do
@ -1023,6 +1024,7 @@ X@file@
#define unq5 "a b"
#define unq6 hi
#define unq7 '\"'
#define unq8 "a b"
]])
done
AT_CLEANUP