From: Eric Blake Date: Wed, 17 Oct 2007 16:02:04 +0000 (-0600) Subject: Fix m4_combine for empty suffix list. X-Git-Tag: v2.62~208 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0c0e7bbd41d23eedd0453598c5193965d6b5c52a;p=thirdparty%2Fautoconf.git 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 --- diff --git a/ChangeLog b/ChangeLog index 2afeb3d65..523d5d375 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2007-10-17 Eric Blake + 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 3c553c144..2710a6adc 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]], [-]) +@result{} +m4_combine([, ], [[a], [b]], [-], []) +@result{}a-, b- +m4_combine([, ], [], [-], [1], [2]) +@result{} +m4_combine([, ], [[]], [-], [1], [2]) +@result{}-1, -2 @end example @end defmac diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4 index 14ded41fa..a1be414b1 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])