From 30b6acb0b012fe0bb37ced1e15dc3315812960d3 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Sat, 7 Sep 2013 09:38:13 +0200 Subject: Apply --time-colon option only to time commodities See #989 --- src/amount.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/amount.cc b/src/amount.cc index 4fe73546..6ff2f4dd 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -196,8 +196,8 @@ namespace { for (const char * p = buf; *p; p++) { if (*p == '.') { - if (commodity_t::time_colon_by_default || - (comm && comm->has_flags(COMMODITY_STYLE_TIME_COLON))) + if (("h" == comm->symbol() || "m" == comm->symbol()) && (commodity_t::time_colon_by_default || + (comm && comm->has_flags(COMMODITY_STYLE_TIME_COLON)))) out << ':'; else if (commodity_t::decimal_comma_by_default || (comm && comm->has_flags(COMMODITY_STYLE_DECIMAL_COMMA))) @@ -213,8 +213,8 @@ namespace { out << *p; if (integer_digits > 3 && --integer_digits % 3 == 0) { - if (commodity_t::time_colon_by_default || - (comm && comm->has_flags(COMMODITY_STYLE_TIME_COLON))) + if (("h" == comm->symbol() || "m" == comm->symbol()) && (commodity_t::time_colon_by_default || + (comm && comm->has_flags(COMMODITY_STYLE_TIME_COLON)))) out << ':'; else if (commodity_t::decimal_comma_by_default || (comm && comm->has_flags(COMMODITY_STYLE_DECIMAL_COMMA))) @@ -744,7 +744,7 @@ void amount_t::in_place_unreduce() } if (shifted) { - if ("h" == comm->symbol() && commodity_t::time_colon_by_default) { + if (("h" == comm->symbol() || "m" == comm->symbol()) && commodity_t::time_colon_by_default) { amount_t floored = tmp.floored(); amount_t precision = tmp - floored; if (precision < 0.0) { -- cgit v1.2.3 From d30c3fb869b8c4f7740eefec573fadedbe21b7d1 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 20 Sep 2013 00:54:21 -0500 Subject: Guard against a possible null value --- src/journal.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/journal.cc b/src/journal.cc index 3e2ecbea..7eeaabe8 100644 --- a/src/journal.cc +++ b/src/journal.cc @@ -151,7 +151,7 @@ account_t * journal_t::register_account(const string& name, post_t * post, // the payee indicates an account that should be used. if (result->name == _("Unknown")) { foreach (account_mapping_t& value, payees_for_unknown_accounts) { - if (value.first.match(post->xact->payee)) { + if (post && value.first.match(post->xact->payee)) { result = value.second; break; } -- cgit v1.2.3