diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index 4c99c93..44a6bcd 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -606,7 +606,7 @@ public: parseResult_.Clear(); state_ = IterativeParsingStartState; } - + //! Parse one token from JSON text /*! \tparam InputStream Type of input stream, implementing Stream concept \tparam Handler Type of handler, implementing Handler concept. @@ -618,11 +618,11 @@ public: bool IterativeParseNext(InputStream& is, Handler& handler) { while (RAPIDJSON_LIKELY(is.Peek() != '\0')) { SkipWhitespaceAndComments(is); - + Token t = Tokenize(is.Peek()); IterativeParsingState n = Predict(state_, t); IterativeParsingState d = Transit(state_, t, n, is, handler); - + // If we've finished or hit an error... if (RAPIDJSON_UNLIKELY(IsIterativeParsingCompleteState(d))) { // Report errors. @@ -630,11 +630,11 @@ public: HandleError(state_, is); return false; } - + // Transition to the finish state. RAPIDJSON_ASSERT(d == IterativeParsingFinishState); state_ = d; - + // If StopWhenDone is not set... if (!(parseFlags & kParseStopWhenDoneFlag)) { // ... and extra non-whitespace data is found... @@ -645,11 +645,11 @@ public: return false; } } - + // Success! We are done! return true; } - + // Transition to the new state. state_ = d; @@ -657,7 +657,7 @@ public: if (!IsIterativeParsingDelimiterState(n)) return true; } - + // We reached the end of file. stack_.Clear(); @@ -665,10 +665,10 @@ public: HandleError(state_, is); return false; } - + return true; } - + //! Check if token-by-token parsing JSON text is complete /*! \return Whether the JSON has been fully decoded. */ @@ -1523,7 +1523,7 @@ private: } } } - + if (RAPIDJSON_UNLIKELY(!useNanOrInf)) { RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, s.Tell()); } @@ -1701,7 +1701,7 @@ private: d = internal::StrtodNormalPrecision(d, p); // Use > max, instead of == inf, to fix bogus warning -Wfloat-equal - if (d > std::numeric_limits::max()) { + if (d > (std::numeric_limits::max)()) { // Overflow // TODO: internal::StrtodX should report overflow (or underflow) RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, startOffset); @@ -1769,12 +1769,12 @@ private: // Single value state IterativeParsingValueState, - + // Delimiter states (at bottom) IterativeParsingElementDelimiterState, IterativeParsingMemberDelimiterState, IterativeParsingKeyValueDelimiterState, - + cIterativeParsingStateCount }; @@ -2167,43 +2167,43 @@ private: RAPIDJSON_FORCEINLINE bool IsIterativeParsingDelimiterState(IterativeParsingState s) const { return s >= IterativeParsingElementDelimiterState; } - + RAPIDJSON_FORCEINLINE bool IsIterativeParsingCompleteState(IterativeParsingState s) const { return s <= IterativeParsingErrorState; } - + template ParseResult IterativeParse(InputStream& is, Handler& handler) { parseResult_.Clear(); ClearStackOnExit scope(*this); IterativeParsingState state = IterativeParsingStartState; - + SkipWhitespaceAndComments(is); RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); while (is.Peek() != '\0') { Token t = Tokenize(is.Peek()); IterativeParsingState n = Predict(state, t); IterativeParsingState d = Transit(state, t, n, is, handler); - + if (d == IterativeParsingErrorState) { HandleError(state, is); break; } - + state = d; - + // Do not further consume streams if a root JSON has been parsed. if ((parseFlags & kParseStopWhenDoneFlag) && state == IterativeParsingFinishState) break; - + SkipWhitespaceAndComments(is); RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_); } - + // Handle the end of file. if (state != IterativeParsingFinishState) HandleError(state, is); - + return parseResult_; } diff --git a/test/unittest/itoatest.cpp b/test/unittest/itoatest.cpp index f41edeb..f7524b8 100644 --- a/test/unittest/itoatest.cpp +++ b/test/unittest/itoatest.cpp @@ -1,5 +1,5 @@ // Tencent is pleased to support the open source community by making RapidJSON available. -// +// // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. // // Licensed under the MIT License (the "License"); you may not use this file except @@ -7,9 +7,9 @@ // // http://opensource.org/licenses/MIT // -// Unless required by applicable law or agreed to in writing, software distributed -// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, either express or implied. See the License for the +// Unless required by applicable law or agreed to in writing, software distributed +// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See the License for the // specific language governing permissions and limitations under the License. #include "unittest.h" @@ -61,7 +61,7 @@ static void VerifyValue(T value, void(*f)(T, char*), char* (*g)(T, char*)) { f(value, buffer1); *g(value, buffer2) = '\0'; - + EXPECT_STREQ(buffer1, buffer2); } @@ -79,12 +79,12 @@ static void Verify(void(*f)(T, char*), char* (*g)(T, char*)) { do { VerifyValue(i - 1, f, g); VerifyValue(i, f, g); - if (std::numeric_limits::min() < 0) { + if ((std::numeric_limits::min)() < 0) { VerifyValue(Traits::Negate(i), f, g); VerifyValue(Traits::Negate(i + 1), f, g); } last = i; - if (i > static_cast(std::numeric_limits::max() / static_cast(power))) + if (i > static_cast((std::numeric_limits::max)() / static_cast(power))) break; i *= static_cast(power); } while (last < i); diff --git a/test/unittest/readertest.cpp b/test/unittest/readertest.cpp index 71ef6db..2de9bb6 100644 --- a/test/unittest/readertest.cpp +++ b/test/unittest/readertest.cpp @@ -422,7 +422,7 @@ static void TestParseDouble() { "67546703537516986049910576551282076245490090389328944075868508455133942" "30458323690322294816580855933212334827479782620414472316873817718091929" "9881250404026184124858368", - std::numeric_limits::max()); + (std::numeric_limits::max)()); TEST_DOUBLE(fullPrecision, "243546080556034731077856379609316893158278902575447060151047"