On Sun, Apr 03, 2016 at 10:31:33AM +0200, Martin Natano wrote:

> On Sun, Apr 03, 2016 at 09:14:40AM +0200, Otto Moerbeek wrote:
> > On Sat, Apr 02, 2016 at 09:13:20PM +0000, H??ctor Luis Gimbatti wrote:
> > 
> > > Hi,
> > > Apparently the error seems to be in /usr/src/usr.bin/grep/util.c at line 
> > > 400:
> > > 
> > >         if ((!(lflag || cflag)) && ((!(bol || eol)) &&
> > >             ((lastHalfDot) && ((firstHalfDot < 0) ||
> > >             ((fg->patternLen - (lastHalfDot + 1)) < firstHalfDot))))) {
> > >                 fg->reversedSearch = 1;
> > >                 hasDot = fg->patternLen - (firstHalfDot < 0 ?
> > >                     firstLastHalfDot : firstHalfDot) - 1;
> > >                 grep_revstr(fg->pattern, fg->patternLen);
> > >         }
> > > 
> > > If you comment out those lines grep works as expected.
> > > $ pwd
> > > /usr/src/usr.bin/grep
> > > $ echo "stuffb01b02stuff" | ./grep -o b..
> > > b01
> > > b02
> > > 
> > > Cheers
> > 
> > Thanks for the report,
> > 
> > Diff below, reverse search optimization makes no sense (and doesn't
> > work) if we are looking for all matches in a line,
> > 
> >     -Otto
> 
> This fix makes sense to me. Fwiw, ok natano@

Commited, 

        -Otto
> 
> 
> > 
> > Index: util.c
> > ===================================================================
> > RCS file: /cvs/src/usr.bin/grep/util.c,v
> > retrieving revision 1.54
> > diff -u -p -r1.54 util.c
> > --- util.c  22 Dec 2015 19:35:50 -0000      1.54
> > +++ util.c  3 Apr 2016 07:11:18 -0000
> > @@ -391,7 +391,7 @@ nonspecial:
> >      * Determine if a reverse search would be faster based on the placement
> >      * of the dots.
> >      */
> > -   if ((!(lflag || cflag)) && ((!(bol || eol)) &&
> > +   if ((!(lflag || cflag || oflag)) && ((!(bol || eol)) &&
> >         ((lastHalfDot) && ((firstHalfDot < 0) ||
> >         ((fg->patternLen - (lastHalfDot + 1)) < firstHalfDot))))) {
> >             fg->reversedSearch = 1;
> > 

Reply via email to