Skip to content

Commit

Permalink
fix: using stream operator not set eofbit
Browse files Browse the repository at this point in the history
  • Loading branch information
Night12138 committed Feb 12, 2022
1 parent 111c9be commit 087e00b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion picojson.h
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,12 @@ inline std::string parse(value &out, const std::string &s) {

inline std::string parse(value &out, std::istream &is) {
std::string err;
parse(out, std::istreambuf_iterator<char>(is.rdbuf()), std::istreambuf_iterator<char>(), &err);
const auto &beg = std::istreambuf_iterator<char>(is.rdbuf());
const auto &end = std::istreambuf_iterator<char>();
parse(out, beg, end, &err);
if (beg == end) {
is.setstate(std::ios_base::eofbit);
}
return err;
}

Expand Down

0 comments on commit 087e00b

Please sign in to comment.