]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* libm4.m4 (m4_for): New macro.
authorAkim Demaille <akim@epita.fr>
Tue, 8 Feb 2000 08:41:52 +0000 (08:41 +0000)
committerAkim Demaille <akim@epita.fr>
Tue, 8 Feb 2000 08:41:52 +0000 (08:41 +0000)
ChangeLog
libm4.m4

index d4a6a44d0156df4196dd50757303299eaf46fd55..72a55b9868b509beca810e96ce0aac6c79d91efd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2000-02-08  Akim Demaille  <akim@epita.fr>
+
+       * libm4.m4 (m4_for): New macro.
+
 2000-02-07  Akim Demaille  <akim@epita.fr>
 
        Stay in Autoconf's name space.
index 4049453e5ed078d0fa9e95b4445dc2a0ba88034f..71c1a7e9a48c54d5dda3e36f8cb5a5b20c55dcf0 100644 (file)
--- 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.
 #