From 79ab6ccf4ff239b41be9400c3e8b8a8e0d7ef130 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Apr 2025 11:01:59 -0700 Subject: [PATCH] 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. --- NEWS | 3 +++ lib/autoconf/general.m4 | 2 +- tests/torture.at | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index b859fff6..0b57386c 100644 --- 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 diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 1355b900..7eae5bd2 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -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] diff --git a/tests/torture.at b/tests/torture.at index 167b8126..0e14315e 100644 --- a/tests/torture.at +++ b/tests/torture.at @@ -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