summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e3f67d3)
raw | patch | inline | side by side (parent: e3f67d3)
author | Benjamin Kramer <benny.kra@googlemail.com> | |
Tue, 26 Jan 2010 17:48:36 +0000 (18:48 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 26 Jan 2010 18:44:10 +0000 (10:44 -0800) |
BSD and glibc have an extension to regexec which takes a buffer + length pair
instead of a NUL-terminated string. Since we already have the length computed
this can save us a strlen call inside regexec.
Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
instead of a NUL-terminated string. Since we already have the length computed
this can save us a strlen call inside regexec.
Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.c | patch | blob | history |
index 8e1f7de7717da95e8954491f5205547f2091aa35..452c2cbae4c4b706c867574c437490cdf7ac9bd5 100644 (file)
--- a/grep.c
+++ b/grep.c
if (p->fixed)
hit = !fixmatch(p->pattern, bol, p->ignore_case, &m);
- else
+ else {
+#ifdef REG_STARTEND
+ m.rm_so = 0;
+ m.rm_eo = *left_p;
+ hit = !regexec(&p->regexp, bol, 1, &m, REG_STARTEND);
+#else
hit = !regexec(&p->regexp, bol, 1, &m, 0);
+#endif
+ }
if (!hit || m.rm_so < 0 || m.rm_eo < 0)
continue;
if (earliest < 0 || m.rm_so < earliest)