Lines 77-90
Link Here
|
77 |
#include <bits/uClibc_fpmax.h> |
77 |
#include <bits/uClibc_fpmax.h> |
78 |
#endif /* __UCLIBC_HAS_FLOATS__ */ |
78 |
#endif /* __UCLIBC_HAS_FLOATS__ */ |
79 |
|
79 |
|
80 |
#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ |
|
|
81 |
#ifdef L_vfscanf |
82 |
/* only emit this once */ |
83 |
#warning Forcing undef of __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ until implemented! |
84 |
#endif |
85 |
#undef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ |
86 |
#endif |
87 |
|
88 |
#undef __STDIO_HAS_VSSCANF |
80 |
#undef __STDIO_HAS_VSSCANF |
89 |
#if defined(__STDIO_BUFFERS) || !defined(__UCLIBC_HAS_WCHAR__) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__) |
81 |
#if defined(__STDIO_BUFFERS) || !defined(__UCLIBC_HAS_WCHAR__) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__) |
90 |
#define __STDIO_HAS_VSSCANF 1 |
82 |
#define __STDIO_HAS_VSSCANF 1 |
Lines 433-440
Link Here
|
433 |
|
425 |
|
434 |
|
426 |
|
435 |
/* float layout 0123456789012345678901 repeat n for "l[" */ |
427 |
/* float layout 0123456789012345678901 repeat n for "l[" */ |
436 |
#define SPEC_CHARS "npxXoudifFeEgGaACSncs[" |
428 |
#define SPEC_CHARS "npxXoudifFeEgGaACSnmcs[" |
437 |
/* npxXoudif eEgG CS cs[ */ |
429 |
/* npxXoudif eEgG CS cs[ */ |
|
|
430 |
/* NOTE: the 'm' flag must come before any convs that support it */ |
438 |
|
431 |
|
439 |
/* NOTE: Ordering is important! In particular, CONV_LEFTBRACKET |
432 |
/* NOTE: Ordering is important! In particular, CONV_LEFTBRACKET |
440 |
* must immediately precede CONV_c. */ |
433 |
* must immediately precede CONV_c. */ |
Lines 444-450
Link Here
|
444 |
CONV_p, |
437 |
CONV_p, |
445 |
CONV_x, CONV_X, CONV_o, CONV_u, CONV_d, CONV_i, |
438 |
CONV_x, CONV_X, CONV_o, CONV_u, CONV_d, CONV_i, |
446 |
CONV_f, CONV_F, CONV_e, CONV_E, CONV_g, CONV_G, CONV_a, CONV_A, |
439 |
CONV_f, CONV_F, CONV_e, CONV_E, CONV_g, CONV_G, CONV_a, CONV_A, |
447 |
CONV_C, CONV_S, CONV_LEFTBRACKET, CONV_c, CONV_s, CONV_leftbracket, |
440 |
CONV_C, CONV_S, CONV_LEFTBRACKET, CONV_m, CONV_c, CONV_s, CONV_leftbracket, |
448 |
CONV_percent, CONV_whitespace /* not in SPEC_* and no flags */ |
441 |
CONV_percent, CONV_whitespace /* not in SPEC_* and no flags */ |
449 |
}; |
442 |
}; |
450 |
|
443 |
|
Lines 474-480
Link Here
|
474 |
FLAG_SURPRESS = 0x10, /* MUST BE 1ST!! See DO_FLAGS. */ |
467 |
FLAG_SURPRESS = 0x10, /* MUST BE 1ST!! See DO_FLAGS. */ |
475 |
FLAG_THOUSANDS = 0x20, |
468 |
FLAG_THOUSANDS = 0x20, |
476 |
FLAG_I18N = 0x40, /* only works for d, i, u */ |
469 |
FLAG_I18N = 0x40, /* only works for d, i, u */ |
477 |
FLAG_MALLOC = 0x80, /* only works for s, S, and [ (and l[)*/ |
470 |
FLAG_MALLOC = 0x80, /* only works for c, s, S, and [ (and l[)*/ |
478 |
}; |
471 |
}; |
479 |
|
472 |
|
480 |
|
473 |
|
Lines 491-497
Link Here
|
491 |
/* fFeEgGaA */ (0x0c|FLAG_SURPRESS|FLAG_THOUSANDS|FLAG_I18N), \ |
484 |
/* fFeEgGaA */ (0x0c|FLAG_SURPRESS|FLAG_THOUSANDS|FLAG_I18N), \ |
492 |
/* C */ ( 0|FLAG_SURPRESS), \ |
485 |
/* C */ ( 0|FLAG_SURPRESS), \ |
493 |
/* S and l[ */ ( 0|FLAG_SURPRESS|FLAG_MALLOC), \ |
486 |
/* S and l[ */ ( 0|FLAG_SURPRESS|FLAG_MALLOC), \ |
494 |
/* c */ (0x04|FLAG_SURPRESS), \ |
487 |
/* c */ (0x04|FLAG_SURPRESS|FLAG_MALLOC), \ |
495 |
/* s and [ */ (0x04|FLAG_SURPRESS|FLAG_MALLOC), \ |
488 |
/* s and [ */ (0x04|FLAG_SURPRESS|FLAG_MALLOC), \ |
496 |
} |
489 |
} |
497 |
|
490 |
|
Lines 904-920
Link Here
|
904 |
if (*psfs->fmt == *p) { |
897 |
if (*psfs->fmt == *p) { |
905 |
int p_m_spec_chars = p - spec_chars; |
898 |
int p_m_spec_chars = p - spec_chars; |
906 |
|
899 |
|
907 |
#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ |
900 |
if (*p == 'm' && |
908 |
#error implement gnu a flag |
901 |
(psfs->fmt[1] == '[' || psfs->fmt[1] == 'c' || |
909 |
if ((*p == 'a') |
902 |
/* Assumes ascii for 's' and 'S' test. */ |
910 |
&& ((psfs->fmt[1] == '[') || ((psfs->fmt[1]|0x20) == 's')) |
903 |
(psfs->fmt[1]|0x20) == 's')) |
911 |
) { /* Assumes ascii for 's' and 'S' test. */ |
904 |
{ |
912 |
psfs->flags |= FLAG_MALLOC; |
905 |
if (psfs->store) |
|
|
906 |
psfs->flags |= FLAG_MALLOC; |
913 |
++psfs->fmt; |
907 |
++psfs->fmt; |
914 |
++p; |
908 |
++p; |
915 |
continue; /* The related conversions follow 'a'. */ |
909 |
continue; /* The related conversions follow ''. */ |
916 |
} |
910 |
} |
917 |
#endif /* __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ */ |
|
|
918 |
|
911 |
|
919 |
for (p = spec_ranges; p_m_spec_chars > *p ; ++p) {} |
912 |
for (p = spec_ranges; p_m_spec_chars > *p ; ++p) {} |
920 |
if (((psfs->dataargtype >> 8) | psfs->flags) |
913 |
if (((psfs->dataargtype >> 8) | psfs->flags) |
Lines 1265-1276
Link Here
|
1265 |
while (*wf && __isascii(*wf) && (b < buf + sizeof(buf) - 1)) { |
1258 |
while (*wf && __isascii(*wf) && (b < buf + sizeof(buf) - 1)) { |
1266 |
*b++ = *wf++; |
1259 |
*b++ = *wf++; |
1267 |
} |
1260 |
} |
1268 |
#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ |
|
|
1269 |
#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. |
1270 |
if ((*b == 'a') && ((*wf == '[') || ((*wf|0x20) == 's'))) { |
1271 |
goto DONE; /* Spec was excessively long. */ |
1272 |
} |
1273 |
#endif /* __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ */ |
1274 |
*b = 0; |
1261 |
*b = 0; |
1275 |
if (b == buf) { /* Bad conversion specifier! */ |
1262 |
if (b == buf) { /* Bad conversion specifier! */ |
1276 |
goto DONE; |
1263 |
goto DONE; |
Lines 1390-1402
Link Here
|
1390 |
} |
1377 |
} |
1391 |
|
1378 |
|
1392 |
if (psfs.conv_num == CONV_s) { |
1379 |
if (psfs.conv_num == CONV_s) { |
|
|
1380 |
/* We might have to handle the allocation ourselves */ |
1381 |
int len; |
1382 |
/* With 'm', we actually got a pointer to a pointer */ |
1383 |
unsigned char **ptr = (void *)b; |
1384 |
|
1385 |
i = 0; |
1386 |
if (psfs.flags & FLAG_MALLOC) { |
1387 |
len = 0; |
1388 |
b = NULL; |
1389 |
} else |
1390 |
len = -1; |
1391 |
|
1393 |
/* Yes, believe it or not, a %s conversion can store nuls. */ |
1392 |
/* Yes, believe it or not, a %s conversion can store nuls. */ |
1394 |
while ((__scan_getc(&sc) >= 0) && !isspace(sc.cc)) { |
1393 |
while ((__scan_getc(&sc) >= 0) && !isspace(sc.cc)) { |
1395 |
zero_conversions = 0; |
1394 |
zero_conversions = 0; |
1396 |
*b = sc.cc; |
1395 |
if (i == len) { |
1397 |
b += psfs.store; |
1396 |
/* Pick a size that won't trigger a lot of |
|
|
1397 |
* mallocs early on ... */ |
1398 |
len += 256; |
1399 |
b = realloc(b, len + 1); |
1400 |
} |
1401 |
b[i] = sc.cc; |
1402 |
i += psfs.store; |
1398 |
fail = 0; |
1403 |
fail = 0; |
1399 |
} |
1404 |
} |
|
|
1405 |
|
1406 |
if (psfs.flags & FLAG_MALLOC) |
1407 |
*ptr = b; |
1408 |
/* The code below takes care of terminating NUL */ |
1409 |
b += i; |
1400 |
} else { |
1410 |
} else { |
1401 |
#ifdef __UCLIBC_HAS_WCHAR__ |
1411 |
#ifdef __UCLIBC_HAS_WCHAR__ |
1402 |
assert((psfs.conv_num == CONV_LEFTBRACKET) || \ |
1412 |
assert((psfs.conv_num == CONV_LEFTBRACKET) || \ |