Change 30100 by [EMAIL PROTECTED] on 2007/02/02 21:52:26
Integrate:
[ 29308]
Subject: [perl #36909] $^R undefined on matches involving backreferences
From: yves orton via RT <[EMAIL PROTECTED]>
Date: Nov 17, 2006 4:07 PM
Affected files ...
... //depot/maint-5.8/perl/regcomp.c#99 integrate
... //depot/maint-5.8/perl/regexec.c#85 integrate
... //depot/maint-5.8/perl/t/op/pat.t#38 edit
... //depot/maint-5.8/perl/t/op/subst.t#12 integrate
Differences ...
==== //depot/maint-5.8/perl/regexec.c#85 (text) ====
Index: perl/regexec.c
--- perl/regexec.c#84~30066~ 2007-01-29 11:07:36.000000000 -0800
+++ perl/regexec.c 2007-02-02 13:52:26.000000000 -0800
@@ -2903,7 +2903,15 @@
cc.lastloc = 0;
PL_reginput = locinput;
n = regmatch(PREVOPER(next)); /* start on the WHILEM */
- regcpblow(cp);
+ if (PL_reg_eval_set){
+ SV *pres= GvSV(PL_replgv);
+ SvREFCNT_inc(pres);
+ regcpblow(cp);
+ sv_setsv(GvSV(PL_replgv), pres);
+ SvREFCNT_dec(pres);
+ } else {
+ regcpblow(cp);
+ }
PL_regcc = cc.oldcc;
saySAME(n);
}
==== //depot/maint-5.8/perl/t/op/pat.t#38 (xtext) ====
Index: perl/t/op/pat.t
--- perl/t/op/pat.t#37~30073~ 2007-01-29 14:44:03.000000000 -0800
+++ perl/t/op/pat.t 2007-02-02 13:52:26.000000000 -0800
@@ -7,12 +7,13 @@
$| = 1;
# please update note at bottom of file when you change this
-print "1..1222\n";
+print "1..1231\n";
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
}
+our $Message = "Line";
eval 'use Config'; # Defaults assumed if this fails
@@ -2037,10 +2038,11 @@
my $test = 687;
# Force scalar context on the patern match
-sub ok ($$) {
+sub ok ($;$) {
my($ok, $name) = @_;
- printf "%sok %d - %s\n", ($ok ? "" : "not "), $test, $name;
+ printf "%sok %d - %s\n", ($ok ? "" : "not "), $test,
+ $name||"$Message:".((caller)[2]);
printf "# Failed test at line %d\n", (caller)[2] unless $ok;
@@ -3453,7 +3455,7 @@
my $ok= $got eq $expect;
printf "%sok %d - %s\n", ($ok ? "" : "not "), $test,
- ($name||$Message)."\tLine ".((caller)[2]);
+ $name||"$Message:".((caller)[2]);
printf "# Failed test at line %d\n".
"# expected: %s\n".
@@ -3475,6 +3477,7 @@
}
}
{
+ local $Message = "Relative Recursion";
local $Message = "RT#22614";
local $_='ab';
our @len=();
@@ -3484,6 +3487,39 @@
{
local $Message = "RT#18209";
my $text = ' word1 word2 word3 word4 word5 word6 ';
+{
+ local $Message = "RT#36909 test";
+ $^R = 'Nothing';
+ {
+ local $^R = "Bad";
+ ok('x foofoo y' =~ m{
+ (foo) # $^R correctly set
+ (?{ "last regexp code result" })
+ }x);
+ iseq($^R,'last regexp code result');
+ }
+ iseq($^R,'Nothing');
+ {
+ local $^R = "Bad";
+
+ ok('x foofoo y' =~ m{
+ (?:foo|bar)+ # $^R correctly set
+ (?{"last regexp code result"})
+ }x);
+ iseq($^R,'last regexp code result');
+ }
+ iseq($^R,'Nothing');
+
+ {
+ local $^R = "Bad";
+ ok('x foofoo y' =~ m{
+ (foo|bar)\1+ # $^R undefined
+ (?{"last regexp code result"})
+ }x);
+ iseq($^R,'last regexp code result');
+ }
+ iseq($^R,'Nothing');
+}
my @words = ('word1', 'word3', 'word5');
my $count;
@@ -3500,4 +3536,4 @@
}
-# last test 1222
+# last test 1231
==== //depot/maint-5.8/perl/t/op/subst.t#12 (xtext) ====
Index: perl/t/op/subst.t
--- perl/t/op/subst.t#11~30011~ 2007-01-26 06:31:27.000000000 -0800
+++ perl/t/op/subst.t 2007-02-02 13:52:26.000000000 -0800
@@ -7,7 +7,7 @@
}
require './test.pl';
-plan( tests => 133 );
+plan( tests => 134 );
$x = 'foo';
$_ = "x";
@@ -562,4 +562,13 @@
($c = "\x20\x00\x30\x01\x40\x1A\x50\x1F\x60") =~ s/[\x00-\x1f]//g;
is($c, "\x20\x30\x40\x50\x60", "s/[\\x00-\\x1f]//g");
}
+TODO:{
+ local $TODO = "RT#6006 needs resolution";
+ $TODO=$TODO;
+ $_ = "xy";
+ no warnings 'uninitialized';
+ /(((((((((x)))))))))(z)/; # clear $10
+ s/(((((((((x)))))))))(y)/${10}/;
+ is($_,"y","RT#6006: \$_ eq '$_'");
+}
End of Patch.