From: Rafael Garcia-Suarez Date: Tue, 6 Aug 2002 19:50:12 +0000 (+0000) Subject: PerlIO::scalar wasn't able to read from non-string X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=34fcc551b151471f232d194ddbeab12be5909ede;p=p5sagit%2Fp5-mst-13.2.git PerlIO::scalar wasn't able to read from non-string scalar ; now stringifies its argument. p4raw-id: //depot/perl@17687 --- diff --git a/ext/PerlIO/scalar/scalar.xs b/ext/PerlIO/scalar/scalar.xs index c027bd1..7bcee57 100644 --- a/ext/PerlIO/scalar/scalar.xs +++ b/ext/PerlIO/scalar/scalar.xs @@ -25,6 +25,8 @@ PerlIOScalar_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg, if (arg) { if (SvROK(arg)) { s->var = SvREFCNT_inc(SvRV(arg)); + if (!SvPOK(s->var)) + (void)SvPV_nolen(s->var); } else { s->var = diff --git a/ext/PerlIO/t/scalar.t b/ext/PerlIO/t/scalar.t index fd1b852..4e6615e 100644 --- a/ext/PerlIO/t/scalar.t +++ b/ext/PerlIO/t/scalar.t @@ -10,7 +10,7 @@ BEGIN { } $| = 1; -print "1..22\n"; +print "1..23\n"; my $fh; my $var = "ok 2\n"; @@ -115,3 +115,8 @@ while (<$dup>) { close($fh); close($dup); +# Check reading from non-string scalars + +open $fh, '<', \42; +print <$fh> eq "42" ? "ok 23\n" : "not ok 23\n"; +close $fh;