summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/convert.cc8
-rw-r--r--src/draft.cc8
-rw-r--r--src/lookup.cc10
-rw-r--r--src/lookup.h7
4 files changed, 16 insertions, 17 deletions
diff --git a/src/convert.cc b/src/convert.cc
index 5d3f23fa..3a9a143d 100644
--- a/src/convert.cc
+++ b/src/convert.cc
@@ -121,14 +121,10 @@ value_t convert_command(call_scope_t& args)
}
else {
if (xact->posts.front()->account == NULL) {
- xacts_iterator xi;
- xi.xacts_i = current_xacts.begin();
- xi.xacts_end = current_xacts.end();
- xi.xacts_uninitialized = false;
-
// jww (2010-03-07): Bind this logic to an option: --auto-match
if (account_t * acct =
- lookup_probable_account(xact->payee, xi, bucket).second)
+ lookup_probable_account(xact->payee, current_xacts.rbegin(),
+ current_xacts.rend(), bucket).second)
xact->posts.front()->account = acct;
else
xact->posts.front()->account = unknown;
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<xact_t> 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;
diff --git a/src/lookup.cc b/src/lookup.cc
index 221397ca..28007d9a 100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -60,9 +60,10 @@ namespace {
}
std::pair<xact_t *, account_t *>
-lookup_probable_account(const string& ident,
- xacts_iterator& iter_func,
- account_t * ref_account)
+lookup_probable_account(const string& ident,
+ xacts_list::reverse_iterator iter,
+ xacts_list::reverse_iterator end,
+ account_t * ref_account)
{
scorecard_t scores;
@@ -83,7 +84,8 @@ lookup_probable_account(const string& ident,
" with reference account: " << ref_account->fullname());
#endif
- while (xact_t * xact = iter_func()) {
+ xact_t * xact;
+ while (iter != end && (xact = *iter++) != NULL) {
#if 0
// Only consider transactions from the last two years (jww (2010-03-07):
// make this an option)
diff --git a/src/lookup.h b/src/lookup.h
index 7776be80..8e83b84e 100644
--- a/src/lookup.h
+++ b/src/lookup.h
@@ -47,9 +47,10 @@
namespace ledger {
std::pair<xact_t *, account_t *>
-lookup_probable_account(const string& ident,
- xacts_iterator& iter_func,
- account_t * ref_account = NULL);
+lookup_probable_account(const string& ident,
+ xacts_list::reverse_iterator iter,
+ xacts_list::reverse_iterator end,
+ account_t * ref_account = NULL);
} // namespace ledger