Core: CParser overflow checks FP Win32 #541

git-svn-id: svn://ultimatepp.org/upp/trunk@6469 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2013-10-23 05:47:29 +00:00
parent d52d87d669
commit 140aeb8b79

View file

@ -236,10 +236,11 @@ uint64 CParser::ReadNumber64(int base) throw(Error)
double CParser::ReadDouble() throw(Error)
{
LTIMING("ReadDouble");
#ifdef PLATFORM_POSIX
#ifdef FE_OVERFLOW
feclearexcept(FE_OVERFLOW);
#ifdef PLARFORM_WIN32
_clearfp();
#endif
#if defined(PLATFORM_POSIX) && defined(FE_OVERFLOW)
feclearexcept(FE_OVERFLOW);
#endif
int sign = Sgn();
if(!IsDigit(*term))
@ -258,11 +259,15 @@ double CParser::ReadDouble() throw(Error)
n *= pow(10.0, ReadInt());
DoSpaces();
n = sign * n;
#ifdef PLATFORM_POSIX
#ifdef FE_OVERFLOW
if(fetestexcept(FE_OVERFLOW))
#ifdef PLATFORM_WIN32
if(_clearfp() & SW_OVERFLOW)
ThrowError("number is too big");
#endif
#if defined(PLATFORM_POSIX) && defined(FE_OVERFLOW)
if(fetestexcept(FE_OVERFLOW)) {
ThrowError("number is too big");
feclearexcept(FE_OVERFLOW);
}
#endif
return n;
}