print command correctly prints amount expressions
This commit is contained in:
parent
d0460b0692
commit
4028f0bcb4
2 changed files with 22 additions and 5 deletions
15
src/expr.cc
15
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)
|
||||
|
|
|
|||
12
src/print.cc
12
src/print.cc
|
|
@ -140,9 +140,15 @@ namespace {
|
|||
if (slip > 0)
|
||||
out << string(slip, ' ');
|
||||
|
||||
std::ostringstream amt_str;
|
||||
report.scrub(post->amount).print(amt_str, 12, -1, true);
|
||||
string amt = amt_str.str();
|
||||
string amt;
|
||||
if (post->amount_expr) {
|
||||
amt = post->amount_expr->text();
|
||||
} else {
|
||||
std::ostringstream amt_str;
|
||||
report.scrub(post->amount).print(amt_str, 12, -1, true);
|
||||
amt = amt_str.str();
|
||||
}
|
||||
|
||||
string trimmed_amt(amt);
|
||||
trim_left(trimmed_amt);
|
||||
int amt_slip = (static_cast<int>(amt.length()) -
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue