msvcrt: Fixed strtod_l/wcstod_l implementation.
This commit is contained in:
parent
c4bf9fb710
commit
9915dd03b4
|
@ -169,6 +169,7 @@ double CDECL MSVCRT_strtod_l( const char *str, char **end, MSVCRT__locale_t loca
|
|||
int exp=0, sign=1;
|
||||
const char *p;
|
||||
double ret;
|
||||
BOOL found_digit = FALSE;
|
||||
|
||||
if(!str) {
|
||||
MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
|
||||
|
@ -191,6 +192,7 @@ double CDECL MSVCRT_strtod_l( const char *str, char **end, MSVCRT__locale_t loca
|
|||
p++;
|
||||
|
||||
while(isdigit(*p)) {
|
||||
found_digit = TRUE;
|
||||
hlp = d*10+*(p++)-'0';
|
||||
if(d>MSVCRT_UI64_MAX/10 || hlp<d) {
|
||||
exp++;
|
||||
|
@ -207,6 +209,7 @@ double CDECL MSVCRT_strtod_l( const char *str, char **end, MSVCRT__locale_t loca
|
|||
p++;
|
||||
|
||||
while(isdigit(*p)) {
|
||||
found_digit = TRUE;
|
||||
hlp = d*10+*(p++)-'0';
|
||||
if(d>MSVCRT_UI64_MAX/10 || hlp<d)
|
||||
break;
|
||||
|
@ -217,7 +220,7 @@ double CDECL MSVCRT_strtod_l( const char *str, char **end, MSVCRT__locale_t loca
|
|||
while(isdigit(*p))
|
||||
p++;
|
||||
|
||||
if(p == str) {
|
||||
if(!found_digit) {
|
||||
if(end)
|
||||
*end = (char*)str;
|
||||
return 0.0;
|
||||
|
|
|
@ -1096,6 +1096,7 @@ static void test__strtod(void)
|
|||
const char double4[] = ".21e12";
|
||||
const char double5[] = "214353e-3";
|
||||
const char overflow[] = "1d9999999999999999999";
|
||||
const char white_chars[] = " d10";
|
||||
|
||||
char *end;
|
||||
double d;
|
||||
|
@ -1123,6 +1124,10 @@ static void test__strtod(void)
|
|||
d = strtod("12.1d2", NULL);
|
||||
ok(almost_equal(d, 12.1e2), "d = %lf\n", d);
|
||||
|
||||
d = strtod(white_chars, &end);
|
||||
ok(almost_equal(d, 0), "d = %lf\n", d);
|
||||
ok(end == white_chars, "incorrect end (%d)\n", (int)(end-white_chars));
|
||||
|
||||
/* Set locale with non '.' decimal point (',') */
|
||||
if(!setlocale(LC_ALL, "Polish")) {
|
||||
win_skip("system with limited locales\n");
|
||||
|
|
|
@ -133,6 +133,7 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
|
|||
int exp=0, sign=1;
|
||||
const MSVCRT_wchar_t *p;
|
||||
double ret;
|
||||
BOOL found_digit = FALSE;
|
||||
|
||||
if(!str) {
|
||||
MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
|
||||
|
@ -154,6 +155,7 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
|
|||
p++;
|
||||
|
||||
while(isdigitW(*p)) {
|
||||
found_digit = TRUE;
|
||||
hlp = d*10+*(p++)-'0';
|
||||
if(d>MSVCRT_UI64_MAX/10 || hlp<d) {
|
||||
exp++;
|
||||
|
@ -169,6 +171,7 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
|
|||
p++;
|
||||
|
||||
while(isdigitW(*p)) {
|
||||
found_digit = TRUE;
|
||||
hlp = d*10+*(p++)-'0';
|
||||
if(d>MSVCRT_UI64_MAX/10 || hlp<d)
|
||||
break;
|
||||
|
@ -179,7 +182,7 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
|
|||
while(isdigitW(*p))
|
||||
p++;
|
||||
|
||||
if(p == str) {
|
||||
if(!found_digit) {
|
||||
if(end)
|
||||
*end = (MSVCRT_wchar_t*)str;
|
||||
return 0.0;
|
||||
|
|
Loading…
Reference in New Issue