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.
diff --git a/NEWS b/NEWS
index b859fff..0b57386 100644
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,9 @@
 
 ** 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 1355b90..7eae5bd 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2385,7 +2385,7 @@
 # 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 167b812..0e14315 100644
--- a/tests/torture.at
+++ b/tests/torture.at
@@ -988,12 +988,13 @@
 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 @@
 #define unq5 "a  b"
 #define unq6 hi
 #define unq7 '\"'
+#define unq8 "a  b"
 ]])
 done
 AT_CLEANUP