Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
35829928
Unverified
Commit
35829928
authored
Nov 09, 2018
by
Niels Lohmann
Committed by
GitHub
Nov 09, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1343 from mefyl/develop
Set eofbit on exhausted input stream.
parents
f86090aa
aa103826
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
include/nlohmann/detail/input/input_adapters.hpp
include/nlohmann/detail/input/input_adapters.hpp
+7
-3
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+7
-3
test/src/unit-regression.cpp
test/src/unit-regression.cpp
+13
-0
No files found.
include/nlohmann/detail/input/input_adapters.hpp
View file @
35829928
...
...
@@ -60,8 +60,8 @@ class input_stream_adapter : public input_adapter_protocol
~
input_stream_adapter
()
override
{
// clear stream flags; we use underlying streambuf I/O, do not
// maintain ifstream flags
is
.
clear
();
// maintain ifstream flags
, except eof
is
.
clear
(
is
.
rdstate
()
&
std
::
ios
::
eofbit
);
}
explicit
input_stream_adapter
(
std
::
istream
&
i
)
...
...
@@ -79,7 +79,11 @@ class input_stream_adapter : public input_adapter_protocol
// end up as the same value, eg. 0xFFFFFFFF.
std
::
char_traits
<
char
>::
int_type
get_character
()
override
{
return
sb
.
sbumpc
();
auto
res
=
sb
.
sbumpc
();
// set eof manually, as we don't use the istream interface.
if
(
res
==
EOF
)
is
.
clear
(
is
.
rdstate
()
|
std
::
ios
::
eofbit
);
return
res
;
}
private:
...
...
single_include/nlohmann/json.hpp
View file @
35829928
...
...
@@ -2109,8 +2109,8 @@ class input_stream_adapter : public input_adapter_protocol
~
input_stream_adapter
()
override
{
// clear stream flags; we use underlying streambuf I/O, do not
// maintain ifstream flags
is
.
clear
();
// maintain ifstream flags
, except eof
is
.
clear
(
is
.
rdstate
()
&
std
::
ios
::
eofbit
);
}
explicit
input_stream_adapter
(
std
::
istream
&
i
)
...
...
@@ -2128,7 +2128,11 @@ class input_stream_adapter : public input_adapter_protocol
// end up as the same value, eg. 0xFFFFFFFF.
std
::
char_traits
<
char
>::
int_type
get_character
()
override
{
return
sb
.
sbumpc
();
auto
res
=
sb
.
sbumpc
();
// set eof manually, as we don't use the istream interface.
if
(
res
==
EOF
)
is
.
clear
(
is
.
rdstate
()
|
std
::
ios
::
eofbit
);
return
res
;
}
private:
...
...
test/src/unit-regression.cpp
View file @
35829928
...
...
@@ -1708,3 +1708,16 @@ TEST_CASE("regression tests")
CHECK
(
expected
==
data
);
}
}
TEST_CASE
(
"regression tests, exceptions dependent"
,
"[!throws]"
)
{
SECTION
(
"issue #1340 - eof not set on exhausted input stream"
)
{
std
::
stringstream
s
(
"{}{}"
);
json
j
;
s
>>
j
;
s
>>
j
;
CHECK_THROWS_AS
(
s
>>
j
,
json
::
parse_error
const
&
);
CHECK
(
s
.
eof
());
}
}
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