This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GNU M4 source repository".
http://git.sv.gnu.org/gitweb/?p=m4.git;a=commitdiff;h=d8726aac7acd47435ad3e4dedef44d01cd828dc1 The branch, master has been updated via d8726aac7acd47435ad3e4dedef44d01cd828dc1 (commit) via 028f5c5976a35256f5fa3804f33292a75ba56c6e (commit) via 4cd6b69ea7747052d12c0f2c4c28be082b030b00 (commit) via 7c675b594080836fde2aa524ef7aa504c46e5069 (commit) from cc55111948ac37d1dd492bbef85364bf08ed2d2d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d8726aac7acd47435ad3e4dedef44d01cd828dc1 Author: Eric Blake <[email protected]> Date: Wed Feb 18 13:36:15 2009 -0700 Prefer buffer over byte operations. * modules/format.c (format): Use memchr for speed. * modules/gnu.c (substitute): Likewise. * m4/macro.c (locate_dollar): Inline into only caller... (process_macro): ...and rearrange for readability. * m4/input.c (consume_buffer): Allow C++ compilation. * doc/m4.texinfo (Changesyntax): Enhance test. Signed-off-by: Eric Blake <[email protected]> (cherry picked from commit 45a154e6d70517bf1b837715aae2fe366c9c1116) commit 028f5c5976a35256f5fa3804f33292a75ba56c6e Author: Eric Blake <[email protected]> Date: Wed Feb 18 11:38:54 2009 -0700 Speed up esyscmd with buffer reads. * modules/gnu.c (esyscmd): Read blocks directly into obstack, rather than repeatedly reading bytes. Detect read errors. Signed-off-by: Eric Blake <[email protected]> (cherry picked from commit 1974da270a84d8c0cf2b3e3e08ce5292fdb211f3) commit 4cd6b69ea7747052d12c0f2c4c28be082b030b00 Author: Eric Blake <[email protected]> Date: Wed Feb 18 12:03:03 2009 -0700 Avoid risk of stack overflow. * m4/output.c (insert_file): Avoid stack allocation of large buffer. Signed-off-by: Eric Blake <[email protected]> (cherry picked from commit 01f216c3c98d41db7878b18c93d23e8dc38d8643) commit 7c675b594080836fde2aa524ef7aa504c46e5069 Author: Eric Blake <[email protected]> Date: Wed Feb 18 14:20:46 2009 -0700 Synchronize THANKS with branch. * THANKS: Import more names. Signed-off-by: Eric Blake <[email protected]> ----------------------------------------------------------------------- Summary of changes: ChangeLog | 19 +++++++++++++++++++ THANKS | 5 ++++- doc/m4.texinfo | 5 +++++ m4/input.c | 2 +- m4/macro.c | 48 ++++++++++++++++++++++++++---------------------- m4/output.c | 8 ++++---- modules/format.c | 13 ++++++++----- modules/gnu.c | 39 +++++++++++++++++++++++++++++---------- 8 files changed, 96 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66ac3df..9469fbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,24 @@ 2009-02-18 Eric Blake <[email protected]> + Prefer buffer over byte operations. + * modules/format.c (format): Use memchr for speed. + * modules/gnu.c (substitute): Likewise. + * m4/macro.c (locate_dollar): Inline into only caller... + (process_macro): ...and rearrange for readability. + * m4/input.c (consume_buffer): Allow C++ compilation. + * doc/m4.texinfo (Changesyntax): Enhance test. + + Speed up esyscmd with buffer reads. + * modules/gnu.c (esyscmd): Read blocks directly into obstack, + rather than repeatedly reading bytes. Detect read errors. + + Avoid risk of stack overflow. + * m4/output.c (insert_file): Avoid stack allocation of large + buffer. + + Synchronize THANKS with branch. + * THANKS: Import more names. + Improve handling of $ in syntax table. * m4/m4module.h (m4_is_syntax_single_dollar): New function. (M4_SYNTAX_DOLLAR, M4_SYNTAX_LBRACE, M4_SYNTAX_RBRACE): Change to diff --git a/THANKS b/THANKS index 6e7e706..84b366b 100644 --- a/THANKS +++ b/THANKS @@ -124,6 +124,7 @@ Robert Bihlmeyer [email protected] Roderick Koehle [email protected] Roland H. Pesch [email protected] Roland McGrath [email protected] +Ronny Peine [email protected] Sami Liedes [email protected] Santiago Vila [email protected] Scott Bartram deneb!scottb @@ -138,6 +139,7 @@ Terry Jones [email protected] Thomas Klausner [email protected] Thomas Tanner [email protected] Thorsten Ohl [email protected] +Tom G. Christensen [email protected] Tom McConnell [email protected] Tom Quinn [email protected] Tom Tromey [email protected] @@ -155,7 +157,8 @@ Local Variables: coding: utf-8 End: -Copyright (C) 2000, 2006, 2007 Free Software Foundation, Inc. +Copyright (C) 2000, 2006, 2007, 2008, 2009 Free Software Foundation, +Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or diff --git a/doc/m4.texinfo b/doc/m4.texinfo index e3eee25..7f7bb3f 100644 --- a/doc/m4.texinfo +++ b/doc/m4.texinfo @@ -5628,6 +5628,11 @@ define(`escape', `$?`'1$?1?') @result{} escape(foo) @result{}$?1$foo? +dnl Multiple argument identifiers. +changesyntax(`$+$') +...@result{} +argref(1, 2, 3) +...@result{}dollar: 3, Question: 3 @end example Macro calls can be given a @TeX{} or Texinfo like syntax using an diff --git a/m4/input.c b/m4/input.c index e061bcd..1b40e5d 100644 --- a/m4/input.c +++ b/m4/input.c @@ -416,7 +416,7 @@ file_consume (m4_input_block *me, m4 *context, size_t len) buf = freadptr (me->u.u_f.fp, &buf_len); assert (buf && len <= buf_len); buf_len = 0; - while ((p = memchr (buf + buf_len, '\n', len - buf_len))) + while ((p = (char *) memchr (buf + buf_len, '\n', len - buf_len))) { if (p == buf + len - 1) start_of_input_line = true; diff --git a/m4/macro.c b/m4/macro.c index 7295157..fc28cd3 100644 --- a/m4/macro.c +++ b/m4/macro.c @@ -688,22 +688,6 @@ m4_macro_call (m4 *context, m4_symbol_value *value, m4_obstack *expansion, trace_post (context, trace_start, argv->info); } -/* Locate the next byte with dollar syntax in string STR of length - LEN, or return NULL. */ -static const char * -locate_dollar (m4 *context, const char *str, size_t len) -{ - if (m4_is_syntax_single_dollar (M4SYNTAX)) - return (char *) memchr (str, M4SYNTAX->dollar, len); - while (len--) - { - if (m4_has_syntax (M4SYNTAX, *str, M4_SYNTAX_DOLLAR)) - return str; - str++; - } - return NULL; -} - /* This function handles all expansion of user defined and predefined macros. It is called with an obstack OBS, where the macros expansion will be placed, as an unfinished object. SYMBOL points to the macro @@ -715,16 +699,38 @@ process_macro (m4 *context, m4_symbol_value *value, m4_obstack *obs, { const char *text = m4_get_symbol_value_text (value); size_t len = m4_get_symbol_value_len (value); + const char *end = text + len; int i; - const char *dollar = locate_dollar (context, text, len); - - while (dollar) + while (1) { + const char *dollar; + if (m4_is_syntax_single_dollar (M4SYNTAX)) + dollar = (char *) memchr (text, M4SYNTAX->dollar, len); + else + { + dollar = text; + while (dollar != end) + { + if (m4_has_syntax (M4SYNTAX, *dollar, M4_SYNTAX_DOLLAR)) + break; + dollar++; + } + if (dollar == end) + dollar = NULL; + } + if (!dollar) + { + obstack_grow (obs, text, len); + return; + } obstack_grow (obs, text, dollar - text); len -= dollar - text; text = dollar; if (len == 1) - break; + { + obstack_1grow (obs, *dollar); + return; + } len--; switch (*++text) { @@ -813,9 +819,7 @@ process_macro (m4 *context, m4_symbol_value *value, m4_obstack *obs, } break; } - dollar = locate_dollar (context, text, len); } - obstack_grow (obs, text, len); } diff --git a/m4/output.c b/m4/output.c index baea127..b2f6530 100644 --- a/m4/output.c +++ b/m4/output.c @@ -1,6 +1,6 @@ /* GNU m4 -- A simple macro processor Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1998, 2002, 2004, - 2006, 2007, 2008 Free Software Foundation, Inc. + 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of GNU M4. @@ -887,16 +887,16 @@ m4_make_diversion (m4 *context, int divnum) static void insert_file (m4 *context, FILE *file, bool escaped) { - char buffer[COPY_BUFFER_SIZE]; + static char buffer[COPY_BUFFER_SIZE]; size_t length; char *str = buffer; bool first = true; assert (output_diversion); /* Insert output by big chunks. */ - for (;;) + while (1) { - length = fread (buffer, 1, COPY_BUFFER_SIZE, file); + length = fread (buffer, 1, sizeof buffer, file); if (ferror (file)) m4_error (context, EXIT_FAILURE, errno, NULL, _("reading inserted file")); diff --git a/modules/format.c b/modules/format.c index 55333be..a402d38 100644 --- a/modules/format.c +++ b/modules/format.c @@ -182,14 +182,17 @@ format (m4 *context, m4_obstack *obs, int argc, m4_macro_args *argv) f_len = M4ARGLEN (1); assert (!f[f_len]); /* Requiring a terminating NUL makes parsing simpler. */ memset (ok, 0, sizeof ok); - while (f_len--) + while (1) { - c = *fmt++; - if (c != '%') + const char *percent = (char *) memchr (fmt, '%', f_len); + if (!percent) { - obstack_1grow (obs, c); - continue; + obstack_grow (obs, fmt, f_len); + break; } + obstack_grow (obs, fmt, percent - fmt); + f_len -= percent - fmt + 1; + fmt = percent + 1; if (*fmt == '%') { diff --git a/modules/gnu.c b/modules/gnu.c index f44f0ba..53a3ecb 100644 --- a/modules/gnu.c +++ b/modules/gnu.c @@ -238,22 +238,23 @@ substitute (m4 *context, m4_obstack *obs, const m4_call_info *caller, m4_pattern_buffer *buf) { int ch; - - while (repl_len--) + while (1) { - ch = *repl++; - if (ch != '\\') + const char *backslash = (char *) memchr (repl, '\\', repl_len); + if (!backslash) { - obstack_1grow (obs, ch); - continue; + obstack_grow (obs, repl, repl_len); + return; } + obstack_grow (obs, repl, backslash - repl); + repl_len -= backslash - repl + 1; if (!repl_len) { m4_warn (context, 0, caller, _("trailing \\ ignored in replacement")); return; } - + repl = backslash + 1; ch = *repl++; repl_len--; switch (ch) @@ -654,7 +655,6 @@ M4BUILTIN_HANDLER (esyscmd) if (m4_set_sysval && m4_sysval_flush) { FILE *pin; - int ch; if (m4_get_safer_opt (context)) { @@ -684,8 +684,27 @@ M4BUILTIN_HANDLER (esyscmd) } else { - while ((ch = getc (pin)) != EOF) - obstack_1grow (obs, ch); + while (1) + { + size_t avail = obstack_room (obs); + if (!avail) + { + int ch = getc (pin); + if (ch == EOF) + break; + obstack_1grow (obs, ch); + } + else + { + size_t len = fread (obstack_next_free (obs), 1, avail, pin); + if (len <= 0) + break; + obstack_blank_fast (obs, len); + } + } + if (ferror (pin)) + m4_warn (context, errno, me, _("cannot read pipe to command %s"), + quotearg_style (locale_quoting_style, cmd)); m4_set_sysval (pclose (pin)); } } hooks/post-receive -- GNU M4 source repository
