[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] add m4_stack_foreach and m4_stack_foreach_lifo
From: |
Eric Blake |
Subject: |
Re: [PATCH] add m4_stack_foreach and m4_stack_foreach_lifo |
Date: |
Fri, 19 Dec 2008 00:22:31 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Eric Blake <ebb9 <at> byu.net> writes:
>
> In which case, here's my two patches to do it. Part 1 adds two more macros:
> m4_stack_foreach_sep{,_lifo} (using m4_curry in m4_copy is cute, but not as
> efficient as directly constructing a macro call with multiple arguments; this
> has the nice side effect of even fewer macros that can't be m4_copy'd).
While documenting this trick in the m4 manual, I noticed a slight consistency
bug; in other places where we handle a separator argument (like m4_mapall_sep),
the separator is followed by [] before the prefix.
I still plan on writing a documentation patch for m4_stack_foreach_sep and
friends...
From: Eric Blake <address@hidden>
Date: Thu, 18 Dec 2008 17:15:13 -0700
Subject: [PATCH] Fix separator in m4_stack_foreach_sep.
* lib/m4sugar/m4sugar.m4 (_m4_stack_reverse): Separate separator
from prefix.
* tests/m4sugar.at (m4@&address@hidden): Enhance test.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 7 +++++++
lib/m4sugar/m4sugar.m4 | 2 +-
tests/m4sugar.at | 3 ++-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c1d367a..369433c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2008-12-18 Eric Blake <address@hidden>
+ Fix separator in m4_stack_foreach_sep.
+ * lib/m4sugar/m4sugar.m4 (_m4_stack_reverse): Separate separator
+ from prefix.
+ * tests/m4sugar.at (m4@&address@hidden): Enhance test.
+
+2008-12-18 Eric Blake <address@hidden>
+
Mention limitation of M4 1.4.x on builtin tokens.
* doc/autoconf.texi (Redefined M4 Macros) <m4_dumpdef>: Document
ramification of M4 1.4.x's inability to pass builtin tokens
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index fe6af4f..6ca825f 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -1293,7 +1293,7 @@ m4_define([m4_stack_foreach_sep_lifo],
# swapped copy.
m4_define([_m4_stack_reverse],
[m4_ifdef([$1], [m4_pushdef([$2],
- _m4_defn([$1]))$3[]_m4_popdef([$1])$0([$1], [$2], [$4$3])])])
+ _m4_defn([$1]))$3[]_m4_popdef([$1])$0([$1], [$2], [$4[]$3])])])
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index 8a538f0..a876588 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -60,7 +60,8 @@ m4_copy([abc], [foo])dnl
m4_stack_foreach([foo], [m4_n])
m4_stack_foreach_lifo([foo], [m4_n])
m4_stack_foreach_sep([abc], [ m4_index([abcdefghijkl],], [)])
-m4_stack_foreach_sep_lifo([abc], [<], [>], [:])
+m4_define([colon], [:])dnl
+m4_stack_foreach_sep_lifo([abc], [<], [>], [colon])
m4_pushdef([xyz], [123])dnl
m4_pushdef([xyz], [456])dnl
m4_define([doit], [[$1](m4_stack_foreach_sep([xyz], [m4_dquote(], [)], [,]))
--
1.6.0.4