Use C macros with the correct header instead of std::numeric_limits and static_cast

=D
This commit is contained in:
abolz 2018-06-15 14:06:14 +02:00
parent 1d636de81e
commit 695c9cb976

View File

@ -19,7 +19,7 @@
#include "biginteger.h" #include "biginteger.h"
#include "diyfp.h" #include "diyfp.h"
#include "pow10.h" #include "pow10.h"
#include <limits> #include <climits>
RAPIDJSON_NAMESPACE_BEGIN RAPIDJSON_NAMESPACE_BEGIN
namespace internal { namespace internal {
@ -230,18 +230,18 @@ inline double StrtodFullPrecision(double d, int p, const char* decimals, size_t
if (StrtodFast(d, p, &result)) if (StrtodFast(d, p, &result))
return result; return result;
RAPIDJSON_ASSERT(length <= std::numeric_limits<int>::max()); RAPIDJSON_ASSERT(length <= INT_MAX);
int dLen = static_cast<int>(length); int dLen = static_cast<int>(length);
RAPIDJSON_ASSERT(length >= decimalPosition); RAPIDJSON_ASSERT(length >= decimalPosition);
RAPIDJSON_ASSERT(length - decimalPosition <= std::numeric_limits<int>::max()); RAPIDJSON_ASSERT(length - decimalPosition <= INT_MAX);
int dExpAdjust = static_cast<int>(length - decimalPosition); int dExpAdjust = static_cast<int>(length - decimalPosition);
RAPIDJSON_ASSERT(exp >= std::numeric_limits<int>::min() + dExpAdjust); RAPIDJSON_ASSERT(exp >= INT_MIN + dExpAdjust);
int dExp = exp - dExpAdjust; int dExp = exp - dExpAdjust;
// Make sure length+dExp does not overflow // Make sure length+dExp does not overflow
RAPIDJSON_ASSERT(dExp <= std::numeric_limits<int>::max() - dLen); RAPIDJSON_ASSERT(dExp <= INT_MAX - dLen);
// Trim leading zeros // Trim leading zeros
while (dLen > 0 && *decimals == '0') { while (dLen > 0 && *decimals == '0') {