Improved detection of iostream's eof() condition
This commit is contained in:
parent
32eaa03469
commit
9617266905
2 changed files with 4 additions and 2 deletions
|
|
@ -87,7 +87,7 @@ char * csv_reader::next_line(std::istream& in)
|
||||||
while (in.good() && ! in.eof() && in.peek() == '#')
|
while (in.good() && ! in.eof() && in.peek() == '#')
|
||||||
in.getline(context.linebuf, parse_context_t::MAX_LINE);
|
in.getline(context.linebuf, parse_context_t::MAX_LINE);
|
||||||
|
|
||||||
if (! in.good() || in.eof())
|
if (! in.good() || in.eof() || in.peek() == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
in.getline(context.linebuf, parse_context_t::MAX_LINE);
|
in.getline(context.linebuf, parse_context_t::MAX_LINE);
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags)
|
||||||
|
|
||||||
char c = peek_next_nonws(in);
|
char c = peek_next_nonws(in);
|
||||||
|
|
||||||
if (in.eof()) {
|
if (in.eof() || c == -1) {
|
||||||
kind = TOK_EOF;
|
kind = TOK_EOF;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -426,6 +426,8 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags)
|
||||||
expected('\0', c);
|
expected('\0', c);
|
||||||
|
|
||||||
parse_ident(in);
|
parse_ident(in);
|
||||||
|
} else {
|
||||||
|
throw_(parse_error, _("Unexpected EOF"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! value.is_string() || value.as_string().empty()) {
|
if (! value.is_string() || value.as_string().empty()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue