From 6974abe0e67063b46dd30005d9b8b68257a376dd Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Mon, 26 Apr 2010 12:33:49 +0200 Subject: [PATCH] msvcrt: Use wcstod_l/strtod_l in other functions that parses doubles. --- dlls/msvcr80/msvcr80.spec | 8 ++-- dlls/msvcr90/msvcr90.spec | 8 ++-- dlls/msvcrt/msvcrt.spec | 6 +-- dlls/msvcrt/string.c | 24 ++++++++---- dlls/msvcrt/wcs.c | 81 ++++++++------------------------------- 5 files changed, 43 insertions(+), 84 deletions(-) diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index b8e89e496fe..65da4271d41 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -289,7 +289,7 @@ @ cdecl _assert(str str long) msvcrt._assert @ stub _atodbl @ stub _atodbl_l -@ stub _atof_l +@ cdecl _atof_l(str ptr) msvcrt._atof_l @ stub _atoflt @ stub _atoflt_l @ cdecl -ret64 _atoi64(str) msvcrt._atoi64 @@ -1105,7 +1105,7 @@ @ cdecl _wcsrev(wstr) msvcrt._wcsrev @ cdecl _wcsset(wstr long) msvcrt._wcsset @ stub _wcsset_s -@ stub _wcstod_l +@ cdecl _wcstod_l(wstr ptr) msvcrt._wcstod_l @ stub _wcstoi64 @ stub _wcstoi64_l @ stub _wcstol_l @@ -1207,8 +1207,8 @@ @ cdecl _wtempnam(wstr wstr) msvcrt._wtempnam @ stub _wtmpnam @ stub _wtmpnam_s -@ stub _wtof -@ stub _wtof_l +@ cdecl _wtof(wstr) msvcrt._wtof +@ cdecl _wtof_l(wstr ptr) msvcrt._wtof_l @ cdecl _wtoi(wstr) msvcrt._wtoi @ cdecl _wtoi64(wstr) msvcrt._wtoi64 @ stub _wtoi64_l diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index 141592d990e..b7884dc8400 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -281,7 +281,7 @@ @ cdecl _assert(str str long) msvcrt._assert @ stub _atodbl @ stub _atodbl_l -@ stub _atof_l +@ cdecl _atof_l(str ptr) msvcrt._atof_l @ stub _atoflt @ stub _atoflt_l @ cdecl -ret64 _atoi64(str) msvcrt._atoi64 @@ -1092,7 +1092,7 @@ @ cdecl _wcsrev(wstr) msvcrt._wcsrev @ cdecl _wcsset(wstr long) msvcrt._wcsset @ stub _wcsset_s -@ stub _wcstod_l +@ cdecl _wcstod_l(wstr ptr) msvcrt._wcstod_l @ stub _wcstoi64 @ stub _wcstoi64_l @ stub _wcstol_l @@ -1191,8 +1191,8 @@ @ cdecl _wtempnam(wstr wstr) msvcrt._wtempnam @ stub _wtmpnam @ stub _wtmpnam_s -@ stub _wtof -@ stub _wtof_l +@ cdecl _wtof(wstr) msvcrt._wtof +@ cdecl _wtof_l(wstr ptr) msvcrt._wtof_l @ cdecl _wtoi(wstr) msvcrt._wtoi @ cdecl _wtoi64(wstr) msvcrt._wtoi64 @ stub _wtoi64_l diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 81e07a7fd99..06803758498 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -264,7 +264,7 @@ @ cdecl _assert(str str long) MSVCRT__assert @ stub _atodbl #(ptr str) # stub _atodbl_l -# stub _atof_l +@ cdecl _atof_l(str ptr) MSVCRT__atof_l # stub _atoflt_l @ cdecl -ret64 _atoi64(str) ntdll._atoi64 # stub _atoi64_l @@ -1136,8 +1136,8 @@ # stub _wtempnam_dbg @ stub _wtmpnam #(ptr) # stub _wtmpnam_s -# stub _wtof -# stub _wtof_l +@ cdecl _wtof(wstr) MSVCRT__wtof +@ cdecl _wtof_l(wstr ptr) MSVCRT__wtof_l @ cdecl _wtoi(wstr) ntdll._wtoi @ cdecl _wtoi64(wstr) ntdll._wtoi64 # stub _wtoi64_l diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c index 6829e2516f1..d99c508c985 100644 --- a/dlls/msvcrt/string.c +++ b/dlls/msvcrt/string.c @@ -131,14 +131,6 @@ void CDECL MSVCRT__swab(char* src, char* dst, int len) } } -/********************************************************************* - * atof (MSVCRT.@) - */ -double CDECL MSVCRT_atof( const char *str ) -{ - return atof( str ); -} - /********************************************************************* * strtod_l (MSVCRT.@) */ @@ -252,6 +244,22 @@ double CDECL MSVCRT_strtod( const char *str, char **end ) return MSVCRT_strtod_l( str, end, NULL ); } +/********************************************************************* + * atof (MSVCRT.@) + */ +double CDECL MSVCRT_atof( const char *str ) +{ + return MSVCRT_strtod_l(str, NULL, NULL); +} + +/********************************************************************* + * _atof_l (MSVCRT.@) + */ +double CDECL MSVCRT__atof_l( const char *str, MSVCRT__locale_t locale) +{ + return MSVCRT_strtod_l(str, NULL, locale); +} + /********************************************************************* * strcoll (MSVCRT.@) */ diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index 94c638b9b54..44a3b4d8b8d 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -231,73 +231,24 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end, */ double CDECL MSVCRT_wcstod(const MSVCRT_wchar_t* lpszStr, MSVCRT_wchar_t** end) { - const MSVCRT_wchar_t* str = lpszStr; - int negative = 0; - double ret = 0, divisor = 10.0; - - TRACE("(%s,%p) semi-stub\n", debugstr_w(lpszStr), end); - - /* FIXME: - * - Should set errno on failure - * - Should fail on overflow - * - Need to check which input formats are allowed - */ - while (isspaceW(*str)) - str++; - - if (*str == '-') - { - negative = 1; - str++; - } - - while (isdigitW(*str)) - { - ret = ret * 10.0 + (*str - '0'); - str++; - } - if (*str == '.') - str++; - while (isdigitW(*str)) - { - ret = ret + (*str - '0') / divisor; - divisor *= 10; - str++; - } - - if (*str == 'E' || *str == 'e' || *str == 'D' || *str == 'd') - { - int negativeExponent = 0; - int exponent = 0; - if (*(++str) == '-') - { - negativeExponent = 1; - str++; - } - while (isdigitW(*str)) - { - exponent = exponent * 10 + (*str - '0'); - str++; - } - if (exponent != 0) - { - if (negativeExponent) - ret = ret / pow(10.0, exponent); - else - ret = ret * pow(10.0, exponent); - } - } - - if (negative) - ret = -ret; - - if (end) - *end = (MSVCRT_wchar_t*)str; - - TRACE("returning %g\n", ret); - return ret; + return MSVCRT__wcstod_l(lpszStr, end, NULL); } +/********************************************************************* + * _wtof (MSVCRT.@) + */ +double CDECL MSVCRT__wtof(const MSVCRT_wchar_t *str) +{ + return MSVCRT__wcstod_l(str, NULL, NULL); +} + +/********************************************************************* + * _wtof_l (MSVCRT.@) + */ +double CDECL MSVCRT__wtof_l(const MSVCRT_wchar_t *str, MSVCRT__locale_t locale) +{ + return MSVCRT__wcstod_l(str, NULL, locale); +} typedef struct pf_output_t {