summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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';