diff options
author | John Wiegley <johnw@newartisans.com> | 2012-05-15 00:22:00 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-05-15 00:22:00 -0600 |
commit | 72dd4d85bdd1f6da79dee405366311e6da96776b (patch) | |
tree | e3e0a0d6bb7bec06505965da4e845e12bbc63971 /src/token.cc | |
parent | 64a9b42381c26baf24e58b40f50f0b253e551811 (diff) | |
parent | 96172669053bbba7263a370f109f70615049a0c6 (diff) | |
download | fork-ledger-72dd4d85bdd1f6da79dee405366311e6da96776b.tar.gz fork-ledger-72dd4d85bdd1f6da79dee405366311e6da96776b.tar.bz2 fork-ledger-72dd4d85bdd1f6da79dee405366311e6da96776b.zip |
Merge branch 'release/v3.0.0-20120510'
Diffstat (limited to 'src/token.cc')
-rw-r--r-- | src/token.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/token.cc b/src/token.cc index e5d6b218..1392c29f 100644 --- a/src/token.cc +++ b/src/token.cc @@ -148,7 +148,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags) char c = peek_next_nonws(in); - if (in.eof()) { + if (in.eof() || c == -1) { kind = TOK_EOF; return; } @@ -417,16 +417,20 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags) if (! temp.parse(in, parse_flags.plus_flags(PARSE_SOFT_FAIL))) { in.clear(); in.seekg(pos, std::ios::beg); - if (in.fail()) + if (in.fail() || ! in.good()) throw_(parse_error, _("Failed to reset input stream")); c = static_cast<char>(in.peek()); - if (! std::isalpha(c) && c != '_') - expected('\0', c); + if (c != -1) { + if (! std::isalpha(c) && c != '_') + expected('\0', c); - parse_ident(in); + parse_ident(in); + } else { + throw_(parse_error, _("Unexpected EOF")); + } - if (value.as_string().length() == 0) { + if (! value.is_string() || value.as_string().empty()) { kind = ERROR; symbol[0] = c; symbol[1] = '\0'; |