]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Add m4_joinall.
authorEric Blake <ebb9@byu.net>
Fri, 18 Jul 2008 14:30:07 +0000 (08:30 -0600)
committerEric Blake <ebb9@byu.net>
Sat, 19 Jul 2008 02:18:37 +0000 (20:18 -0600)
* lib/m4sugar/m4sugar.m4 (m4_joinall, _m4_joinall): New macros.
* tests/m4sugar.at (m4@&t@_join): Test them.
* doc/autoconf.texi (Text processing Macros) <m4_join>: Document
m4_joinall.
* NEWS: Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
NEWS
doc/autoconf.texi
lib/m4sugar/m4sugar.m4
tests/m4sugar.at

index da65cc7ec5915cbfec0fcec13f37700288c596ea..af9b4d9b61512512c9da1574039f08c0655edc78 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-07-18  Eric Blake  <ebb9@byu.net>
+
+       Add m4_joinall.
+       * lib/m4sugar/m4sugar.m4 (m4_joinall, _m4_joinall): New macros.
+       * tests/m4sugar.at (m4@&t@_join): Test them.
+       * doc/autoconf.texi (Text processing Macros) <m4_join>: Document
+       m4_joinall.
+       * NEWS: Likewise.
+
 2008-07-17  Stepan Kasal  <skasal@redhat.com>
        and Eric Blake  <ebb9@byu.net>
 
diff --git a/NEWS b/NEWS
index 06b705f7d81c8a3c9b148c18a4e39378aef42403..d3fb23b9cb69041467177f5826202fe8a86c3d4d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,9 @@ GNU Autoconf NEWS - User visible changes.
 ** Two new quadrigraphs have been introduced: @{:@ for (, and @:}@ for ),
    allowing the output of unbalanced parantheses in more contexts.
 
+** The following m4sugar macros are new:
+   m4_joinall
+
 ** AT_KEYWORDS once again performs expansion on its argument, such that
    AT_KEYWORDS([m4_if([$1], [], [default])]) no longer complains about
    the possibly unexpanded m4_if [regression introduced in 2.62].
index bfe5c1b43e5296244cca3964e13d1415f83f89b3..4e8638d34c4b419382d09ed701f3a343266bf816 100644 (file)
@@ -11163,14 +11163,19 @@ still a quoted string.
 @end defmac
 
 @defmac m4_join (@ovar{separator}, @var{args}@dots{})
+@defmacx m4_joinall (@ovar{separator}, @var{args}@dots{})
 @msindex{join}
-Concatenate each @var{arg}, separated by @var{separator}, with the
-exception that no back-to-back separators are issued for empty
-arguments.  The result is a quoted string.
+@msindex{joinall}
+Concatenate each @var{arg}, separated by @var{separator}.
+@code{joinall} uses every argument, while @code{join} omits empty
+arguments so that there are no back-to-back separators in the output.
+The result is a quoted string.
 @example
 m4_define([active], [ACTIVE])dnl
 m4_join([|], [one], [], [active], [two])
 @result{}one|active|two
+m4_joinall([|], [one], [], [active], [two])
+@result{}one||active|two
 @end example
 
 Note that if all you intend to do is join @var{args} with commas between
index c6993ee9cdf1b346e4f7b38a57bc061009eec2d3..eb4374e2d53891784c6ffc90293c1d95d1cb5797 100644 (file)
@@ -1846,6 +1846,13 @@ m4_define([_m4_join],
 [m4_if([$#$2], [2], [],
        [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift2($@))])])
 
+# m4_joinall(SEP, ARG1, ARG2...)
+# ------------------------------
+# Produce ARG1SEPARG2...SEPARGn.  An empty ARG results in back-to-back SEP.
+# No expansion is performed on SEP or ARGs.
+m4_define([m4_joinall], [[$2]_$0([$1], m4_shift($@))])
+m4_define([_m4_joinall],
+[m4_if([$#], [2], [], [[$1$3]$0([$1], m4_shift2($@))])])
 
 # m4_combine([SEPARATOR], PREFIX-LIST, [INFIX], SUFFIX...)
 # --------------------------------------------------------
index 69cb74b59706102411a7afe9cc7ac49e86902953..b6a4cac5ebf253af636410f7edf10ac3636d4906 100644 (file)
@@ -284,6 +284,8 @@ AT_CLEANUP
 
 AT_SETUP([m4@&t@_join])
 
+AT_KEYWORDS([m4@&t@_joinall])
+
 AT_CHECK_M4SUGAR_TEXT(
 [[m4_define([active], [ACTIVE])
 m4_join
@@ -297,6 +299,12 @@ m4_join([], ,,,[two])
 m4_join([], [two],,,)
 m4_join([ active ], [one], , [two])
 m4_join([], [one], [two])
+m4_joinall([-], [one], [], [two])
+m4_joinall([-], [], [], [three], [], [])
+m4_joinall([], [one], [], [two])
+m4_joinall
+m4_joinall([-])
+m4_joinall([-], [one])
 ]],
 [[
 
@@ -310,6 +318,12 @@ two
 two
 one active two
 onetwo
+one--two
+--three--
+onetwo
+
+
+one
 ]])
 
 AT_CLEANUP