grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v3.5-14-gffc6e40


From: Jim Meyering
Subject: grep branch, master, updated. v3.5-14-gffc6e40
Date: Sun, 1 Nov 2020 14:39:38 -0500 (EST)

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 "grep".

The branch, master has been updated
       via  ffc6e407e3657598702ba24ab1ba3a6b8ab253ea (commit)
      from  3bd06de4f7fd6331a59e7285afadc719ce09f384 (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 -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=ffc6e407e3657598702ba24ab1ba3a6b8ab253ea


commit ffc6e407e3657598702ba24ab1ba3a6b8ab253ea
Author: Norihiro Tanaka <noritnk@kcn.ne.jp>
Date:   Thu Oct 8 18:20:13 2020 +0900

    grep: use RE_NO_SUB when calling regex solely to check syntax
    
    * src/dfasearch.c (regex_compile): New parameter. All callers changed.
    (GEAcompile): Move setting syntax for regex into regex_compile()
    function.  This addresses a performance problem exposed by extreme
    regular expressions, as described in https://bugs.gnu.org/43862 .

diff --git a/src/dfasearch.c b/src/dfasearch.c
index 812a0dc..8ede0ec 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -145,7 +145,8 @@ possible_backrefs_in_pattern (char const *keys, ptrdiff_t 
len, bool bs_safe)
 
 static bool
 regex_compile (struct dfa_comp *dc, char const *p, ptrdiff_t len,
-               ptrdiff_t pcount, ptrdiff_t lineno, bool syntax_only)
+               ptrdiff_t pcount, ptrdiff_t lineno, reg_syntax_t syntax_bits,
+               bool syntax_only)
 {
   struct re_pattern_buffer pat0;
   struct re_pattern_buffer *pat = syntax_only ? &pat0 : &dc->patterns[pcount];
@@ -157,6 +158,11 @@ regex_compile (struct dfa_comp *dc, char const *p, 
ptrdiff_t len,
 
   pat->translate = NULL;
 
+  if (syntax_only)
+    re_set_syntax (syntax_bits | RE_NO_SUB);
+  else
+    re_set_syntax (syntax_bits);
+
   char const *err = re_compile_pattern (p, len, pat);
   if (!err)
     return true;
@@ -189,7 +195,6 @@ GEAcompile (char *pattern, size_t size, reg_syntax_t 
syntax_bits,
 
   if (match_icase)
     syntax_bits |= RE_ICASE;
-  re_set_syntax (syntax_bits);
   int dfaopts = eolbyte ? 0 : DFA_EOL_NUL;
   dfasyntax (dc->dfa, &localeinfo, syntax_bits, dfaopts);
   bool bs_safe = !localeinfo.multibyte | localeinfo.using_utf8;
@@ -242,7 +247,10 @@ GEAcompile (char *pattern, size_t size, reg_syntax_t 
syntax_bits,
           dc->patterns++;
         }
 
-      if (!regex_compile (dc, p, len, dc->pcount, lineno, !backref))
+      re_set_syntax (syntax_bits);
+
+      if (!regex_compile (dc, p, len, dc->pcount, lineno, syntax_bits,
+                          !backref))
         compilation_failed = true;
 
       p = sep + 1;
@@ -317,7 +325,7 @@ GEAcompile (char *pattern, size_t size, reg_syntax_t 
syntax_bits,
           dc->patterns--;
           dc->pcount++;
 
-          if (!regex_compile (dc, buf, buflen, 0, -1, false))
+          if (!regex_compile (dc, buf, buflen, 0, -1, syntax_bits, false))
             abort ();
         }
 

-----------------------------------------------------------------------

Summary of changes:
 src/dfasearch.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]