|
@@ -77,14 +77,6 @@
|
|
|
#include <bits/uClibc_fpmax.h>
|
|
|
#endif
|
|
|
|
|
|
-#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
|
|
|
-#ifdef L_vfscanf
|
|
|
-
|
|
|
-#warning Forcing undef of __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ until implemented!
|
|
|
-#endif
|
|
|
-#undef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
|
|
|
-#endif
|
|
|
-
|
|
|
#undef __STDIO_HAS_VSSCANF
|
|
|
#if defined(__STDIO_BUFFERS) || !defined(__UCLIBC_HAS_WCHAR__) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__)
|
|
|
#define __STDIO_HAS_VSSCANF 1
|
|
@@ -433,8 +425,9 @@ libc_hidden_def(vswscanf)
|
|
|
|
|
|
|
|
|
|
|
|
-#define SPEC_CHARS "npxXoudifFeEgGaACSncs["
|
|
|
-
|
|
|
+#define SPEC_CHARS "npxXoudifFeEgGaACSnmcs["
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
* must immediately precede CONV_c. */
|
|
@@ -444,7 +437,7 @@ enum {
|
|
|
CONV_p,
|
|
|
CONV_x, CONV_X, CONV_o, CONV_u, CONV_d, CONV_i,
|
|
|
CONV_f, CONV_F, CONV_e, CONV_E, CONV_g, CONV_G, CONV_a, CONV_A,
|
|
|
- CONV_C, CONV_S, CONV_LEFTBRACKET, CONV_c, CONV_s, CONV_leftbracket,
|
|
|
+ CONV_C, CONV_S, CONV_LEFTBRACKET, CONV_m, CONV_c, CONV_s, CONV_leftbracket,
|
|
|
CONV_percent, CONV_whitespace
|
|
|
};
|
|
|
|
|
@@ -474,7 +467,7 @@ enum {
|
|
|
FLAG_SURPRESS = 0x10,
|
|
|
FLAG_THOUSANDS = 0x20,
|
|
|
FLAG_I18N = 0x40,
|
|
|
- FLAG_MALLOC = 0x80,
|
|
|
+ FLAG_MALLOC = 0x80,
|
|
|
};
|
|
|
|
|
|
|
|
@@ -491,7 +484,7 @@ enum {
|
|
|
(0x0c|FLAG_SURPRESS|FLAG_THOUSANDS|FLAG_I18N), \
|
|
|
( 0|FLAG_SURPRESS), \
|
|
|
( 0|FLAG_SURPRESS|FLAG_MALLOC), \
|
|
|
- (0x04|FLAG_SURPRESS), \
|
|
|
+ (0x04|FLAG_SURPRESS|FLAG_MALLOC), \
|
|
|
(0x04|FLAG_SURPRESS|FLAG_MALLOC), \
|
|
|
}
|
|
|
|
|
@@ -904,17 +897,17 @@ int attribute_hidden __psfs_parse_spec(register psfs_t *psfs)
|
|
|
if (*psfs->fmt == *p) {
|
|
|
int p_m_spec_chars = p - spec_chars;
|
|
|
|
|
|
-#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
|
|
|
-#error implement gnu a flag
|
|
|
- if ((*p == 'a')
|
|
|
- && ((psfs->fmt[1] == '[') || ((psfs->fmt[1]|0x20) == 's'))
|
|
|
- ) {
|
|
|
- psfs->flags |= FLAG_MALLOC;
|
|
|
+ if (*p == 'm' &&
|
|
|
+ (psfs->fmt[1] == '[' || psfs->fmt[1] == 'c' ||
|
|
|
+
|
|
|
+ (psfs->fmt[1] | 0x20) == 's'))
|
|
|
+ {
|
|
|
+ if (psfs->store)
|
|
|
+ psfs->flags |= FLAG_MALLOC;
|
|
|
++psfs->fmt;
|
|
|
++p;
|
|
|
- continue;
|
|
|
+ continue;
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
for (p = spec_ranges; p_m_spec_chars > *p ; ++p) {}
|
|
|
if (((psfs->dataargtype >> 8) | psfs->flags)
|
|
@@ -1265,12 +1258,6 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
|
|
|
while (*wf && __isascii(*wf) && (b < buf + sizeof(buf) - 1)) {
|
|
|
*b++ = *wf++;
|
|
|
}
|
|
|
-#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
|
|
|
-#error this is wrong... we need to ched in __psfs_parse_spec instead since this checks last char in buffer and conversion my have stopped before it.
|
|
|
- if ((*b == 'a') && ((*wf == '[') || ((*wf|0x20) == 's'))) {
|
|
|
- goto DONE;
|
|
|
- }
|
|
|
-#endif
|
|
|
*b = 0;
|
|
|
if (b == buf) {
|
|
|
goto DONE;
|
|
@@ -1390,13 +1377,36 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
|
|
|
}
|
|
|
|
|
|
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)) {
|
|
|
zero_conversions = 0;
|
|
|
- *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;
|
|
|
}
|
|
|
+
|
|
|
+ if (psfs.flags & FLAG_MALLOC)
|
|
|
+ *ptr = b;
|
|
|
+
|
|
|
+ b += i;
|
|
|
} else {
|
|
|
#ifdef __UCLIBC_HAS_WCHAR__
|
|
|
assert((psfs.conv_num == CONV_LEFTBRACKET) || \
|