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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
dnl @ ../doc/m4.texi:8197: 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(`foreach2.m4')
dnl @result{}
include(`foreachq2.m4')
dnl @result{}
dnl 0-element list:
foreach(`x', `', `<x>') / foreachq(`x', `', `<x>')
dnl @result{} /
dnl 1-element list of empty element
foreach(`x', `()', `<x>') / foreachq(`x', ``'', `<x>')
dnl @result{}<> / <>
dnl 2-element list of empty elements
foreach(`x', `(`',`')', `<x>') / foreachq(`x', ``',`'', `<x>')
dnl @result{}<><> / <><>
dnl 1-element list of a comma
foreach(`x', `(`,')', `<x>') / foreachq(`x', ``,'', `<x>')
dnl @result{}<,> / <,>
dnl 2-element list of unbalanced parentheses
foreach(`x', `(`(', `)')', `<x>') / foreachq(`x', ``(', `)'', `<x>')
dnl @result{}<(><)> / <(><)>
define(`ab', `oops')dnl using defn(`iterator')
foreach(`x', `(`a', `b')', `defn(`x')') /dnl
foreachq(`x', ``a', `b'', `defn(`x')')
dnl @result{}ab / ab
define(`active', `ACT, IVE')
dnl @result{}
traceon(`active')
dnl @result{}
dnl list of unquoted macros; expansion occurs before recursion
foreach(`x', `(active, active)', `<x>
')dnl
dnl @error{}m4trace: -4- active -> `ACT, IVE'
dnl @error{}m4trace: -4- active -> `ACT, IVE'
dnl @result{}<ACT>
dnl @result{}<IVE>
dnl @result{}<ACT>
dnl @result{}<IVE>
foreachq(`x', `active, active', `<x>
')dnl
dnl @error{}m4trace: -3- active -> `ACT, IVE'
dnl @error{}m4trace: -3- active -> `ACT, IVE'
dnl @result{}<ACT>
dnl @error{}m4trace: -3- active -> `ACT, IVE'
dnl @error{}m4trace: -3- active -> `ACT, IVE'
dnl @result{}<IVE>
dnl @result{}<ACT>
dnl @result{}<IVE>
dnl list of quoted macros; expansion occurs during recursion
foreach(`x', `(`active', `active')', `<x>
')dnl
dnl @error{}m4trace: -1- active -> `ACT, IVE'
dnl @result{}<ACT, IVE>
dnl @error{}m4trace: -1- active -> `ACT, IVE'
dnl @result{}<ACT, IVE>
foreachq(`x', ``active', `active'', `<x>
')dnl
dnl @error{}m4trace: -1- active -> `ACT, IVE'
dnl @result{}<ACT, IVE>
dnl @error{}m4trace: -1- active -> `ACT, IVE'
dnl @result{}<ACT, IVE>
dnl list of double-quoted macro names; no expansion
foreach(`x', `(``active'', ``active'')', `<x>
')dnl
dnl @result{}<active>
dnl @result{}<active>
foreachq(`x', ```active'', ``active''', `<x>
')dnl
dnl @result{}<active>
dnl @result{}<active>
|