develooper Front page | perl.perl5.porters | Postings from February 2003

[perl #20684] [fix] s/// with (??{..}) inside returns wrong count

Thread Next
From:
Enache Adrian
Date:
February 21, 2003 07:50
Subject:
[perl #20684] [fix] s/// with (??{..}) inside returns wrong count
Message ID:
20030221154941.GA793@ratsnest.hole
$ perl -le '$_="111"; print s/(??{1})/2/ge'

This should print 3 but prints 0

Patch:
-------------------------------------------------------------------
--- /arc/perl-current/pp_ctl.c	2003-02-16 16:24:51.000000000 +0200
+++ perl-current/pp_ctl.c	2003-02-21 08:40:36.000000000 +0200
@@ -200,7 +200,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);
-------------------------------------------------------------------
#! /usr/bin/perl
require "test.pl";
{
    $_="1111"; is(s/(??{1})/x/eg,4,'#20684 s/// with (??{..}) inside');
}
__END__
-------------------------------------------------------------------

Of course, it would be better to do all inside S_regtry, but that's
a little bit trickier. Since pp_substcont was already patched to
save then restore cxstack->sb_iters ( < 5.8.0 ) , I used that.

Regards

Adi

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About