From: Adrian M. Enache Date: Thu, 17 Apr 2003 14:35:36 +0000 (+0300) Subject: Re: [perl #21950] 5.8.x -- :scalar and magic strings X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c5b94a97fd82571950babee90bae3a327a5936a9;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #21950] 5.8.x -- :scalar and magic strings Message-Id: <20030417113536.GA898@ratsnest.hole> p4raw-id: //depot/perl@19247 --- diff --git a/ext/PerlIO/scalar/scalar.xs b/ext/PerlIO/scalar/scalar.xs index b26a238..0d56ecc 100644 --- a/ext/PerlIO/scalar/scalar.xs +++ b/ext/PerlIO/scalar/scalar.xs @@ -37,7 +37,7 @@ PerlIOScalar_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg, else { s->var = newSVpvn("", 0); } - sv_upgrade(s->var, SVt_PV); + SvUPGRADE(s->var, SVt_PV); code = PerlIOBase_pushed(aTHX_ f, mode, Nullsv, tab); if ((PerlIOBase(f)->flags) & PERLIO_F_TRUNCATE) SvCUR(s->var) = 0; diff --git a/ext/PerlIO/t/scalar.t b/ext/PerlIO/t/scalar.t index 4e6615e..58ef97f 100644 --- a/ext/PerlIO/t/scalar.t +++ b/ext/PerlIO/t/scalar.t @@ -10,7 +10,7 @@ BEGIN { } $| = 1; -print "1..23\n"; +print "1..24\n"; my $fh; my $var = "ok 2\n"; @@ -120,3 +120,9 @@ close($dup); open $fh, '<', \42; print <$fh> eq "42" ? "ok 23\n" : "not ok 23\n"; close $fh; + +# reading from magic scalars + +{ package P; sub TIESCALAR {bless{}} sub FETCH {"ok 24\n"} } +tie $p, P; open $fh, '<', \$p; +print <$fh>;