summaryrefslogtreecommitdiff
path: root/ext/PerlIO
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2002-08-06 19:50:12 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2002-08-06 19:50:12 +0000
commit34fcc551b151471f232d194ddbeab12be5909ede (patch)
treef66de94defe6cda269fce0f4eba528ec6cd4fb9e /ext/PerlIO
parentdbc6b789d967350cc68b3321f366f9441dcf35af (diff)
downloadperl-34fcc551b151471f232d194ddbeab12be5909ede.tar.gz
PerlIO::scalar wasn't able to read from non-string
scalar ; now stringifies its argument. p4raw-id: //depot/perl@17687
Diffstat (limited to 'ext/PerlIO')
-rw-r--r--ext/PerlIO/scalar/scalar.xs2
-rw-r--r--ext/PerlIO/t/scalar.t7
2 files changed, 8 insertions, 1 deletions
diff --git a/ext/PerlIO/scalar/scalar.xs b/ext/PerlIO/scalar/scalar.xs
index c027bd12d1..7bcee5774e 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 fd1b852657..4e6615e799 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;