]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* doc/autoconf.texi (Evaluation Macros): New.
authorAkim Demaille <akim@epita.fr>
Mon, 4 Mar 2002 15:05:13 +0000 (15:05 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 4 Mar 2002 15:05:13 +0000 (15:05 +0000)
* lib/m4sugar/m4sugar.m4 (m4_lquote): Remove, it is totally
useless.
(_m4_foreach): Define the variant with immediate evaluation so
that it contains exactly the items, not an expression which
evaluation is the current item.
(m4_re_string, m4_re_word): Don't over quote them.

ChangeLog
doc/autoconf.texi
lib/m4sugar/m4sugar.m4

index e15467f173e8bc2f870105eab07003df432c1436..868fe65845e6fc7c3771b3c0b8b426467a008239 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2002-03-04  Akim Demaille  <akim@epita.fr>
+
+       * doc/autoconf.texi (Evaluation Macros): New.
+       * lib/m4sugar/m4sugar.m4 (m4_lquote): Remove, it is totally
+       useless.
+       (_m4_foreach): Define the variant with immediate evaluation so
+       that it contains exactly the items, not an expression which
+       evaluation is the current item.
+       (m4_re_string, m4_re_word): Don't over quote them.
+
 2002-03-04  Akim Demaille  <akim@epita.fr>
 
        Instead of having stacking `shift's evaluated at the end, let
index b6d62de7d63a28a85bec655f47a6c2e04ca7c068..d4c72dc2f62b74be3e5bdfec48dd2fbc7f424fa6 100644 (file)
@@ -327,6 +327,7 @@ M4 Quotation
 Programming in M4sugar
 
 * Redefined M4 Macros::         M4 builtins changed in M4sugar
+* Evaluation Macros::           More quotation and evaluation control
 * Forbidden Patterns::          Catching unexpanded macros
 
 Writing Autoconf Macros
@@ -6877,6 +6878,7 @@ M4sugar''.
 
 @menu
 * Redefined M4 Macros::         M4 builtins changed in M4sugar
+* Evaluation Macros::           More quotation and evaluation control
 * Forbidden Patterns::          Catching unexpanded macros
 @end menu
 
@@ -6964,6 +6966,44 @@ m4_wrap([foo])
 @end example
 @end defmac
 
+@node Evaluation Macros
+@subsection Evaluation Macros
+
+The following macros give some control over the order of the evaluation
+by adding or removing levels of quotes.  They are meant for hard core M4
+programmers.
+
+@defmac m4_dquote (@var{arg1}, ...)
+@msindex dquote
+Return the arguments as a quoted list of quoted arguments.
+@end defmac
+
+@defmac m4_quote (@var{arg1}, ...)
+@msindex quote
+Return the arguments as a single entity, i.e., wrap them into a pair of
+quotes.
+@end defmac
+
+The following example aims at emphasing the difference between (i), not
+using these macros, (ii), using @code{m4_quote}, and (iii), using
+@code{m4_dquote}.
+
+@example
+$ @kbd{cat example.m4}
+# Over quote, so that quotes are visible.
+m4_define([show], [$[]1 = [$1], $[]@@ = [$@@]])
+m4_divert(0)dnl
+show(a, b)
+show(m4_quote(a, b))
+show(m4_dquote(a, b))
+$ @kbd{autom4te -l m4sugar example.m4}
+$1 = a, $@@ = [a],[b]
+$1 = a,b, $@@ = [a,b]
+$1 = [a],[b], $@@ = [[a],[b]]
+@end example
+
+
+
 @node Forbidden Patterns
 @subsection Forbidden Patterns
 
index 8dac844ae7594f752408741ae21e0d225ebfb7d8..08317ccc77eb1842f40b0904ab179e9c75c05638 100644 (file)
@@ -523,17 +523,14 @@ m4_builtin([popdef], $@)])
 
 # m4_quote(ARGS)
 # --------------
-# Return ARGS quoted.  Note that a list of quoted arguments is returned,
-# not a quoted list.
+# Return ARGS as a single arguments.
 #
 # It is important to realize the difference between `m4_quote(exp)' and
 # `[exp]': in the first case you obtain the quoted *result* of the
 # expansion of EXP, while in the latter you just obtain the string
 # `exp'.
 m4_define([m4_quote],  [[$*]])
-m4_define([m4_lquote], [$@])
-m4_define([m4_dquote], [[$@]])
-
+m4_define([m4_dquote],  [[$@]])
 
 # m4_noquote(STRING)
 # ------------------
@@ -701,9 +698,9 @@ m4_define([m4_car], [[$1]])
 m4_define([m4_cdr], [m4_dquote(m4_shift($@))])
 m4_define([_m4_foreach],
 [m4_if([$2], [[]], [],
-       [m4_define([$1], [m4_car($2)])$3[]_m4_foreach([$1],
-                                                     m4_cdr($2),
-                                                     [$3])])])
+       [m4_define([$1], m4_car($2))$3[]_m4_foreach([$1],
+                                                   m4_cdr($2),
+                                                   [$3])])])
 
 
 
@@ -1377,7 +1374,7 @@ m4_define([m4_re_escape],
 # ------------
 # Regexp for `[a-zA-Z_0-9]*'
 m4_define([m4_re_string],
-m4_quote(m4_defn([m4_cr_symbols2]))dnl
+m4_defn([m4_cr_symbols2])dnl
 [*]dnl
 )
 
@@ -1386,7 +1383,7 @@ m4_quote(m4_defn([m4_cr_symbols2]))dnl
 # ----------
 # Regexp for `[a-zA-Z_][a-zA-Z_0-9]*'
 m4_define([m4_re_word],
-m4_quote(m4_defn([m4_cr_symbols1]))dnl
+m4_defn([m4_cr_symbols1])dnl
 m4_defn([m4_re_string])dnl
 )