CVSROOT: /sources/m4 Module name: m4 Branch: branch-1_4 Changes by: Eric Blake <ericb> 06/10/21 02:55:56
Index: examples/foreach2.m4 =================================================================== RCS file: examples/foreach2.m4 diff -N examples/foreach2.m4 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ examples/foreach2.m4 21 Oct 2006 02:55:56 -0000 1.1.2.1 @@ -0,0 +1,10 @@ +include(`quote.m4')dnl +divert(`-1') +# foreach(x, (item_1, item_2, ..., item_n), stmt) +# parenthesized list, improved version +define(`foreach', `pushdef(`$1')_foreach(`$1', + (dquote(dquote_elt$2)), `$3')popdef(`$1')') +define(`_arg1', `$1') +define(`_foreach', `ifelse(`$2', `(`')', `', + `define(`$1', _arg1$2)$3`'$0(`$1', (dquote(shift$2)), `$3')')') +divert`'dnl
