X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fstdio%2Fvfscanf.c;h=414c2a3d79e088e1e6919e99689012ef7ec6cdfa;hp=69f45081bf83dda70b42157ac0bc2284a399904e;hb=e8dbf00a789e3b56ca6c3d88e8048b7b2c18b797;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01 diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c index 69f45081..414c2a3d 100644 --- a/src/stdio/vfscanf.c +++ b/src/stdio/vfscanf.c @@ -9,7 +9,7 @@ static void f_read(rctx_t *r) { FILE *f = r->opaque; - if ((r->c = __uflow(f)) >= 0) r->l++; + if ((r->c = getc_unlocked(f)) >= 0) r->l++; } int vfscanf(FILE *f, const char *fmt, va_list ap) @@ -28,15 +28,8 @@ int vfscanf(FILE *f, const char *fmt, va_list ap) result = __scanf(&r, fmt2, ap); - if (r.u && r.c >= 0) { - /* This code takes care of the case where the caller performs - * a nonmatching scanf to leave a character in the unscan - * buffer, followed by an unget, followed by a scanf that - * matches zero characters. In this case the final 'unread' - * character must be returned to the unget buffer rather than - * the unscan buffer. */ - f->rpos--; - } + if (r.u && r.c >= 0) + ungetc(r.c, f); FUNLOCK(f); return result;