From 04fd1ae24c3be6f9d3400c55bce90c3fd743e96b Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 22 Feb 2009 03:14:58 -0400 Subject: Fixed the way values are justified for printing --- src/value.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/value.cc') diff --git a/src/value.cc b/src/value.cc index 7162a610..52760535 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1317,12 +1317,17 @@ value_t value_t::strip_annotations(const keep_details_t& what_to_keep) const void value_t::print(std::ostream& out, const int first_width, const int latter_width, + const bool right_justify, const optional& date_format) const { if (first_width > 0 && ! is_amount() && ! is_balance() && ! is_string()) { out.width(first_width); - out << std::left; + + if (right_justify) + out << std::right; + else + out << std::left; } switch (type()) { @@ -1355,17 +1360,17 @@ void value_t::print(std::ostream& out, case AMOUNT: { if (as_amount().is_zero()) { out.width(first_width); - out << std::right << 0L; + out << (right_justify ? std::right : std::left) << 0; } else { std::ostringstream buf; buf << as_amount(); - justify(out, buf.str(), first_width, true); + justify(out, buf.str(), first_width, right_justify); } break; } case STRING: - justify(out, as_string(), first_width); + justify(out, as_string(), first_width, right_justify); break; case MASK: @@ -1381,14 +1386,15 @@ void value_t::print(std::ostream& out, else out << ", "; - value.print(out, first_width, latter_width, date_format); + value.print(out, first_width, latter_width, right_justify, + date_format); } out << ')'; break; } case BALANCE: - as_balance().print(out, first_width, latter_width); + as_balance().print(out, first_width, latter_width, right_justify); break; case POINTER: -- cgit v1.2.3