Commit 695c9cb9 authored by abolz's avatar abolz

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

=D
parent 1d636de8
...@@ -19,7 +19,7 @@ ...@@ -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 ...@@ -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') {
......
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