Signed-off-by: Daniel Lehman dlehman25@gmail.com --- dlls/msvcrt/tests/string.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index b5b877e7ec..ccbd049c4c 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -1938,6 +1938,7 @@ static void test__strtod(void) const char *str; int len; double ret; + int err; } tests[] = { { "12.1", 4, 12.1 }, { "-13.721", 7, -13.721 }, @@ -1953,7 +1954,7 @@ static void test__strtod(void) { "0.82181281288121", 16, 0.82181281288121 }, { "21921922352523587651128218821", 29, 21921922352523587651128218821.0 }, { "0.1d238", 7, 0.1e238 }, - { "0.1D-4736", 9, 0 }, + { "0.1D-4736", 9, 0, ERANGE }, { "3.4028234663852887e38", 21, FLT_MAX }, { "1.7976931348623158e+308", 23, DBL_MAX }, { "00", 2, 0 }, @@ -1975,7 +1976,8 @@ static void test__strtod(void) ok(d == tests[i].ret, "%d) d = %.16e\n", i, d); ok(end == tests[i].str + tests[i].len, "%d) len = %d\n", i, (int)(end - tests[i].str)); - ok(errno = 0xdeadbeef, "%d) errno = %d\n", i, errno); + todo_wine_if(!tests[i].err) + ok(errno == tests[i].err, "%d) errno = %d\n", i, errno); }
if (!p__strtod_l)
Signed-off-by: Daniel Lehman dlehman25@gmail.com --- dlls/msvcrt/string.c | 3 ++- dlls/msvcrt/tests/string.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c index 62ec54607e..cf4fc65ff4 100644 --- a/dlls/msvcrt/string.c +++ b/dlls/msvcrt/string.c @@ -696,6 +696,8 @@ double parse_double(MSVCRT_wchar_t (*get)(void *ctx), void (*unget)(void *ctx), nch = get(ctx); }
+ if(!err) err = MSVCRT__errno(); + *err = 0; if(!found_digit) { if(nch != MSVCRT_WEOF) unget(ctx); if(found_dp) unget(ctx); @@ -759,7 +761,6 @@ double parse_double(MSVCRT_wchar_t (*get)(void *ctx), void (*unget)(void *ctx), if(off < 0) off += LIMB_DIGITS; if(off) bnum_mult(&b, p10s[off]);
- if(!err) err = MSVCRT__errno(); if(dp-1 > MSVCRT_DBL_MAX_10_EXP) return make_double(sign, INT_MAX, 1, ROUND_ZERO, err); /* Count part of exponent stored in denormalized mantissa. */ diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index ccbd049c4c..8a2d678b63 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -1976,7 +1976,6 @@ static void test__strtod(void) ok(d == tests[i].ret, "%d) d = %.16e\n", i, d); ok(end == tests[i].str + tests[i].len, "%d) len = %d\n", i, (int)(end - tests[i].str)); - todo_wine_if(!tests[i].err) ok(errno == tests[i].err, "%d) errno = %d\n", i, errno); }
Signed-off-by: Daniel Lehman dlehman25@gmail.com --- dlls/msvcrt/string.c | 2 +- dlls/msvcrt/tests/string.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c index cf4fc65ff4..ff1195e19b 100644 --- a/dlls/msvcrt/string.c +++ b/dlls/msvcrt/string.c @@ -423,7 +423,7 @@ static double make_double(int sign, int exp, ULONGLONG m, enum round round, int } }
- if (exp >= 1<<EXP_BITS) + if (exp >= (1<<EXP_BITS)-1) { if (err) *err = MSVCRT_ERANGE; return sign * INFINITY; diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index 8a2d678b63..ad41ad4d24 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -1956,7 +1956,12 @@ static void test__strtod(void) { "0.1d238", 7, 0.1e238 }, { "0.1D-4736", 9, 0, ERANGE }, { "3.4028234663852887e38", 21, FLT_MAX }, + { "1.1754943508222875e-38", 22, FLT_MIN }, { "1.7976931348623158e+308", 23, DBL_MAX }, + { "1.7976931348623159e+308", 23, INFINITY, ERANGE }, + { "2.2250738585072014e-308", 23, DBL_MIN }, + { "-1.7976931348623158e+308", 24, -DBL_MAX }, + { "-1.7976931348623159e+308", 24, -INFINITY, ERANGE }, { "00", 2, 0 }, { "00.", 3, 0 }, { ".00", 3, 0 },
Signed-off-by: Daniel Lehman dlehman25@gmail.com --- dlls/ucrtbase/tests/string.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/ucrtbase/tests/string.c b/dlls/ucrtbase/tests/string.c index f85f9abf73..1a51784af0 100644 --- a/dlls/ucrtbase/tests/string.c +++ b/dlls/ucrtbase/tests/string.c @@ -77,12 +77,15 @@ static BOOL local_isnan(double d) return d != d; }
-#define test_strtod_str(string, value, length) _test_strtod_str(__LINE__, string, value, length) -static void _test_strtod_str(int line, const char* string, double value, int length) +#define test_strtod_str_errno(string, value, length, err) _test_strtod_str(__LINE__, string, value, length, err) +#define test_strtod_str(string, value, length) _test_strtod_str(__LINE__, string, value, length, 0) +static void _test_strtod_str(int line, const char* string, double value, int length, int err) { char *end; double d; + errno = 0xdeadbeef; d = strtod(string, &end); + ok(!err || errno == err, "errno = %d\n", errno); if (local_isnan(value)) ok_(__FILE__, line)(local_isnan(d), "d = %.16le ("%s")\n", d, string); else @@ -102,6 +105,8 @@ static void test_strtod(void) test_strtod_str("infini", INFINITY, 3); test_strtod_str("input", 0, 0); test_strtod_str("-input", 0, 0); + test_strtod_str_errno("1.7976931348623159e+308", INFINITY, 23, ERANGE); + test_strtod_str_errno("-1.7976931348623159e+308", -INFINITY, 24, ERANGE);
test_strtod_str("NAN", NAN, 3); test_strtod_str("nan", NAN, 3); @@ -137,6 +142,7 @@ static void test_strtod(void)
test_strtod_str("4.0621786324484881721115322e-53", 4.0621786324484881721115322e-53, 31); test_strtod_str("1.8905590910042396899370942", 1.8905590910042396899370942, 27); + test_strtod_str("1.7976931348623158e+308", 1.7976931348623158e+308, 23); test_strtod_str("2.2250738585072014e-308", 2.2250738585072014e-308, 23); test_strtod_str("4.9406564584124654e-324", 4.9406564584124654e-324, 23); }