From: Akim Demaille Date: Tue, 8 Feb 2000 13:53:32 +0000 (+0000) Subject: Because of commas and brackets, m4_split must mess with the X-Git-Tag: autoconf-2.50~1191 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=881b4d908f2124d22aa5bb259a9504df33baa78d;p=thirdparty%2Fautoconf.git Because of commas and brackets, m4_split must mess with the quotes. * libm4.m4 (m4_split): Quote the elements of the list you produce. * tests/base.m4: New file, testing libm4. All callers adapted. Test m4_wrap. --- diff --git a/ChangeLog b/ChangeLog index 3778ef76c..365959321 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2000-02-08 Akim Demaille + + Because of commas and brackets, m4_split must mess with the + quotes. + + * libm4.m4 (m4_split): Quote the elements of the list you produce. + * tests/base.m4: New file, testing libm4. + All callers adapted. + Test m4_wrap. + 2000-02-08 Akim Demaille * acgeneral.m4 (AC_CONFIG_UNIQUE): Strip the `:foo.in' part diff --git a/libm4.m4 b/libm4.m4 index bbde61f06..67f262e30 100644 --- a/libm4.m4 +++ b/libm4.m4 @@ -475,41 +475,47 @@ define([m4_quote], [[$@]]) # m4_split(STRING, [REGEXP]) # -------------------------- +# # Split STRING into an m4 list of quoted elements. The elements are # quoted with [ and ]. Beginning spaces and end spaces *are kept*. # Use m4_strip to remove them. # # REGEXP specifies where to split. Default is [\t ]+. +# # Pay attention to the changequotes. Inner changequotes exist for # obvious reasons (we want to insert square brackets). Outer # changequotes are needed because otherwise the m4 parser, when it # sees the closing bracket we add to the result, believes it is the -# end of the body of the macro we define. +# end of the body of the macro we define. And since the active quote +# when `define' is called are not the ones which were used in its +# definition, we cannot use `define' as defined above. Therefore, +# using m4's builtin `m4_define', which is indepedent from the +# current quotes, to define `m4_split', and then register `m4_split' +# in libm4. # -# Also, notice that $1 is quoted twice, since we want the result to be -# quoted. Then you should understand that the argument of patsubst is -# ``STRING'' (i.e., with additional `` and ''). +# Also, notice that $1 is quoted twice, since we want the result to +# be quoted. Then you should understand that the argument of +# patsubst is ``STRING'' (i.e., with additional `` and ''). # # This macro is safe on active symbols, i.e.: # define(active, ACTIVE) # m4_split([active active ])end # => [active], [active], []end -#changequote(<<, >>) -#define(m4_split, -#<>) -#changequote([, ]) -#changequote(<<, >>) - -define(m4_split, -[patsubst([[$1]], - ifelse([$2],, [[[ ]+]], [[$2]]), - [,])]) + +changequote(<<, >>) +m4_define(m4_split, +<>) +changequote([, ]) +changequote(<<, >>) + +m4_namespace_register(m4_split, [libm4]) + # m4_join(STRING) diff --git a/tests/Makefile.am b/tests/Makefile.am index e21190b2c..aa2f657b8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -20,7 +20,7 @@ AUTOMAKE_OPTIONS = gnits -SUITE = torture.m4 semantics.m4 syntax.m4 +SUITE = torture.m4 semantics.m4 syntax.m4 base.m4 # We don't actually distribute the testsuite, since one only # needs m4 to build it, m4 being required anyway to install Autoconf. diff --git a/tests/suite.m4 b/tests/suite.m4 index 031a4ddb0..587efa160 100644 --- a/tests/suite.m4 +++ b/tests/suite.m4 @@ -17,5 +17,6 @@ EOF dnl Run the tests from the most selective to the easiest. AT_INCLUDE(torture.m4) +AT_INCLUDE(base.m4) AT_INCLUDE(semantics.m4) AT_INCLUDE(syntax.m4)