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=a6c565c6f4b934be334dd9ada97b215595d10103 The branch, branch-1.4 has been updated via a6c565c6f4b934be334dd9ada97b215595d10103 (commit) via cde8ed621040381a2e9584b3d72940ef8c125115 (commit) from 30cd2068dcb8b51f9fe29741732027bb00b522a5 (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 a6c565c6f4b934be334dd9ada97b215595d10103 Author: Eric Blake <[email protected]> Date: Fri Nov 27 21:45:33 2009 -0700 Work around BSD getopt bug. * gnulib: Update. * doc/m4.texinfo (Command line files): Add test. Signed-off-by: Eric Blake <[email protected]> commit cde8ed621040381a2e9584b3d72940ef8c125115 Author: Eric Blake <[email protected]> Date: Fri Nov 27 21:21:39 2009 -0700 Use fastmap for better regex performance. * src/input.c (word_start): Delete. (pop_wrapup): Free memory on exit. (set_word_regexp): Compile a fastmap instead. (peek_token, next_token): Use the fastmap. Signed-off-by: Eric Blake <[email protected]> (cherry picked from commit 950807234e3ffd376ad51b2a21cd276dd8b4e59c) ----------------------------------------------------------------------- Summary of changes: ChangeLog | 12 ++++++++++++ doc/m4.texinfo | 16 ++++++++++++++++ gnulib | 2 +- src/input.c | 42 +++++++++++++++--------------------------- 4 files changed, 44 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19cf20d..0c9b193 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2009-11-28 Eric Blake <[email protected]> + + Work around BSD getopt bug. + * gnulib: Update. + * doc/m4.texinfo (Command line files): Add test. + + Use fastmap for better regex performance. + * src/input.c (word_start): Delete. + (pop_wrapup): Free memory on exit. + (set_word_regexp): Compile a fastmap instead. + (peek_token, next_token): Use the fastmap. + 2009-11-26 Eric Blake <[email protected]> Ignore write failures before stack overflow exit. diff --git a/doc/m4.texinfo b/doc/m4.texinfo index 2cf86d4..550fa4a 100644 --- a/doc/m4.texinfo +++ b/doc/m4.texinfo @@ -989,6 +989,22 @@ syscmd([echo 'esyscmd(echo hi >&2 && echo err"print(bye @error{}bye @result{}0 @end example + +...@comment Test that we obey POSIX semantics with -D interspersed with +...@comment files, even with POSIXLY_CORRECT (BSD getopt gets it wrong). + +$ @kbd{m4 } +...@example +ifdef(`__unix__', , + `errprint(` skipping: syscmd does not have unix semantics +')m4exit(`77')')dnl +changequote(`[', `]')dnl +syscmd([POSIXLY_CORRECT=1 ']__program__[' -Dbar=hello foo -Dbar=world foo])dnl +...@result{}hello +...@result{}world +sysval +...@result{}0 +...@end example @end ignore @node Syntax diff --git a/gnulib b/gnulib index 23cd741..c0c5acf 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 23cd74133c81b80d335c701848b71d85a53402c6 +Subproject commit c0c5acfbe255f5542bc1c81c7aec223d95e504a6 diff --git a/src/input.c b/src/input.c index 740df78..7336c53 100644 --- a/src/input.c +++ b/src/input.c @@ -154,7 +154,6 @@ STRING ecomm; # define DEFAULT_WORD_REGEXP "[_a-zA-Z][_a-zA-Z0-9]*" -static char *word_start; static struct re_pattern_buffer word_regexp; static int default_word_regexp; static struct re_registers regs; @@ -396,6 +395,9 @@ pop_wrapup (void) obstack_free (&file_names, NULL); obstack_free (wrapup_stack, NULL); free (wrapup_stack); +#ifdef ENABLE_CHANGEWORD + regfree (&word_regexp); +#endif /* ENABLE_CHANGEWORD */ return false; } @@ -762,8 +764,6 @@ set_comment (const char *bc, const char *ec) void set_word_regexp (const char *regexp) { - int i; - char test[2]; const char *msg; struct re_pattern_buffer new_word_regexp; @@ -785,31 +785,19 @@ set_word_regexp (const char *regexp) return; } - /* If compilation worked, retry using the word_regexp struct. - Can't rely on struct assigns working, so redo the compilation. */ - regfree (&word_regexp); + /* If compilation worked, retry using the word_regexp struct. We + can't rely on struct assigns working, so redo the compilation. + The fastmap can be reused between compilations, and will be freed + by the final regfree. */ + if (!word_regexp.fastmap) + word_regexp.fastmap = xcharalloc (UCHAR_MAX + 1); msg = re_compile_pattern (regexp, strlen (regexp), &word_regexp); + assert (!msg); re_set_registers (&word_regexp, ®s, regs.num_regs, regs.start, regs.end); - - if (msg != NULL) - { - M4ERROR ((EXIT_FAILURE, 0, - "INTERNAL ERROR: expression recompilation `%s': %s", - regexp, msg)); - } + if (re_compile_fastmap (&word_regexp)) + assert (false); default_word_regexp = false; - - if (word_start == NULL) - word_start = (char *) xmalloc (256); - - word_start[0] = '\0'; - test[1] = '\0'; - for (i = 1; i < 256; i++) - { - test[0] = i; - word_start[i] = re_search (&word_regexp, test, 1, 0, 0, NULL) >= 0; - } } #endif /* ENABLE_CHANGEWORD */ @@ -900,7 +888,7 @@ next_token (token_data *td, int *line) #ifdef ENABLE_CHANGEWORD - else if (!default_word_regexp && word_start[ch]) + else if (!default_word_regexp && word_regexp.fastmap[ch]) { obstack_1grow (&token_stack, ch); while (1) @@ -1062,9 +1050,9 @@ peek_token (void) } else if ((default_word_regexp && (isalpha (ch) || ch == '_')) #ifdef ENABLE_CHANGEWORD - || (! default_word_regexp && word_start[ch]) + || (! default_word_regexp && word_regexp.fastmap[ch]) #endif /* ENABLE_CHANGEWORD */ - ) + ) { result = TOKEN_WORD; } hooks/post-receive -- GNU M4 source repository
