Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
08b1a8a4
Unverified
Commit
08b1a8a4
authored
Sep 10, 2018
by
Milo Yip
Committed by
GitHub
Sep 10, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1302 from chwarr/min-max-guard
Guard against min/max being macros in reader.h
parents
81af404b
960b9cfd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
30 deletions
+30
-30
reader.h
include/rapidjson/reader.h
+22
-22
itoatest.cpp
test/unittest/itoatest.cpp
+7
-7
readertest.cpp
test/unittest/readertest.cpp
+1
-1
No files found.
include/rapidjson/reader.h
View file @
08b1a8a4
...
...
@@ -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
<
parseFlags
>
(
is
);
Token
t
=
Tokenize
(
is
.
Peek
());
IterativeParsingState
n
=
Predict
(
state_
,
t
);
IterativeParsingState
d
=
Transit
<
parseFlags
>
(
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
());
}
...
...
@@ -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
<
unsigned
parseFlags
,
typename
InputStream
,
typename
Handler
>
ParseResult
IterativeParse
(
InputStream
&
is
,
Handler
&
handler
)
{
parseResult_
.
Clear
();
ClearStackOnExit
scope
(
*
this
);
IterativeParsingState
state
=
IterativeParsingStartState
;
SkipWhitespaceAndComments
<
parseFlags
>
(
is
);
RAPIDJSON_PARSE_ERROR_EARLY_RETURN
(
parseResult_
);
while
(
is
.
Peek
()
!=
'\0'
)
{
Token
t
=
Tokenize
(
is
.
Peek
());
IterativeParsingState
n
=
Predict
(
state
,
t
);
IterativeParsingState
d
=
Transit
<
parseFlags
>
(
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
<
parseFlags
>
(
is
);
RAPIDJSON_PARSE_ERROR_EARLY_RETURN
(
parseResult_
);
}
// Handle the end of file.
if
(
state
!=
IterativeParsingFinishState
)
HandleError
(
state
,
is
);
return
parseResult_
;
}
...
...
test/unittest/itoatest.cpp
View file @
08b1a8a4
// 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
<
T
>
(
i
-
1
,
f
,
g
);
VerifyValue
<
T
>
(
i
,
f
,
g
);
if
(
std
::
numeric_limits
<
T
>::
min
()
<
0
)
{
if
(
(
std
::
numeric_limits
<
T
>::
min
)
()
<
0
)
{
VerifyValue
<
T
>
(
Traits
<
T
>::
Negate
(
i
),
f
,
g
);
VerifyValue
<
T
>
(
Traits
<
T
>::
Negate
(
i
+
1
),
f
,
g
);
}
last
=
i
;
if
(
i
>
static_cast
<
T
>
(
std
::
numeric_limits
<
T
>::
max
()
/
static_cast
<
T
>
(
power
)))
if
(
i
>
static_cast
<
T
>
(
(
std
::
numeric_limits
<
T
>::
max
)
()
/
static_cast
<
T
>
(
power
)))
break
;
i
*=
static_cast
<
T
>
(
power
);
}
while
(
last
<
i
);
...
...
test/unittest/readertest.cpp
View file @
08b1a8a4
...
...
@@ -422,7 +422,7 @@ static void TestParseDouble() {
"67546703537516986049910576551282076245490090389328944075868508455133942"
"30458323690322294816580855933212334827479782620414472316873817718091929"
"9881250404026184124858368"
,
std
::
numeric_limits
<
double
>::
max
());
(
std
::
numeric_limits
<
double
>::
max
)
());
TEST_DOUBLE
(
fullPrecision
,
"243546080556034731077856379609316893158278902575447060151047"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment