From 9bc648147f297cac824aecca53c6e0232b54c002 Mon Sep 17 00:00:00 2001 From: Gurusamy Sarathy Date: Mon, 6 Jul 1998 18:45:35 +0000 Subject: [PATCH] per Larry suggestion, toss change#1327 and fix the documentation to match behavior instead p4raw-link: @1327 on //depot/perl: 0ce625782f64de805c21893bca308710ed297c68 p4raw-id: //depot/perl@1338 --- pod/perlfunc.pod | 2 +- pp_sys.c | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 3fb569b..4e78f69 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -1428,7 +1428,7 @@ formline() always returns TRUE. See L 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: diff --git a/pp_sys.c b/pp_sys.c index a7e8dd5..6a4ad31 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -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; } -- 2.7.4