X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=inline;f=src%2Fstdio%2Fvfscanf.c;h=9e030fc4441f0854f95eae1cf31ae3687fd71dd6;hb=8cd738bbee3b4e60a99b71599c338bf444070f18;hp=bb9284809846473f09a2ca3aab0de7fd0e2bbab9;hpb=ef5507867b59d19f21437970e87b5d0415c07b2e;p=musl diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c index bb928480..9e030fc4 100644 --- a/src/stdio/vfscanf.c +++ b/src/stdio/vfscanf.c @@ -5,10 +5,7 @@ #include #include #include -#include -#include -#include -#include +#include #include "stdio_impl.h" #include "shgetc.h" @@ -81,6 +78,8 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap) for (p=(const unsigned char *)fmt; *p; p++) { + alloc = 0; + if (isspace(*p)) { while (isspace(p[1])) p++; shlim(f, 0); @@ -90,15 +89,19 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap) continue; } if (*p != '%' || p[1] == '%') { - p += *p=='%'; shlim(f, 0); - c = shgetc(f); + if (*p == '%') { + p++; + while (isspace((c=shgetc(f)))); + } else { + c = shgetc(f); + } if (c!=*p) { shunget(f); if (c<0) goto input_fail; goto match_fail; } - pos++; + pos += shcnt(f); continue; } @@ -116,6 +119,8 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap) } if (*p=='m') { + wcs = 0; + s = 0; alloc = !!dest; p++; } else { @@ -327,3 +332,5 @@ match_fail: FUNLOCK(f); return matches; } + +weak_alias(vfscanf,__isoc99_vfscanf);