summaryrefslogtreecommitdiff
path: root/checks/217.improved_f
blob: 68ad0376148aae8e97de62ea1630f1a8ef24aec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
dnl @ ../doc/m4.texinfo:7845: Origin of test
dnl @ expected status: 0
dnl @ extra options: 
dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software
dnl @ Foundation, Inc.
dnl @ This file is free software; the Free Software Foundation
dnl @ gives unlimited permission to copy and/or distribute it
dnl @ with or without modifications, as long as this notice
dnl @ is preserved.
include(`forloop3.m4')
dnl @result{}
undivert(`forloop3.m4')dnl
dnl @result{}divert(`-1')
dnl @result{}# forloop_arg(from, to, macro) - invoke MACRO(value) for
dnl @result{}#   each value between FROM and TO, without define overhead
dnl @result{}define(`forloop_arg', `ifelse(eval(`($1) <= ($2)'), `1',
dnl @result{}  `_forloop(`$1', eval(`$2'), `$3(', `)')')')
dnl @result{}# forloop(var, from, to, stmt) - refactored to share code
dnl @result{}define(`forloop', `ifelse(eval(`($2) <= ($3)'), `1',
dnl @result{}  `pushdef(`$1')_forloop(eval(`$2'), eval(`$3'),
dnl @result{}    `define(`$1',', `)$4')popdef(`$1')')')
dnl @result{}define(`_forloop',
dnl @result{}  `$3`$1'$4`'ifelse(`$1', `$2', `',
dnl @result{}    `$0(incr(`$1'), `$2', `$3', `$4')')')
dnl @result{}divert`'dnl
forloop(`i', `1', `3', ` i')
dnl @result{} 1 2 3
define(`echo', `$@')
dnl @result{}
forloop_arg(`1', `3', ` echo')
dnl @result{} 1 2 3
include(`curry.m4')
dnl @result{}
forloop_arg(`1', `3', `curry(`pushdef', `a')')
dnl @result{}
a
dnl @result{}3
popdef(`a')a
dnl @result{}2
popdef(`a')a
dnl @result{}1
popdef(`a')a
dnl @result{}a