Imported Upstream version 1.4.16
[platform/upstream/m4.git] / examples / forloop2.m4
1 divert(`-1')
2 # forloop(var, from, to, stmt) - improved version:
3 #   works even if VAR is not a strict macro name
4 #   performs sanity check that FROM is larger than TO
5 #   allows complex numerical expressions in TO and FROM
6 define(`forloop', `ifelse(eval(`($2) <= ($3)'), `1',
7   `pushdef(`$1')_$0(`$1', eval(`$2'),
8     eval(`$3'), `$4')popdef(`$1')')')
9 define(`_forloop',
10   `define(`$1', `$2')$4`'ifelse(`$2', `$3', `',
11     `$0(`$1', incr(`$2'), `$3', `$4')')')
12 divert`'dnl