X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2F__toread.c;h=f142ff09c087ef5459a29acd004fd005ddfc8a0c;hb=2a0bb9e0f2d87d2bcad746ffad96fb3355f1de6e;hp=52624f3d4f2370edbbd8d40a418ee48d06b4a98d;hpb=c463e11eda8326aacee2ac1d516954a9574a2dcd;p=musl diff --git a/src/stdio/__toread.c b/src/stdio/__toread.c index 52624f3d..f142ff09 100644 --- a/src/stdio/__toread.c +++ b/src/stdio/__toread.c @@ -3,19 +3,17 @@ int __toread(FILE *f) { f->mode |= f->mode-1; - if (f->wpos > f->buf) f->write(f, 0, 0); + if (f->wpos != f->wbase) f->write(f, 0, 0); f->wpos = f->wbase = f->wend = 0; - if (f->flags & (F_EOF|F_NORD)) { - if (f->flags & F_NORD) f->flags |= F_ERR; + if (f->flags & F_NORD) { + f->flags |= F_ERR; return EOF; } - f->rpos = f->rend = f->buf; - return 0; + f->rpos = f->rend = f->buf + f->buf_size; + return (f->flags & F_EOF) ? EOF : 0; } -void __stdio_exit_needed(void); - -void __toread_needs_stdio_exit() +hidden void __toread_needs_stdio_exit() { __stdio_exit_needed(); }