All of lore.kernel.org
 help / color / mirror / Atom feed
* improve performance of PCRE2 bug 2642 bug workaround
@ 2022-03-22 16:38 Paul Eggert
  2022-03-22 20:26 ` René Scharfe
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Eggert @ 2022-03-22 16:38 UTC (permalink / raw)
  To: git; +Cc: Carlo Arenas

[-- Attachment #1: Type: text/plain, Size: 805 bytes --]

Today, Carlo Arenas pointed out[1] that GNU grep didn't work around 
PCRE2 bug 2642, which Git grep has a workaround for. While installing a 
GNU grep patch to fix this[2] I noticed that Git's workaround appears to 
be too pessimistic: on older PCRE2 libraries Git grep sets 
PCRE2_NO_START_OPTIMIZE even when PCRE2_CASELESS is not set.

Attached is a patch to Git that I just now cobbled up and have not even 
compiled, much less tested. Please feel free to ignore it, as it would 
merely improve performance on older, buggy PCRE2 libraries and that 
might not be worth your trouble. I'm sending this email as more of a 
thank-you for letting us know indirectly of the PCRE2 bug.

[1]: https://lists.gnu.org/r/grep-devel/2022-03/msg00004.html
[2]: https://lists.gnu.org/r/grep-devel/2022-03/msg00005.html

[-- Attachment #2: git-grep.diff --]
[-- Type: text/x-patch, Size: 559 bytes --]

diff --git a/grep.c b/grep.c
index 82eb7da102..b9553ec9f5 100644
--- a/grep.c
+++ b/grep.c
@@ -297,7 +297,9 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
 
 #ifndef GIT_PCRE2_VERSION_10_36_OR_HIGHER
 	/* Work around https://bugs.exim.org/show_bug.cgi?id=2642 fixed in 10.36 */
-	if (PCRE2_MATCH_INVALID_UTF && options & (PCRE2_UTF | PCRE2_CASELESS))
+	if (PCRE2_MATCH_INVALID_UTF &&
+	    ((options & (PCRE2_UTF | PCRE2_CASELESS)) ==
+	     (PCRE2_UTF | PCRE2_CASELESS)))
 		options |= PCRE2_NO_START_OPTIMIZE;
 #endif
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-03-23 20:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22 16:38 improve performance of PCRE2 bug 2642 bug workaround Paul Eggert
2022-03-22 20:26 ` René Scharfe
2022-03-22 21:12   ` Paul Eggert
2022-03-23  1:09   ` Carlo Marcelo Arenas Belón
2022-03-23  4:06     ` Paul Eggert
2022-03-23 18:37     ` René Scharfe
2022-03-23 20:24       ` Carlo Arenas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.