X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2Ffread.c;h=aef75f7376f700dd584bf346ab1b7b17717ab097;hb=670d6d01f53b4e85be6b333bf8a137e2be6d3fc3;hp=3f31af8a28f15a129edf4697e256e67d1a026aa5;hpb=400c5e5c8307a2ebe44ef1f203f5a15669f20347;p=musl diff --git a/src/stdio/fread.c b/src/stdio/fread.c index 3f31af8a..aef75f73 100644 --- a/src/stdio/fread.c +++ b/src/stdio/fread.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include #define MIN(a,b) ((a)<(b) ? (a) : (b)) @@ -6,12 +7,12 @@ size_t fread(void *restrict destv, size_t size, size_t nmemb, FILE *restrict f) { unsigned char *dest = destv; size_t len = size*nmemb, l = len, k; - - /* Never touch the file if length is zero.. */ - if (!l) return 0; + if (!size) nmemb = 0; FLOCK(f); + f->mode |= f->mode-1; + if (f->rend - f->rpos > 0) { /* First exhaust the buffer. */ k = MIN(f->rend - f->rpos, l);