From b5097ced2bf621c0bf9b79c9bcc85bb715ce6218 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 10 Apr 2004 10:52:14 +0000 Subject: [PATCH] *** empty log message *** --- amount.cc | 4 ++-- ledger.cc | 30 ++++++++++++------------------ 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/amount.cc b/amount.cc index 4d6a9754..6984d9bb 100644 --- a/amount.cc +++ b/amount.cc @@ -470,8 +470,8 @@ static void parse_number(mpz_t out, const std::string& number, else { static char buf[256]; - // The number is specified as the user desires, with the - // commodity telling us how to parse it. + // The number is specified as the user desires, with the commodity + // telling us how to parse it. std::memset(buf, '0', 255); std::strncpy(buf, num, std::strlen(num)); diff --git a/ledger.cc b/ledger.cc index 08edc278..cc295e04 100644 --- a/ledger.cc +++ b/ledger.cc @@ -44,12 +44,13 @@ void transaction::print(std::ostream& out, bool display_quantity, if (cost && display_quantity) { out << " "; - out.width(10); + out.width(12); std::string value = cost->as_str(true); if (! display_price) { int index = value.find('@'); - value = std::string(value, index - 1); + if (index != -1) + value = std::string(value, 0, index - 1); } out << std::right << value; } @@ -71,29 +72,23 @@ void entry::print(std::ostream& out, bool shortcut) const if (! code.empty()) out << '(' << code << ") "; if (! desc.empty()) - out << " " << desc; + out << desc; out << std::endl; - // jww (2003-10-11): Unspecified virtual transactions should not - // factor into the size computation. - - commodity * comm = NULL; - int size = 0; + commodity * comm = NULL; + int size = 0; for (std::list::const_iterator x = xacts.begin(); x != xacts.end(); x++) { - if ((*x)->is_virtual && ! (*x)->specified) + if ((*x)->is_virtual && ! (*x)->must_balance) continue; - if (! comm) { + if (! comm) comm = (*x)->cost->commdty(); - } - else if (comm != (*x)->cost->commdty()) { + else if (comm != (*x)->cost->commdty()) shortcut = false; - break; - } size++; } @@ -109,10 +104,9 @@ void entry::print(std::ostream& out, bool shortcut) const out << " "; - // jww (2003-10-03): If we are shortcutting, don't print the - // "per-unit price" of a commodity, if it is not necessary. - - (*x)->print(out, ! shortcut || x == xacts.begin()); + (*x)->print(out, (! shortcut || x == xacts.begin() || + ((*x)->is_virtual && ! (*x)->must_balance)), + size != 2); } out << std::endl;