From 66ed9fc3dcf5cef4ed49ecb18a8ec3a8aba60773 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 7 Mar 2018 22:41:45 +0100 Subject: [PATCH] Minor fixes --- src/io/json.cpp | 16 +++++++++++----- tests/io/json_tests.cpp | 12 ++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/io/json.cpp b/src/io/json.cpp index 6230fd1..606fa85 100644 --- a/src/io/json.cpp +++ b/src/io/json.cpp @@ -32,6 +32,12 @@ namespace fc fc::string pretty_print( const fc::string& v, uint8_t indent ); } +#if __cplusplus > 201402L +#define FALLTHROUGH [[fallthrough]]; +#else +#define FALLTHROUGH +#endif + #define MAX_RECURSION_DEPTH 200 #include @@ -290,7 +296,7 @@ namespace fc if (dot) FC_THROW_EXCEPTION(parse_error_exception, "Can't parse a number with two decimal places"); dot = true; - [[fallthrough]]; + FALLTHROUGH case '0': case '1': case '2': @@ -320,7 +326,7 @@ namespace fc { // read error ends the loop } fc::string str = ss.str(); - if (str == "-." || str == ".") // check the obviously wrong things we could have encountered + if (str == "-." || str == "." || str == "-") // check the obviously wrong things we could have encountered FC_THROW_EXCEPTION(parse_error_exception, "Can't parse token \"${token}\" as a JSON numeric constant", ("token", str)); if( dot ) return @@ -443,7 +449,7 @@ namespace fc case 0: if( parser_type == fc::json::broken_nul_parser ) return variant(); - [[fallthrough]]; + FALLTHROUGH default: FC_THROW_EXCEPTION( parse_error_exception, "Unexpected char '${c}' in \"${s}\"", ("c", c)("s", stringFromToken(in)) ); @@ -591,7 +597,7 @@ namespace fc return; case variant::int64_type: if( format == json::stringify_large_ints_and_doubles && - v.as_int64() > 0xffffffff ) + ( v.as_int64() > 0xffffffff || v.as_int64() < -int64_t(0xffffffff) ) ) os << '"'<