From: Zack Weinberg Date: Mon, 8 Jul 2024 15:22:44 +0000 (-0400) Subject: Quote separators in foreach.m4 version of m4_joinall. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cfc73b4d6872604ae211058ad8d14e8f49b02e1f;p=thirdparty%2Fautoconf.git Quote separators in foreach.m4 version of m4_joinall. 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. --- diff --git a/lib/m4sugar/foreach.m4 b/lib/m4sugar/foreach.m4 index c5f26d133..ab558ac54 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 7ea786b74..0b36e6261 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 +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