This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Separate handling of ${^PREMATCH} from $` etc
authorDavid Mitchell <davem@iabyn.com>
Thu, 26 Jul 2012 14:35:39 +0000 (15:35 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sat, 8 Sep 2012 14:42:06 +0000 (15:42 +0100)
commit2c7b5d7698f52b86acffe19a7ec15e85c99337fe
tree5ebca5ec9ae16235bc7d69b64bbd2bfbabcee1f9
parentac0ba89f3ee4e5469c43dc0a34b548a9aa415f98
Separate handling of ${^PREMATCH} from $` etc

Currently the handling of getting the value, length etc of ${^PREMATCH}
etc is identical to that of $` etc.

Handle them separately, by adding RX_BUFF_IDX_CARET_PREMATCH etc
constants to the existing RX_BUFF_IDX_PREMATCH set.

This allows, when retrieving them, to always return undef if the current
match didn't use //p. Previously the result depended on stuff such
as whether the (non-//p) pattern included captures or not.

The documentation for ${^PREMATCH} etc states that it's only guaranteed to
return a defined value when the last pattern was //p.

As well as making things more consistent, this is a necessary
prerequisite for the following commit, which may not always copy the
whole string during a non-//p match.
mg.c
regcomp.c
regexp.h
t/re/reg_pmod.t