From 7e3136378328f90878eb7873a7a3197897e68253 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 22 Sep 2012 07:13:36 -0700 Subject: [PATCH] [perl #96230] Stop 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. --- pp_hot.c | 6 ++++-- t/op/qr.t | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pp_hot.c b/pp_hot.c index 4100ae2..827395f 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1286,8 +1286,10 @@ PP(pp_match) - /* empty pattern special-cased to use last successful pattern if possible */ - if (!RX_PRELEN(rx) && PL_curpm) { + /* empty pattern special-cased to use last successful pattern if + possible, except for qr// */ + if (!((struct regexp *)SvANY(rx))->mother_re && !RX_PRELEN(rx) + && PL_curpm) { pm = PL_curpm; rx = PM_GETRE(pm); } diff --git a/t/op/qr.t b/t/op/qr.t index 83bb3d9..4130799 100644 --- a/t/op/qr.t +++ b/t/op/qr.t @@ -7,7 +7,7 @@ BEGIN { require './test.pl'; } -plan(tests => 18); +plan(tests => 19); sub r { return qr/Good/; @@ -59,3 +59,7 @@ $$e = 'Fake!'; is($$e, 'Fake!'); object_ok($e, 'Stew'); 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'; -- 2.7.4