mirror of
https://github.com/git/git.git
synced 2024-06-10 06:26:13 +02:00
Merge branch 'rs/pcre2-utf'
"git grep --perl-regexp" failed to match UTF-8 characters with wildcard when the pattern consists only of ASCII letters, which has been corrected. * rs/pcre2-utf: grep/pcre2: factor out literal variable grep/pcre2: use PCRE2_UTF even with ASCII patterns
This commit is contained in:
commit
c91b0b7c72
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() && has_non_ascii(p->pattern) &&
|
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
|
||||||
|
|
|
@ -123,4 +123,10 @@ test_expect_success GETTEXT_LOCALE,LIBPCRE2,PCRE2_MATCH_INVALID_UTF 'PCRE v2: gr
|
||||||
test_cmp invalid-0xe5 actual
|
test_cmp invalid-0xe5 actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-literal ASCII from UTF-8' '
|
||||||
|
git grep --perl-regexp -h -o -e ll. file >actual &&
|
||||||
|
echo "lló" >expected &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in New Issue