]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Quote separators in foreach.m4 version of m4_joinall.
authorZack Weinberg <zack@owlfolio.org>
Wed, 26 Jun 2024 18:35:09 +0000 (14:35 -0400)
committerZack Weinberg <zack@owlfolio.org>
Wed, 26 Jun 2024 19:22:29 +0000 (15:22 -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 ba7191afc8a9453041d4f3c6ebe04c8413462bc2..c241ff079a04f426b185a294059ad911e78970d5 100644 (file)
@@ -1160,43 +1160,90 @@ 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], [one], [two])
+m4_join([|], [one], [two], [one])
+m4_join([|], [one], [on], [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], [one], [two])
+m4_joinall([-], [one], [two], [one])
+m4_joinall([-], [one], [on], [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|one|two
+one|two|one
+one|on|two
 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-one-two
+one-two-one
+one-on-two
+one, two
+[one, two]
+active-active
+active--active
+one active  active two
+---one
+one---
+two
+two
+--three--
 ]])
 
 AT_CLEANUP