diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-10-16 14:36:43 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-10-16 14:36:43 -0700 |
commit | 6a97c51d3ccb6044a8e13896ba95a46e330ffa4b (patch) | |
tree | 2210890372625d53dceca7023fffbe62aebec9dc | |
parent | 90814a4e3c744b161cec74d3372d8d7546b0c9da (diff) | |
download | perl-6a97c51d3ccb6044a8e13896ba95a46e330ffa4b.tar.gz |
[perl #96230] Stop s/$qr// from reusing last pattern
qr// should not be using the last-successful pattern, because it is
"(?^:)", not the empty pattern. A stringified qr// does not use the
last-successful pattern.
This was fixed for m/$qr/ (and =~ qr//) in commit 7e31363783, but
s/$qr// was left out.
-rw-r--r-- | pod/perldelta.pod | 5 | ||||
-rw-r--r-- | pp_hot.c | 3 | ||||
-rw-r--r-- | t/op/qr.t | 6 |
3 files changed, 8 insertions, 6 deletions
diff --git a/pod/perldelta.pod b/pod/perldelta.pod index d314937826..59d6904879 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -504,10 +504,7 @@ beginning with an alphanumeric character. [perl #105922] =item * An empty pattern created with C<qr//> used in C<m///> no longer triggers -the "empty pattern reuses last pattern" behaviour. C<s///> has not yet -been fixed. [perl #96230] - -XXX There is no reason s/// should not be fixed before 5.17.5. Nag sprout. +the "empty pattern reuses last pattern" behaviour. [perl #96230] =item * @@ -2133,7 +2133,8 @@ PP(pp_subst) position, once with zero-length, second time with non-zero. */ - if (!RX_PRELEN(rx) && PL_curpm) { + if (!RX_PRELEN(rx) && PL_curpm + && !((struct regexp *)SvANY(rx))->mother_re) { pm = PL_curpm; rx = PM_GETRE(pm); } @@ -7,7 +7,7 @@ BEGIN { require './test.pl'; } -plan(tests => 19); +plan(tests => 20); sub r { return qr/Good/; @@ -63,3 +63,7 @@ like("$e", qr/\Stew=SCALAR\(0x[0-9a-f]+\)\z/); # [perl #96230] qr// should not have the reuse-last-pattern magic "foo" =~ /foo/; like "bar",qr//,'[perl #96230] =~ qr// does not reuse last successful pat'; +"foo" =~ /foo/; +$_ = "bar"; +$_ =~ s/${qr||}/baz/; +is $_, "bazbar", '[perl #96230] s/$qr// does not reuse last pat'; |