diff options
author | Andreas Schwab <schwab@suse.de> | 2013-10-31 12:51:03 +0100 |
---|---|---|
committer | Andreas Schwab <schwab@suse.de> | 2013-10-31 12:51:03 +0100 |
commit | a4966c6104918ac884ee1131a4ed23c5ad6b4c5a (patch) | |
tree | 50d215a87669be3f9b9cc0164a2affe45f392bad /stdio-common/tst-sscanf.c | |
parent | 28d708c44bc47b56f6551ff285f78edcf61c208a (diff) | |
download | glibc-a4966c6104918ac884ee1131a4ed23c5ad6b4c5a.tar.gz glibc-a4966c6104918ac884ee1131a4ed23c5ad6b4c5a.tar.xz glibc-a4966c6104918ac884ee1131a4ed23c5ad6b4c5a.zip |
Fix parsing of 0e+0 as float
Diffstat (limited to 'stdio-common/tst-sscanf.c')
-rw-r--r-- | stdio-common/tst-sscanf.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/stdio-common/tst-sscanf.c b/stdio-common/tst-sscanf.c index 1edb227199..3c34f58a63 100644 --- a/stdio-common/tst-sscanf.c +++ b/stdio-common/tst-sscanf.c @@ -109,6 +109,19 @@ struct test double_tests[] = { L("-inf"), L("%g"), 1 } }; +struct test2 +{ + const CHAR *str; + const CHAR *fmt; + int retval; + char residual; +} double_tests2[] = +{ + { L("0e+0"), L("%g%c"), 1, 0 }, + { L("0xe+0"), L("%g%c"), 2, '+' }, + { L("0x.e+0"), L("%g%c"), 2, '+' }, +}; + int main (void) { @@ -196,5 +209,26 @@ main (void) } } + for (i = 0; i < sizeof (double_tests2) / sizeof (double_tests2[0]); ++i) + { + double dummy; + int ret; + char c = 0; + + if ((ret = SSCANF (double_tests2[i].str, double_tests2[i].fmt, + &dummy, &c)) != double_tests2[i].retval) + { + printf ("double_tests2[%d] returned %d != %d\n", + i, ret, double_tests2[i].retval); + result = 1; + } + else if (ret == 2 && c != double_tests2[i].residual) + { + printf ("double_tests2[%d] stopped at '%c' != '%c'\n", + i, c, double_tests2[i].residual); + result = 1; + } + } + return result; } |