fix nl_langinfo table for LC_TIME era-related items
[musl] / src / stdio / vfscanf.c
index 6bea6ad..d4d2454 100644 (file)
@@ -5,10 +5,7 @@
 #include <wctype.h>
 #include <limits.h>
 #include <string.h>
-#include <errno.h>
-#include <math.h>
-#include <float.h>
-#include <inttypes.h>
+#include <stdint.h>
 
 #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);
@@ -116,6 +115,8 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap)
                }
 
                if (*p=='m') {
+                       wcs = 0;
+                       s = 0;
                        alloc = !!dest;
                        p++;
                } else {
@@ -265,8 +266,10 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap)
                                if (size == SIZE_l) *(wchar_t **)dest = wcs;
                                else *(char **)dest = s;
                        }
-                       if (wcs) wcs[i] = 0;
-                       if (s) s[i] = 0;
+                       if (t != 'c') {
+                               if (wcs) wcs[i] = 0;
+                               if (s) s[i] = 0;
+                       }
                        break;
                case 'p':
                case 'X':
@@ -325,3 +328,5 @@ match_fail:
        FUNLOCK(f);
        return matches;
 }
+
+weak_alias(vfscanf,__isoc99_vfscanf);