From: Akim Demaille Date: Tue, 8 Feb 2000 08:41:52 +0000 (+0000) Subject: * libm4.m4 (m4_for): New macro. X-Git-Tag: autoconf-2.50~1222 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cd449970f6c2af4dfa621dfe82fc3ec2bc78e23;p=thirdparty%2Fautoconf.git * libm4.m4 (m4_for): New macro. --- diff --git a/ChangeLog b/ChangeLog index d4a6a44d0..72a55b986 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2000-02-08 Akim Demaille + + * libm4.m4 (m4_for): New macro. + 2000-02-07 Akim Demaille Stay in Autoconf's name space. diff --git a/libm4.m4 b/libm4.m4 index 4049453e5..71c1a7e9a 100644 --- a/libm4.m4 +++ b/libm4.m4 @@ -233,8 +233,21 @@ define(m4_match, ## --------------------- ## -# Implementing loops (`foreach' loops) in m4 is much more tricky than it -# may seem. Actually, the example of a `foreach' loop in the m4 +# m4_for(VARIABLE, FROM, TO, EXPRESSION) +# -------------------------------------- +# Expand EXPRESSION defining VARIABLE to FROM, FROM + 1, ..., TO. +# Both limits are included. +define([m4_for], +[pushdef([$1], [$2])_m4_for([$1], [$2], [$3], [$4])popdef([$1])]) + +define([_m4_for], +[$4[]ifelse($1, [$3], [], + [define([$1], incr($1))_m4_for([$1], [$2], [$3], [$4])])]) + + + +# Implementing `foreach' loops in m4 is much more tricky than it may +# seem. Actually, the example of a `foreach' loop in the m4 # documentation is wrong: it does not quote the arguments properly, # which leads to undesired expansions. #