summaryrefslogtreecommitdiff
path: root/src/stdio/vfscanf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdio/vfscanf.c')
-rw-r--r--src/stdio/vfscanf.c13
1 files changed, 3 insertions, 10 deletions
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;