[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02-m4-quote.patch
From: |
Akim Demaille |
Subject: |
02-m4-quote.patch |
Date: |
Mon, 04 Mar 2002 15:23:39 +0100 |
Index: ChangeLog
from Akim Demaille <address@hidden>
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.
Index: lib/autoconf/general.m4
--- lib/autoconf/general.m4 Tue, 05 Feb 2002 22:43:38 +0100 akim
+++ lib/autoconf/general.m4 Tue, 26 Feb 2002 22:19:10 +0100 akim
@@ -1167,10 +1167,10 @@ m4_define([_AC_INIT_PREPARE],
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: lib/m4sugar/m4sugar.m4
--- lib/m4sugar/m4sugar.m4 Wed, 14 Nov 2001 20:54:00 +0100 akim
+++ lib/m4sugar/m4sugar.m4 Thu, 28 Feb 2002 18:39:05 +0100 akim
@@ -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], address@hidden)
+m4_define([m4_dquote], address@hidden)
# 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], address@hidden)
+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_define([m4_re_string],
# ----------
# 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).
@@ -1618,15 +1601,15 @@ m4_define([m4_text_wrap],
1, [m4_define([m4_Cursor], m4_len(m4_Prefix))
m4_Prefix])[]dnl
m4_foreach([m4_Word], m4_quote(m4_split(m4_normalize([$1]))),
-[m4_define([m4_Cursor], m4_eval(m4_Cursor + m4_len(m4_Word) + 1))dnl
+[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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 02-m4-quote.patch,
Akim Demaille <=