mirror of
git://git.sv.gnu.org/autoconf
synced 2025-01-24 10:54:42 +08:00
m4_map is a looping construct.
* lib/m4sugar/m4sugar.m4 (m4_map, _m4_map, m4_map_sep): Move. Signed-off-by: Eric Blake <ebb9@byu.net>
This commit is contained in:
parent
33239cbd38
commit
96a08a7ee4
@ -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.
|
||||
|
@ -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. ##
|
||||
|
Loading…
Reference in New Issue
Block a user