1 dnl @ ../doc/m4.texi:8376: 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(`stack_sep.m4')
12 define(`copy', `ifdef(`$2', `errprint(`$2 already defined
14 `stack_foreach_sep(`$1', `pushdef(`$2',', `)')')')dnl
15 pushdef(`a', `1')pushdef(`a', defn(`divnum'))
25 pushdef(`c', `1')pushdef(`c', `2')
27 stack_foreach_sep_lifo(`c', `', `', `, ')
29 undivert(`stack_sep.m4')dnl
30 dnl @result{}divert(`-1')
31 dnl @result{}# stack_foreach_sep(macro, pre, post, sep)
32 dnl @result{}# Invoke PRE`'defn`'POST with a single argument of each definition
33 dnl @result{}# from the definition stack of MACRO, starting with the oldest, and
34 dnl @result{}# separated by SEP between definitions.
35 dnl @result{}define(`stack_foreach_sep',
36 dnl @result{}`_stack_reverse_sep(`$1', `tmp-$1')'dnl
37 dnl @result{}`_stack_reverse_sep(`tmp-$1', `$1', `$2`'defn(`$1')$3', `$4`'')')
38 dnl @result{}# stack_foreach_sep_lifo(macro, pre, post, sep)
39 dnl @result{}# Like stack_foreach_sep, but starting with the newest definition.
40 dnl @result{}define(`stack_foreach_sep_lifo',
41 dnl @result{}`_stack_reverse_sep(`$1', `tmp-$1', `$2`'defn(`$1')$3', `$4`'')'dnl
42 dnl @result{}`_stack_reverse_sep(`tmp-$1', `$1')')
43 dnl @result{}define(`_stack_reverse_sep',
44 dnl @result{}`ifdef(`$1', `pushdef(`$2', defn(`$1'))$3`'popdef(`$1')$0(
45 dnl @result{} `$1', `$2', `$4$3')')')
46 dnl @result{}divert`'dnl