From: Gurusamy Sarathy Date: Thu, 10 Feb 2000 00:56:27 +0000 (+0000) Subject: formline() could wipe out readonly-ness, freeing constants X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=445b3f5100bf9bd5899b8cc5eed925e1cf28b5b2;p=p5sagit%2Fp5-mst-13.2.git formline() could wipe out readonly-ness, freeing constants prematurely, or affect cloning of pad constants p4raw-id: //depot/perl@5056 --- diff --git a/pp_ctl.c b/pp_ctl.c index 972c21d..7b4cbfe 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -302,8 +302,13 @@ PP(pp_formline) bool item_is_utf = FALSE; if (!SvMAGICAL(tmpForm) || !SvCOMPILED(tmpForm)) { - SvREADONLY_off(tmpForm); - doparseform(tmpForm); + if (SvREADONLY(tmpForm)) { + SvREADONLY_off(tmpForm); + doparseform(tmpForm); + SvREADONLY_on(tmpForm); + } + else + doparseform(tmpForm); } SvPV_force(PL_formtarget, len); diff --git a/t/op/write.t b/t/op/write.t index 9918b2f..87d5042 100755 --- a/t/op/write.t +++ b/t/op/write.t @@ -1,8 +1,6 @@ #!./perl -# $RCSfile: write.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:38 $ - -print "1..6\n"; +print "1..8\n"; my $CAT = ($^O eq 'MSWin32') ? 'type' : 'cat'; @@ -190,3 +188,16 @@ if (`$CAT Op_write.tmp` eq $right) else { print "not ok 6\n"; } +# test lexicals and globals +{ + my $this = "ok"; + our $that = 7; + format LEX = +@<<@| +$this,$that +. + open(LEX, ">&STDOUT") or die; + write LEX; + $that = 8; + write LEX; +}