Re: [PATCH 05/11] grep/icase: avoid kwsset when -F is specified

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nguyễn Thái Ngọc Duy  <pclouds@xxxxxxxxx> writes:

> @@ -408,7 +427,11 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
>  	ascii_only     = !has_non_ascii(p->pattern);
>  
>  	if (opt->fixed) {
> -		p->fixed = 1;
> +		p->fixed = !icase || ascii_only;
> +		if (!p->fixed) {
> +			compile_fixed_regexp(p, opt);
> +			return;
> +		}
>  	} else if ((!icase || ascii_only) &&
>  		   is_fixed(p->pattern, p->patternlen))
>  		p->fixed = 1;

Makes me feel somewhat dirty to see that we do the same "!icase ||
ascii_only" on both sides of the if/else cascade.

I wonder if it would be more readable to structure it like this
instead?

	if (opt->fixed || is_fixed(...))
		p->fixed = (!icase || ascii_only);
	else
        	p->fixed = 0;

	if (p->fixed)
        	/* do the kws thing and return */
	else if (opt->fixed)
        	/* do the "quote into regexp" thing and return */

	/* pcre and other from the original follows */

--
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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]