]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix m4_cond corner case.
authorEric Blake <ebb9@byu.net>
Tue, 12 Aug 2008 15:18:53 +0000 (09:18 -0600)
committerEric Blake <ebb9@byu.net>
Tue, 12 Aug 2008 15:18:53 +0000 (09:18 -0600)
* lib/m4sugar/foreach.m4 (_m4_cond): Ensure alternate
implementation allows concatenation with subsequent text.
* tests/m4sugar.at (m4@&t@_cond): Enhance test.

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

index 8c1faa2163230f0366636f4b02abbe3849386b8d..d4600784cae5dae0dba3d7f61e1c7c9a74c8ac78 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2008-08-12  Eric Blake  <ebb9@byu.net>
 
+       Fix m4_cond corner case.
+       * lib/m4sugar/foreach.m4 (_m4_cond): Ensure alternate
+       implementation allows concatenation with subsequent text.
+       * tests/m4sugar.at (m4@&t@_cond): Enhance test.
+
        Add test for m4_cond.
        * tests/m4sugar.at (m4@&t@_cond): New test.
        Reported by Ralf Wildenhues.
index 78779c4040984534c515b5ade88528dce52a603a..b85fce2ffb060f55aed9121f5d53f917319a5c72 100644 (file)
@@ -132,17 +132,18 @@ m4_define([_m4_case_],
 # m4_cond already guarantees either 3*n or 3*n + 1 arguments, 1 <= n.
 # We only have to speed up _m4_cond, by building the temporary _m4_c:
 #   m4_define([_m4_c], _m4_defn([m4_unquote]))_m4_c([m4_if(($1), [($2)],
-#   [$3[]m4_define([_m4_c])])])_m4_c([m4_if(($4), [($5)],
-#   [$6[]m4_define([_m4_c])])])..._m4_c([m4_if(($m-2), [($m-1)],
-#   [$m[]m4_define([_m4_c])])])_m4_c([$m+1]_m4_popdef([_m4_c]))
+#   [[$3]m4_define([_m4_c])])])_m4_c([m4_if(($4), [($5)],
+#   [[$6]m4_define([_m4_c])])])..._m4_c([m4_if(($m-2), [($m-1)],
+#   [[$m]m4_define([_m4_c])])])_m4_c([[$m+1]]_m4_popdef([_m4_c]))
+# We invoke m4_unquote(_m4_c($@)), for concatenation with later text.
 m4_define([_m4_cond],
 [m4_define([_m4_c], m4_pushdef([_m4_c])[m4_define([_m4_c],
   _m4_defn([m4_unquote]))]_m4_for([_m4_c], [2], m4_eval([$# / 3 * 3 - 1]), [3],
-  [$0_(m4_decr(_m4_c), _m4_c, m4_incr(_m4_c))])[_m4_c(]m4_dquote(
-  [$]m4_eval([$# / 3 * 3 + 1]))[_m4_popdef([_m4_c]))])_m4_c($@)])
+  [$0_(m4_decr(_m4_c), _m4_c, m4_incr(_m4_c))])[_m4_c(]m4_dquote(m4_dquote(
+  [$]m4_eval([$# / 3 * 3 + 1])))[_m4_popdef([_m4_c]))])m4_unquote(_m4_c($@))])
 
 m4_define([_m4_cond_],
-[[_m4_c([m4_if(($$1), [($$2)], [$$3[]m4_define([_m4_c])])])]])
+[[_m4_c([m4_if(($$1), [($$2)], [[$$3]m4_define([_m4_c])])])]])
 
 # m4_bpatsubsts(STRING, RE1, SUBST1, RE2, SUBST2, ...)
 # ----------------------------------------------------
index b52b833554b8e6d934e4f559fd91b8508d60f1ee..8e5fd012db45b8926d80ff1714e8d3d955ab1765 100644 (file)
@@ -214,6 +214,10 @@ m4_cond([[a,a]], [a,a], [yes])
 m4_cond([a,a], [a,b], [yes], [no])
 m4_cond([a,a], [a,b], [yes])
 m4_cond([m4_eval([0xa])])
+m4_define([ab], [AB])dnl
+m4_cond([a])b
+m4_cond([1], [1], [a])b
+m4_cond([1], [2], [3], [a])b
 ]], [[
 a
 c
@@ -223,6 +227,9 @@ yes
 no
 
 10
+AB
+AB
+AB
 ]], [[1
 2
 2