autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix AT_SETUP formatting


From: Eric Blake
Subject: Re: Fix AT_SETUP formatting
Date: Mon, 8 Oct 2007 19:26:52 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Eric Blake <ebb9 <at> byu.net> writes:

> 
> However, there is a slight caveat that I could not work around.  This used
> to "work" (albeit, not necessarily with the right alignment):
> AT_SETUP([name, with comma])
> 
> Now, to avoid losing whitespace after a single-quoted comma, you must do:
> AT_SETUP([[name, with comma]])
> or
> AT_SETUP([name,@&t@ with comma])
> 
> or any other trick that will not lose whitespace to m4_dquote.

I don't like this regression.  I will apply this in another day or two to avoid 
the regression, unless I get some feedback on the proposed naming of m4_expand 
(seeing as how we already have m4_expand_once, with different semantics).

From: Eric Blake <address@hidden>
Date: Mon, 8 Oct 2007 11:53:00 -0600
Subject: [PATCH] Fix 2007-10-03 regression with AT_SETUP([a, b]).

* 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.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |   11 ++++
 NEWS                    |    5 +--
 lib/autotest/general.m4 |    2 +-
 lib/m4sugar/m4sugar.m4  |  128 +++++++++++++++++++++++++++++-----------------
 tests/autotest.at       |    2 +-

diff --git a/ChangeLog b/ChangeLog
index 6d613c1..aaa7696 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2007-10-08  Eric Blake  <address@hidden>
 
+       Fix 2007-10-03 regression with AT_SETUP([a, b]).
+       * 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.
+
        Avoid m4 warnings on bad m4_format usage.
        * lib/m4sugar/m4sugar.m4 (m4_text_wrap): Use %*s, in case width
        evaulates to 0.
diff --git a/NEWS b/NEWS
index 70a4a1a..f454c53 100644
--- a/NEWS
+++ b/NEWS
@@ -49,10 +49,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.
 
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 707c7db..5fb5cb4 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -1250,7 +1250,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([TESTS])dnl
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index 5385b3f..355f84e 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -561,6 +561,38 @@ m4_define([m4_dumpdefs],
 _m4_dumpdefs_down([$1])])
 
 
+# m4_shiftn(N, ...)
+# -----------------
+# Returns ... shifted N times.  Useful for recursive "varargs" constructs.
+m4_define([m4_shiftn],
+[m4_assert(0 <= $1 && $1 < $#)dnl
+_m4_shiftn($@)])
+
+m4_define([_m4_shiftn],
+[m4_if([$1], 0,
+       [m4_shift($@)],
+       [_m4_shiftn(m4_eval([$1]-1), m4_shift(m4_shift($@)))])])
+
+# m4_shift2(...)
+# m4_shift3(...)
+# -----------------
+# Returns ... shifted twice, and three times.  Faster than m4_shiftn.
+m4_define([m4_shift2], [m4_shift(m4_shift($@))])
+m4_define([m4_shift3], [m4_shift(m4_shift(m4_shift($@)))])
+
+# m4_undefine(NAME)
+# -----------------
+# Like the original, except don't tolerate undefining something which is
+# undefined, and only support one argument.
+#
+# This macro is called frequently, so minimize the amount of additional
+# expansions by skipping m4_ifndef.
+m4_define([m4_undefine],
+[m4_ifdef([$1], [],
+         [m4_fatal([$0: undefined macro: $1])])]dnl
+[m4_builtin([undefine], $@)])
+
+
 # m4_popdef(NAME)
 # ---------------
 # Like the original, except don't tolerate popping something which is
@@ -574,6 +606,40 @@ m4_define([m4_popdef],
 [m4_builtin([popdef], $@)])
 
 
+## ------------------------ ##
+## 7. Manipulating quotes.  ##
+## ------------------------ ##
+
+# 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 is currently unable to preserve whitespace after
+# any unquoted commas encountered in the expansion).
+#
+#   m4_define([active], [ACT, IVE])
+#   m4_quote(active, active)
+#   => ACT,IVE,ACT,IVE
+#   m4_expand([active, active])
+#   => ACT,IVE, ACT,IVE
+#
+# Implementation - splitting a quoted ARG on `,' preserves space, but
+# produces an overquoted list.  The first _m4_expand unquotes the list,
+# the second expands each element.  Finally, the m4_quote collects
+# everything into a single string, where whitespace from the original ARG
+# is not lost.
+m4_define([m4_expand],
+[m4_quote(_$0(_$0(m4_split([$1], [,]))))])
+
+# _m4_expand(ARGS)
+# ----------------
+# Return the expansion of each ARG, separated by `,'.
+m4_define([_m4_expand],
+[m4_if([$#], [0], [],
+       [$#], [1], [$1],
+       [$1,$0(m4_shift($@))])])
+
+
 # m4_quote(ARGS)
 # --------------
 # Return ARGS as a single argument.  Any whitespace after unquoted commas
@@ -602,40 +668,8 @@ m4_define([m4_noquote],
 [m4_changequote(-=<{,}>=-)$1-=<{}>=-m4_changequote([,])])
 
 
-# m4_shiftn(N, ...)
-# -----------------
-# Returns ... shifted N times.  Useful for recursive "varargs" constructs.
-m4_define([m4_shiftn],
-[m4_assert(0 <= $1 && $1 < $#)dnl
-_m4_shiftn($@)])
-
-m4_define([_m4_shiftn],
-[m4_if([$1], 0,
-       [m4_shift($@)],
-       [_m4_shiftn(m4_eval([$1]-1), m4_shift(m4_shift($@)))])])
-
-# m4_shift2(...)
-# m4_shift3(...)
-# -----------------
-# Returns ... shifted twice, and three times.  Faster than m4_shiftn.
-m4_define([m4_shift2], [m4_shift(m4_shift($@))])
-m4_define([m4_shift3], [m4_shift(m4_shift(m4_shift($@)))])
-
-# m4_undefine(NAME)
-# -----------------
-# Like the original, except don't tolerate undefining something which is
-# undefined, and only support one argument.
-#
-# This macro is called frequently, so minimize the amount of additional
-# expansions by skipping m4_ifndef.
-m4_define([m4_undefine],
-[m4_ifdef([$1], [],
-         [m4_fatal([$0: undefined macro: $1])])]dnl
-[m4_builtin([undefine], $@)])
-
-
 ## -------------------------- ##
-## 7. Implementing m4 loops.  ##
+## 8. Implementing m4 loops.  ##
 ## -------------------------- ##
 
 
@@ -800,7 +834,7 @@ m4_define([m4_foreach_w],
 
 
 ## --------------------------- ##
-## 8. More diversion support.  ##
+## 9. More diversion support.  ##
 ## --------------------------- ##
 
 
@@ -893,9 +927,9 @@ m4_define([m4_undivert],
 [m4_builtin([undivert], _m4_divert([$1]))])
 
 
-## -------------------------------------------- ##
-## 8. Defining macros with bells and whistles.  ##
-## -------------------------------------------- ##
+## --------------------------------------------- ##
+## 10. Defining macros with bells and whistles.  ##
+## --------------------------------------------- ##
 
 # `m4_defun' is basically `m4_define' but it equips the macro with the
 # needed machinery for `m4_require'.  A macro must be m4_defun'd if
@@ -1287,9 +1321,9 @@ m4_define([m4_pattern_forbid], [])
 m4_define([m4_pattern_allow], [])
 
 
-## ----------------------------- ##
-## Dependencies between macros.  ##
-## ----------------------------- ##
+## --------------------------------- ##
+## 11. Dependencies between macros.  ##
+## --------------------------------- ##
 
 
 # m4_before(THIS-MACRO-NAME, CALLED-MACRO-NAME)
@@ -1395,9 +1429,9 @@ m4_define([m4_provide_if],
          [$2], [$3])])
 
 
-## -------------------- ##
-## 9. Text processing.  ##
-## -------------------- ##
+## --------------------- ##
+## 12. Text processing.  ##
+## --------------------- ##
 
 
 # m4_cr_letters
@@ -1801,7 +1835,7 @@ m4_define([m4_qdelta],
 
 
 ## ----------------------- ##
-## 10. Number processing.  ##
+## 13. Number processing.  ##
 ## ----------------------- ##
 
 # m4_sign(A)
@@ -1843,7 +1877,7 @@ m4_define([m4_list_cmp],
 
 
 ## ------------------------ ##
-## 11. Version processing.  ##
+## 14. Version processing.  ##
 ## ------------------------ ##
 
 
@@ -1902,7 +1936,7 @@ m4_define([m4_version_prereq],
 
 
 ## ------------------- ##
-## 12. File handling.  ##
+## 15. File handling.  ##
 ## ------------------- ##
 
 
@@ -1924,7 +1958,7 @@ m4_if(m4_sysval, [0], [],
 
 
 ## ------------------------ ##
-## 13. Setting M4sugar up.  ##
+## 16. Setting M4sugar up.  ##
 ## ------------------------ ##
 
 
diff --git a/tests/autotest.at b/tests/autotest.at
index adef6ce..6be9970 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -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])
-- 
1.5.3.2








reply via email to

[Prev in Thread] Current Thread [Next in Thread]