RETURN;
}
if (!gv || do_eof(gv)) { /* make sure we have fp with something */
- if (ckWARN2(WARN_UNOPENED,WARN_CLOSED) && IoTYPE(io) != IoTYPE_WRONLY)
+ if (ckWARN2(WARN_UNOPENED,WARN_CLOSED)
+ && (!io || (!IoIFP(io) && IoTYPE(io) != IoTYPE_WRONLY)))
report_evil_fh(gv, io, PL_op->op_type);
RETPUSHUNDEF;
}
getc FOO;
close STDIN;
getc STDIN;
+# Create an empty file
+$file = 'getcwarn.tmp';
+open FH1, ">$file" or die "# $!"; close FH1;
+open FH2, $file or die "# $!";
+getc FH2; # Should not warn at EOF
+close FH2;
+getc FH2; # Warns, now
+unlink $file;
no warnings qw(unopened closed) ;
getc FOO;
getc STDIN;
+getc FH2;
EXPECT
getc() on unopened filehandle FOO at - line 3.
getc() on closed filehandle STDIN at - line 5.
+getc() on closed filehandle FH2 at - line 12.