summaryrefslogtreecommitdiff
path: root/src/token.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2011-02-04 22:39:41 -0500
committerJohn Wiegley <johnw@newartisans.com>2011-02-04 22:39:41 -0500
commit2208ac1226bb3be82be550d465f08fc1dd7c1bae (patch)
tree35ac78b7e439263c24a14c1fe214fd5db61745f9 /src/token.cc
parente0c42ff44352b414e8a6ea3ba735afea98db6d18 (diff)
downloadfork-ledger-2208ac1226bb3be82be550d465f08fc1dd7c1bae.tar.gz
fork-ledger-2208ac1226bb3be82be550d465f08fc1dd7c1bae.tar.bz2
fork-ledger-2208ac1226bb3be82be550d465f08fc1dd7c1bae.zip
Fixes for compilation as C++0x code
Diffstat (limited to 'src/token.cc')
-rw-r--r--src/token.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/token.cc b/src/token.cc
index 199c3b3c..64a5e9f9 100644
--- a/src/token.cc
+++ b/src/token.cc
@@ -393,13 +393,17 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
// If not, rewind back to the beginning of the word to scan it
// again. If the result was -1, it means no identifier was scanned
// so we don't have to rewind.
- if (result == 0) {
+ if (result == 0 || ! in.good()) {
in.clear();
in.seekg(pos, std::ios::beg);
if (in.fail())
throw_(parse_error, _("Failed to reset input stream"));
}
+ assert(in.good());
+ assert(! in.eof());
+ assert(in.tellg() != -1);
+
// When in relaxed parsing mode, we want to migrate commodity flags
// so that any precision specified by the user updates the current
// maximum displayed precision.
@@ -452,6 +456,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
void expr_t::token_t::rewind(std::istream& in)
{
+ in.clear();
in.seekg(- int(length), std::ios::cur);
if (in.fail())
throw_(parse_error, _("Failed to rewind input stream"));