wcstod: added exponent parsing and fixed handling of negative sign.

This commit is contained in:
Dave Belanger 2004-04-08 19:48:19 +00:00 committed by Alexandre Julliard
parent 70c4864e8c
commit 9a05e1fd41
1 changed files with 27 additions and 0 deletions

View File

@ -20,6 +20,7 @@
*/
#include <limits.h>
#include <stdio.h>
#include <math.h>
#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;