Skip to content

Commit 009351f

Browse files
authored
Merge pull request #1680 from clasp-developers/clear-eof
Clear EOF if we hit it in a C file stream
2 parents 49bb86c + 3c738cd commit 009351f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/core/lispStream.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4974,9 +4974,12 @@ cl_index CFileStream_O::read_byte8(unsigned char* c, cl_index n) {
49744974
out = fread(c, sizeof(char), n, _file);
49754975
} while (out < 0 && ferror(_file) && errno == EINTR);
49764976
} END_PARK;
4977-
// note: EOF we leave to the caller to figure out
4978-
if (out < n && ferror(_file)) io_error("fread");
4979-
4977+
// note: EOF we leave to the caller to figure out,
4978+
// though we do clear it in case there's more reading to do later.
4979+
if (out < n) {
4980+
if (ferror(_file)) io_error("fread");
4981+
else clearerr(_file);
4982+
}
49804983
return out;
49814984
}
49824985

0 commit comments

Comments
 (0)