7e1f47fd606be3a29b8a5da5f0f7e3f75773c900
[platform/upstream/m4.git] / checks / 229.improved_c
1 dnl @ ../doc/m4.texinfo:8347: Origin of test
2 dnl @ expected status: 0
3 dnl @ extra options: 
4 dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software
5 dnl @ Foundation, Inc.
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
9 dnl @ is preserved.
10 include(`stack_sep.m4')
11 dnl @result{}
12 define(`copy', `ifdef(`$2', `errprint(`$2 already defined
13 ')m4exit(`1')',
14    `stack_foreach_sep(`$1', `pushdef(`$2',', `)')')')dnl
15 pushdef(`a', `1')pushdef(`a', defn(`divnum'))
16 dnl @result{}
17 copy(`a', `b')
18 dnl @result{}
19 b
20 dnl @result{}0
21 popdef(`b')
22 dnl @result{}
23 b
24 dnl @result{}1
25 pushdef(`c', `1')pushdef(`c', `2')
26 dnl @result{}
27 stack_foreach_sep_lifo(`c', `', `', `, ')
28 dnl @result{}2, 1
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