|
@@ -1352,7 +1352,21 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
|
|
|
(psfs.conv_num >= CONV_c)
|
|
|
#endif
|
|
|
{
|
|
|
+
|
|
|
+ int len;
|
|
|
+ unsigned char **ptr;
|
|
|
+
|
|
|
b = (psfs.store ? ((unsigned char *) psfs.cur_ptr) : buf);
|
|
|
+
|
|
|
+ ptr = (void *)b;
|
|
|
+
|
|
|
+ i = 0;
|
|
|
+ if (psfs.flags & FLAG_MALLOC) {
|
|
|
+ len = 0;
|
|
|
+ b = NULL;
|
|
|
+ } else
|
|
|
+ len = -1;
|
|
|
+
|
|
|
fail = 1;
|
|
|
|
|
|
if (psfs.conv_num == CONV_c) {
|
|
@@ -1360,31 +1374,25 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
|
|
|
sc.width = 1;
|
|
|
}
|
|
|
|
|
|
+ if (psfs.flags & FLAG_MALLOC)
|
|
|
+ b = malloc(sc.width);
|
|
|
+
|
|
|
while (__scan_getc(&sc) >= 0) {
|
|
|
zero_conversions = 0;
|
|
|
- *b = sc.cc;
|
|
|
- b += psfs.store;
|
|
|
+ b[i] = sc.cc;
|
|
|
+ i += psfs.store;
|
|
|
}
|
|
|
__scan_ungetc(&sc);
|
|
|
if (sc.width > 0) {
|
|
|
goto DONE;
|
|
|
}
|
|
|
+ if (psfs.flags & FLAG_MALLOC)
|
|
|
+ *ptr = b;
|
|
|
psfs.cnt += psfs.store;
|
|
|
goto NEXT_FMT;
|
|
|
}
|
|
|
|
|
|
if (psfs.conv_num == CONV_s) {
|
|
|
-
|
|
|
- int len;
|
|
|
-
|
|
|
- unsigned char **ptr = (void *)b;
|
|
|
-
|
|
|
- i = 0;
|
|
|
- if (psfs.flags & FLAG_MALLOC) {
|
|
|
- len = 0;
|
|
|
- b = NULL;
|
|
|
- } else
|
|
|
- len = -1;
|
|
|
|
|
|
|
|
|
while ((__scan_getc(&sc) >= 0) && !isspace(sc.cc)) {
|
|
@@ -1400,10 +1408,6 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
|
|
|
fail = 0;
|
|
|
}
|
|
|
|
|
|
- if (psfs.flags & FLAG_MALLOC)
|
|
|
- *ptr = b;
|
|
|
-
|
|
|
- b += i;
|
|
|
} else {
|
|
|
#ifdef __UCLIBC_HAS_WCHAR__
|
|
|
assert((psfs.conv_num == CONV_LEFTBRACKET) || \
|
|
@@ -1459,8 +1463,14 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
|
|
|
if (!scanset[sc.cc]) {
|
|
|
break;
|
|
|
}
|
|
|
- *b = sc.cc;
|
|
|
- b += psfs.store;
|
|
|
+ if (i == len) {
|
|
|
+
|
|
|
+ * mallocs early on ... */
|
|
|
+ len += 256;
|
|
|
+ b = realloc(b, len + 1);
|
|
|
+ }
|
|
|
+ b[i] = sc.cc;
|
|
|
+ i += psfs.store;
|
|
|
fail = 0;
|
|
|
}
|
|
|
}
|
|
@@ -1470,6 +1480,9 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
|
|
|
if (fail) {
|
|
|
goto DONE;
|
|
|
}
|
|
|
+ if (psfs.flags & FLAG_MALLOC)
|
|
|
+ *ptr = b;
|
|
|
+ b += i;
|
|
|
*b = 0;
|
|
|
psfs.cnt += psfs.store;
|
|
|
goto NEXT_FMT;
|