fix overflow behavior of clock() function
[musl] / src / stdio / vfwscanf.c
index a52ba3a..44910b4 100644 (file)
@@ -14,6 +14,7 @@
 #include "shgetc.h"
 #include "intscan.h"
 #include "floatscan.h"
+#include "libc.h"
 
 #define SIZE_hh -2
 #define SIZE_h  -1
@@ -86,7 +87,7 @@ static int in_set(const wchar_t *set, int c)
        ((f)->rend && (c)<128U ? *--(f)->rpos : ungetwc((c),(f)))
 #endif
 
-int vfwscanf(FILE *f, const wchar_t *fmt, va_list ap)
+int vfwscanf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap)
 {
        int width;
        int size;
@@ -181,8 +182,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);
                }
@@ -305,3 +309,5 @@ match_fail:
        FUNLOCK(f);
        return matches;
 }
+
+weak_alias(vfwscanf,__isoc99_vfwscanf);