bug-grep
[Top][All Lists]
Advanced

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

bug#21670: surprising bug in grep -e with anchors


From: Norihiro Tanaka
Subject: bug#21670: surprising bug in grep -e with anchors
Date: Tue, 13 Oct 2015 22:30:03 +0900

On Sun, 11 Oct 2015 21:34:05 -0700
Paul Eggert <address@hidden> wrote:

> greg boyd wrote:
> > test case (single line)
> > abchelloabc
> >
> > grep does not find the line with grep -e '^hello'  nor with grep -e 'hello$'
> > however, the line is output with
> > grep -e '^hello' -e 'hello$'
> 
> Oooo, that's a good one.  Give your student extra credit!  As it happens, the 
> bug was recently fixed by this patch by Norihiro Tanaka:
> 
> http://git.savannah.gnu.org/cgit/grep.git/commit/?id=256a4b494fe1c48083ba73b4f62607234e4fefd5
> 
> and the fix should appear in the next grep release.  However, since the patch 
> was supposed to affect only performance, it appears that the bug fix was due 
> to luck, and I'm taking the liberty of adding your student's test case by 
> installing the attached further patch, to help prevent this bug from coming 
> back in a future version.

I found above patch is also buggy.  It is never fix.  It returns shorter
`must' than expected.  e.g. `must' for pattern `.hello' is `hello', but
returns `hell' by this bug.  Next, `must' for pattern `^hello' is `hello'
but returns `hell'.  It will cause slite performance down, and disappear
bug#21670,  BTW, I guess the bug does not change external behavior.

First patch fixes the bug.  After the patch is applied, bug#21670
appears again.  And, second patch fixes bug#21670.

When pattern has ^ and/or $, if begline and/or endline flag of mp is
turned off, EXACT should be false.

Attachment: 0001-dfa-don-t-use-DFA-for-exact-matching.patch
Description: Text document

Attachment: 0002-dfa-fix-bug-in-alternate-of-sub-patterns-different-i.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]