]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
m4_map is a looping construct.
authorEric Blake <ebb9@byu.net>
Tue, 16 Oct 2007 18:18:24 +0000 (12:18 -0600)
committerEric Blake <ebb9@byu.net>
Tue, 16 Oct 2007 18:18:24 +0000 (12:18 -0600)
* lib/m4sugar/m4sugar.m4 (m4_map, _m4_map, m4_map_sep): Move.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/m4sugar/m4sugar.m4

index f5b770d9ea7bcc7ccda2b50fadde1b01c374f5b6..b0f6842aa56f01087dd816386ec44c64b495b62c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2007-10-16  Eric Blake  <ebb9@byu.net>
 
+       m4_map is a looping construct.
+       * lib/m4sugar/m4sugar.m4 (m4_map, _m4_map, m4_map_sep): Move.
+
        Fix m4_map, and add some more utility macros.
        * lib/m4sugar/m4sugar.m4 (m4_apply, m4_count, m4_dquote_elt)
        (m4_echo, m4_make_list): New documented macros.
index 459dc23be06c77ed87322e744ec29581515587b7..ad46ae451d959dfe7ef48c67a01a92b4631210a8 100644 (file)
@@ -447,32 +447,6 @@ m4_define([m4_cond],
        [m4_if($1, [$2], [$3], [$0(m4_shift3($@))])])])
 
 
-# m4_map(MACRO, LIST)
-# -------------------
-# Invoke MACRO($1), MACRO($2) etc. where $1, $2... are the elements
-# of LIST.  $1, $2... must in turn be lists, appropriate for m4_apply.
-#
-# Since LIST may be quite large, we want to minimize how often it appears
-# in the expansion.  Rather than use m4_car/m4_cdr iteration, we unbox the
-# list, and use _m4_shift2 to detect the end of recursion.
-m4_define([m4_map],
-[m4_if([$2], [], [],
-       [_$0([$1], $2)])])
-m4_define([_m4_map],
-[m4_if([$#], [1], [],
-       [m4_apply([$1], [$2])$0([$1]_m4_shift2($@))])])
-
-
-# m4_map_sep(MACRO, SEPARATOR, LIST)
-# ----------------------------------
-# Invoke MACRO($1), SEPARATOR, MACRO($2), ..., MACRO($N) where $1, $2... $N
-# are the elements of LIST, and are in turn lists appropriate for m4_apply.
-# SEPARATOR is not further expanded.
-m4_define([m4_map_sep],
-[m4_if([$3], [], [],
-       [m4_apply([$1], m4_car($3))m4_map([[$2]$1]_m4_cdr($3))])])
-
-
 ## ---------------------------------------- ##
 ## 6. Enhanced version of some primitives.  ##
 ## ---------------------------------------- ##
@@ -951,6 +925,31 @@ m4_define([m4_foreach_w],
 [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])
 
 
+# m4_map(MACRO, LIST)
+# -------------------
+# Invoke MACRO($1), MACRO($2) etc. where $1, $2... are the elements
+# of LIST.  $1, $2... must in turn be lists, appropriate for m4_apply.
+#
+# Since LIST may be quite large, we want to minimize how often it appears
+# in the expansion.  Rather than use m4_car/m4_cdr iteration, we unbox the
+# list, and use _m4_shift2 to detect the end of recursion.
+m4_define([m4_map],
+[m4_if([$2], [], [],
+       [_$0([$1], $2)])])
+m4_define([_m4_map],
+[m4_if([$#], [1], [],
+       [m4_apply([$1], [$2])$0([$1]_m4_shift2($@))])])
+
+
+# m4_map_sep(MACRO, SEPARATOR, LIST)
+# ----------------------------------
+# Invoke MACRO($1), SEPARATOR, MACRO($2), ..., MACRO($N) where $1, $2... $N
+# are the elements of LIST, and are in turn lists appropriate for m4_apply.
+# SEPARATOR is not further expanded.
+m4_define([m4_map_sep],
+[m4_if([$3], [], [],
+       [m4_apply([$1], m4_car($3))m4_map([[$2]$1]_m4_cdr($3))])])
+
 
 ## --------------------------- ##
 ## 9. More diversion support.  ##