Re: [PATCH 2/2] grep: don't call regexec() for fixed strings
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 12, 2009, 13:33 UTC
- Message-ID
- <alpine.DEB.1.00.0901121433240.3586@pacific.mpi-cbg.de>
- In-Reply-To
- <237967ef0901120425x79b7c1a4p238081a99694ae23@mail.gmail.com>
Hi,
On Mon, 12 Jan 2009, Mikael Magnusson wrote:
Show 20 quoted lines
> 2009/1/10 René Scharfe <rene.scharfe@lsrfire.ath.cx>:
> > Add the new flag "fixed" to struct grep_pat and set it if the pattern
> > is doesn't contain any regex control characters in addition to if the
> > flag -F/--fixed-strings was specified.
> >
> > diff --git a/grep.c b/grep.c
> > index 394703b..a1092df 100644
> > --- a/grep.c
> > +++ b/grep.c
> > @@ -28,9 +28,31 @@ void append_grep_pattern(struct grep_opt *opt, const char *pat,
> > p->next = NULL;
> > }
> >
> > +static int isregexspecial(int c)
> > +{
> > + return isspecial(c) || c == '$' || c == '(' || c == ')' || c == '+' ||
> > + c == '.' || c == '^' || c == '{' || c == '|';
> > +}
>
> Shouldn't this include '*' and '\'?This is covered by isspecial(): see ctype.c.
Hth, Dscho