Compare commits
2 Commits
40b078e0a2
...
2980ee3973
Author | SHA1 | Date | |
---|---|---|---|
2980ee3973 | |||
88011fc162 |
@ -21,7 +21,7 @@ void show_motd()
|
||||
}
|
||||
|
||||
char buf[4096];
|
||||
size_t nread = fread(buf, sizeof(buf) - 1, 1, fp);
|
||||
size_t nread = fread(buf, 1, sizeof(buf) - 1, fp);
|
||||
if (ferror(fp))
|
||||
{
|
||||
perror("fread");
|
||||
|
@ -127,15 +127,15 @@ extern "C"
|
||||
|
||||
size_t fread(void* buf, size_t size, size_t nmemb, FILE* stream)
|
||||
{
|
||||
ssize_t status =
|
||||
read(stream->f_fd, buf,
|
||||
size * nmemb); // FIXME: This function should use file_read_buf() to not conflict with fgets().
|
||||
size_t rsize = size * nmemb;
|
||||
ssize_t status = read(stream->f_fd, buf, rsize);
|
||||
if (status < 0)
|
||||
{
|
||||
stream->f_err = 1;
|
||||
return 0;
|
||||
}
|
||||
if (status == 0) stream->f_eof = 1;
|
||||
if (status == 0 && rsize) stream->f_eof = 1;
|
||||
if (status == 0) return (size_t)status;
|
||||
return (size_t)status / size;
|
||||
}
|
||||
|
||||
@ -281,13 +281,15 @@ extern "C"
|
||||
|
||||
size_t fwrite(const void* buf, size_t size, size_t nmemb, FILE* stream)
|
||||
{
|
||||
ssize_t status = write(stream->f_fd, buf, size * nmemb);
|
||||
size_t rsize = size * nmemb;
|
||||
ssize_t status = write(stream->f_fd, buf, rsize);
|
||||
if (status < 0)
|
||||
{
|
||||
stream->f_err = 1;
|
||||
return 0;
|
||||
}
|
||||
if (status == 0) stream->f_eof = 1;
|
||||
if (status == 0 && rsize) stream->f_eof = 1;
|
||||
if (status == 0) return (size_t)status;
|
||||
return (size_t)status / size;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user