X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2F__toread.c;h=f142ff09c087ef5459a29acd004fd005ddfc8a0c;hb=711673ee772e20a74aaf301c2d7745c20c4f4d47;hp=c2ae80fd59d2ae631a0ad58631cf6909d9f6ab75;hpb=a71e0af25544fd2486e57ea51c6d05abdbf44c3e;p=musl diff --git a/src/stdio/__toread.c b/src/stdio/__toread.c index c2ae80fd..f142ff09 100644 --- a/src/stdio/__toread.c +++ b/src/stdio/__toread.c @@ -3,20 +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; } -static const int dummy = 0; -weak_alias(dummy, __towrite_used); - -void __seek_on_exit() +hidden void __toread_needs_stdio_exit() { - if (!__towrite_used) __stdio_exit(); + __stdio_exit_needed(); }