[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: m4sugar speedups
From: |
Eric Blake |
Subject: |
Re: m4sugar speedups |
Date: |
Mon, 03 Mar 2008 06:41:12 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello again, Ralf,
According to Ralf Wildenhues on 3/2/2008 3:15 PM:
| Hi Eric,
|
| late review of an old patch:
|
<http://thread.gmane.org/gmane.comp.sysutils.autoconf.general/9586/focus=4902>
Applying the following, which should address all of your nits, with one
explanation:
|> address@hidden m4_list_cmp (@var{list-1}, @var{list-2})
|> address@hidden
|> +Compare the two M4 lists consisting of comma-separated arithmetic
|> +expressions, left to right. Expand to @samp{-1} for the first element
|> +pairing where the value from @var{list-1} is smaller, @samp{1} where the
|> +value from @var{list-2} is smaller, or @samp{0} if both lists have the
|> +same values. If one list is shorter than the other, the remaining
|> +elements of the longer list are compared against 0.
|
| 0 vs. @samp{0}.
Here, I went with 'zero' instead of '@samp{0}', to try and distinguish
between literal '0' as output vs. numerical value for comparison on
mismatched length input.
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHy//484KuGfSFAYARAmvQAJ0W59hSXUsV4xsczVBC2MLhcukrKQCgs9BN
w1y005aoxwqmgPgLl1yGKAA=
=eCIW
-----END PGP SIGNATURE-----
>From e3d1e29bc329ead5d710f944e91d8c08d7189a73 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 3 Mar 2008 06:29:00 -0700
Subject: [PATCH] Documentation improvements.
* doc/autoconf.texi (Looping constructs): s/recurses/repeats/.
(Evaluation Macros): Drop `1' suffix from metasyntax variable name
that preceeds @dots. Improve wording.
(Text processing Macros): Drop `1' suffix from metasyntax variable
name that preceeds @dots.
(Number processing Macros): Drop `1' suffix from metasyntax
variable name that preceeds @dots. Improve wording.
* lib/m4sugar/m4sugar.m4 (m4_cmp): Comment wording fix.
Suggested by Ralf Wildenhues.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 13 +++++++++++++
doc/autoconf.texi | 31 +++++++++++++++----------------
lib/m4sugar/m4sugar.m4 | 3 ++-
3 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9b72b3c..08cfd73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-03-03 Eric Blake <address@hidden>
+
+ Documentation improvements.
+ * doc/autoconf.texi (Looping constructs): s/recurses/repeats/.
+ (Evaluation Macros): Drop `1' suffix from metasyntax variable name
+ that preceeds @dots. Improve wording.
+ (Text processing Macros): Drop `1' suffix from metasyntax variable
+ name that preceeds @dots.
+ (Number processing Macros): Drop `1' suffix from metasyntax
+ variable name that preceeds @dots. Improve wording.
+ * lib/m4sugar/m4sugar.m4 (m4_cmp): Comment wording fix.
+ Suggested by Ralf Wildenhues.
+
2008-03-02 Jim Meyering <address@hidden>
Don't infloop upon "make dist".
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index ea5997a..c4edf8b 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -10688,7 +10688,7 @@ elements, @code{m4_cdr} should be called without any
extra quotes.
For example, this is a simple implementation of @code{m4_map}; note how
each iteration checks for the end of recursion, then merely applies the
-first argument to the first element of the list, then recurses with the
+first argument to the first element of the list, then repeats with the
rest of the list. (The actual implementation in M4sugar is a bit more
involved, to gain some speed and share code with @code{m4_map_sep}).
@example
@@ -10798,34 +10798,34 @@ m4_apply([m4_join], [[|], [1], [2]])
@end example
@end defmac
address@hidden m4_count (@var{arg1}, @dots{})
address@hidden m4_count (@var{arg}, @dots{})
@msindex{count}
This macro returns the decimal count of the number of arguments it was
passed.
@end defmac
address@hidden m4_do (@var{arg1}, @dots{})
address@hidden m4_do (@var{arg}, @dots{})
@msindex{do}
This macro loops over its arguments and expands each @var{arg} in
sequence. Its main use is for readability; it allows the use of
indentation and fewer @code{dnl} to result in the same expansion.
@end defmac
address@hidden m4_dquote (@var{arg1}, @dots{})
address@hidden m4_dquote (@var{arg}, @dots{})
@msindex{dquote}
Return the arguments as a quoted list of quoted arguments.
Conveniently, if there is just one @var{arg}, this effectively adds a
level of quoting.
@end defmac
address@hidden m4_dquote_elt (@var{arg1}, @dots{})
address@hidden m4_dquote_elt (@var{arg}, @dots{})
@msindex{dquote_elt}
Return the arguments as a series of double-quoted arguments. Whereas
@code{m4_dquote} returns a single argument, @code{m4_dquote_elt} returns
as many arguments as it was passed.
@end defmac
address@hidden m4_echo (@var{arg1}, @dots{})
address@hidden m4_echo (@var{arg}, @dots{})
@msindex{echo}
Return the arguments, with the same level of quoting. Other than
discarding whitespace after unquoted commas, this macro is a no-op.
@@ -10868,8 +10868,7 @@ m4_expand([active2, active2])
This macro was introduced in Autoconf 2.62. Expands to nothing,
ignoring all of its arguments. By itself, this isn't very useful.
However, it can be used to conditionally ignore an arbitrary number of
-arguments, by making a decision about which macro name to apply to a
-list of arguments.
+arguments, by deciding which macro name to apply to a list of arguments.
@example
dnl foo outputs a message only if [debug] is defined.
m4_define([foo],
@@ -10880,7 +10879,7 @@ Note that for earlier versions of Autoconf, the macro
@code{__gnu__} can
serve the same purpose, although it is less readable.
@end defmac
address@hidden m4_make_list (@var{arg1}, @dots{})
address@hidden m4_make_list (@var{arg}, @dots{})
@msindex{make_list}
This macro exists to aid debugging of M4sugar algorithms. Its net
effect is similar to @code{m4_dquote}---it produces a quoted list of
@@ -10907,14 +10906,14 @@ m4_foreach([number], m4_make_list(zero, [one],
[[two]]), [ number])
@c probably rely on @samp{[]} nested quoting for proper operation. The
@c user should generally prefer m4_unquote instead.
address@hidden m4_quote (@var{arg1}, @dots{})
address@hidden m4_quote (@var{arg}, @dots{})
@msindex{quote}
Return the arguments as a single entity, i.e., wrap them into a pair of
quotes. This effectively collapses multiple arguments into one,
although it loses whitespace after unquoted commas in the process.
@end defmac
address@hidden m4_unquote (@var{arg1}, @dots{})
address@hidden m4_unquote (@var{arg}, @dots{})
@msindex{unquote}
This macro was introduced in Autoconf 2.62. Expand each argument,
separated by commas. For a single @var{arg}, this effectively removes a
@@ -11043,7 +11042,7 @@ numbers
@end defmac
@defmac m4_combine (@ovar{separator}, @var{prefix-list}, @ovar{infix}, @
- @var{suffix-1}, @dots{})
+ @var{suffix-1}, @ovar{suffix-2}, @dots{})
@msindex{combine}
This macro produces a quoted string containing the pairwise combination
of every element of the quoted, comma-separated @var{prefix-list}, and
@@ -11188,7 +11187,7 @@ respectively.
@node Number processing Macros
@subsection Arithmetic computation in M4
-The following macros make it easier to deal with arithmetic operations.
+The following macros facilitate integer arithmetic operations.
Where a parameter is documented as taking an arithmetic expression, you
can use anything that can be parsed by @code{m4_eval}.
@@ -11206,7 +11205,7 @@ expressions, left to right. Expand to @samp{-1} for
the first element
pairing where the value from @var{list-1} is smaller, @samp{1} where the
value from @var{list-2} is smaller, or @samp{0} if both lists have the
same values. If one list is shorter than the other, the remaining
-elements of the longer list are compared against 0.
+elements of the longer list are compared against zero.
@example
m4_list_cmp([1, 0], [1])
@result{}0
@@ -11225,13 +11224,13 @@ m4_list_cmp([1], [1, 2])
@end example
@end defmac
address@hidden m4_max (@var{arg1}, @dots{})
address@hidden m4_max (@var{arg}, @dots{})
@msindex{max}
This macro was introduced in Autoconf 2.62. Expand to the decimal value
of the maximum arithmetic expression among all the arguments.
@end defmac
address@hidden m4_min (@var{arg1}, @dots{})
address@hidden m4_min (@var{arg}, @dots{})
@msindex{min}
This macro was introduced in Autoconf 2.62. Expand to the decimal value
of the minimum arithmetic expression among all the arguments.
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index e831555..cd4a1c6 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -2076,7 +2076,8 @@ m4_define([m4_cmp],
# Rather than face the overhead of m4_case, we use a helper function whose
# expansion includes the name of the macro to invoke on the tail, either
# m4_ignore or m4_unquote. This is particularly useful when comparing
-# long lists, since less text is being expanded to determine when to recurse.
+# long lists, since less text is being expanded for deciding when to end
+# recursion.
m4_define([m4_list_cmp],
[m4_if([$1$2], [], 0,
[$1], [], [$0(0, [$2])],
--
1.5.4