Re: [PATCH v6 01/11] grep: allow -F -i combination
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 17, 2016, 21:54 UTC
- Message-ID
- <xmqqk2hnzdkc.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1454724190-14063-2-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> -F means "no regex", not "case sensitive" so it should not override -i
That logic is flawed, isn't it?
"-F" means "no regex", so it should not touch opt.regflags at all.
Show 18 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> builtin/grep.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/grep.c b/builtin/grep.c
> index 5526fd7..4be0df5 100644
> --- a/builtin/grep.c
> +++ b/builtin/grep.c
> @@ -809,7 +809,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
>
> if (!opt.pattern_list)
> die(_("no pattern given."));
> - if (!opt.fixed && opt.ignore_case)
> + if (opt.ignore_case)
> opt.regflags |= REG_ICASE;
>
> compile_grep_patterns(&opt);In grep.c, we do this:
static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
{
int err;p->word_regexp = opt->word_regexp; p->ignore_case = opt->ignore_case;
if (opt->fixed || is_fixed(p->pattern, p->patternlen)) p->fixed = 1; else p->fixed = 0;
if (p->fixed) {
if (opt->regflags & REG_ICASE || p->ignore_case)
p->kws = kwsalloc(tolower_trans_tbl);
elseIt is possible that your later changes _depend_ on having REG_ICASE set in opt->regflags, but if that is why this commit is needed, then you are going in a wrong direction.
I liked the overall objective of making "-i" work better on non-ASCII, and I wanted to like this whole series, but at least this change needs to be dropped (and the remainder of the series fixed if they depend on this change).
Thanks.