summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-10-16 14:36:43 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-10-16 14:36:43 -0700
commit6a97c51d3ccb6044a8e13896ba95a46e330ffa4b (patch)
tree2210890372625d53dceca7023fffbe62aebec9dc
parent90814a4e3c744b161cec74d3372d8d7546b0c9da (diff)
downloadperl-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.pod5
-rw-r--r--pp_hot.c3
-rw-r--r--t/op/qr.t6
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 *
diff --git a/pp_hot.c b/pp_hot.c
index 9d2885551c..13123bb490 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -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);
}
diff --git a/t/op/qr.t b/t/op/qr.t
index 41307995b7..29f2773e2a 100644
--- a/t/op/qr.t
+++ b/t/op/qr.t
@@ -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';