Autor: Philip Hazel Fecha: A: ND Cc: pcre-dev Asunto: Re: [pcre-dev] Add ability to return last MARK with failed match
On Fri, 11 Nov 2011, ND wrote:
> I suppose is not the Perl way. It seems that Perl keeps last MARK value
> regardless starting point was advanced.
>
> Perl code:
> $_ = "abc";
> if (/b(*:m)f|a(*:n)w/) { print "-YES-$REGMARK"; }
> else { print "-NO-$REGERROR"; }
>
> Result:
> -NO-m
>
> *MARK:m was keeped by Perl in $REGERROR and may be accessed after match fails.
I have committed a patch that reworks the way *MARK and *PRUNE:name and
*THEN:name are handled. This makes your example above work like Perl. It
also makes some other cases work in a more Perl-like manner.
There is a lucky side-effect in that the new code needs one less
argument to the match() function, and so uses less stack.