diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-27 14:10:28 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-27 14:10:28 -0400 |
commit | afe3a899c6a6e2cdd01fcf55c5f8ce62a1ef8b8c (patch) | |
tree | 48dd1c78904302c7afaa3c19bb7e60b7f2ad6045 /src/filters.cc | |
parent | 0efe0c63ce285cc562933180a4a2b4ecb5a308b7 (diff) | |
download | fork-ledger-afe3a899c6a6e2cdd01fcf55c5f8ce62a1ef8b8c.tar.gz fork-ledger-afe3a899c6a6e2cdd01fcf55c5f8ce62a1ef8b8c.tar.bz2 fork-ledger-afe3a899c6a6e2cdd01fcf55c5f8ce62a1ef8b8c.zip |
Fixed the operation of --head and --tail
Diffstat (limited to 'src/filters.cc')
-rw-r--r-- | src/filters.cc | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/filters.cc b/src/filters.cc index 3071a951..ea3ed99d 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -61,22 +61,22 @@ void truncate_xacts::flush() if (! posts.size()) return; - xact_t * last_xact = (*posts.begin())->xact; + xact_t * xact = (*posts.begin())->xact; int l = 0; foreach (post_t * post, posts) - if (last_xact != post->xact) { + if (xact != post->xact) { l++; - last_xact = post->xact; + xact = post->xact; } l++; - last_xact = (*posts.begin())->xact; + xact = (*posts.begin())->xact; int i = 0; foreach (post_t * post, posts) { - if (last_xact != post->xact) { - last_xact = post->xact; + if (xact != post->xact) { + xact = post->xact; i++; } @@ -103,6 +103,21 @@ void truncate_xacts::flush() item_handler<post_t>::flush(); } +void truncate_xacts::operator()(post_t& post) +{ + if (last_xact != post.xact) { + if (last_xact) + xacts_seen++; + last_xact = post.xact; + } + + if (tail_count == 0 && head_count > 0 && + static_cast<int>(xacts_seen) >= head_count) + return; + + posts.push_back(&post); +} + void set_account_value::operator()(post_t& post) { account_t * acct = post.reported_account(); |