summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-06-27 01:45:31 +0100
committerJohn Wiegley <johnw@newartisans.com>2009-06-27 01:45:31 +0100
commit7b0559569986545b31a925ccb826c0ea1ca4690f (patch)
tree365821ba2d4737c2adac6d152a399e4605ae3f6d /src
parentbf30f989f6c661d5e7ac3a41984cf7d98ed50913 (diff)
downloadfork-ledger-7b0559569986545b31a925ccb826c0ea1ca4690f.tar.gz
fork-ledger-7b0559569986545b31a925ccb826c0ea1ca4690f.tar.bz2
fork-ledger-7b0559569986545b31a925ccb826c0ea1ca4690f.zip
Improved usefulness of the "print --anon" output
Diffstat (limited to 'src')
-rw-r--r--src/filters.cc27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/filters.cc b/src/filters.cc
index 7c27a710..967e0843 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -142,6 +142,7 @@ namespace {
buf.width(8);
buf.fill('0');
buf << std::hex << message_digest[i];
+ break; // only output the first dword
}
return buf.str();
}
@@ -175,13 +176,31 @@ void anonymize_posts::operator()(post_t& post)
post_t& temp = post_temps.back();
temp.xact = &xact;
- sha.Reset();
- sha << post.account->fullname().c_str();
- sha.Result(message_digest);
+ std::list<string> account_names;
+ account_t * new_account = NULL;
+
+ for (account_t * acct = post.account;
+ acct;
+ acct = acct->parent) {
+ if (! acct->parent) {
+ new_account = acct;
+ break;
+ }
+
+ sha.Reset();
+ sha << acct->name.c_str();
+ sha.Result(message_digest);
+
+ account_names.push_front(to_hex(message_digest));
+ }
+ assert(new_account);
+
+ foreach (const string& name, account_names)
+ new_account = new_account->find_account(name);
temp.copy_details(post);
- temp.account = post.xact->journal->find_account(to_hex(message_digest));
+ temp.account = new_account;
temp.note = none;
temp.add_flags(ITEM_TEMP);