From: Rich Felker Date: Wed, 18 Apr 2012 01:17:09 +0000 (-0400) Subject: make wide scanf %[ respect width X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=99fbf4cfdbb3b67f30d595a7f1c535ca17c2f969;p=musl make wide scanf %[ respect width --- diff --git a/src/stdio/vfwscanf.c b/src/stdio/vfwscanf.c index 92b7fa40..beb8e8fb 100644 --- a/src/stdio/vfwscanf.c +++ b/src/stdio/vfwscanf.c @@ -243,7 +243,7 @@ int vfwscanf(FILE *f, const wchar_t *fmt, va_list ap) int gotmatch = 0; - for (;;) { + while (width) { if ((c=getwc(f))<0) break; if (in_set(p, c) == invert) break; @@ -255,9 +255,10 @@ int vfwscanf(FILE *f, const wchar_t *fmt, va_list ap) if (s) s+=l; } pos++; + width--; gotmatch=1; } - ungetwc(c, f); + if (width) ungetwc(c, f); if (!gotmatch) goto match_fail;