summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-11-20 06:48:37 (GMT)
committerPaul Eggert <eggert@cs.ucla.edu>2016-11-20 07:53:39 (GMT)
commitd6c8415e9c8c03db4f062a05dc7e7507af350306 (patch)
tree944bf5c330b9bd652f7e4d16f0559a5c0e325015
parentcfdb4ba4249ac5860979d11436c6a925a298688e (diff)
downloadgrep-d6c8415e9c8c03db4f062a05dc7e7507af350306.zip
grep-d6c8415e9c8c03db4f062a05dc7e7507af350306.tar.gz
grep-d6c8415e9c8c03db4f062a05dc7e7507af350306.tar.bz2
grep: further -P performance fix
Problem reported by Stephane Chazelas in: http://bugs.gnu.org/22655#103 * src/pcresearch.c (Pexecute): Set the subject to the start of each line as it is found.
-rw-r--r--src/pcresearch.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/pcresearch.c b/src/pcresearch.c
index 1948acf..108baff 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -194,12 +194,12 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
/* The search address to pass to pcre_exec. This is the start of
the buffer, or just past the most-recently discovered encoding
- error. */
+ error or line end. */
char const *subject = buf;
- for (; p < buf + size; p = line_start = line_end + 1)
+ do
{
- /* Use a single_line search. Although this code formerly used
+ /* Search line by line. Although this code formerly used
PCRE_MULTILINE for performance, the performance wasn't always
better and the correctness issues were too puzzling. See
Bug#22655. */
@@ -269,7 +269,9 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
if (e != PCRE_ERROR_NOMATCH)
break;
bol = true;
+ p = subject = line_start = line_end + 1;
}
+ while (p < buf + size);
if (e <= 0)
{