Module: wine Branch: master Commit: bab686e7d1483376e0bbec8e8f29d0ba61a317c8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=bab686e7d1483376e0bbec8e8f...
Author: Piotr Caban piotr@codeweavers.com Date: Thu Nov 1 15:27:01 2012 +0100
msvcrt: Fixed %Lf format handling in scanf.
---
dlls/msvcrt/scanf.h | 2 +- dlls/msvcrt/tests/scanf.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/dlls/msvcrt/scanf.h b/dlls/msvcrt/scanf.h index cc2b861..3d02e8c 100644 --- a/dlls/msvcrt/scanf.h +++ b/dlls/msvcrt/scanf.h @@ -379,7 +379,7 @@ _FUNCTION_ { } st = 1; if (!suppress) { - if (L_prefix) _SET_NUMBER_(long double); + if (L_prefix) _SET_NUMBER_(double); else if (l_prefix) _SET_NUMBER_(double); else _SET_NUMBER_(float); } diff --git a/dlls/msvcrt/tests/scanf.c b/dlls/msvcrt/tests/scanf.c index fb9d8e8..7c9f8d4 100644 --- a/dlls/msvcrt/tests/scanf.c +++ b/dlls/msvcrt/tests/scanf.c @@ -31,6 +31,7 @@ static void test_sscanf( void ) char c; void *ptr; float res1= -82.6267f, res2= 27.76f, res11, res12; + double double_res; static const char pname[]=" St. Petersburg, Florida\n"; int hour=21,min=59,sec=20; int number,number_so_far; @@ -99,6 +100,16 @@ static void test_sscanf( void ) ok( ret == 2, "expected 2, got %u\n", ret); ok( (res11 == res1) && (res12 == res2), "Error reading floats\n");
+ /* Check double */ + ret = sprintf(buffer, "%lf", 32.715); + ok(ret == 9, "expected 9, got %u\n", ret); + ret = sscanf(buffer, "%lf", &double_res); + ok(ret == 1, "expected 1, got %u\n", ret); + ok(double_res == 32.715, "Got %lf, expected %lf\n", double_res, 32.715); + ret = sscanf(buffer, "%Lf", &double_res); + ok(ret == 1, "expected 1, got %u\n", ret); + ok(double_res == 32.715, "Got %lf, expected %lf\n", double_res, 32.715); + /* check strings */ ret = sprintf(buffer," %s", pname); ok( ret == 26, "expected 26, got %u\n", ret);