diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 69b4c107548..e12201e08ac 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -753,7 +753,7 @@ @ cdecl wcsrchr(wstr long) ntdll.wcsrchr @ cdecl wcsspn(wstr wstr) ntdll.wcsspn @ cdecl wcsstr(wstr wstr) ntdll.wcsstr -@ stub wcstod #(wstr ptr) +@ cdecl wcstod(wstr ptr) MSVCRT_wcstod @ cdecl wcstok(wstr wstr) ntdll.wcstok @ cdecl wcstol(wstr ptr long) ntdll.wcstol @ cdecl wcstombs(ptr ptr long) ntdll.wcstombs diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index 62462767706..3ea853c32ed 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -111,6 +111,52 @@ MSVCRT_wchar_t* _wcsset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c ) return ret; } +/********************************************************************* + * wcstod (MSVCRT.@) + */ +double 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 (end) + *end = (MSVCRT_wchar_t*)str; + + TRACE("returning %g\n", ret); + return ret; +} + /********************************************************************* * _vsnwprintf (MSVCRT.@) */