major stdio overhaul, using readv/writev, plus other changes
[musl] / src / stdio / vfscanf.c
index 69f4508..414c2a3 100644 (file)
@@ -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;