grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.18-86-ge403616


From: Paul Eggert
Subject: grep branch, master, updated. v2.18-86-ge403616
Date: Mon, 21 Apr 2014 14:55:44 +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  e40361683cdc703121cdd51ffd3e189388b6f9a4 (commit)
       via  2c94326bd94a1ff46fe54cbd0596dd5d669d1b38 (commit)
      from  9276ef47ee5aa4a90908c89b9b1caf46415a8b53 (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=e40361683cdc703121cdd51ffd3e189388b6f9a4


commit e40361683cdc703121cdd51ffd3e189388b6f9a4
Author: Paul Eggert <address@hidden>
Date:   Mon Apr 21 07:27:14 2014 -0700

    dfa: minor improvements to previous patch
    
    * src/dfa.c (dfamust): Use &=, not if-then.
    * src/dfa.h (struct dfamust):
    * src/dfasearch.c (begline, hwsmusts): Use bool for boolean.
    * src/dfasearch.c (kwsmusts):
    * src/kwsearch.c (Fcompile): Prefer decls after statements.
    * src/dfasearch.c (kwsmusts): Avoid conditional branch.
    * src/kwsearch.c (Fcompile): Unify the two calls to kwsincr.

diff --git a/src/dfa.c b/src/dfa.c
index 0a6f061..65fc03d 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3916,10 +3916,8 @@ dfamust (struct dfa *d)
             /* Guaranteed to be.  Unlikely, but ...  */
             if (!STREQ (lmp->is, rmp->is))
               lmp->is[0] = '\0';
-            if (lmp->begline)
-              lmp->begline = rmp->begline;
-            if (lmp->endline)
-              lmp->endline = rmp->endline;
+            lmp->begline &= rmp->begline;
+            lmp->endline &= rmp->endline;
             /* Left side--easy */
             i = 0;
             while (lmp->left[i] != '\0' && lmp->left[i] == rmp->left[i])
diff --git a/src/dfa.h b/src/dfa.h
index 3829e6a..60aff11 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -19,15 +19,16 @@
 /* Written June, 1988 by Mike Haertel */
 
 #include <regex.h>
+#include <stdbool.h>
 #include <stddef.h>
 
 /* Element of a list of strings, at least one of which is known to
    appear in any R.E. matching the DFA. */
 struct dfamust
 {
-  int exact;
-  int begline;
-  int endline;
+  bool exact;
+  bool begline;
+  bool endline;
   char *must;
   struct dfamust *next;
 };
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 34c4505..dc76397 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -51,7 +51,7 @@ static size_t pcount;
    call the regexp matcher at all. */
 static size_t kwset_exact_matches;
 
-static int begline;
+static bool begline;
 
 void
 dfaerror (char const *mesg)
@@ -87,25 +87,21 @@ kwsmusts (void)
   if (dm)
     {
       kwsinit (&kwset);
-      begline = 0;
       /* First, we compile in the substrings known to be exact
          matches.  The kwset matcher will return the index
          of the matching string that it chooses. */
       for (; dm; dm = dm->next)
         {
-          char *must, *mp;
-          size_t old_len, new_len;
           if (!dm->exact)
             continue;
           ++kwset_exact_matches;
-          old_len = strlen (dm->must);
-          new_len = old_len + dm->begline + dm->endline;
-          must = mp = xmalloc (new_len);
-          if (dm->begline)
-            {
-              (mp++)[0] = eolbyte;
-              begline = 1;
-            }
+          size_t old_len = strlen (dm->must);
+          size_t new_len = old_len + dm->begline + dm->endline;
+          char *must = xmalloc (new_len);
+          char *mp = must;
+          *mp = eolbyte;
+          mp += dm->begline;
+          begline |= dm->begline;
           memcpy (mp, dm->must, old_len);
           if (dm->endline)
             mp[old_len] = eolbyte;
diff --git a/src/kwsearch.c b/src/kwsearch.c
index 9904bfe..7c64c86 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -57,16 +57,19 @@ Fcompile (char const *pattern, size_t size)
           total = 0;
         }
 
+      char *buf = NULL;
       if (match_lines)
         {
-          char *buf = xmalloc (len + 2);
-          memcpy (&buf[1], p, len);
-          buf[0] = buf[len + 1] = eolbyte;
-          kwsincr (kwset, buf, len + 2);
-          free (buf);
+          buf = xmalloc (len + 2);
+          buf[0] = eolbyte;
+          memcpy (buf + 1, p, len);
+          buf[len + 1] = eolbyte;
+          p = buf;
+          len += 2;
         }
-      else
-        kwsincr (kwset, p, len);
+      kwsincr (kwset, p, len);
+      free (buf);
+
       p = sep;
     }
   while (p);

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


commit e40361683cdc703121cdd51ffd3e189388b6f9a4
Author: Paul Eggert <address@hidden>
Date:   Mon Apr 21 07:27:14 2014 -0700

    dfa: minor improvements to previous patch
    
    * src/dfa.c (dfamust): Use &=, not if-then.
    * src/dfa.h (struct dfamust):
    * src/dfasearch.c (begline, hwsmusts): Use bool for boolean.
    * src/dfasearch.c (kwsmusts):
    * src/kwsearch.c (Fcompile): Prefer decls after statements.
    * src/dfasearch.c (kwsmusts): Avoid conditional branch.
    * src/kwsearch.c (Fcompile): Unify the two calls to kwsincr.

diff --git a/src/dfa.c b/src/dfa.c
index 0a6f061..65fc03d 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3916,10 +3916,8 @@ dfamust (struct dfa *d)
             /* Guaranteed to be.  Unlikely, but ...  */
             if (!STREQ (lmp->is, rmp->is))
               lmp->is[0] = '\0';
-            if (lmp->begline)
-              lmp->begline = rmp->begline;
-            if (lmp->endline)
-              lmp->endline = rmp->endline;
+            lmp->begline &= rmp->begline;
+            lmp->endline &= rmp->endline;
             /* Left side--easy */
             i = 0;
             while (lmp->left[i] != '\0' && lmp->left[i] == rmp->left[i])
diff --git a/src/dfa.h b/src/dfa.h
index 3829e6a..60aff11 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -19,15 +19,16 @@
 /* Written June, 1988 by Mike Haertel */
 
 #include <regex.h>
+#include <stdbool.h>
 #include <stddef.h>
 
 /* Element of a list of strings, at least one of which is known to
    appear in any R.E. matching the DFA. */
 struct dfamust
 {
-  int exact;
-  int begline;
-  int endline;
+  bool exact;
+  bool begline;
+  bool endline;
   char *must;
   struct dfamust *next;
 };
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 34c4505..dc76397 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -51,7 +51,7 @@ static size_t pcount;
    call the regexp matcher at all. */
 static size_t kwset_exact_matches;
 
-static int begline;
+static bool begline;
 
 void
 dfaerror (char const *mesg)
@@ -87,25 +87,21 @@ kwsmusts (void)
   if (dm)
     {
       kwsinit (&kwset);
-      begline = 0;
       /* First, we compile in the substrings known to be exact
          matches.  The kwset matcher will return the index
          of the matching string that it chooses. */
       for (; dm; dm = dm->next)
         {
-          char *must, *mp;
-          size_t old_len, new_len;
           if (!dm->exact)
             continue;
           ++kwset_exact_matches;
-          old_len = strlen (dm->must);
-          new_len = old_len + dm->begline + dm->endline;
-          must = mp = xmalloc (new_len);
-          if (dm->begline)
-            {
-              (mp++)[0] = eolbyte;
-              begline = 1;
-            }
+          size_t old_len = strlen (dm->must);
+          size_t new_len = old_len + dm->begline + dm->endline;
+          char *must = xmalloc (new_len);
+          char *mp = must;
+          *mp = eolbyte;
+          mp += dm->begline;
+          begline |= dm->begline;
           memcpy (mp, dm->must, old_len);
           if (dm->endline)
             mp[old_len] = eolbyte;
diff --git a/src/kwsearch.c b/src/kwsearch.c
index 9904bfe..7c64c86 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -57,16 +57,19 @@ Fcompile (char const *pattern, size_t size)
           total = 0;
         }
 
+      char *buf = NULL;
       if (match_lines)
         {
-          char *buf = xmalloc (len + 2);
-          memcpy (&buf[1], p, len);
-          buf[0] = buf[len + 1] = eolbyte;
-          kwsincr (kwset, buf, len + 2);
-          free (buf);
+          buf = xmalloc (len + 2);
+          buf[0] = eolbyte;
+          memcpy (buf + 1, p, len);
+          buf[len + 1] = eolbyte;
+          p = buf;
+          len += 2;
         }
-      else
-        kwsincr (kwset, p, len);
+      kwsincr (kwset, p, len);
+      free (buf);
+
       p = sep;
     }
   while (p);

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

Summary of changes:
 src/dfa.c       |   40 ++++++++++++++++++++++++++++++++++------
 src/dfa.h       |    5 ++++-
 src/dfasearch.c |   25 ++++++++++++++++++++-----
 src/kwsearch.c  |   29 ++++++++++++++++++-----------
 4 files changed, 76 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

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