]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix m4_combine for empty suffix list.
authorEric Blake <ebb9@byu.net>
Wed, 17 Oct 2007 16:02:04 +0000 (10:02 -0600)
committerEric Blake <ebb9@byu.net>
Wed, 17 Oct 2007 16:02:04 +0000 (10:02 -0600)
* lib/m4sugar/m4sugar.m4 (m4_combine): Check for suffix list.
* doc/autoconf.texi (Text processing Macros): Document this.

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

index 2afeb3d65b805ec20e53b4493912e6a64d2d569c..523d5d375f9c4820ce9f2bd33c7d9cc7d0586a6e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2007-10-17  Eric Blake  <ebb9@byu.net>
 
+       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.
index 3c553c144da04addbe6d40d4d0a122e702dd28d0..2710a6adcf7cb198d3d89797577ce6e85cb6eee1 100644 (file)
@@ -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]], [-])
+@result{}
+m4_combine([, ], [[a], [b]], [-], [])
+@result{}a-, b-
+m4_combine([, ], [], [-], [1], [2])
+@result{}
+m4_combine([, ], [[]], [-], [1], [2])
+@result{}-1, -2
 @end example
 @end defmac
 
index 14ded41fa59bef05b51d7ec3e0e81b499204e986..a1be414b1c598f2f005a088088f63397245d0c1d 100644 (file)
@@ -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])