summaryrefslogtreecommitdiff
path: root/src/token.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-04-28 05:24:29 -0500
committerJohn Wiegley <johnw@newartisans.com>2012-04-28 05:24:29 -0500
commit95c44609a4d39e4fd70e74ba9d1d5c0bb8896188 (patch)
treebe1c1ec614a80a0d3be712b043d75ed2ac254487 /src/token.cc
parent7b406922e96189c0bdfbf40cd9cefd6a5a7c1f8a (diff)
downloadfork-ledger-95c44609a4d39e4fd70e74ba9d1d5c0bb8896188.tar.gz
fork-ledger-95c44609a4d39e4fd70e74ba9d1d5c0bb8896188.tar.bz2
fork-ledger-95c44609a4d39e4fd70e74ba9d1d5c0bb8896188.zip
Made some of the value term parsing code more resilient
Diffstat (limited to 'src/token.cc')
-rw-r--r--src/token.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/token.cc b/src/token.cc
index e5d6b218..afe48b08 100644
--- a/src/token.cc
+++ b/src/token.cc
@@ -417,16 +417,18 @@ 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);
+ }
- if (value.as_string().length() == 0) {
+ if (! value.is_string() || value.as_string().empty()) {
kind = ERROR;
symbol[0] = c;
symbol[1] = '\0';