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 | 2 +- tests/m4sugar.at | 65 ++++++++++++++++++++++++++++++++---------- 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/lib/m4sugar/foreach.m4 b/lib/m4sugar/foreach.m4 index c5f26d13..ab558ac5 100644 --- a/lib/m4sugar/foreach.m4 +++ b/lib/m4sugar/foreach.m4 @@ -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) # ----------------- diff --git a/tests/m4sugar.at b/tests/m4sugar.at index 7ea786b7..0b36e626 100644 --- a/tests/m4sugar.at +++ b/tests/m4sugar.at @@ -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 -one -one -two -two +active|active one active two -onetwo -one--two ---three-- -onetwo +one +one +two +two +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 -- 2.44.2