From f7197663c998d989c6ecf26ddc8c09208fff873c Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Mon, 26 Apr 2010 12:33:38 +0200 Subject: [PATCH] msvcrt: Added wcstod_l implementation. It's almost a copy of strtod_l. --- dlls/msvcrt/msvcrt.spec | 1 + dlls/msvcrt/wcs.c | 107 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 156ab2e0ed6..81e07a7fd99 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -1413,3 +1413,4 @@ @ cdecl _create_locale(long str) @ cdecl _free_locale(ptr) @ cdecl _configthreadlocale(long) +@ cdecl _wcstod_l(wstr ptr) MSVCRT__wcstod_l diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index 21d0d2809c5..94c638b9b54 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -18,6 +18,9 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + #include #include #include @@ -119,6 +122,110 @@ INT CDECL MSVCRT__wcsupr_s( MSVCRT_wchar_t* str, MSVCRT_size_t n ) return MSVCRT_EINVAL; } +/********************************************************************* + * _wcstod_l - not exported in native msvcrt + */ +double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end, + MSVCRT__locale_t locale) +{ + unsigned __int64 d=0, hlp; + int exp=0, sign=1; + const MSVCRT_wchar_t *p; + double ret; + + if(!str) { + MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0); + *MSVCRT__errno() = MSVCRT_EINVAL; + return 0; + } + + if(!locale) + locale = get_locale(); + + p = str; + while(isspaceW(*p)) + p++; + + if(*p == '-') { + sign = -1; + p++; + } else if(*p == '+') + p++; + + while(isdigitW(*p)) { + hlp = d*10+*(p++)-'0'; + if(d>MSVCRT_UI64_MAX/10 || hlplocinfo->lconv->decimal_point) + p++; + + while(isdigitW(*p)) { + hlp = d*10+*(p++)-'0'; + if(d>MSVCRT_UI64_MAX/10 || hlpINT_MAX/10 || (e=e*10+*p-'0')<0) + e = INT_MAX; + p++; + } + e *= s; + + if(exp<0 && e<0 && exp+e>=0) exp = INT_MIN; + else if(exp>0 && e>0 && exp+e<0) exp = INT_MAX; + else exp += e; + } else { + if(*p=='-' || *p=='+') + p--; + p--; + } + } + + if(exp>0) + ret = (double)sign*d*pow(10, exp); + else + ret = (double)sign*d/pow(10, -exp); + + if((d && ret==0.0) || isinf(ret)) + *MSVCRT__errno() = MSVCRT_ERANGE; + + if(end) + *end = (MSVCRT_wchar_t*)p; + + return ret; +} + /********************************************************************* * wcstod (MSVCRT.@) */