From 966b6fc359bacad6b22e79fd5afbec0ea80e8d6a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 19 Jul 2011 23:29:31 -0500 Subject: Lookup probable accounts in reverse historical order Fixes #510 --- src/draft.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/draft.cc') diff --git a/src/draft.cc b/src/draft.cc index ba78fc42..ca2d35df 100644 --- a/src/draft.cc +++ b/src/draft.cc @@ -245,12 +245,12 @@ xact_t * draft_t::insert(journal_t& journal) if (tmpl->payee_mask.empty()) throw std::runtime_error(_("'xact' command requires at least a payee")); - xact_t * matching = NULL; - + xact_t * matching = NULL; std::auto_ptr added(new xact_t); - xacts_iterator xi(journal); - if (xact_t * xact = lookup_probable_account(tmpl->payee_mask.str(), xi).first) { + if (xact_t * xact = + lookup_probable_account(tmpl->payee_mask.str(), journal.xacts.rbegin(), + journal.xacts.rend()).first) { DEBUG("draft.xact", "Found payee by lookup: transaction on line " << xact->pos->beg_line); matching = xact; -- cgit v1.2.3 From add6f6ca2a711e3337f83bd15be5a03e22842591 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 18 Aug 2011 14:46:36 -0400 Subject: Removed unused variables --- src/amount.cc | 6 +----- src/draft.cc | 10 ---------- src/filters.cc | 2 -- src/query.cc | 1 - src/report.cc | 6 ++++-- src/textual.cc | 6 ++---- src/times.cc | 5 +---- 7 files changed, 8 insertions(+), 28 deletions(-) (limited to 'src/draft.cc') diff --git a/src/amount.cc b/src/amount.cc index 1dc160cc..bc7e9918 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -1049,16 +1049,12 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags) // Create the commodity if has not already been seen, and update the // precision if something greater was used for the quantity. - bool newly_created = false; - if (symbol.empty()) { commodity_ = NULL; } else { commodity_ = commodity_pool_t::current_pool->find(symbol); - if (! commodity_) { + if (! commodity_) commodity_ = commodity_pool_t::current_pool->create(symbol); - newly_created = true; - } assert(commodity_); if (details) diff --git a/src/draft.cc b/src/draft.cc index ca2d35df..0cce1d5d 100644 --- a/src/draft.cc +++ b/src/draft.cc @@ -66,16 +66,6 @@ void draft_t::xact_template_t::dump(std::ostream& out) const << _("") << std::endl; } else { - bool has_only_from = true; - bool has_only_to = true; - - foreach (const post_template_t& post, posts) { - if (post.from) - has_only_to = false; - else - has_only_from = false; - } - foreach (const post_template_t& post, posts) { straccstream accum; out << std::endl diff --git a/src/filters.cc b/src/filters.cc index b7e96366..a08e5d25 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -916,8 +916,6 @@ void interval_posts::report_subtotal(const date_interval_t& interval) void interval_posts::operator()(post_t& post) { - date_t date = post.date(); - if (! interval.find_period(post.date())) return; diff --git a/src/query.cc b/src/query.cc index 2a29a1e7..b93c6534 100644 --- a/src/query.cc +++ b/src/query.cc @@ -127,7 +127,6 @@ query_t::lexer_t::token_t query_t::lexer_t::next_token() // fall through... default: { string ident; - string::const_iterator beg = arg_i; for (; arg_i != arg_end; ++arg_i) { switch (*arg_i) { case '\0': diff --git a/src/report.cc b/src/report.cc index 91b9025d..473308a0 100644 --- a/src/report.cc +++ b/src/report.cc @@ -657,7 +657,8 @@ value_t report_t::fn_quoted(call_scope_t& args) std::ostringstream out; out << '"'; - foreach (const char ch, args.get(0)) { + string arg(args.get(0)); + foreach (const char ch, arg) { if (ch == '"') out << "\\\""; else @@ -672,7 +673,8 @@ value_t report_t::fn_join(call_scope_t& args) { std::ostringstream out; - foreach (const char ch, args.get(0)) { + string arg(args.get(0)); + foreach (const char ch, arg) { if (ch != '\n') out << ch; else diff --git a/src/textual.cc b/src/textual.cc index 6dd0caa6..ecdf53d4 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -1165,11 +1165,7 @@ post_t * instance_t::parse_post(char * line, // Parse the optional amount - bool saw_amount = false; - if (next && *next && (*next != ';' && *next != '=')) { - saw_amount = true; - beg = next - line; ptristream stream(next, len - beg); @@ -1569,6 +1565,7 @@ xact_t * instance_t::parse_xact(char * line, } } +#if 0 if (xact->_state == item_t::UNCLEARED) { item_t::state_t result = item_t::CLEARED; @@ -1582,6 +1579,7 @@ xact_t * instance_t::parse_xact(char * line, } } } +#endif xact->pos->end_pos = curr_pos; xact->pos->end_line = linenum; diff --git a/src/times.cc b/src/times.cc index 5249c11c..851da938 100644 --- a/src/times.cc +++ b/src/times.cc @@ -709,12 +709,9 @@ void date_parser_t::determine_when(date_parser_t::lexer_t::token_t& tok, when += gregorian::years(amount * adjust); break; case lexer_t::token_t::TOK_QUARTER: - case lexer_t::token_t::TOK_QUARTERS: { - date_t temp = - date_duration_t::find_nearest(today, date_duration_t::QUARTERS); + case lexer_t::token_t::TOK_QUARTERS: when += gregorian::months(amount * 3 * adjust); break; - } case lexer_t::token_t::TOK_MONTH: case lexer_t::token_t::TOK_MONTHS: when += gregorian::months(amount * adjust); -- cgit v1.2.3