grep/pcre2: factor out literal variable

Patterns that contain no wildcards and don't have to be case-folded are literal. Give this condition a name to increase the readability of the boolean expression for enabling the option PCRE2_UTF. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Dec 18, 2021 at 20:53 UTC 32e3e8bc551e7b10bbda07110ae7cb15442d0392
1 file changed +2 -2
grep.c
+2 -2
@@ -362,6 +362,7 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
362 int jitret;
363 int patinforet;
364 size_t jitsizearg;
365 + int literal = !opt->ignore_case && (p->fixed || p->is_fixed);
366
367 /*
368 * Call pcre2_general_context_create() before calling any
@@ -382,8 +383,7 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
383 }
384 options |= PCRE2_CASELESS;
385 }
385 - if (!opt->ignore_locale && is_utf8_locale() &&
386 - !(!opt->ignore_case && (p->fixed || p->is_fixed)))
386 + if (!opt->ignore_locale && is_utf8_locale() && !literal)
387 options |= (PCRE2_UTF | PCRE2_MATCH_INVALID_UTF);
388
389 #ifdef GIT_PCRE2_VERSION_10_36_OR_HIGHER