add packaging
[platform/upstream/m4.git] / examples / stack.m4
1 divert(`-1')
2 # stack_foreach(macro, action)
3 # Invoke ACTION with a single argument of each definition
4 # from the definition stack of MACRO, starting with the oldest.
5 define(`stack_foreach',
6 `_stack_reverse(`$1', `tmp-$1')'dnl
7 `_stack_reverse(`tmp-$1', `$1', `$2(defn(`$1'))')')
8 # stack_foreach_lifo(macro, action)
9 # Invoke ACTION with a single argument of each definition
10 # from the definition stack of MACRO, starting with the newest.
11 define(`stack_foreach_lifo',
12 `_stack_reverse(`$1', `tmp-$1', `$2(defn(`$1'))')'dnl
13 `_stack_reverse(`tmp-$1', `$1')')
14 define(`_stack_reverse',
15 `ifdef(`$1', `pushdef(`$2', defn(`$1'))$3`'popdef(`$1')$0($@)')')
16 divert`'dnl