PerlIO::scalar wasn't able to read from non-string
Rafael Garcia-Suarez [Tue, 6 Aug 2002 19:50:12 +0000 (19:50 +0000)]
scalar ; now stringifies its argument.

p4raw-id: //depot/perl@17687

ext/PerlIO/scalar/scalar.xs
ext/PerlIO/t/scalar.t

index c027bd1..7bcee57 100644 (file)
@@ -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 =
index fd1b852..4e6615e 100644 (file)
@@ -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;