perl/perl-5.8.8-U27914.patch
2006-06-02 04:35:38 +00:00

62 lines
1.8 KiB
Diff

--- perl-5.8.8/t/op/local.t.U27914 2006-01-03 10:11:35.000000000 -0500
+++ perl-5.8.8/t/op/local.t 2006-06-01 19:49:54.000000000 -0400
@@ -4,7 +4,7 @@
chdir 't' if -d 't';
require './test.pl';
}
-plan tests => 81;
+plan tests => 85;
my $list_assignment_supported = 1;
@@ -313,3 +313,19 @@
{ local @x{c,d,e}; }
ok(! exists $x{c});
}
+
+# local() and readonly magic variables
+
+eval { local $1 = 1 };
+like($@, qr/Modification of a read-only value attempted/);
+
+eval { for ($1) { local $_ = 1 } };
+like($@, qr/Modification of a read-only value attempted/);
+
+# make sure $1 is still read-only
+eval { for ($1) { local $_ = 1 } };
+is($@, "");
+
+# The s/// adds 'g' magic to $_, but it should remain non-readonly
+eval { for("a") { for $x (1,2) { local $_="b"; s/(.*)/+$1/ } } };
+is($@, "");
--- perl-5.8.8/scope.c.U27914 2005-09-30 09:56:51.000000000 -0400
+++ perl-5.8.8/scope.c 2006-06-01 19:49:54.000000000 -0400
@@ -205,9 +205,9 @@
register SV * const sv = *sptr = NEWSV(0,0);
if (SvTYPE(osv) >= SVt_PVMG && SvMAGIC(osv) && SvTYPE(osv) != SVt_PVGV) {
+ MAGIC *mg;
sv_upgrade(sv, SvTYPE(osv));
if (SvGMAGICAL(osv)) {
- MAGIC* mg;
const bool oldtainted = PL_tainted;
mg_get(osv); /* note, can croak! */
if (PL_tainting && PL_tainted &&
@@ -220,6 +220,16 @@
PL_tainted = oldtainted;
}
SvMAGIC_set(sv, SvMAGIC(osv));
+ /* if it's a special scalar or if it has no 'set' magic,
+ * propagate the SvREADONLY flag. --rgs 20030922 */
+ for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
+ if (mg->mg_type == '\0'
+ || !(mg->mg_virtual && mg->mg_virtual->svt_set))
+ {
+ SvFLAGS(sv) |= SvREADONLY(osv);
+ break;
+ }
+ }
SvFLAGS(sv) |= SvMAGICAL(osv);
/* XXX SvMAGIC() is *shared* between osv and sv. This can
* lead to coredumps when both SVs are destroyed without one