From: Zack Weinberg Date: Wed, 26 Jun 2024 18:35:09 +0000 (-0400) Subject: Quote separators in foreach.m4 version of m4_joinall. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4578ab146cdb000614f71b083e06a2012bc8c8d1;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 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 ba7191af..c241ff07 100644 --- a/tests/m4sugar.at +++ b/tests/m4sugar.at @@ -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