fix wide scanf's handling of input failure on %c, and simplify %[
[musl] / src / stdio / vfwscanf.c
index a52ba3a..de74fe0 100644 (file)
@@ -181,8 +181,11 @@ int vfwscanf(FILE *f, const wchar_t *fmt, va_list ap)
                /* Transform ls,lc -> S,C */
                if (size==SIZE_l && (t&15)==3) t&=~32;
 
-               if (t != 'n' && t != '[' && (t|32) != 'c') {
-                       while (iswspace((c=getwc(f)))) pos++;
+               if (t != 'n') {
+                       if (t != '[' && (t|32) != 'c')
+                               while (iswspace((c=getwc(f)))) pos++;
+                       else
+                               c=getwc(f);
                        if (c < 0) goto input_fail;
                        ungetwc(c, f);
                }