1 dnl @ ../doc/m4.texi:7874: Origin of test
2 dnl @ expected status: 0
4 dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software
6 dnl @ This file is free software; the Free Software Foundation
7 dnl @ gives unlimited permission to copy and/or distribute it
8 dnl @ with or without modifications, as long as this notice
10 include(`forloop3.m4')
12 undivert(`forloop3.m4')dnl
13 dnl @result{}divert(`-1')
14 dnl @result{}# forloop_arg(from, to, macro) - invoke MACRO(value) for
15 dnl @result{}# each value between FROM and TO, without define overhead
16 dnl @result{}define(`forloop_arg', `ifelse(eval(`($1) <= ($2)'), `1',
17 dnl @result{} `_forloop(`$1', eval(`$2'), `$3(', `)')')')
18 dnl @result{}# forloop(var, from, to, stmt) - refactored to share code
19 dnl @result{}define(`forloop', `ifelse(eval(`($2) <= ($3)'), `1',
20 dnl @result{} `pushdef(`$1')_forloop(eval(`$2'), eval(`$3'),
21 dnl @result{} `define(`$1',', `)$4')popdef(`$1')')')
22 dnl @result{}define(`_forloop',
23 dnl @result{} `$3`$1'$4`'ifelse(`$1', `$2', `',
24 dnl @result{} `$0(incr(`$1'), `$2', `$3', `$4')')')
25 dnl @result{}divert`'dnl
26 forloop(`i', `1', `3', ` i')
30 forloop_arg(`1', `3', ` echo')
34 forloop_arg(`1', `3', `curry(`pushdef', `a')')