From 134b8cd8023b245ceceb96a0cb1a255bd3400f27 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Thu, 16 Jun 2011 22:31:07 +0200 Subject: [PATCH] Test studied scalars with s///ge. --- pp_ctl.c | 7 +++++++ t/op/study.t | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/pp_ctl.c b/pp_ctl.c index 0016484..8e53116 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -298,6 +298,13 @@ PP(pp_substcont) s -= RX_GOFS(rx); /* Are we done */ + /* I believe that we can't set REXEC_SCREAM here if + SvSCREAM(cx->sb_targ) is true because SvPVX(cx->sb_targ) isn't always + equal to s. [See the comment before Perl_re_intuit_start(), which is + called from Perl_regexec_flags(), which says that it should be when + SvSCREAM() is true.] s, cx->sb_strend and orig will be consistent + with SvPVX(cx->sb_targ), as substconst doesn't modify cx->sb_targ + during the match. */ if (CxONCE(cx) || s < orig || !CALLREGEXEC(rx, s, cx->sb_strend, orig, (s == m) + RX_GOFS(rx), cx->sb_targ, NULL, diff --git a/t/op/study.t b/t/op/study.t index adf5e2b..3733849 100644 --- a/t/op/study.t +++ b/t/op/study.t @@ -7,7 +7,7 @@ BEGIN { } watchdog(10); -plan(tests => 30); +plan(tests => 36); use strict; use vars '$x'; @@ -92,3 +92,20 @@ TODO: { my @a = split /aab*/, $a; is("@a", 'Q Q Q Q', 'split with studied string passed to the regep engine'); } + +{ + $_ = "AABBAABB"; + study; + is(s/AB+/1/ge, 2, 'studied scalar passed to pp_substconst'); + is($_, 'A1A1'); +} + +{ + $_ = "AABBAABB"; + study; + is(s/(A)B+/1/ge, 2, + 'studied scalar passed to pp_substconst with RX_MATCH_COPIED() true'); + is($1, 'A'); + is($2, undef); + is($_, 'A1A1'); +} -- 2.7.4