From: Rafael Garcia-Suarez Date: Tue, 5 Mar 2002 14:35:57 +0000 (+0100) Subject: Re: [ID 20020227.024] unexpected warning getc() on unopened filehandle STDIN X-Git-Tag: accepted/trunk/20130322.191538~27760 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=97e322ff169812aac5db3010a41269f2b1e7fae7;p=platform%2Fupstream%2Fperl.git Re: [ID 20020227.024] unexpected warning getc() on unopened filehandle STDIN Message-ID: <20020305143557.C695@rafael> p4raw-id: //depot/perl@15044 --- diff --git a/pp_sys.c b/pp_sys.c index e44ab1c..87231ee 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -1158,7 +1158,8 @@ PP(pp_getc) 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; } diff --git a/t/lib/warnings/pp_sys b/t/lib/warnings/pp_sys index 5349f50..8dc0bf9 100644 --- a/t/lib/warnings/pp_sys +++ b/t/lib/warnings/pp_sys @@ -419,9 +419,19 @@ use warnings qw(unopened closed) ; 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.