grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.18-98-ga9c9f65


From: Paul Eggert
Subject: grep branch, master, updated. v2.18-98-ga9c9f65
Date: Thu, 24 Apr 2014 16:44:56 +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  a9c9f65425ee313b1a24b32bfa3f9fec679bbcc7 (commit)
       via  eebb7161b7321f08b448f9d7ab4d99d860445ef5 (commit)
      from  2c780631f89a1e50fe8221f72e128cf39b212141 (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=a9c9f65425ee313b1a24b32bfa3f9fec679bbcc7


commit a9c9f65425ee313b1a24b32bfa3f9fec679bbcc7
Author: Paul Eggert <address@hidden>
Date:   Thu Apr 24 09:40:34 2014 -0700

    dfa: minor tuneup of dfamust memory savings patch
    
    * src/dfa.c (allocmust): Use xmalloc, not xzalloc.
    Initialize the must completely, so that the caller need not
    invoke resetmust.  All callers changed.
    (dfamust): Omit asserts that aren't needed on typical machines
    where dereferencing NULL dumps core.  Don't leak memory if the
    pattern contains a NUL byte.

diff --git a/src/dfa.c b/src/dfa.c
index ee1e8e6..8fc3d6f 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3828,11 +3828,13 @@ struct must
 static must *
 allocmust (must *mp)
 {
-  must *new_mp = xzalloc (sizeof *new_mp);
+  must *new_mp = xmalloc (sizeof *new_mp);
   new_mp->in = xzalloc (sizeof *new_mp->in);
   new_mp->left = xzalloc (2);
   new_mp->right = xzalloc (2);
   new_mp->is = xzalloc (2);
+  new_mp->begline = false;
+  new_mp->endline = false;
   new_mp->prev = mp;
   return new_mp;
 }
@@ -3877,12 +3879,10 @@ dfamust (struct dfa *d)
         {
         case BEGLINE:
           mp = allocmust (mp);
-          resetmust (mp);
           mp->begline = true;
           break;
         case ENDLINE:
           mp = allocmust (mp);
-          resetmust (mp);
           mp->endline = true;
           break;
         case LPAREN:
@@ -3898,23 +3898,20 @@ dfamust (struct dfa *d)
         case ANYCHAR:
         case MBCSET:
           mp = allocmust (mp);
-          /* Fall through.  */
+          break;
+
         case STAR:
         case QMARK:
-          assert (mp != NULL);
           resetmust (mp);
           break;
 
         case OR:
-          assert (mp && mp->prev);
           {
             char **new;
-            must *lmp;
-            must *rmp;
+            must *rmp = mp;
+            must *lmp = mp = mp->prev;
             size_t j, ln, rn, n;
 
-            rmp = mp;
-            lmp = mp = mp->prev;
             /* Guaranteed to be.  Unlikely, but ...  */
             if (!STREQ (lmp->is, rmp->is))
               lmp->is[0] = '\0';
@@ -3946,34 +3943,27 @@ dfamust (struct dfa *d)
           break;
 
         case PLUS:
-          assert (mp != NULL);
           mp->is[0] = '\0';
           break;
 
         case END:
-          assert (!mp || !mp->prev);
-          if (mp)
+          assert (!mp->prev);
+          for (i = 0; mp->in[i] != NULL; ++i)
+            if (strlen (mp->in[i]) > strlen (result))
+              result = mp->in[i];
+          if (STREQ (result, mp->is))
             {
-              for (i = 0; mp->in[i] != NULL; ++i)
-                if (strlen (mp->in[i]) > strlen (result))
-                  result = mp->in[i];
-              if (STREQ (result, mp->is))
-                {
-                  exact = true;
-                  begline = mp->begline;
-                  endline = mp->endline;
-                }
+              exact = true;
+              begline = mp->begline;
+              endline = mp->endline;
             }
           goto done;
 
         case CAT:
-          assert (mp && mp->prev);
           {
-            must *lmp;
-            must *rmp;
+            must *rmp = mp;
+            must *lmp = mp = mp->prev;
 
-            rmp = mp;
-            lmp = mp = mp->prev;
             /* In.  Everything in left, plus everything in
                right, plus concatenation of
                left's right and right's left.  */
@@ -4018,7 +4008,6 @@ dfamust (struct dfa *d)
 
         default:
           mp = allocmust (mp);
-          resetmust (mp);
           if (CSET <= t)
             {
               /* If T is a singleton, or if case-folding in a unibyte
@@ -4059,8 +4048,13 @@ done:
       dm->next = d->musts;
       d->musts = dm;
     }
-  if (mp)
-    freemust (mp);
+
+  while (mp)
+    {
+      must *prev = mp->prev;
+      freemust (mp);
+      mp = prev;
+    }
 }
 
 struct dfa *

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


commit a9c9f65425ee313b1a24b32bfa3f9fec679bbcc7
Author: Paul Eggert <address@hidden>
Date:   Thu Apr 24 09:40:34 2014 -0700

    dfa: minor tuneup of dfamust memory savings patch
    
    * src/dfa.c (allocmust): Use xmalloc, not xzalloc.
    Initialize the must completely, so that the caller need not
    invoke resetmust.  All callers changed.
    (dfamust): Omit asserts that aren't needed on typical machines
    where dereferencing NULL dumps core.  Don't leak memory if the
    pattern contains a NUL byte.

diff --git a/src/dfa.c b/src/dfa.c
index ee1e8e6..8fc3d6f 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3828,11 +3828,13 @@ struct must
 static must *
 allocmust (must *mp)
 {
-  must *new_mp = xzalloc (sizeof *new_mp);
+  must *new_mp = xmalloc (sizeof *new_mp);
   new_mp->in = xzalloc (sizeof *new_mp->in);
   new_mp->left = xzalloc (2);
   new_mp->right = xzalloc (2);
   new_mp->is = xzalloc (2);
+  new_mp->begline = false;
+  new_mp->endline = false;
   new_mp->prev = mp;
   return new_mp;
 }
@@ -3877,12 +3879,10 @@ dfamust (struct dfa *d)
         {
         case BEGLINE:
           mp = allocmust (mp);
-          resetmust (mp);
           mp->begline = true;
           break;
         case ENDLINE:
           mp = allocmust (mp);
-          resetmust (mp);
           mp->endline = true;
           break;
         case LPAREN:
@@ -3898,23 +3898,20 @@ dfamust (struct dfa *d)
         case ANYCHAR:
         case MBCSET:
           mp = allocmust (mp);
-          /* Fall through.  */
+          break;
+
         case STAR:
         case QMARK:
-          assert (mp != NULL);
           resetmust (mp);
           break;
 
         case OR:
-          assert (mp && mp->prev);
           {
             char **new;
-            must *lmp;
-            must *rmp;
+            must *rmp = mp;
+            must *lmp = mp = mp->prev;
             size_t j, ln, rn, n;
 
-            rmp = mp;
-            lmp = mp = mp->prev;
             /* Guaranteed to be.  Unlikely, but ...  */
             if (!STREQ (lmp->is, rmp->is))
               lmp->is[0] = '\0';
@@ -3946,34 +3943,27 @@ dfamust (struct dfa *d)
           break;
 
         case PLUS:
-          assert (mp != NULL);
           mp->is[0] = '\0';
           break;
 
         case END:
-          assert (!mp || !mp->prev);
-          if (mp)
+          assert (!mp->prev);
+          for (i = 0; mp->in[i] != NULL; ++i)
+            if (strlen (mp->in[i]) > strlen (result))
+              result = mp->in[i];
+          if (STREQ (result, mp->is))
             {
-              for (i = 0; mp->in[i] != NULL; ++i)
-                if (strlen (mp->in[i]) > strlen (result))
-                  result = mp->in[i];
-              if (STREQ (result, mp->is))
-                {
-                  exact = true;
-                  begline = mp->begline;
-                  endline = mp->endline;
-                }
+              exact = true;
+              begline = mp->begline;
+              endline = mp->endline;
             }
           goto done;
 
         case CAT:
-          assert (mp && mp->prev);
           {
-            must *lmp;
-            must *rmp;
+            must *rmp = mp;
+            must *lmp = mp = mp->prev;
 
-            rmp = mp;
-            lmp = mp = mp->prev;
             /* In.  Everything in left, plus everything in
                right, plus concatenation of
                left's right and right's left.  */
@@ -4018,7 +4008,6 @@ dfamust (struct dfa *d)
 
         default:
           mp = allocmust (mp);
-          resetmust (mp);
           if (CSET <= t)
             {
               /* If T is a singleton, or if case-folding in a unibyte
@@ -4059,8 +4048,13 @@ done:
       dm->next = d->musts;
       d->musts = dm;
     }
-  if (mp)
-    freemust (mp);
+
+  while (mp)
+    {
+      must *prev = mp->prev;
+      freemust (mp);
+      mp = prev;
+    }
 }
 
 struct dfa *

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

Summary of changes:
 src/dfa.c |  129 ++++++++++++++++++++++++++++--------------------------------
 1 files changed, 60 insertions(+), 69 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

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