grep/pcre: prepare locale-dependent tables for icase matching
The default tables are usually built with C locale and only suitable for LANG=C or similar. This should make case insensitive search work correctly for all single-byte charsets. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
e944d9d932
commit
9d9babb84d
8
grep.c
8
grep.c
@ -324,11 +324,14 @@ static void compile_pcre_regexp(struct grep_pat *p, const struct grep_opt *opt)
|
||||
int erroffset;
|
||||
int options = PCRE_MULTILINE;
|
||||
|
||||
if (opt->ignore_case)
|
||||
if (opt->ignore_case) {
|
||||
if (has_non_ascii(p->pattern))
|
||||
p->pcre_tables = pcre_maketables();
|
||||
options |= PCRE_CASELESS;
|
||||
}
|
||||
|
||||
p->pcre_regexp = pcre_compile(p->pattern, options, &error, &erroffset,
|
||||
NULL);
|
||||
p->pcre_tables);
|
||||
if (!p->pcre_regexp)
|
||||
compile_regexp_failed(p, error);
|
||||
|
||||
@ -362,6 +365,7 @@ static void free_pcre_regexp(struct grep_pat *p)
|
||||
{
|
||||
pcre_free(p->pcre_regexp);
|
||||
pcre_free(p->pcre_extra_info);
|
||||
pcre_free((void *)p->pcre_tables);
|
||||
}
|
||||
#else /* !USE_LIBPCRE */
|
||||
static void compile_pcre_regexp(struct grep_pat *p, const struct grep_opt *opt)
|
||||
|
||||
Reference in New Issue
Block a user