defs.m4: New macros for inserting separators into lists.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 4 May 2015 10:00:46 +0000 (11:00 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 4 May 2015 10:00:46 +0000 (11:00 +0100)
defs.m4

diff --git a/defs.m4 b/defs.m4
index c289385..f2767fd 100644 (file)
--- a/defs.m4
+++ b/defs.m4
@@ -73,6 +73,19 @@ m4_pushdef(<:_foreach_func:>, <:$1:>)m4_dnl
 _FOREACH($2)<::>m4_dnl
 m4_popdef(<:_foreach_func:>):>)
 
+## CLRSEP
+##
+## Clear the separator.  Use in conjunction with `SEP' below.
+m4_define(<:CLRSEP:>, <:m4_define(<:__sep:>, <::>):>)m4_dnl
+
+## SEP(newsep)
+##
+## Insert the current separator, and then set the separator to NEWSEP.  This
+## is handy in `FOREACH' loops, in order to separate the items with the
+## correct number of fenceposts: call `CLRSEP' before the list, and begin
+## each item with SEP(...).
+m4_define(<:SEP:>, <:__sep<::>m4_define(<:__sep:>, <:$1:>):>)m4_dnl
+
 ## DIVERT(name)
 ##
 ## Make _div:NAME be the current diversion.