Paul Eggert wrote:
> On 03/16/2012 05:14 AM, Jim Meyering wrote:
>> A patch would be most welcome.
>
> OK, here's a proposed patch. It assumes syncing from gnulib
> (to pick up the gnulib regex fix).
>
>>From 0dd8ab2b726e6f7486db25cf10ac24f4b961faa0 Mon Sep 17 00:00:00 2001
> From: Paul Eggert <[email protected]>
> Date: Sat, 17 Mar 2012 18:04:50 -0700
> Subject: [PATCH] grep: report overflow for ERE a{1000000000}
>
> * NEWS: Document this.
> * src/dfa.c (MIN): New macro.
> (lex): Lexically analyze the repeat-count operator once, not
> twice; the double-scan complicated the code and made it harder to
> understand and fix. Adjust the repeat-count parsing so that it
> better matches the behavior of the regex code, in three ways:
> 1. Diagnose too-large repeat counts rather than treating them as
> literal characters. 2. Use RE_INVALID_INTERVAL_ORD, not
> RE_NO_BK_BRACES, to decide whether to treat invalid-syntax {...}s
> as literals. 3. Use the same wording for {...}-related
> diagnostics that the regex code uses.
> * tests/bre.tests, tests/ere.tests, tests/repetition-overflow:
> Adjust to match new behavior, and add a few tests.
Oops.
One minor adjustment to avoid a syntax-check failure:
src/dfa.c:1375: dfaerror (_("Invalid content of \\{\\}"));
src/dfa.c:1378: dfaerror (_("Regular expression too big"));
maint.mk: found capitalized error message
diff --git a/cfg.mk b/cfg.mk
index 84115c2..329af43 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -88,3 +88,4 @@ exclude_file_name_regexp--sc_prohibit_xalloc_without_use =
^src/kwset\.c$$
exclude_file_name_regexp--sc_prohibit_tab_based_indentation = \
(Makefile|\.(am|mk)$$|^gl/lib/.*\.c\.diff$$)
exclude_file_name_regexp--sc_space_tab = ^gl/lib/.*\.c\.diff$$
+exclude_file_name_regexp--sc_error_message_uppercase = ^src/dfa\.c$$