diff --git a/src/json.hpp b/src/json.hpp index 143ac5732..d61a52a36 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -8832,7 +8832,6 @@ basic_json_parser_63: T result = 0; const char *fst = st; - bool successful_parse = false; char cp = *fst; int exp = 0; // exponent { @@ -8841,7 +8840,6 @@ basic_json_parser_63: if (cp == '-' or cp == '+') { ++fst; - successful_parse = true; } // read in fractional part of number, until an 'e' is reached. @@ -8849,7 +8847,6 @@ basic_json_parser_63: while (nl_isdigit(cp = *fst)) { result = result * 10 + (cp - '0'); - successful_parse = true; ++fst; } @@ -8858,7 +8855,6 @@ basic_json_parser_63: while (nl_isdigit(cp = *++fst)) { result = result * 10 + (cp - '0'); - successful_parse = true; --exp; } } @@ -8874,7 +8870,7 @@ basic_json_parser_63: // if exponent is bogus (i.e. "1.234empty" or "1.234e+mpty") restore // bogus exponent back onto returned string (endptr). - if (successful_parse and (*fst == 'e' or *fst == 'E')) + if (*fst == 'e' or *fst == 'E') { cp = *++fst; bool negative_exp = cp == '-'; // read in exponent sign (+/-) @@ -8959,7 +8955,7 @@ skip_loop: if (endptr != nullptr) { - *endptr = const_cast(successful_parse ? fst : st); + *endptr = const_cast(fst); } return result; diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 4f29a79e2..389405872 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -8129,7 +8129,6 @@ class basic_json T result = 0; const char *fst = st; - bool successful_parse = false; char cp = *fst; int exp = 0; // exponent { @@ -8138,7 +8137,6 @@ class basic_json if (cp == '-' or cp == '+') { ++fst; - successful_parse = true; } // read in fractional part of number, until an 'e' is reached. @@ -8146,7 +8144,6 @@ class basic_json while (nl_isdigit(cp = *fst)) { result = result * 10 + (cp - '0'); - successful_parse = true; ++fst; } @@ -8155,7 +8152,6 @@ class basic_json while (nl_isdigit(cp = *++fst)) { result = result * 10 + (cp - '0'); - successful_parse = true; --exp; } } @@ -8171,7 +8167,7 @@ class basic_json // if exponent is bogus (i.e. "1.234empty" or "1.234e+mpty") restore // bogus exponent back onto returned string (endptr). - if (successful_parse and (*fst == 'e' or *fst == 'E')) + if (*fst == 'e' or *fst == 'E') { cp = *++fst; bool negative_exp = cp == '-'; // read in exponent sign (+/-) @@ -8256,7 +8252,7 @@ skip_loop: if (endptr != nullptr) { - *endptr = const_cast(successful_parse ? fst : st); + *endptr = const_cast(fst); } return result;