Imported Upstream version 1.4.16
[platform/upstream/m4.git] / examples / stack_sep.m4
1 divert(`-1')
2 # stack_foreach_sep(macro, pre, post, sep)
3 # Invoke PRE`'defn`'POST with a single argument of each definition
4 # from the definition stack of MACRO, starting with the oldest, and
5 # separated by SEP between definitions.
6 define(`stack_foreach_sep',
7 `_stack_reverse_sep(`$1', `tmp-$1')'dnl
8 `_stack_reverse_sep(`tmp-$1', `$1', `$2`'defn(`$1')$3', `$4`'')')
9 # stack_foreach_sep_lifo(macro, pre, post, sep)
10 # Like stack_foreach_sep, but starting with the newest definition.
11 define(`stack_foreach_sep_lifo',
12 `_stack_reverse_sep(`$1', `tmp-$1', `$2`'defn(`$1')$3', `$4`'')'dnl
13 `_stack_reverse_sep(`tmp-$1', `$1')')
14 define(`_stack_reverse_sep',
15 `ifdef(`$1', `pushdef(`$2', defn(`$1'))$3`'popdef(`$1')$0(
16   `$1', `$2', `$4$3')')')
17 divert`'dnl