aboutsummaryrefslogtreecommitdiffstats
path: root/grep.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-06-25 07:22:33 +0200
committerJunio C Hamano <gitster@pobox.com>2016-07-01 12:44:57 -0700
commit9d9babb84d45234132f3cb1f4527ce1106e3d2ec (patch)
treed087573f2adde39ba70c0c864a01962fbbe8e67c /grep.c
parente944d9d932b3653debcfdd16eec2721eed0670e5 (diff)
downloadgit-9d9babb84d45234132f3cb1f4527ce1106e3d2ec.tar.gz
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>
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/grep.c b/grep.c
index 6325cafe73..af920c4542 100644
--- a/grep.c
+++ b/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)