grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v3.5-10-gf31abf7


From: Paul Eggert
Subject: grep branch, master, updated. v3.5-10-gf31abf7
Date: Sun, 11 Oct 2020 12:53:59 -0400 (EDT)

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  f31abf786f61f4bdd7134559a5f155fc9c8c2513 (commit)
       via  0c64ce796dfec048499d1ad82d88f97ab09a0292 (commit)
      from  b3ebcf6fa928c5801e8d13e6dd01b029771ac40a (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=f31abf786f61f4bdd7134559a5f155fc9c8c2513


commit f31abf786f61f4bdd7134559a5f155fc9c8c2513
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sun Oct 11 09:53:22 2020 -0700

    grep: minor kwset cleanups
    
    * src/kwsearch.c (Fexecute):
    Assume C99 to put declarations nearer uses.
    * src/kwset.c (bmexec): Omit unnecessary test.
    * src/kwset.h (struct kwsmatch): Make OFFSET and SIZE individual
    elements, not arrays of size 1 (a revenant of an earlier API).
    All uses changed.

diff --git a/src/kwsearch.c b/src/kwsearch.c
index 1b31917..685502d 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -87,8 +87,8 @@ Fcompile (char *pattern, size_t size, reg_syntax_t ignored, 
bool exact)
   while (p <= pattern + size);
 
   free (buf);
-  ptrdiff_t words = kwswords (kwset);
 
+  ptrdiff_t words = kwswords (kwset);
   kwsprep (kwset);
 
   struct kwsearch *kwsearch = xmalloc (sizeof *kwsearch);
@@ -111,32 +111,22 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t 
*match_size,
   char const *beg, *end, *mb_start;
   ptrdiff_t len;
   char eol = eolbyte;
-  struct kwsmatch kwsmatch;
-  size_t ret_val;
-  bool mb_check;
-  bool longest;
   struct kwsearch *kwsearch = vcp;
   kwset_t kwset = kwsearch->kwset;
-  size_t mbclen;
-
-  if (match_lines)
-    mb_check = longest = false;
-  else
-    {
-      mb_check = localeinfo.multibyte & !localeinfo.using_utf8;
-      longest = mb_check | !!start_ptr | match_words;
-    }
+  bool mb_check = localeinfo.multibyte & !localeinfo.using_utf8 & !match_lines;
+  bool longest = (mb_check | !!start_ptr | match_words) & !match_lines;
 
   for (mb_start = beg = start_ptr ? start_ptr : buf; beg <= buf + size; beg++)
     {
+      struct kwsmatch kwsmatch;
       ptrdiff_t offset = kwsexec (kwset, beg - match_lines,
                                   buf + size - beg + match_lines, &kwsmatch,
                                   longest);
       if (offset < 0)
         break;
-      len = kwsmatch.size[0] - 2 * match_lines;
+      len = kwsmatch.size - 2 * match_lines;
 
-      mbclen = 0;
+      size_t mbclen = 0;
       if (mb_check
           && mb_goback (&mb_start, &mbclen, beg + offset, buf + size) != 0)
         {
@@ -216,10 +206,11 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t 
*match_size,
               }
             if (!len)
               break;
-            offset = kwsexec (kwset, beg, --len, &kwsmatch, true);
-            if (offset != 0)
+
+            struct kwsmatch shorter_match;
+            if (kwsexec (kwset, beg, --len, &shorter_match, true) != 0)
               break;
-            len = kwsmatch.size[0];
+            len = shorter_match.size;
           }
 
       /* No word match was found at BEG.  Skip past word constituents,
@@ -227,7 +218,7 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t 
*match_size,
          them could make things much slower.  */
       beg += wordchars_size (beg, buf + size);
       mb_start = beg;
-    } /* for (beg in buf) */
+    }
 
   return -1;
 
@@ -244,9 +235,6 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t 
*match_size,
   beg = beg ? beg + 1 : buf;
   len = end - beg;
  success_in_beg_and_len:;
-  size_t off = beg - buf;
-
   *match_size = len;
-  ret_val = off;
-  return ret_val;
+  return beg - buf;
 }
diff --git a/src/kwset.c b/src/kwset.c
index 403af7e..b271e39 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -760,13 +760,9 @@ bmexec (kwset_t kwset, char const *text, ptrdiff_t size,
                    (kwset->trans
                     ? bmexec_trans (kwset, text, size)
                     : bmexec_trans (kwset, text, size)));
-  if (0 <= ret)
-    {
-       kwsmatch->index = 0;
-       kwsmatch->offset[0] = ret;
-       kwsmatch->size[0] = kwset->mind;
-    }
-
+  kwsmatch->index = 0;
+  kwsmatch->offset = ret;
+  kwsmatch->size = kwset->mind;
   return ret;
 }
 
@@ -891,8 +887,8 @@ acexec_trans (kwset_t kwset, char const *text, ptrdiff_t 
len,
     }
 
   kwsmatch->index = accept->accepting / 2;
-  kwsmatch->offset[0] = left - text;
-  kwsmatch->size[0] = accept->depth;
+  kwsmatch->offset = left - text;
+  kwsmatch->size = accept->depth;
 
   return left - text;
 }
diff --git a/src/kwset.h b/src/kwset.h
index 793e210..eee3d73 100644
--- a/src/kwset.h
+++ b/src/kwset.h
@@ -24,9 +24,9 @@
 
 struct kwsmatch
 {
-  ptrdiff_t index;                     /* Index number of matching keyword.  */
-  ptrdiff_t offset[1];         /* Offset of match.  */
-  ptrdiff_t size[1];           /* Length of match.  */
+  ptrdiff_t index;     /* Index number of matching keyword.  */
+  ptrdiff_t offset;    /* Offset of match.  */
+  ptrdiff_t size;      /* Length of match.  */
 };
 
 #include "arg-nonnull.h"

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


commit f31abf786f61f4bdd7134559a5f155fc9c8c2513
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sun Oct 11 09:53:22 2020 -0700

    grep: minor kwset cleanups
    
    * src/kwsearch.c (Fexecute):
    Assume C99 to put declarations nearer uses.
    * src/kwset.c (bmexec): Omit unnecessary test.
    * src/kwset.h (struct kwsmatch): Make OFFSET and SIZE individual
    elements, not arrays of size 1 (a revenant of an earlier API).
    All uses changed.

diff --git a/src/kwsearch.c b/src/kwsearch.c
index 1b31917..685502d 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -87,8 +87,8 @@ Fcompile (char *pattern, size_t size, reg_syntax_t ignored, 
bool exact)
   while (p <= pattern + size);
 
   free (buf);
-  ptrdiff_t words = kwswords (kwset);
 
+  ptrdiff_t words = kwswords (kwset);
   kwsprep (kwset);
 
   struct kwsearch *kwsearch = xmalloc (sizeof *kwsearch);
@@ -111,32 +111,22 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t 
*match_size,
   char const *beg, *end, *mb_start;
   ptrdiff_t len;
   char eol = eolbyte;
-  struct kwsmatch kwsmatch;
-  size_t ret_val;
-  bool mb_check;
-  bool longest;
   struct kwsearch *kwsearch = vcp;
   kwset_t kwset = kwsearch->kwset;
-  size_t mbclen;
-
-  if (match_lines)
-    mb_check = longest = false;
-  else
-    {
-      mb_check = localeinfo.multibyte & !localeinfo.using_utf8;
-      longest = mb_check | !!start_ptr | match_words;
-    }
+  bool mb_check = localeinfo.multibyte & !localeinfo.using_utf8 & !match_lines;
+  bool longest = (mb_check | !!start_ptr | match_words) & !match_lines;
 
   for (mb_start = beg = start_ptr ? start_ptr : buf; beg <= buf + size; beg++)
     {
+      struct kwsmatch kwsmatch;
       ptrdiff_t offset = kwsexec (kwset, beg - match_lines,
                                   buf + size - beg + match_lines, &kwsmatch,
                                   longest);
       if (offset < 0)
         break;
-      len = kwsmatch.size[0] - 2 * match_lines;
+      len = kwsmatch.size - 2 * match_lines;
 
-      mbclen = 0;
+      size_t mbclen = 0;
       if (mb_check
           && mb_goback (&mb_start, &mbclen, beg + offset, buf + size) != 0)
         {
@@ -216,10 +206,11 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t 
*match_size,
               }
             if (!len)
               break;
-            offset = kwsexec (kwset, beg, --len, &kwsmatch, true);
-            if (offset != 0)
+
+            struct kwsmatch shorter_match;
+            if (kwsexec (kwset, beg, --len, &shorter_match, true) != 0)
               break;
-            len = kwsmatch.size[0];
+            len = shorter_match.size;
           }
 
       /* No word match was found at BEG.  Skip past word constituents,
@@ -227,7 +218,7 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t 
*match_size,
          them could make things much slower.  */
       beg += wordchars_size (beg, buf + size);
       mb_start = beg;
-    } /* for (beg in buf) */
+    }
 
   return -1;
 
@@ -244,9 +235,6 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t 
*match_size,
   beg = beg ? beg + 1 : buf;
   len = end - beg;
  success_in_beg_and_len:;
-  size_t off = beg - buf;
-
   *match_size = len;
-  ret_val = off;
-  return ret_val;
+  return beg - buf;
 }
diff --git a/src/kwset.c b/src/kwset.c
index 403af7e..b271e39 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -760,13 +760,9 @@ bmexec (kwset_t kwset, char const *text, ptrdiff_t size,
                    (kwset->trans
                     ? bmexec_trans (kwset, text, size)
                     : bmexec_trans (kwset, text, size)));
-  if (0 <= ret)
-    {
-       kwsmatch->index = 0;
-       kwsmatch->offset[0] = ret;
-       kwsmatch->size[0] = kwset->mind;
-    }
-
+  kwsmatch->index = 0;
+  kwsmatch->offset = ret;
+  kwsmatch->size = kwset->mind;
   return ret;
 }
 
@@ -891,8 +887,8 @@ acexec_trans (kwset_t kwset, char const *text, ptrdiff_t 
len,
     }
 
   kwsmatch->index = accept->accepting / 2;
-  kwsmatch->offset[0] = left - text;
-  kwsmatch->size[0] = accept->depth;
+  kwsmatch->offset = left - text;
+  kwsmatch->size = accept->depth;
 
   return left - text;
 }
diff --git a/src/kwset.h b/src/kwset.h
index 793e210..eee3d73 100644
--- a/src/kwset.h
+++ b/src/kwset.h
@@ -24,9 +24,9 @@
 
 struct kwsmatch
 {
-  ptrdiff_t index;                     /* Index number of matching keyword.  */
-  ptrdiff_t offset[1];         /* Offset of match.  */
-  ptrdiff_t size[1];           /* Length of match.  */
+  ptrdiff_t index;     /* Index number of matching keyword.  */
+  ptrdiff_t offset;    /* Offset of match.  */
+  ptrdiff_t size;      /* Length of match.  */
 };
 
 #include "arg-nonnull.h"

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

Summary of changes:
 src/kwsearch.c | 83 +++++++++-------------------------------------------------
 src/kwset.c    | 14 ++++------
 src/kwset.h    |  6 ++---
 3 files changed, 20 insertions(+), 83 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

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