summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-09-08 12:19:08 +0200
committerJarkko Hietaniemi <jhi@iki.fi>2003-09-08 08:07:55 +0000
commitb5a808db3c007cbb4159178941346ac3c6f968a7 (patch)
treef65173762e697110a6396b8575165af361d66aa6 /ext
parentcc5fd0943567be6ee0408b6bc088cce15ca15861 (diff)
downloadperl-b5a808db3c007cbb4159178941346ac3c6f968a7.tar.gz
Re: one nit to fix [PATCH]
Message-Id: <20030908101908.5571326d.rgarcia@hexaflux.com> p4raw-id: //depot/perl@21073
Diffstat (limited to 'ext')
-rw-r--r--ext/PerlIO/scalar/scalar.xs2
-rw-r--r--ext/PerlIO/t/scalar.t14
2 files changed, 14 insertions, 2 deletions
diff --git a/ext/PerlIO/scalar/scalar.xs b/ext/PerlIO/scalar/scalar.xs
index 0d56ecc613..884cd5880a 100644
--- a/ext/PerlIO/scalar/scalar.xs
+++ b/ext/PerlIO/scalar/scalar.xs
@@ -23,7 +23,7 @@ PerlIOScalar_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg,
* or the _name_ of the scalar
*/
if (arg) {
- if (SvROK(arg)) {
+ if (SvROK(arg) && SvTYPE(SvRV(arg)) > SVt_NULL) {
s->var = SvREFCNT_inc(SvRV(arg));
if (!SvPOK(s->var))
(void)SvPV_nolen(s->var);
diff --git a/ext/PerlIO/t/scalar.t b/ext/PerlIO/t/scalar.t
index 58ef97f6fe..01e12b047e 100644
--- a/ext/PerlIO/t/scalar.t
+++ b/ext/PerlIO/t/scalar.t
@@ -10,7 +10,7 @@ BEGIN {
}
$| = 1;
-print "1..24\n";
+print "1..25\n";
my $fh;
my $var = "ok 2\n";
@@ -126,3 +126,15 @@ close $fh;
{ package P; sub TIESCALAR {bless{}} sub FETCH {"ok 24\n"} }
tie $p, P; open $fh, '<', \$p;
print <$fh>;
+
+# don't warn when writing to an undefined scalar
+
+{
+ use warnings;
+ my $ok = 1;
+ local $SIG{__WARN__} = sub { $ok = 0; };
+ open my $fh, '>', \my $scalar;
+ print $fh "foo";
+ close $fh;
+ print $ok ? "ok 25\n" : "not ok 25\n";
+}