diff options
-rw-r--r-- | pod/perlfunc.pod | 2 | ||||
-rw-r--r-- | pp_sys.c | 13 |
2 files changed, 3 insertions, 12 deletions
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 3fb569bab0..4e78f69da5 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -1428,7 +1428,7 @@ formline() always returns TRUE. See L<perlform> for other examples. =item getc Returns the next character from the input file attached to FILEHANDLE, -or a null string at end of file, or undef if there was an error. If +or the undefined value at end of file, or if there was an error. If FILEHANDLE is omitted, reads from STDIN. This is not particularly efficient. It cannot be used to get unbuffered single-characters, however. For that, try something more like: @@ -889,7 +889,6 @@ PP(pp_getc) djSP; dTARGET; GV *gv; MAGIC *mg; - PerlIO *fp; if (MAXARG <= 0) gv = stdingv; @@ -911,19 +910,11 @@ PP(pp_getc) SvSetMagicSV_nosteal(TARG, TOPs); RETURN; } - if (!gv || !GvIO(gv) || !(fp = IoIFP(GvIOp(gv)))) /* valid fp? */ + if (!gv || do_eof(gv)) /* make sure we have fp with something */ RETPUSHUNDEF; - - if (do_eof(gv)) { /* handle magic argv, if needed */ - if (PerlIO_error(fp)) - PUSHs(&sv_undef); - else - PUSHp("",0); - RETURN; - } TAINT; sv_setpv(TARG, " "); - *SvPVX(TARG) = PerlIO_getc(fp); /* should never be EOF */ + *SvPVX(TARG) = PerlIO_getc(IoIFP(GvIOp(gv))); /* should never be EOF */ PUSHTARG; RETURN; } |