]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Quote separators in foreach.m4 version of m4_joinall.
authorZack Weinberg <zack@owlfolio.org>
Mon, 8 Jul 2024 15:22:44 +0000 (11:22 -0400)
committerZack Weinberg <zack@owlfolio.org>
Wed, 17 Jul 2024 17:16:21 +0000 (13:16 -0400)
The entire output of m4_joinall is supposed to be quoted, including
separators, but the foreach.m4 implementation (used with M4 1.4.x)
was missing some quotes, and we didn’t notice because the test suite
wasn’t thorough enough.  Fix.

* lib/m4sugar/foreach.m4 (m4_joinall): Quote each separator as it’s
  emitted.
* tests/m4sugar.at (m4_join test): Expand tests of both m4_join and
  m4_joinall.

lib/m4sugar/foreach.m4
tests/m4sugar.at

index c5f26d133dbeeb867a486b105ee503af78c938b5..ab558ac54aa0be76723e8f0828ef9439cba69b95 100644 (file)
@@ -292,7 +292,7 @@ m4_define([_m4_join],
 # A bit easier than m4_join.  _m4_foreach to the rescue.
 m4_define([m4_joinall],
 [[$2]m4_if(m4_eval([$# <= 2]), [1], [],
-          [_m4_foreach([$1], [], m4_shift($@))])])
+          [_m4_foreach([[$1]], [], m4_shift($@))])])
 
 # m4_list_cmp(A, B)
 # -----------------
index 7ea786b74cdf13705bad1cbab077f566e6e83e1c..0b36e6261e872b6c42354f0c08e63f21ed8be4aa 100644 (file)
@@ -1160,43 +1160,78 @@ AT_SETUP([m4@&t@_join])
 AT_KEYWORDS([m4@&t@_joinall])
 
 AT_CHECK_M4SUGAR_TEXT(
-[[m4_define([active], [ACTIVE])
+[[m4_define([active], [ACTIVE])dnl
 m4_join
 m4_join([|])
+m4_join([|], [one])
+m4_join([|], [one], [two])
+m4_join([|], [one], [], [two])
+m4_join([], [one], [two])
+m4_join([], [one], [], [two])
 m4_join([, ], [one], [two])
 m4_dquote(m4_join([, ], [one], [two]))
 m4_join([|], [active], [active])
+m4_join([|], [active], [], [active])
+m4_join([ active ], [one], , [two])
 m4_join([|], ,,,[one])
 m4_join([|], [one],,,)
 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_join([|], [], [], [three], [], [])
+----
 m4_joinall
 m4_joinall([-])
 m4_joinall([-], [one])
+m4_joinall([-], [one], [two])
+m4_joinall([-], [one], [], [two])
+m4_joinall([], [one], [two])
+m4_joinall([], [one], [], [two])
+m4_joinall([, ], [one], [two])
+m4_dquote(m4_joinall([, ], [one], [two]))
+m4_joinall([-], [active], [active])
+m4_joinall([-], [active], [], [active])
+m4_joinall([ active ], [one], , [two])
+m4_joinall([-], ,,,[one])
+m4_joinall([-], [one],,,)
+m4_joinall([], ,,,[two])
+m4_joinall([], [two],,,)
+m4_joinall([-], [], [], [three], [], [])
 ]],
 [[
 
-
+one
+one|two
+one|two
+onetwo
+onetwo
 one, two
 [one, two]
 active|active
+active|active
+one active two
 one
 one
 two
 two
-one active two
-onetwo
-one--two
---three--
-onetwo
+three
+----
 
 
 one
+one-two
+one--two
+onetwo
+onetwo
+one, two
+[one, two]
+active-active
+active--active
+one active  active two
+---one
+one---
+two
+two
+--three--
 ]])
 
 AT_CLEANUP