]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Instead of having stacking `shift's evaluated at the end, let
authorAkim Demaille <akim@epita.fr>
Mon, 4 Mar 2002 15:02:21 +0000 (15:02 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 4 Mar 2002 15:02:21 +0000 (15:02 +0000)
`foreach' loops immediately evaluate them.
* lib/m4sugar/m4sugar.m4 (m4_quote, m4_dquote): Use $@ rather than
$*.  This is the n-th time I change my mind, but hopefully this is
the last...
(m4_lquote): New.
(m4_text_wrap): Use m4_foreach, which is finally correct _and_
efficient.
(m4_foreach_quoted, m4_car_quoted, _m4_foreach_quoted): Remove, as
it was only a hack for m4_text_wrap.
(m4_car2): Remove, replaced by...
(m4_cdr): New.
(_m4_foreach): Adjust.
* lib/autoconf/general.m4 (_AC_INIT_PREPARE): Adjust, and use
m4_bpatsubst for clarification.

ChangeLog
lib/autoconf/general.m4
lib/m4sugar/m4sugar.m4

index 99546aae321106c13538b93d106d6c649ceaee21..e15467f173e8bc2f870105eab07003df432c1436 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2002-03-04  Akim Demaille  <akim@epita.fr>
+
+       Instead of having stacking `shift's evaluated at the end, let
+       `foreach' loops immediately evaluate them.
+
+       * lib/m4sugar/m4sugar.m4 (m4_quote, m4_dquote): Use $@ rather than
+       $*.  This is the n-th time I change my mind, but hopefully this is
+       the last...
+       (m4_lquote): New.
+       (m4_text_wrap): Use m4_foreach, which is finally correct _and_
+       efficient.
+       (m4_foreach_quoted, m4_car_quoted, _m4_foreach_quoted): Remove, as
+       it was only a hack for m4_text_wrap.
+       (m4_car2): Remove, replaced by...
+       (m4_cdr): New.
+       (_m4_foreach): Adjust.
+       * lib/autoconf/general.m4 (_AC_INIT_PREPARE): Adjust, and use
+       m4_bpatsubst for clarification.
+
 2002-03-04  Akim Demaille  <akim@epita.fr>
 
        * doc/autoconf.texi (Changequote is Evil): New.
index 08c5964dd6effbedfdd0e6b7d2c98056bb98df54..111ad29051e49e243ae8e32754fa58e398cf1651 100644 (file)
@@ -1164,10 +1164,10 @@ trap 'exit_status=$?
     echo
     AS_BOX([Cache variables.])
     echo
-    m4_bpatsubst(m4_bpatsubst(m4_dquote(m4_defn([_AC_CACHE_DUMP])),
-                            [^ *\(#.*\)?
-]),
-                ['], ['"'"'])
+    m4_bpatsubsts(m4_defn([_AC_CACHE_DUMP]),
+                  [^ *\(#.*\)?
+],                [],
+                  ['], ['"'"'])
     echo
     if test -s confdefs.h; then
       AS_BOX([confdefs.h.])
index 834a2056836c57c7b18016aa1433333f29801eb8..8dac844ae7594f752408741ae21e0d225ebfb7d8 100644 (file)
@@ -521,16 +521,18 @@ m4_define([m4_popdef],
 m4_builtin([popdef], $@)])
 
 
-# m4_quote(STRING)
-# ----------------
-# Return STRING quoted.
+# m4_quote(ARGS)
+# --------------
+# Return ARGS quoted.  Note that a list of quoted arguments is returned,
+# not a quoted list.
 #
 # It is important to realize the difference between `m4_quote(exp)' and
 # `[exp]': in the first case you obtain the quoted *result* of the
 # expansion of EXP, while in the latter you just obtain the string
 # `exp'.
-m4_define([m4_quote], [[$*]])
-m4_define([m4_dquote], [[[$*]]])
+m4_define([m4_quote],  [[$*]])
+m4_define([m4_lquote], [$@])
+m4_define([m4_dquote], [[$@]])
 
 
 # m4_noquote(STRING)
@@ -696,11 +698,11 @@ m4_define([m4_foreach],
 
 # Low level macros used to define m4_foreach.
 m4_define([m4_car], [[$1]])
-m4_define([m4_car2], [[$@]])
+m4_define([m4_cdr], [m4_dquote(m4_shift($@))])
 m4_define([_m4_foreach],
-[m4_if(m4_quote($2), [], [],
+[m4_if([$2], [[]], [],
        [m4_define([$1], [m4_car($2)])$3[]_m4_foreach([$1],
-                                                     m4_car2(m4_shift($2)),
+                                                     m4_cdr($2),
                                                      [$3])])])
 
 
@@ -1375,7 +1377,7 @@ m4_define([m4_re_escape],
 # ------------
 # Regexp for `[a-zA-Z_0-9]*'
 m4_define([m4_re_string],
-m4_dquote(m4_defn([m4_cr_symbols2]))dnl
+m4_quote(m4_defn([m4_cr_symbols2]))dnl
 [*]dnl
 )
 
@@ -1384,7 +1386,7 @@ m4_dquote(m4_defn([m4_cr_symbols2]))dnl
 # ----------
 # Regexp for `[a-zA-Z_][a-zA-Z_0-9]*'
 m4_define([m4_re_word],
-m4_dquote(m4_defn([m4_cr_symbols1]))dnl
+m4_quote(m4_defn([m4_cr_symbols1]))dnl
 m4_defn([m4_re_string])dnl
 )
 
@@ -1554,22 +1556,6 @@ m4_define([m4_append_uniq],
           [m4_append($@)])])
 
 
-# m4_foreach_quoted(VARIABLE, LIST, EXPRESSION)
-# ---------------------------------------------
-# FIXME: This macro should not exists.  Currently it's used only in
-# m4_wrap, which needs to be rewritten.  But it's godam hard.
-m4_define([m4_foreach_quoted],
-[m4_pushdef([$1], [])_m4_foreach_quoted($@)m4_popdef([$1])])
-
-# Low level macros used to define m4_foreach.
-m4_define([m4_car_quoted], [[$1]])
-m4_define([_m4_foreach_quoted],
-[m4_if($2, [()], ,
-       [m4_define([$1], [m4_car_quoted$2])$3[]_m4_foreach_quoted([$1],
-                                                               [(m4_shift$2)],
-                                                               [$3])])])
-
-
 # m4_text_wrap(STRING, [PREFIX], [FIRST-PREFIX], [WIDTH])
 # -------------------------------------------------------
 # Expands into STRING wrapped to hold in WIDTH columns (default = 79).
@@ -1617,16 +1603,16 @@ m4_Prefix1[]dnl
 m4_if(m4_eval(m4_Cursor > m4_len(m4_Prefix)),
       1, [m4_define([m4_Cursor], m4_len(m4_Prefix))
 m4_Prefix])[]dnl
-m4_foreach_quoted([m4_Word], (m4_split(m4_normalize([$1]))),
-[m4_define([m4_Cursor], m4_eval(m4_Cursor + m4_len(m4_Word) + 1))dnl
+m4_foreach([m4_Word], m4_quote(m4_split(m4_normalize([$1]))),
+[m4_define([m4_Cursor], m4_eval(m4_Cursor + m4_len(m4_defn([m4_Word])) + 1))dnl
 dnl New line if too long, else insert a space unless it is the first
 dnl of the words.
 m4_if(m4_eval(m4_Cursor > m4_Width),
       1, [m4_define([m4_Cursor],
-                    m4_eval(m4_len(m4_Prefix) + m4_len(m4_Word) + 1))]
+                    m4_eval(m4_len(m4_Prefix) + m4_len(m4_defn([m4_Word])) + 1))]
 m4_Prefix,
        [m4_Separator])[]dnl
-m4_Word[]dnl
+m4_defn([m4_Word])[]dnl
 m4_define([m4_Separator], [ ])])dnl
 m4_popdef([m4_Separator])dnl
 m4_popdef([m4_Cursor])dnl