autoconf-patches
[Top][All Lists]
Advanced

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

Re: m4_combine


From: Eric Blake
Subject: Re: m4_combine
Date: Wed, 17 Oct 2007 16:06:21 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Eric Blake <ebb9 <at> byu.net> writes:

> Based on libtool's lt_combine, but a bit more efficient.  Committed.
> 
> 2007-10-17  Eric Blake  <ebb9 <at> byu.net>
> 
>       Add m4_combine, based on Libtool's lt_combine.

And this followup, to match lt_combine semantics when there are no suffixes (it 
already matched when there were no prefixes).

From: Eric Blake <address@hidden>
Date: Wed, 17 Oct 2007 10:02:04 -0600
Subject: [PATCH] Fix m4_combine for empty suffix list.

* lib/m4sugar/m4sugar.m4 (m4_combine): Check for suffix list.
* doc/autoconf.texi (Text processing Macros): Document this.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog              |    4 ++++
 doc/autoconf.texi      |   11 ++++++++++-
 lib/m4sugar/m4sugar.m4 |   15 ++++++++-------
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2afeb3d..523d5d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2007-10-17  Eric Blake  <address@hidden>
 
+       Fix m4_combine for empty suffix list.
+       * lib/m4sugar/m4sugar.m4 (m4_combine): Check for suffix list.
+       * doc/autoconf.texi (Text processing Macros): Document this.
+
        Add m4_combine, based on Libtool's lt_combine.
        * lib/m4sugar/m4sugar.m4 (m4_combine): New macro.
        * doc/autoconf.texi (Text processing Macros): Document it.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 3c553c1..2710a6a 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -10950,11 +10950,20 @@ of every element of the quoted, comma-separated @var
{prefix-list}, and
 every element from the @var{suffix} arguments.  Each pairwise
 combination is joined with @var{infix} in the middle, and successive
 pairs are joined by @var{separator}.  No expansion occurs on any of the
-arguments.
+arguments.  No output occurs if either the @var{prefix} or @var{suffix}
+list is empty, but the lists can contain empty elements.
 @example
 m4_define([a], [oops])dnl
 m4_combine([, ], [[a], [b], [c]], [-], [1], [2], [3])
 @result{}a-1, a-2, a-3, b-1, b-2, b-3, c-1, c-2, c-3
+m4_combine([, ], [[a], [b]], [-])
address@hidden
+m4_combine([, ], [[a], [b]], [-], [])
address@hidden, b-
+m4_combine([, ], [], [-], [1], [2])
address@hidden
+m4_combine([, ], [[]], [-], [1], [2])
address@hidden, -2
 @end example
 @end defmac
 
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index 14ded41..a1be414 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -1830,13 +1830,14 @@ m4_define([_m4_join],
 # we compute the m4_shift3 only once, rather than in each iteration of the
 # outer m4_foreach.
 m4_define([m4_combine],
-[m4_pushdef([m4_Separator], [m4_define([m4_Separator], [[$1]])])]dnl
-[m4_foreach([m4_Prefix], [$2],
-           [m4_foreach([m4_Suffix], ]m4_dquote(m4_dquote(m4_shift3($@)))[,
-                       [m4_Separator[]m4_builtin([defn],
-                                      [m4_Prefix])[$3]m4_builtin([defn],
-                                                      [m4_Suffix])])])]dnl
-[m4_builtin([popdef], [m4_Separator])])
+[m4_if(m4_eval([$# > 3]), [1],
+       [m4_pushdef([m4_Separator], [m4_define([m4_Separator], [[$1]])])]]dnl
+[[m4_foreach([m4_Prefix], [$2],
+            [m4_foreach([m4_Suffix], ]m4_dquote(m4_dquote(m4_shift3($@)))[,
+                        [m4_Separator[]m4_builtin([defn],
+                                       [m4_Prefix])[$3]m4_builtin([defn],
+                                                       [m4_Suffix])])])]]dnl
+[[m4_builtin([popdef], [m4_Separator])])])
 
 
 # m4_append(MACRO-NAME, STRING, [SEPARATOR])
-- 
1.5.3.2








reply via email to

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