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