]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix 2007-10-03 regression with AT_SETUP([a, b]).
authorEric Blake <ebb9@byu.net>
Mon, 8 Oct 2007 17:53:00 +0000 (11:53 -0600)
committerEric Blake <ebb9@byu.net>
Mon, 15 Oct 2007 14:43:21 +0000 (08:43 -0600)
* lib/m4sugar/m4sugar.m4 (m4_expand): New macro.
* lib/autotest/general.m4 (AT_SETUP): Use it to preserve
whitespace after single-quoted comma.
* tests/autotest.at (AT_CHECK_AT_TITLE_CHAR): Test this.
* NEWS: Revert caveat about semantics change on comma.
* doc/autoconf.texi (Programming in M4): Lighten the warning on
using m4sugar; it is stabilizing.
(Redefined M4 Macros): Touch up wording on M4 builtins.
(Evaluation Macros): Document m4_expand.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
NEWS
doc/autoconf.texi
lib/autotest/general.m4
lib/m4sugar/m4sh.m4
lib/m4sugar/m4sugar.m4
tests/autotest.at

index 9efbbe4143e21e8c720540ee7135e00fe18b6957..3d25d0dde0cc977bcde9c94aaea62bfb32beac82 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-10-15  Eric Blake  <ebb9@byu.net>
+
+       Fix 2007-10-03 regression with AT_SETUP([a, b]).
+       * lib/m4sugar/m4sugar.m4 (m4_expand): New macro.
+       (m4_text_box): Use it.
+       * lib/autotest/general.m4 (AT_SETUP): Use it.
+       * lib/m4sugar/m4sh.m4 (_AS_RUN): Use it.
+       * tests/autotest.at (AT_CHECK_AT_TITLE_CHAR): Test this.
+       * NEWS: Revert caveat about semantics change on comma.
+       * doc/autoconf.texi (Evaluation Macros): Document m4_expand.
+
 2007-10-13  Eric Blake  <ebb9@byu.net>
 
        Change m4_join to match libtool's ltsugar semantics.
diff --git a/NEWS b/NEWS
index 95c7e3bdb13f88269b7b6e7c889802520a071f2a..8804f93986414a981d8919bd45412d819cf6954e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -61,10 +61,7 @@ GNU Autoconf NEWS - User visible changes.
    expanded libdir value of /usr/lib, not /usr//lib.
 
 ** AT_SETUP now handles macro expansions properly when calculating line
-   length.  However, as a side effect, any whitespace immediately
-   following a single-quoted comma is lost.  If you previously used
-   AT_SETUP([a, b]), you could change to AT_SETUP([a,[] b]) to keep
-   the space.
+   length.
 
 ** Autotest now determines $srcdir correctly.
 
@@ -117,8 +114,8 @@ GNU Autoconf NEWS - User visible changes.
    be used to take action depending on whether anything was appended.
 
 ** The following m4sugar macros are new:
-   m4_cond  m4_ignore  m4_max  m4_min  m4_newline  m4_shift2
-   m4_shift3  m4_unquote
+   m4_cond  m4_expand  m4_ignore  m4_max  m4_min  m4_newline
+   m4_shift2  m4_shift3  m4_unquote
 
 ** Warnings are now generated by default when an installer invokes
    'configure' with an unknown --enable-* or --with-* option.
index 3a8c126c6fae7900fe7972c3137f4cb1d407dd83..fb7a3ad9ceb09e25d76112f94e6f94951e89ee32 100644 (file)
@@ -10696,6 +10696,32 @@ Conveniently, if there is just one @var{arg}, this effectively adds a
 level of quoting.
 @end defmac
 
+@defmac m4_expand (@var{arg})
+@msindex{expand}
+Return the expansion of @var{arg} as a quoted string.  Whereas
+@code{m4_quote} is designed to collect expanded text into a single
+argument, @code{m4_expand} is designed to perform one level of expansion
+on quoted text.  The distinction is in the treatment of whitespace
+following a comma in the original @var{arg}.  Any time multiple
+arguments are collected into one with @code{m4_quote}, the M4 argument
+collection rules discard the whitespace.  But with @code{m4_quote},
+whitespace is discarded only if it results from unquoted commas in the
+expansion of macros contained in @var{arg}.
+
+@example
+m4_define([active], [ACT, IVE])dnl
+m4_define([active2], [[ACT, IVE]])dnl
+m4_quote(active, active)
+@result{}ACT,IVE,ACT,IVE
+m4_expand([active, active])
+@result{}ACT,IVE, ACT,IVE
+m4_quote(active2, active2)
+@result{}ACT, IVE,ACT, IVE
+m4_expand([active2, active2])
+@result{}ACT, IVE, ACT, IVE
+@end example
+@end defmac
+
 @defmac m4_ignore (@dots{})
 @msindex{ignore}
 This macro was introduced in Autoconf 2.62.  Expands to nothing,
@@ -10735,34 +10761,43 @@ with @code{m4_split}, in order to convert a single quoted list into a
 series of quoted elements.
 @end defmac
 
-The following example aims at emphasizing the difference between (i), not
-using these macros, (ii), using @code{m4_quote}, and (iii), using
-@code{m4_dquote}.
+The following example aims at emphasizing the difference between several
+scenarios: not using these macros, using @code{m4_defn}, using
+@code{m4_quote}, using @code{m4_dquote}, and using @code{m4_expand}.
 
 @example
 $ @kbd{cat example.m4}
 # Overquote, so that quotes are visible.
 m4_define([show], [$[]1 = [$1], $[]@@ = [$@@]])
-m4_define([mkargs], [1, 2, 3])
+m4_define([a], [A])
+m4_define([mkargs], [1, 2[,] 3])
 m4_define([arg1], [[$1]])
-m4_divert(0)dnl
+m4_divert([0])dnl
 show(a, b)
+show([a, b])
 show(m4_quote(a, b))
 show(m4_dquote(a, b))
+show(m4_expand([a, b]))
+
 arg1(mkargs)
 arg1([mkargs])
 arg1(m4_defn([mkargs]))
 arg1(m4_quote(mkargs))
 arg1(m4_dquote(mkargs))
+arg1(m4_expand([mkargs]))
 $ @kbd{autom4te -l m4sugar example.m4}
-$1 = a, $@@ = [a],[b]
-$1 = a,b, $@@ = [a,b]
-$1 = [a],[b], $@@ = [[a],[b]]
+$1 = A, $@@ = [A],[b]
+$1 = a, b, $@@ = [a, b]
+$1 = A,b, $@@ = [A,b]
+$1 = [A],[b], $@@ = [[A],[b]]
+$1 = A, b, $@@ = [A, b]
+
 1
 mkargs
-1, 2, 3
-1,2,3
-[1],[2],[3]
+1, 2[,] 3
+1,2, 3
+[1],[2, 3]
+1,2, 3
 @end example
 
 
index e34055eb560d73889ea4d7ee05698bfa86b917d1..ce8abc8ed3ad3fb2879e4314fedb329e9088b99a 100644 (file)
@@ -1289,7 +1289,7 @@ m4_define([AT_SETUP],
 m4_define([AT_capture_files], [])
 m4_define([AT_line], AT_LINE)
 m4_define([AT_xfail], [at_xfail=no])
-m4_define([AT_description], m4_quote($1))
+m4_define([AT_description], m4_expand([$1]))
 m4_define([AT_ordinal], m4_incr(AT_ordinal))
 m4_append([AT_groups_all], [ ]m4_defn([AT_ordinal]))
 m4_divert_push([TEST_FUNCTIONS])dnl
index 157b844d95a31f298b19841d9b2366b9a1ac0539..31fecbcc3108e828c879feec0d96416410e379ae 100644 (file)
@@ -197,7 +197,7 @@ _AS_BOURNE_COMPATIBLE
 $1
 _ASEOF
 }],
-[(eval "AS_ESCAPE(m4_quote($1))")])])
+[(eval "AS_ESCAPE(m4_expand([$1]))")])])
 
 
 # _AS_DETECT_REQUIRED(TEST)
index 8c7070ba5b86191b07f2d5e720c7f855914ed9db..dc9f1da1f07895e595dd3ed41e3fdcde59d0293c 100644 (file)
@@ -615,6 +615,36 @@ m4_define([m4_do],
 m4_define([m4_dquote],  [[$@]])
 
 
+# m4_expand(ARG)
+# --------------
+# Return the expansion of ARG as a single string.  Unlike m4_quote($1), this
+# correctly preserves whitespace following single-quoted commas that appeared
+# within ARG (however, it does not preserve whitespace after any unquoted
+# commas encountered in the expansion).
+#
+#   m4_define([active], [ACT, IVE])
+#   m4_define([active2], [[ACT, IVE]])
+#   m4_quote(active, active2)
+#   => ACT,IVE,ACT, IVE
+#   m4_expand([active, active2])
+#   => ACT,IVE, ACT, IVE
+#
+# Splitting a quoted ARG on `,' preserves space, but produces a quoted list.
+# Unquote the list, then expand each argument while preserving the leading
+# spaces; finally, collect each argument back into the final string.
+m4_define([m4_expand],
+[m4_quote(_$0(m4_unquote(m4_split([$1], [,]))))])
+
+# _m4_expand(ARGS)
+# ----------------
+# Return the expansion of each ARG, separated by `,'.  Less efficient than
+# m4_unquote, but preserves quoted leading space in each ARG.
+m4_define([_m4_expand],
+[m4_if([$#], [0], [],
+       [$#], [1], [$1],
+       [$1,$0(m4_shift($@))])])
+
+
 # m4_ignore(ARGS)
 # ---------------
 # Expands to nothing.  Useful for conditionally ignoring an arbitrary
@@ -1834,7 +1864,7 @@ m4_builtin([popdef], [m4_Prefix])dnl
 # using FRAME-CHARACTER in the border.
 m4_define([m4_text_box],
 [m4_pushdef([m4_Border],
-           m4_translit(m4_format([%*s], m4_qlen(m4_quote($1)), []),
+           m4_translit(m4_format([%*s], m4_qlen(m4_expand([$1])), []),
                        [ ], m4_if([$2], [], [[-]], [[$2]])))dnl
 @%:@@%:@ m4_Border @%:@@%:@
 @%:@@%:@ $1 @%:@@%:@
index c84cfceea41544cd27e515b10d3c82167e7024db..2a339e1143bc6a3f55323c5673780ed2ea8b8c06 100644 (file)
@@ -290,7 +290,7 @@ AT_CHECK_AT_TITLE_CHAR([Backslash],     [\])
 AT_CHECK_AT_TITLE_CHAR([Brackets],   [[[]]], [[]])
 AT_CHECK_AT_TITLE_CHAR([Pound],       [[#]], [#])
 AT_CHECK_AT_TITLE_CHAR([Quoted comma],[[,]], [,])
-AT_CHECK_AT_TITLE_CHAR([Comma],       [,[]], [,])
+AT_CHECK_AT_TITLE_CHAR([Comma],         [,], [,])
 
 AT_CHECK_AT_TITLE_CHAR([Quoted Macro], [[macro_name]], [macro_name])
 AT_CHECK_AT_TITLE_CHAR([Macro],        [macro_name],   [macro_expanded])