mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +00:00
LibC: In fgetc(), fread() will never return < 0.
Furthermore, fread() has already handled EOF, so there's no need to do it again. If we read a character, return it, otherwise return EOF. Note that EOF means "EOF or error" here.
This commit is contained in:
parent
caeb4b7a7e
commit
bd08664f05
1 changed files with 3 additions and 6 deletions
|
@ -129,12 +129,9 @@ int fgetc(FILE* stream)
|
|||
assert(stream);
|
||||
char ch;
|
||||
size_t nread = fread(&ch, sizeof(char), 1, stream);
|
||||
if (nread <= 0) {
|
||||
stream->eof = nread == 0;
|
||||
stream->error = errno;
|
||||
return EOF;
|
||||
}
|
||||
return ch;
|
||||
if (nread == 1)
|
||||
return ch;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
int getc(FILE* stream)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue