Szerző: ph10 Dátum: Címzett: Joel Uckelman CC: pcre-dev@exim.org Tárgy: Re: [pcre-dev] possible lookaround bug
On Tue, 31 Mar 2015, Joel Uckelman wrote:
> When I try this with PCRE 8.33 on Fedora 20, I get what appears to be
> an infinite loop:
>
> echo -n a | pcregrep -o '(?<=\Ka)'
>
> pcregrep prints 'a', one per line, until I kill it.
>
> It looks as though the problem has something to do with the '-o' flag,
Yes, it is a bug in pcregrep when trying to find all the matches in one
line. Because of \K, it keeps finding the same one. This bug is easy to
fix in PCRE2 (i.e. pcre2grep), because pcre2_match() passes back more
information about the match. I have committed the fix for that.
PCRE1 (pcregrep) needs a bit more thought because it does not pass back
the start-of-match offset. I will have to find a different way of fixing
pcregrep.