diff options
Diffstat (limited to 'stdio-common')
-rw-r--r-- | stdio-common/tstscanf.c | 6 | ||||
-rw-r--r-- | stdio-common/vfscanf.c | 30 |
2 files changed, 21 insertions, 15 deletions
diff --git a/stdio-common/tstscanf.c b/stdio-common/tstscanf.c index 277d4e1cbf..eb2f30d0f9 100644 --- a/stdio-common/tstscanf.c +++ b/stdio-common/tstscanf.c @@ -160,6 +160,12 @@ main (int argc, char **argv) if (res != 2 || a != 123 || b != 456 || n != 6) return 1; + + res = sscanf ("0", "%lg", &a); + printf ("res = %d, a = %g\n", res, a); + + if (res != 1 || a != 0) + exit (EXIT_FAILURE); } exit(EXIT_SUCCESS); diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c index 4780f51021..3738e44f0a 100644 --- a/stdio-common/vfscanf.c +++ b/stdio-common/vfscanf.c @@ -925,24 +925,24 @@ __vfscanf (FILE *s, const char *format, va_list argptr) else negative = 0; - if (c == '0' && tolower (c == inchar ()) == 'x') + is_hexa = 0; + exp_char = 'e'; + if (c == '0') { - /* It is a number in hexadecimal format. */ - ADDW ('0'); - ADDW ('x'); + ADDW (c); + c = inchar (); + if (tolower (c) == 'x') + { + /* It is a number in hexadecimal format. */ + ADDW (c); - is_hexa = 1; - exp_char = 'p'; + is_hexa = 1; + exp_char = 'p'; - /* Grouping is not allowed. */ - flags &= ~GROUP; - c = inchar (); - } - else - { - /* It not a hexadecimal prefix. */ - is_hexa = 0; - exp_char = 'e'; + /* Grouping is not allowed. */ + flags &= ~GROUP; + c = inchar (); + } } got_dot = got_e = 0; |