Commit 117faee9 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Fix strtod and wcstod implementation.

parent 7492e773
......@@ -170,6 +170,8 @@ extern void msvcrt_free_signals(void);
extern unsigned msvcrt_create_io_inherit_block(WORD*, BYTE**);
extern unsigned int __cdecl _control87(unsigned int, unsigned int);
/* run-time error codes */
#define _RT_STACK 0
#define _RT_NULLPTR 1
......
......@@ -164,6 +164,7 @@ void CDECL MSVCRT__swab(char* src, char* dst, int len)
double CDECL MSVCRT_strtod_l( const char *str, char **end, MSVCRT__locale_t locale)
{
unsigned __int64 d=0, hlp;
unsigned fpcontrol;
int exp=0, sign=1;
const char *p;
double ret;
......@@ -249,11 +250,17 @@ double CDECL MSVCRT_strtod_l( const char *str, char **end, MSVCRT__locale_t loca
}
}
fpcontrol = _control87(0, 0);
_control87(MSVCRT__EM_DENORMAL|MSVCRT__EM_INVALID|MSVCRT__EM_ZERODIVIDE
|MSVCRT__EM_OVERFLOW|MSVCRT__EM_UNDERFLOW|MSVCRT__EM_INEXACT, 0xffffffff);
if(exp>0)
ret = (double)sign*d*pow(10, exp);
else
ret = (double)sign*d/pow(10, -exp);
_control87(fpcontrol, 0xffffffff);
if((d && ret==0.0) || isinf(ret))
*MSVCRT__errno() = MSVCRT_ERANGE;
......
......@@ -129,6 +129,7 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
MSVCRT__locale_t locale)
{
unsigned __int64 d=0, hlp;
unsigned fpcontrol;
int exp=0, sign=1;
const MSVCRT_wchar_t *p;
double ret;
......@@ -212,11 +213,17 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
}
}
fpcontrol = _control87(0, 0);
_control87(MSVCRT__EM_DENORMAL|MSVCRT__EM_INVALID|MSVCRT__EM_ZERODIVIDE
|MSVCRT__EM_OVERFLOW|MSVCRT__EM_UNDERFLOW|MSVCRT__EM_INEXACT, 0xffffffff);
if(exp>0)
ret = (double)sign*d*pow(10, exp);
else
ret = (double)sign*d/pow(10, -exp);
_control87(fpcontrol, 0xffffffff);
if((d && ret==0.0) || isinf(ret))
*MSVCRT__errno() = MSVCRT_ERANGE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment