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
ecf3d642
Commit
ecf3d642
authored
Feb 23, 2017
by
StilesCrisis
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'nan-inf-parse-fix' into token-by-token-parsing
parents
bd4c282d
5e785d3d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
9 deletions
+22
-9
reader.h
include/rapidjson/reader.h
+18
-9
readertest.cpp
test/unittest/readertest.cpp
+4
-0
No files found.
include/rapidjson/reader.h
View file @
ecf3d642
...
...
@@ -1247,18 +1247,27 @@ private:
}
// Parse NaN or Infinity here
else
if
((
parseFlags
&
kParseNanAndInfFlag
)
&&
RAPIDJSON_LIKELY
((
s
.
Peek
()
==
'I'
||
s
.
Peek
()
==
'N'
)))
{
useNanOrInf
=
true
;
if
(
RAPIDJSON_LIKELY
(
Consume
(
s
,
'N'
)
&&
Consume
(
s
,
'a'
)
&&
Consume
(
s
,
'N'
)))
{
d
=
std
::
numeric_limits
<
double
>::
quiet_NaN
();
if
(
Consume
(
s
,
'N'
))
{
if
(
Consume
(
s
,
'a'
)
&&
Consume
(
s
,
'N'
))
{
d
=
std
::
numeric_limits
<
double
>::
quiet_NaN
();
useNanOrInf
=
true
;
}
}
else
if
(
RAPIDJSON_LIKELY
(
Consume
(
s
,
'I'
)
&&
Consume
(
s
,
'n'
)
&&
Consume
(
s
,
'f'
)))
{
d
=
(
minus
?
-
std
::
numeric_limits
<
double
>::
infinity
()
:
std
::
numeric_limits
<
double
>::
infinity
());
if
(
RAPIDJSON_UNLIKELY
(
s
.
Peek
()
==
'i'
&&
!
(
Consume
(
s
,
'i'
)
&&
Consume
(
s
,
'n'
)
&&
Consume
(
s
,
'i'
)
&&
Consume
(
s
,
't'
)
&&
Consume
(
s
,
'y'
))))
RAPIDJSON_PARSE_ERROR
(
kParseErrorValueInvalid
,
s
.
Tell
());
else
if
(
RAPIDJSON_LIKELY
(
Consume
(
s
,
'I'
)))
{
if
(
Consume
(
s
,
'n'
)
&&
Consume
(
s
,
'f'
))
{
d
=
(
minus
?
-
std
::
numeric_limits
<
double
>::
infinity
()
:
std
::
numeric_limits
<
double
>::
infinity
());
useNanOrInf
=
true
;
if
(
RAPIDJSON_UNLIKELY
(
s
.
Peek
()
==
'i'
&&
!
(
Consume
(
s
,
'i'
)
&&
Consume
(
s
,
'n'
)
&&
Consume
(
s
,
'i'
)
&&
Consume
(
s
,
't'
)
&&
Consume
(
s
,
'y'
))))
{
RAPIDJSON_PARSE_ERROR
(
kParseErrorValueInvalid
,
s
.
Tell
());
}
}
}
else
if
(
RAPIDJSON_UNLIKELY
(
!
useNanOrInf
))
{
RAPIDJSON_PARSE_ERROR
(
kParseErrorValueInvalid
,
s
.
Tell
());
}
}
else
RAPIDJSON_PARSE_ERROR
(
kParseErrorValueInvalid
,
s
.
Tell
());
...
...
test/unittest/readertest.cpp
View file @
ecf3d642
...
...
@@ -1877,6 +1877,10 @@ TEST(Reader, ParseNanAndInfinity) {
TEST_NAN_INF
(
"Infinity"
,
inf
);
TEST_NAN_INF
(
"-Inf"
,
-
inf
);
TEST_NAN_INF
(
"-Infinity"
,
-
inf
);
TEST_NAN_INF_ERROR
(
kParseErrorValueInvalid
,
"NInf"
,
1
);
TEST_NAN_INF_ERROR
(
kParseErrorValueInvalid
,
"NaInf"
,
2
);
TEST_NAN_INF_ERROR
(
kParseErrorValueInvalid
,
"INan"
,
1
);
TEST_NAN_INF_ERROR
(
kParseErrorValueInvalid
,
"InNan"
,
2
);
TEST_NAN_INF_ERROR
(
kParseErrorValueInvalid
,
"nan"
,
1
);
TEST_NAN_INF_ERROR
(
kParseErrorValueInvalid
,
"-nan"
,
1
);
TEST_NAN_INF_ERROR
(
kParseErrorValueInvalid
,
"NAN"
,
1
);
...
...
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