On Thu, Jan 28, 2016 at 6:56 AM, Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> wrote: > When we detect the pattern is just a literal string, we avoid heavy > regex engine and use fast substring search implemented in kwsset.c. > But kws uses git-ctype which is locale-independent so it does not know > how to fold case properly outside ascii range. Let regcomp or pcre > take care of this case instead. Slower, but accurate. > > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> > --- > diff --git a/grep.c b/grep.c > @@ -398,12 +399,16 @@ static int is_fixed(const char *s, size_t len) > static void compile_regexp(struct grep_pat *p, struct grep_opt *opt) > { > + int icase_non_ascii; > int err; > > p->word_regexp = opt->word_regexp; > p->ignore_case = opt->ignore_case; > + icase_non_ascii = > + (opt->regflags & REG_ICASE || p->ignore_case) && > + has_non_ascii(p->pattern); > > - if (is_fixed(p->pattern, p->patternlen)) > + if (!icase_non_ascii && is_fixed(p->pattern, p->patternlen)) These double negatives (!non_ascii) here and in patch 5/10 are difficult to grok. I wonder if a different name, such as icase_ascii_only would help. > p->fixed = 1; > else if (opt->fixed) { > p->fixed = 1; -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html