diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-11-19 22:48:37 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-11-19 23:53:39 -0800 |
commit | d6c8415e9c8c03db4f062a05dc7e7507af350306 (patch) | |
tree | 944bf5c330b9bd652f7e4d16f0559a5c0e325015 /src/pcresearch.c | |
parent | cfdb4ba4249ac5860979d11436c6a925a298688e (diff) | |
download | grep-d6c8415e9c8c03db4f062a05dc7e7507af350306.tar.gz |
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.
Diffstat (limited to 'src/pcresearch.c')
-rw-r--r-- | src/pcresearch.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/pcresearch.c b/src/pcresearch.c index 1948acfd..108baff8 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) { |