X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2Fungetc.c;h=bc629d4ca511f812976abb93224e2732e0788e6e;hb=c99b7daafdbf1e2415bf408e67ca7813e7ddeedf;hp=7f56f8d5f07b79dba384f9ef02fe2b8c160b6467;hpb=e3cd6c5c265cd481db6e0c5b529855d99f0bda30;p=musl diff --git a/src/stdio/ungetc.c b/src/stdio/ungetc.c index 7f56f8d5..bc629d4c 100644 --- a/src/stdio/ungetc.c +++ b/src/stdio/ungetc.c @@ -6,7 +6,8 @@ int ungetc(int c, FILE *f) FLOCK(f); - if ((!f->rend && __toread(f)) || f->rpos <= f->buf - UNGET) { + if (!f->rpos) __toread(f); + if (!f->rpos || f->rpos <= f->buf - UNGET) { FUNLOCK(f); return EOF; } @@ -15,5 +16,5 @@ int ungetc(int c, FILE *f) f->flags &= ~F_EOF; FUNLOCK(f); - return c; + return (unsigned char)c; }