`start_ptr' which is 4th argument is always null in do_execute().  So
remove it to simplify.  This patch doesn't change behaviour of grep.
From c3e044c24ccc25fa5733afcdcad9af00532e6523 Mon Sep 17 00:00:00 2001
From: Norihiro Tanaka <nori...@kcn.ne.jp>
Date: Fri, 16 May 2014 18:44:59 +0900
Subject: [PATCH] grep: removal of an unnecessary argument

* src/grep (do_execute): Remove argument `start_ptr'.  It's always null.
(grepbuf): Fix a caller of it.
---
 src/grep.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/grep.c b/src/grep.c
index 6a2a029..acc08c7 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1052,8 +1052,7 @@ prtext (char const *beg, char const *lim)
    is no match, return (size_t) -1.  Otherwise, set *MATCH_SIZE to the
    length of the match and return the offset of the start of the match.  */
 static size_t
-do_execute (char const *buf, size_t size, size_t *match_size,
-            char const *start_ptr)
+do_execute (char const *buf, size_t size, size_t *match_size)
 {
   size_t result;
   const char *line_next;
@@ -1072,7 +1071,7 @@ do_execute (char const *buf, size_t size, size_t 
*match_size,
      return buf + size otherwise.  */
   if (! (execute == Fexecute || execute == Pexecute)
       || MB_CUR_MAX == 1 || !match_icase)
-    return execute (buf, size, match_size, start_ptr);
+    return execute (buf, size, match_size, NULL);
 
   for (line_next = buf; line_next < buf + size; )
     {
@@ -1084,10 +1083,7 @@ do_execute (char const *buf, size_t size, size_t 
*match_size,
       else
         line_next = line_end + 1;
 
-      if (start_ptr && start_ptr >= line_end)
-        continue;
-
-      result = execute (line_buf, line_next - line_buf, match_size, start_ptr);
+      result = execute (line_buf, line_next - line_buf, match_size, NULL);
       if (result != (size_t) -1)
         return (line_buf - buf) + result;
     }
@@ -1108,7 +1104,7 @@ grepbuf (char const *beg, char const *lim)
   for (p = beg; p < lim; p = endp)
     {
       size_t match_size;
-      size_t match_offset = do_execute (p, lim - p, &match_size, NULL);
+      size_t match_offset = do_execute (p, lim - p, &match_size);
       if (match_offset == (size_t) -1)
         {
           if (!out_invert)
-- 
1.9.3

Reply via email to