summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2021-12-18 19:53:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-12-20 20:46:39 (GMT)
commit32e3e8bc551e7b10bbda07110ae7cb15442d0392 (patch)
treeb77583264fe3213e73f463f677c1c446e22cf727 /grep.c
parentdc2c44fbb100fa609174d9069a70e2b54b0591ca (diff)
downloadgit-32e3e8bc551e7b10bbda07110ae7cb15442d0392.zip
git-32e3e8bc551e7b10bbda07110ae7cb15442d0392.tar.gz
git-32e3e8bc551e7b10bbda07110ae7cb15442d0392.tar.bz2
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>
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/grep.c b/grep.c
index 5badb6d..2b6ac32 100644
--- a/grep.c
+++ b/grep.c
@@ -362,6 +362,7 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
int jitret;
int patinforet;
size_t jitsizearg;
+ int literal = !opt->ignore_case && (p->fixed || p->is_fixed);
/*
* 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
}
options |= PCRE2_CASELESS;
}
- if (!opt->ignore_locale && is_utf8_locale() &&
- !(!opt->ignore_case && (p->fixed || p->is_fixed)))
+ if (!opt->ignore_locale && is_utf8_locale() && !literal)
options |= (PCRE2_UTF | PCRE2_MATCH_INVALID_UTF);
#ifdef GIT_PCRE2_VERSION_10_36_OR_HIGHER