1 dnl @ ../doc/m4.texi:8019: 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(`foreachq3.m4')
12 undivert(`foreachq3.m4')dnl
13 dnl @result{}divert(`-1')
14 dnl @result{}# foreachq(x, `item_1, item_2, ..., item_n', stmt)
15 dnl @result{}# quoted list, alternate improved version
16 dnl @result{}define(`foreachq', `ifelse(`$2', `', `',
17 dnl @result{} `pushdef(`$1')_$0(`$1', `$3', `', $2)popdef(`$1')')')
18 dnl @result{}define(`_foreachq', `ifelse(`$#', `3', `',
19 dnl @result{} `define(`$1', `$4')$2`'$0(`$1', `$2',
20 dnl @result{} shift(shift(shift($@))))')')
21 dnl @result{}divert`'dnl
22 traceon(`shift')debugmode(`aq')
24 foreachq(`x', ``1', `2', `3', `4'', `x
27 dnl @error{}m4trace: -4- shift(`x', `x
28 dnl @error{}', `', `1', `2', `3', `4')
29 dnl @error{}m4trace: -3- shift(`x
30 dnl @error{}', `', `1', `2', `3', `4')
31 dnl @error{}m4trace: -2- shift(`', `1', `2', `3', `4')
33 dnl @error{}m4trace: -4- shift(`x', `x
34 dnl @error{}', `1', `2', `3', `4')
35 dnl @error{}m4trace: -3- shift(`x
36 dnl @error{}', `1', `2', `3', `4')
37 dnl @error{}m4trace: -2- shift(`1', `2', `3', `4')
39 dnl @error{}m4trace: -4- shift(`x', `x
40 dnl @error{}', `2', `3', `4')
41 dnl @error{}m4trace: -3- shift(`x
42 dnl @error{}', `2', `3', `4')
43 dnl @error{}m4trace: -2- shift(`2', `3', `4')
45 dnl @error{}m4trace: -4- shift(`x', `x
46 dnl @error{}', `3', `4')
47 dnl @error{}m4trace: -3- shift(`x
48 dnl @error{}', `3', `4')
49 dnl @error{}m4trace: -2- shift(`3', `4')