diff options
author | John Wiegley <johnw@newartisans.com> | 2010-05-07 23:16:45 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-05-07 23:16:45 -0400 |
commit | 4028f0bcb455ce4ea23c355b6a43dc6122447a78 (patch) | |
tree | e7e418087b150c03daa43662076fa8f03c6ea03b /src/expr.cc | |
parent | d0460b06924ce9a25953247ee1c6049d6d0a2d36 (diff) | |
download | fork-ledger-4028f0bcb455ce4ea23c355b6a43dc6122447a78.tar.gz fork-ledger-4028f0bcb455ce4ea23c355b6a43dc6122447a78.tar.bz2 fork-ledger-4028f0bcb455ce4ea23c355b6a43dc6122447a78.zip |
print command correctly prints amount expressions
Diffstat (limited to 'src/expr.cc')
-rw-r--r-- | src/expr.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/expr.cc b/src/expr.cc index 79fb3611..8fed2b14 100644 --- a/src/expr.cc +++ b/src/expr.cc @@ -39,10 +39,21 @@ namespace ledger { void expr_t::parse(std::istream& in, const parse_flags_t& flags, const optional<string>& original_string) { - base_type::parse(in, flags, original_string); - parser_t parser; + istream_pos_type start_pos = in.tellg(); ptr = parser.parse(in, flags, original_string); + istream_pos_type end_pos = in.tellg(); + + if (original_string) { + set_text(*original_string); + } else { + in.clear(); + in.seekg(start_pos, std::ios::beg); + scoped_array<char> buf + (new char[static_cast<std::size_t>(end_pos - start_pos) + 1]); + in.read(buf.get(), end_pos - start_pos); + set_text(buf.get()); + } } void expr_t::compile(scope_t& scope) |