summaryrefslogtreecommitdiff
path: root/src/expr.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-05-12 04:32:02 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-05-12 04:32:02 -0400
commit5f1a858941adc17fcf714c7b6b176aeae727c436 (patch)
tree846efb794cb76fdc4c63fa4c6ab554b83af49f07 /src/expr.cc
parent7ca8149ec5c7fa88d98df83e6260210372223036 (diff)
parentcb047c013df0eaf1c5e9edd67bbb6b6fa537d2a0 (diff)
downloadfork-ledger-5f1a858941adc17fcf714c7b6b176aeae727c436.tar.gz
fork-ledger-5f1a858941adc17fcf714c7b6b176aeae727c436.tar.bz2
fork-ledger-5f1a858941adc17fcf714c7b6b176aeae727c436.zip
Merge branch 'next'
Diffstat (limited to 'src/expr.cc')
-rw-r--r--src/expr.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/expr.cc b/src/expr.cc
index 79fb3611..f3a30de6 100644
--- a/src/expr.cc
+++ b/src/expr.cc
@@ -39,10 +39,26 @@ 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 if (end_pos > start_pos) {
+ 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);
+ buf[end_pos - start_pos] = '\0';
+ set_text(buf.get());
+ }
+ else {
+ set_text("<stream>");
+ }
}
void expr_t::compile(scope_t& scope)