Nguyễn Thái Ngọc Duy  <[email protected]> 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to