[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [3/18] argv_ref speedup: avoid length recomputations
From: |
Eric Blake |
Subject: |
Re: [3/18] argv_ref speedup: avoid length recomputations |
Date: |
Mon, 14 Jan 2008 20:35:21 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Eric Blake <ebb9 <at> byu.net> writes:
> 2007-11-29 Eric Blake <ebb9 <at> byu.net>
>
> Stage 3: cache length, rather than computing it.
> * src/builtin.c (define_user_macro, mkstemp_helper): Use
> pre-computed length.
On the branch (but not head, since I haven't ported --warn-macro-sequence there
yet):
> @@ -407,7 +407,8 @@ free_regex (void)
> `-------------------------------------------------------------------------*/
>
> void
> -define_user_macro (const char *name, const char *text, symbol_lookup mode)
> +define_user_macro (const char *name, size_t len, const char *text,
> + symbol_lookup mode)
> {
> symbol *s;
> char *defn = xstrdup (text ? text : "");
> @@ -423,7 +424,6 @@ define_user_macro (const char *name, const char *text,
symbol_lookup mode)
> if (macro_sequence_inuse && text)
> {
> regoff_t offset = 0;
> - size_t len = strlen (defn);
This hunk caused a regression, because I inadvertently changed len from the
length of the macro's definition to the length of the macro name. And I would
have caught it sooner, had the test suite been testing --warn-macro-sequence.
Checking this in:
From: Eric Blake <address@hidden>
Date: Mon, 14 Jan 2008 11:49:03 -0700
Subject: [PATCH] Fix --warn-macro-sequence regression from 2007-11-29.
* src/builtin.c (define_user_macro): Use correct length.
* doc/m4.texinfo (Arguments): Test the fix.
(History): Reword to account for new year and eventual result of
the argv_ref branch.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 8 ++++++++
doc/m4.texinfo | 12 +++++++-----
src/builtin.c | 10 ++++++----
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f3ed17f..4a20b00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-01-14 Eric Blake <address@hidden>
+
+ Fix --warn-macro-sequence regression from 2007-11-29.
+ * src/builtin.c (define_user_macro): Use correct length.
+ * doc/m4.texinfo (Arguments): Test the fix.
+ (History): Reword to account for new year and eventual result of
+ the argv_ref branch.
+
2008-01-08 Eric Blake <address@hidden>
Bump copyright year.
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index bfdb6f2..b24cc90 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -43,7 +43,7 @@ This manual is for @acronym{GNU} M4 (version @value{VERSION},
@value{UPDATED}),
a package containing an implementation of the m4 macro language.
Copyright @copyright{} 1989, 1990, 1991, 1992, 1993, 1994, 2004, 2005,
-2006, 2007 Free Software Foundation, Inc.
+2006, 2007, 2008 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
@@ -391,9 +391,11 @@ addressed some long standing bugs in the venerable 1.4
release. Then in
2005, Gary V. Vaughan collected together the many patches to
@acronym{GNU} @code{m4} 1.4 that were floating around the net and
released 1.4.3 and 1.4.4. And in 2006, Eric Blake joined the team and
-prepared patches for the release of 1.4.5, 1.4.6, 1.4.7, and 1.4.8. The
-1.4.x series remains open for bug fixes, including releases 1.4.9,
-1.4.10, and 1.4.11 in 2007.
+prepared patches for the release of 1.4.5, 1.4.6, 1.4.7, and 1.4.8.
+More bug fixes were incorporated in 2007, with releases 1.4.9 and
+1.4.10. In 2008, Eric additionally rewrote the scanning engine to
+reduce recursive evaluation from quadratic to linear complexity for
+1.4.11. The 1.4.x branch remains open for bug fixes.
Meanwhile, development has continued on new features for @code{m4}, such
as dynamic module loading and additional builtins. When complete,
@@ -1830,7 +1832,7 @@ default, because it triggers a number of warnings in
Autoconf 2.61 (and
Autoconf uses @option{-E} to treat warnings as errors), and because it
will still be possible to restore older behavior in M4 2.0.
address@hidden ignore
address@hidden options: --warn-macro-sequence
@example
$ @kbd{m4 --warn-macro-sequence}
define(`foo', `$001 address@hidden@} $1')
diff --git a/src/builtin.c b/src/builtin.c
index cb5f274..e873061 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -1,7 +1,7 @@
/* GNU m4 -- A simple macro processor
- Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2000, 2004, 2006, 2007
- Free Software Foundation, Inc.
+ Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2000, 2004, 2006, 2007,
+ 2008 Free Software Foundation, Inc.
This file is part of GNU M4.
@@ -424,9 +424,11 @@ define_user_macro (const char *name, size_t len, const
char *text,
if (macro_sequence_inuse && text)
{
regoff_t offset = 0;
+ len = strlen (defn);
- while ((offset = re_search (¯o_sequence_buf, defn, len, offset,
- len - offset, ¯o_sequence_regs)) >= 0)
+ while (offset < len
+ && (offset = re_search (¯o_sequence_buf, defn, len, offset,
+ len - offset, ¯o_sequence_regs)) >= 0)
{
/* Skip empty matches. */
if (macro_sequence_regs.start[0] == macro_sequence_regs.end[0])
--
1.5.3.8
- Re: [3/18] argv_ref speedup: avoid length recomputations,
Eric Blake <=