summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-05-10 06:51:24 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-05-10 06:51:24 +0000
commit505fdf5d548cad40088ab9dcb60a4212a5c66af0 (patch)
tree1f373a4fc4631981cd0e544d94aaba73d05d12d7 /doio.c
parenta40a317b715a38747586893811eae258898ef4d7 (diff)
downloadperl-505fdf5d548cad40088ab9dcb60a4212a5c66af0.tar.gz
In eof() the errno can get stomped by the peek-ahead.
p4raw-id: //depot/perl@19470
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/doio.c b/doio.c
index 438139f6e5..43c12e7747 100644
--- a/doio.c
+++ b/doio.c
@@ -1030,17 +1030,21 @@ Perl_do_eof(pTHX_ GV *gv)
report_evil_fh(gv, io, OP_phoney_OUTPUT_ONLY);
while (IoIFP(io)) {
+ int saverrno;
if (PerlIO_has_cntptr(IoIFP(io))) { /* (the code works without this) */
if (PerlIO_get_cnt(IoIFP(io)) > 0) /* cheat a little, since */
return FALSE; /* this is the most usual case */
}
+ saverrno = errno; /* getc and ungetc can stomp on errno */
ch = PerlIO_getc(IoIFP(io));
if (ch != EOF) {
(void)PerlIO_ungetc(IoIFP(io),ch);
+ errno = saverrno;
return FALSE;
}
+ errno = saverrno;
if (PerlIO_has_cntptr(IoIFP(io)) && PerlIO_canset_cnt(IoIFP(io))) {
if (PerlIO_get_cnt(IoIFP(io)) < -1)