This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #20684] [fix] s/// with (??{..}) inside returns wrong count
authorAdrian M. Enache <enache@rdslink.ro>
Fri, 21 Feb 2003 17:49:41 +0000 (19:49 +0200)
committerhv <hv@crypt.org>
Tue, 25 Feb 2003 13:53:11 +0000 (13:53 +0000)
Message-ID: <20030221154941.GA793@ratsnest.hole>

p4raw-id: //depot/perl@18775

pp_ctl.c
t/op/subst.t

index cdcbb30..1528168 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -204,7 +204,7 @@ PP(pp_substcont)
            sv_free(dstr);
 
            TAINT_IF(cx->sb_rxtainted & 1);
-           PUSHs(sv_2mortal(newSViv((I32)cx->sb_iters - 1)));
+           PUSHs(sv_2mortal(newSViv(saviters - 1)));
 
            (void)SvPOK_only_UTF8(targ);
            TAINT_IF(cx->sb_rxtainted);
index 59c3d21..689b74f 100755 (executable)
@@ -7,7 +7,7 @@ BEGIN {
 }
 
 require './test.pl';
-plan( tests => 126 );
+plan( tests => 127 );
 
 $x = 'foo';
 $_ = "x";
@@ -516,3 +516,8 @@ is("<$_> <$s>", "<> <4>", "[perl #7806]");
     $f =~ s/x/y/g;
     is($f, "yy", "[perl #17757]");
 }
+
+# [perl #20684] returned a zero count
+$_ = "1111";
+is(s/(??{1})/2/eg, 4, '#20684 s/// with (??{..}) inside');
+