{
dSP; dTARGET;
GV *gv;
- IO *io;
+ IO *io = NULL;
MAGIC *mg;
if (MAXARG == 0)
SvSetMagicSV_nosteal(TARG, TOPs);
RETURN;
}
- if (!gv || do_eof(gv)) /* make sure we have fp with something */
+ if (!gv || do_eof(gv)) { /* make sure we have fp with something */
+ if (ckWARN2(WARN_UNOPENED,WARN_CLOSED) && IoTYPE(io) != IoTYPE_WRONLY)
+ report_evil_fh(gv, io, PL_op->op_type);
RETPUSHUNDEF;
+ }
TAINT;
sv_setpv(TARG, " ");
*SvPVX(TARG) = PerlIO_getc(IoIFP(GvIOp(gv))); /* should never be EOF */
open(F, ">$file") ;
my $a = sysread(F, $a,10) ;
- lstat on filehandle %s [pp_lstat]
+ lstat on filehandle %s [pp_lstat]
+
+ getc() on unopened filehandle [pp_getc]
+
+ getc() on closed filehandle [pp_getc]
__END__
# pp_sys.c [pp_untie]
EXPECT
lstat() on filehandle STDIN at - line 3.
lstat() on filehandle $fh at - line 5.
+########
+# pp_sys.c [pp_getc]
+use warnings qw(unopened closed) ;
+getc FOO;
+close STDIN;
+getc STDIN;
+no warnings qw(unopened closed) ;
+getc FOO;
+getc STDIN;
+EXPECT
+getc() on unopened filehandle FOO at - line 3.
+getc() on closed filehandle STDIN at - line 5.