From: Mike Guy Date: Mon, 14 Aug 2000 08:04:22 +0000 (+0100) Subject: @+, @- readonly (was Re: @ interpolating in "") X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=03a27ae7a2d77f4526cc8f95901f616c50fdc14b;p=p5sagit%2Fp5-mst-13.2.git @+, @- readonly (was Re: @ interpolating in "") Message-Id: p4raw-id: //depot/perl@6615 --- diff --git a/gv.c b/gv.c index 836fdb2..6dc45e7 100644 --- a/gv.c +++ b/gv.c @@ -819,6 +819,7 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type) else { AV* av = GvAVn(gv); sv_magic((SV*)av, Nullsv, 'D', Nullch, 0); + SvREADONLY_on(av); } goto magicalize; case '#': @@ -869,6 +870,7 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type) else { AV* av = GvAVn(gv); sv_magic((SV*)av, (SV*)av, 'D', Nullch, 0); + SvREADONLY_on(av); } /* FALL THROUGH */ case '1': diff --git a/mg.c b/mg.c index 1e5c994..0614099 100644 --- a/mg.c +++ b/mg.c @@ -373,6 +373,7 @@ Perl_magic_regdatum_get(pTHX_ SV *sv, MAGIC *mg) i = t; else /* @- */ i = s; + SvREADONLY_on(sv); sv_setiv(sv,i); } } diff --git a/t/op/pat.t b/t/op/pat.t index fbc234b..91c4b7d 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -4,7 +4,7 @@ # the format supported by op/regexp.t. If you want to add a test # that does fit that format, add it to op/re_tests, not here. -print "1..216\n"; +print "1..220\n"; BEGIN { chdir 't' if -d 't'; @@ -693,6 +693,30 @@ print "not " print "ok $test\n"; $test++; +eval { $+[0] = 13; }; +print "not " + if $@ !~ /^Modification of a read-only value attempted/; +print "ok $test\n"; +$test++; + +eval { $-[0] = 13; }; +print "not " + if $@ !~ /^Modification of a read-only value attempted/; +print "ok $test\n"; +$test++; + +eval { @+ = (7, 6, 5); }; +print "not " + if $@ !~ /^Modification of a read-only value attempted/; +print "ok $test\n"; +$test++; + +eval { @- = qw(foo bar); }; +print "not " + if $@ !~ /^Modification of a read-only value attempted/; +print "ok $test\n"; +$test++; + /.(a)(ba*)?/; print "#$#-..$#+\nnot " if $#+ != 2 or $#- != 1; print "ok $test\n";