Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-01-06 01:01:31 +0300
committerJunio C Hamano <gitster@pobox.com>2022-01-06 01:01:31 +0300
commitc91b0b7c7270dac8c539062d193749e654b7f002 (patch)
tree86df5729ee96b399c5f5b578708305670f6e5fbb
parent5d522cddfd910f6aa9383d121ac8dd17dfffff50 (diff)
parent32e3e8bc551e7b10bbda07110ae7cb15442d0392 (diff)
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
-rw-r--r--grep.c4
-rwxr-xr-xt/t7812-grep-icase-non-ascii.sh6
2 files changed, 8 insertions, 2 deletions
diff --git a/grep.c b/grep.c
index beef5fe47e..47c75ab7fb 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() && has_non_ascii(p->pattern) &&
- !(!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
diff --git a/t/t7812-grep-icase-non-ascii.sh b/t/t7812-grep-icase-non-ascii.sh
index e5d1e4ea68..ca3f24f807 100755
--- a/t/t7812-grep-icase-non-ascii.sh
+++ b/t/t7812-grep-icase-non-ascii.sh
@@ -123,4 +123,10 @@ test_expect_success GETTEXT_LOCALE,LIBPCRE2,PCRE2_MATCH_INVALID_UTF 'PCRE v2: gr
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