Address the cpplint findings of the view's parser
The exponent of the overflow check is an std::int64_t instead of a long (runtime/int). Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 parent
154f240022
commit
ab49a7b1bf
1 file changed
+3
-3
@@ -12,7 +12,7 @@
|
|||||||
#include <algorithm> // find, find_if, max
|
#include <algorithm> // find, find_if, max
|
||||||
#include <array> // array
|
#include <array> // array
|
||||||
#include <cstddef> // size_t, ptrdiff_t
|
#include <cstddef> // size_t, ptrdiff_t
|
||||||
#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
|
#include <cstdint> // int64_t, uint8_t, uint16_t, uint32_t, uint64_t
|
||||||
#include <cstring> // memcmp, memcpy
|
#include <cstring> // memcmp, memcpy
|
||||||
#include <limits> // numeric_limits
|
#include <limits> // numeric_limits
|
||||||
#include <string> // string
|
#include <string> // string
|
||||||
@@ -892,7 +892,7 @@ indent_done:
|
|||||||
frac_digits = static_cast<std::size_t>(p - f0);
|
frac_digits = static_cast<std::size_t>(p - f0);
|
||||||
is_float = true;
|
is_float = true;
|
||||||
}
|
}
|
||||||
long exponent = 0;
|
std::int64_t exponent = 0;
|
||||||
if (p != e && (*p | 0x20) == 'e')
|
if (p != e && (*p | 0x20) == 'e')
|
||||||
{
|
{
|
||||||
++p;
|
++p;
|
||||||
@@ -947,7 +947,7 @@ indent_done:
|
|||||||
// parse() rejects floats that overflow; only numbers whose magnitude
|
// parse() rejects floats that overflow; only numbers whose magnitude
|
||||||
// could reach the largest FloatType (1e308 for double, 1e38 for
|
// could reach the largest FloatType (1e308 for double, 1e38 for
|
||||||
// float) need the conversion
|
// float) need the conversion
|
||||||
if (NLOHMANN_VIEW_UNLIKELY(static_cast<long>(int_digits) + exponent > std::numeric_limits<FloatType>::max_exponent10 - 8 && kind == value_t::number_float))
|
if (NLOHMANN_VIEW_UNLIKELY(static_cast<std::int64_t>(int_digits) + exponent > std::numeric_limits<FloatType>::max_exponent10 - 8 && kind == value_t::number_float))
|
||||||
{
|
{
|
||||||
if (builder::float_overflows(s, p))
|
if (builder::float_overflows(s, p))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user