mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03: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
Notes:
sideshowbarker
2024-07-19 12:57:59 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/bd08664f055
@ -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…
Reference in New Issue
Block a user