grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.18-106-gd3d9950


From: Paul Eggert
Subject: grep branch, master, updated. v2.18-106-gd3d9950
Date: Sun, 27 Apr 2014 01:02:21 +0000

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  d3d99505cb704563cedf4643301d54ecc717ae57 (commit)
       via  3255bc58e8fb2d98145dbb2dd17bae0a5e47a85e (commit)
      from  a0f01ed8dc7e042232eab6bd123204196410c769 (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=d3d99505cb704563cedf4643301d54ecc717ae57


commit d3d99505cb704563cedf4643301d54ecc717ae57
Author: Paul Eggert <address@hidden>
Date:   Sat Apr 26 18:01:11 2014 -0700

    dfa: fix index bug in previous patch, and simplify
    
    * src/dfa.c, src/dfa.h (dfaisfast): Arg is const pointer.
    * src/dfa.c (dfaisfast): Simplify, since supersets never contain BACKREF.
    * src/dfa.h (dfaisfast): Declare to be pure.
    * src/dfasearch.c (EGexecute): Fix typo that could cause buffer
    read overrun when !dfafast.  Hoist duplicate computation out
    of an if's then and else parts.

diff --git a/src/dfa.c b/src/dfa.c
index fc638c8..362de2c 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3412,25 +3412,20 @@ dfahint (struct dfa *d, char const *begin, char *end, 
size_t *count)
 }
 
 bool
-dfaisfast (struct dfa *d)
+dfaisfast (struct dfa const *d)
 {
-  size_t i;
   if (d->superset)
+    return true;
+  else if (d->multibyte)
+    return false;
+  else
     {
-      for (i = 0; i < d->superset->tindex; i++)
-        if (d->superset->tokens[i] == BACKREF)
-          return false;
-      return true;
-    }
-  else if (!d->multibyte)
-    {
+      size_t i;
       for (i = 0; i < d->tindex; i++)
         if (d->tokens[i] == BACKREF)
           return false;
       return true;
     }
-  else
-    return false;
 }
 
 static void
diff --git a/src/dfa.h b/src/dfa.h
index 2dd4871..fbcb191 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -82,9 +82,8 @@ extern char *dfaexec (struct dfa *d, char const *begin, char 
*end,
 extern size_t dfahint (struct dfa *d, char const *begin, char *end,
                        size_t *count);
 
-/* Return true, if `multibyte' attribute of struct dfa is false and the
-   pattern doesn't have BACKREF.  */
-extern bool dfaisfast (struct dfa *);
+/* Return true if the DFA is likely to be fast.  */
+extern bool dfaisfast (struct dfa const *) _GL_ATTRIBUTE_PURE;
 
 /* Free the storage held by the components of a struct dfa. */
 extern void dfafree (struct dfa *);
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 79a0cd8..7edc96b 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -225,21 +225,21 @@ EGexecute (char const *buf, size_t size, size_t 
*match_size,
           /* We don't care about an exact match.  */
           if (kwset)
             {
-              /* Find a possible match using the KWset matcher. */
+              /* Find a possible match using the KWset matcher.  */
               size_t offset = kwsexec (kwset, beg - begline,
                                        buflim - beg + begline, &kwsm);
               if (offset == (size_t) -1)
                 goto failure;
-              beg += offset;
-              /* Narrow down to the line containing the candidate, and
-                 run it through DFA. */
-              match = beg;
-              beg = memrchr (buf, eol, beg - buf);
+              match = beg + offset;
+
+              /* Narrow down to the line containing the candidate.  */
+              beg = memrchr (buf, eol, match - buf);
               beg = beg ? beg + 1 : buf;
+              end = memchr (match, eol, buflim - match);
+              end = end ? end + 1 : buflim;
+
               if (kwsm.index < kwset_exact_matches)
                 {
-                  end = memchr (beg, eol, buflim - beg);
-                  end = end ? end + 1 : buflim;
                   if (MB_CUR_MAX == 1)
                     goto success;
                   if (mb_start < beg)
@@ -256,9 +256,6 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                 }
               else if (!dfafast)
                 {
-                  /* Narrow down to the line we've found if dfa isn't fast. */
-                  end = memchr (match, eol, buflim - beg);
-                  end = end ? end + 1 : buflim;
                   if (dfahint (dfa, beg, (char *) end, NULL) == (size_t) -1)
                     continue;
                   if (! dfaexec (dfa, beg, (char *) end, 0, NULL, &backref))
@@ -267,8 +264,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
             }
           if (!kwset || dfafast)
             {
-              /* No good fixed strings or DFA is fast; start with DFA
-                 broadly. */
+              /* No good fixed strings or DFA is fast; use DFA.  */
               size_t offset, count;
               char const *next_beg;
               count = 0;
@@ -287,7 +283,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                 }
               else
                 next_beg = beg + offset;
-              /* Narrow down to the line we've found. */
+              /* Narrow down to the line we've found.  */
               beg = memrchr (buf, eol, next_beg - buf);
               beg = beg ? beg + 1 : buf;
               if (count != 0)

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=3255bc58e8fb2d98145dbb2dd17bae0a5e47a85e


commit d3d99505cb704563cedf4643301d54ecc717ae57
Author: Paul Eggert <address@hidden>
Date:   Sat Apr 26 18:01:11 2014 -0700

    dfa: fix index bug in previous patch, and simplify
    
    * src/dfa.c, src/dfa.h (dfaisfast): Arg is const pointer.
    * src/dfa.c (dfaisfast): Simplify, since supersets never contain BACKREF.
    * src/dfa.h (dfaisfast): Declare to be pure.
    * src/dfasearch.c (EGexecute): Fix typo that could cause buffer
    read overrun when !dfafast.  Hoist duplicate computation out
    of an if's then and else parts.

diff --git a/src/dfa.c b/src/dfa.c
index fc638c8..362de2c 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3412,25 +3412,20 @@ dfahint (struct dfa *d, char const *begin, char *end, 
size_t *count)
 }
 
 bool
-dfaisfast (struct dfa *d)
+dfaisfast (struct dfa const *d)
 {
-  size_t i;
   if (d->superset)
+    return true;
+  else if (d->multibyte)
+    return false;
+  else
     {
-      for (i = 0; i < d->superset->tindex; i++)
-        if (d->superset->tokens[i] == BACKREF)
-          return false;
-      return true;
-    }
-  else if (!d->multibyte)
-    {
+      size_t i;
       for (i = 0; i < d->tindex; i++)
         if (d->tokens[i] == BACKREF)
           return false;
       return true;
     }
-  else
-    return false;
 }
 
 static void
diff --git a/src/dfa.h b/src/dfa.h
index 2dd4871..fbcb191 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -82,9 +82,8 @@ extern char *dfaexec (struct dfa *d, char const *begin, char 
*end,
 extern size_t dfahint (struct dfa *d, char const *begin, char *end,
                        size_t *count);
 
-/* Return true, if `multibyte' attribute of struct dfa is false and the
-   pattern doesn't have BACKREF.  */
-extern bool dfaisfast (struct dfa *);
+/* Return true if the DFA is likely to be fast.  */
+extern bool dfaisfast (struct dfa const *) _GL_ATTRIBUTE_PURE;
 
 /* Free the storage held by the components of a struct dfa. */
 extern void dfafree (struct dfa *);
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 79a0cd8..7edc96b 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -225,21 +225,21 @@ EGexecute (char const *buf, size_t size, size_t 
*match_size,
           /* We don't care about an exact match.  */
           if (kwset)
             {
-              /* Find a possible match using the KWset matcher. */
+              /* Find a possible match using the KWset matcher.  */
               size_t offset = kwsexec (kwset, beg - begline,
                                        buflim - beg + begline, &kwsm);
               if (offset == (size_t) -1)
                 goto failure;
-              beg += offset;
-              /* Narrow down to the line containing the candidate, and
-                 run it through DFA. */
-              match = beg;
-              beg = memrchr (buf, eol, beg - buf);
+              match = beg + offset;
+
+              /* Narrow down to the line containing the candidate.  */
+              beg = memrchr (buf, eol, match - buf);
               beg = beg ? beg + 1 : buf;
+              end = memchr (match, eol, buflim - match);
+              end = end ? end + 1 : buflim;
+
               if (kwsm.index < kwset_exact_matches)
                 {
-                  end = memchr (beg, eol, buflim - beg);
-                  end = end ? end + 1 : buflim;
                   if (MB_CUR_MAX == 1)
                     goto success;
                   if (mb_start < beg)
@@ -256,9 +256,6 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                 }
               else if (!dfafast)
                 {
-                  /* Narrow down to the line we've found if dfa isn't fast. */
-                  end = memchr (match, eol, buflim - beg);
-                  end = end ? end + 1 : buflim;
                   if (dfahint (dfa, beg, (char *) end, NULL) == (size_t) -1)
                     continue;
                   if (! dfaexec (dfa, beg, (char *) end, 0, NULL, &backref))
@@ -267,8 +264,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
             }
           if (!kwset || dfafast)
             {
-              /* No good fixed strings or DFA is fast; start with DFA
-                 broadly. */
+              /* No good fixed strings or DFA is fast; use DFA.  */
               size_t offset, count;
               char const *next_beg;
               count = 0;
@@ -287,7 +283,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                 }
               else
                 next_beg = beg + offset;
-              /* Narrow down to the line we've found. */
+              /* Narrow down to the line we've found.  */
               beg = memrchr (buf, eol, next_beg - buf);
               beg = beg ? beg + 1 : buf;
               if (count != 0)

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

Summary of changes:
 src/dfa.c       |   17 +++++++++++++++++
 src/dfa.h       |    3 +++
 src/dfasearch.c |   25 +++++++++++++------------
 3 files changed, 33 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

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