]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix AC_DEFINE_UNQUOTED regexp
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 7 Apr 2025 18:01:59 +0000 (11:01 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 7 Apr 2025 18:02:57 +0000 (11:02 -0700)
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.

NEWS
lib/autoconf/general.m4
tests/torture.at

diff --git a/NEWS b/NEWS
index b859fff610827e946a75b8edf530ecd3cea6b73d..0b57386c0ec79227ddc55974b8cd9b97b71cfccc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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
index 1355b900de1c2a70429850652643dac5694b2e2a..7eae5bd23110fb66fcacf8b6fd6b4ef8e3e16ac7 100644 (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]
index 167b812680c444f8ce141d6fb26d937e53b8a9b5..0e14315ef112696d209df027b8c53fc91d1b15bc 100644 (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