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>
This commit is contained in:
parent
dc2c44fbb1
commit
32e3e8bc55
4
grep.c
4
grep.c
@ -362,6 +362,7 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
|
|||||||
int jitret;
|
int jitret;
|
||||||
int patinforet;
|
int patinforet;
|
||||||
size_t jitsizearg;
|
size_t jitsizearg;
|
||||||
|
int literal = !opt->ignore_case && (p->fixed || p->is_fixed);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call pcre2_general_context_create() before calling any
|
* 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;
|
options |= PCRE2_CASELESS;
|
||||||
}
|
}
|
||||||
if (!opt->ignore_locale && is_utf8_locale() &&
|
if (!opt->ignore_locale && is_utf8_locale() && !literal)
|
||||||
!(!opt->ignore_case && (p->fixed || p->is_fixed)))
|
|
||||||
options |= (PCRE2_UTF | PCRE2_MATCH_INVALID_UTF);
|
options |= (PCRE2_UTF | PCRE2_MATCH_INVALID_UTF);
|
||||||
|
|
||||||
#ifdef GIT_PCRE2_VERSION_10_36_OR_HIGHER
|
#ifdef GIT_PCRE2_VERSION_10_36_OR_HIGHER
|
||||||
|
Loading…
Reference in New Issue
Block a user