summaryrefslogtreecommitdiff
path: root/checks/229.improved_c
blob: ce9de2f89d447864e78abf35ffb5e67c6f850276 (plain)
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
dnl @ ../doc/m4.texi:8376: 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(`stack_sep.m4')
dnl @result{}
define(`copy', `ifdef(`$2', `errprint(`$2 already defined
')m4exit(`1')',
   `stack_foreach_sep(`$1', `pushdef(`$2',', `)')')')dnl
pushdef(`a', `1')pushdef(`a', defn(`divnum'))
dnl @result{}
copy(`a', `b')
dnl @result{}
b
dnl @result{}0
popdef(`b')
dnl @result{}
b
dnl @result{}1
pushdef(`c', `1')pushdef(`c', `2')
dnl @result{}
stack_foreach_sep_lifo(`c', `', `', `, ')
dnl @result{}2, 1
undivert(`stack_sep.m4')dnl
dnl @result{}divert(`-1')
dnl @result{}# stack_foreach_sep(macro, pre, post, sep)
dnl @result{}# Invoke PRE`'defn`'POST with a single argument of each definition
dnl @result{}# from the definition stack of MACRO, starting with the oldest, and
dnl @result{}# separated by SEP between definitions.
dnl @result{}define(`stack_foreach_sep',
dnl @result{}`_stack_reverse_sep(`$1', `tmp-$1')'dnl
dnl @result{}`_stack_reverse_sep(`tmp-$1', `$1', `$2`'defn(`$1')$3', `$4`'')')
dnl @result{}# stack_foreach_sep_lifo(macro, pre, post, sep)
dnl @result{}# Like stack_foreach_sep, but starting with the newest definition.
dnl @result{}define(`stack_foreach_sep_lifo',
dnl @result{}`_stack_reverse_sep(`$1', `tmp-$1', `$2`'defn(`$1')$3', `$4`'')'dnl
dnl @result{}`_stack_reverse_sep(`tmp-$1', `$1')')
dnl @result{}define(`_stack_reverse_sep',
dnl @result{}`ifdef(`$1', `pushdef(`$2', defn(`$1'))$3`'popdef(`$1')$0(
dnl @result{}  `$1', `$2', `$4$3')')')
dnl @result{}divert`'dnl