Subject: bug#17143: closed (Re: bug#17143: [PATCH] grep: speed-up for line matching in fgrep)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 06 Apr 2014 15:06:03 +0000

Your bug report

#17143: [PATCH] grep: speed-up for line matching in fgrep

which was filed against the grep package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
17143: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17143
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#17143: [PATCH] grep: speed-up for line matching in fgrep
From: Paul Eggert <[email-masked]>
To: Norihiro Tanaka <[email-masked]>, [email-masked]
Date: Sun, 06 Apr 2014 08:04:58 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Norihiro Tanaka wrote:
> Please close this bug

Thanks, done.  By the way, you can do this yourself, by sending email to 
the address <[email-masked]>.

Subject: [PATCH] grep: speed-up for line matching in fgrep
From: Norihiro Tanaka <[email-masked]>
To: [email-masked]
Date: Sun, 30 Mar 2014 21:14:03 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

If fails in line matching at a position found by kwsexec(), the line
never matches in line matching.  So the line is skipped.

Norihiro
From b8f24ddeb7ddf211a4dce662734ef4387d48b4c2 Mon Sep 17 00:00:00 2001
From: Norihiro Tanaka <[email-masked]>
Date: Sun, 30 Mar 2014 21:03:58 +0900
Subject: [PATCH] grep: speed-up for line matching in fgrep

If fails in line matching at a position found by kwsexec(), the line
never matches in line matching.  So the line is skipped.

* src/kwsearch.c (Fexecute): speed-up for line matching.
---
 src/kwsearch.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/kwsearch.c b/src/kwsearch.c
index dd01518..037b78c 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -141,11 +141,9 @@ Fexecute (char const *buf, size_t size, size_t *match_size,
         goto success_in_beg_and_len;
       if (match_lines)
         {
-          if (beg > buf && beg[-1] != eol)
-            continue;
-          if (beg + len < buf + size && beg[len] != eol)
-            continue;
-          goto success;
+          if (beg[-1] == eol && beg[len] == eol)
+            goto success;
+          beg = memchr (beg, eol, buf + size - beg);
         }
       else if (match_words)
         for (try = beg; ; )
-- 
1.9.1