Skip to content

Commit 32e3e8b

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dc2c44f commit 32e3e8b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

grep.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
362362
int jitret;
363363
int patinforet;
364364
size_t jitsizearg;
365+
int literal = !opt->ignore_case && (p->fixed || p->is_fixed);
365366

366367
/*
367368
* 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
382383
}
383384
options |= PCRE2_CASELESS;
384385
}
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)
387387
options |= (PCRE2_UTF | PCRE2_MATCH_INVALID_UTF);
388388

389389
#ifdef GIT_PCRE2_VERSION_10_36_OR_HIGHER

0 commit comments

Comments
 (0)