autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

m4_joinall


From: Eric Blake
Subject: m4_joinall
Date: Sat, 19 Jul 2008 07:04:44 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've got a pending patch series to add m4_set_* where I wanted to use
m4_join, but not have the empty argument omitted.  I'm borrowing this from
the m4 manual, and committing.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkiB5mwACgkQ84KuGfSFAYDJEQCfXm09UBMbSy08XciAudaJZGcK
GloAn0RLqm177gO5ur/k64qgpWgH9uKv
=yabf
-----END PGP SIGNATURE-----
>From 65ff0e8f8876e4b4e354c8b23fba1b6e2c077689 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 18 Jul 2008 08:30:07 -0600
Subject: [PATCH] Add m4_joinall.

* lib/m4sugar/m4sugar.m4 (m4_joinall, _m4_joinall): New macros.
* tests/m4sugar.at (m4@&address@hidden): Test them.
* doc/autoconf.texi (Text processing Macros) <m4_join>: Document
m4_joinall.
* NEWS: Likewise.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog              |    9 +++++++++
 NEWS                   |    3 +++
 doc/autoconf.texi      |   11 ++++++++---
 lib/m4sugar/m4sugar.m4 |    7 +++++++
 tests/m4sugar.at       |   14 ++++++++++++++
 5 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index da65cc7..af9b4d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-07-18  Eric Blake  <address@hidden>
+
+       Add m4_joinall.
+       * lib/m4sugar/m4sugar.m4 (m4_joinall, _m4_joinall): New macros.
+       * tests/m4sugar.at (m4@&address@hidden): Test them.
+       * doc/autoconf.texi (Text processing Macros) <m4_join>: Document
+       m4_joinall.
+       * NEWS: Likewise.
+
 2008-07-17  Stepan Kasal  <address@hidden>
        and Eric Blake  <address@hidden>
 
diff --git a/NEWS b/NEWS
index 06b705f..d3fb23b 100644
--- 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].
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index bfe5c1b..4e8638d 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -11163,14 +11163,19 @@ still a quoted string.
 @end defmac
 
 @defmac m4_join (@ovar{separator}, @address@hidden)
address@hidden m4_joinall (@ovar{separator}, @address@hidden)
 @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.
address@hidden
+Concatenate each @var{arg}, separated by @var{separator}.
address@hidden 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])
address@hidden||active|two
 @end example
 
 Note that if all you intend to do is join @var{args} with commas between
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index c6993ee..eb4374e 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -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...)
 # --------------------------------------------------------
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index 69cb74b..b6a4cac 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -284,6 +284,8 @@ AT_CLEANUP
 
 AT_SETUP([m4@&address@hidden)
 
+AT_KEYWORDS([m4@&address@hidden)
+
 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
-- 
1.5.6


reply via email to

[Prev in Thread] Current Thread [Next in Thread]