From 9a05e1fd41854d250bca5a66d61ca1d1cf05faab Mon Sep 17 00:00:00 2001 From: Dave Belanger Date: Thu, 8 Apr 2004 19:48:19 +0000 Subject: [PATCH] wcstod: added exponent parsing and fixed handling of negative sign. --- dlls/msvcrt/wcs.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index 3ea853c32ed..3698ec4c5f2 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -20,6 +20,7 @@ */ #include #include +#include #include "msvcrt.h" #include "winnls.h" #include "wine/unicode.h" @@ -150,6 +151,32 @@ double MSVCRT_wcstod(const MSVCRT_wchar_t* lpszStr, MSVCRT_wchar_t** end) 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;