]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Because of commas and brackets, m4_split must mess with the
authorAkim Demaille <akim@epita.fr>
Tue, 8 Feb 2000 13:53:32 +0000 (13:53 +0000)
committerAkim Demaille <akim@epita.fr>
Tue, 8 Feb 2000 13:53:32 +0000 (13:53 +0000)
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.

ChangeLog
libm4.m4
tests/Makefile.am
tests/suite.m4

index 3778ef76cba6e987fda7d7d955edaa57d40eadb9..3659593216d97af047379f56d84877b15bb69226 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2000-02-08  Akim Demaille  <akim@epita.fr>
+
+       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  <akim@epita.fr>
 
        * acgeneral.m4 (AC_CONFIG_UNIQUE): Strip the `:foo.in' part
index bbde61f062440ad66e3881bae7d91b8b11e61ce3..67f262e305f9343152970fdd5642b2cccd27a18f 100644 (file)
--- 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(``, '')dnl
-#[dnl Can't use m4_default here instead of ifelse, because m4_default uses
-#dnl [ and ] as quotes.
-#patsubst(````$1'''',
-#        ifelse(``$2'',, ``[   ]+'', ``$2''),
-#        ``], ['')]dnl
-#changequote([, ])>>)
-#changequote([, ])
-#changequote(<<, >>)
-
-define(m4_split,
-[patsubst([[$1]],
-         ifelse([$2],, [[[   ]+]], [[$2]]),
-         [,])])
+
+changequote(<<, >>)
+m4_define(m4_split,
+<<changequote(``, '')dnl
+[dnl Can't use m4_default here instead of ifelse, because m4_default uses
+dnl [ and ] as quotes.
+patsubst(````$1'''',
+         ifelse(``$2'',, ``[   ]+'', ``$2''),
+         ``], ['')]dnl
+changequote([, ])>>)
+changequote([, ])
+changequote(<<, >>)
+
+m4_namespace_register(m4_split, [libm4])
+
 
 
 # m4_join(STRING)
index e21190b2caafea851d7a5efaa1929b61637315e3..aa2f657b81093b1b05e0dc1a8d27be7a6f769389 100644 (file)
@@ -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.
index 031a4ddb01910679e2f7e5fc2137c9a0c1524399..587efa16031801bff59be767eefeaf2964ecc035 100644 (file)
@@ -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)