Fix a warning bug in Perl_report_evil_fh (didn't report
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Mon, 27 May 2002 20:25:30 +0000 (20:25 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Mon, 27 May 2002 20:25:30 +0000 (20:25 +0000)
stashes correctly.) Partial info is better than wrong info.

p4raw-id: //depot/perl@16821

t/lib/warnings/pp_hot
util.c

index 7df18af..c008dd5 100644 (file)
@@ -115,6 +115,23 @@ print $fh "Shouldn't print anything, but shouldn't SEGV either\n";
 EXPECT
 print() on closed filehandle at - line 7.
 ########
+# pp_hot.c [pp_print]
+package foo;
+use warnings 'closed';
+open my $fh1, "nonexistent";
+print $fh1 42;
+open $fh2, "nonexistent";
+print $fh2 42;
+open $bar::fh3, "nonexistent";
+print $bar::fh3 42;
+open bar::FH4, "nonexistent";
+print bar::FH4 42;
+EXPECT
+print() on closed filehandle $fh1 at - line 5.
+print() on closed filehandle $fh2 at - line 7.
+print() on closed filehandle $fh3 at - line 9.
+print() on closed filehandle FH4 at - line 11.
+########
 # pp_hot.c [pp_rv2av]
 use warnings 'uninitialized' ;
 my $a = undef ;
diff --git a/util.c b/util.c
index 3e7b6d3..572b921 100644 (file)
--- a/util.c
+++ b/util.c
@@ -3458,10 +3458,7 @@ Perl_report_evil_fh(pTHX_ GV *gv, IO *io, I32 op)
     }
 
     if (gv && isGV(gv)) {
-       SV *sv = sv_newmortal();
-       gv_efullname4(sv, gv, Nullch, FALSE);
-        if (SvOK(sv))
-            name = SvPVX(sv);
+       name = GvENAME(gv);
     }
 
     if (op == OP_phoney_OUTPUT_ONLY || op == OP_phoney_INPUT_ONLY) {