From afe3a899c6a6e2cdd01fcf55c5f8ce62a1ef8b8c Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 27 Feb 2009 14:10:28 -0400 Subject: Fixed the operation of --head and --tail --- src/filters.cc | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/filters.cc') 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::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(xacts_seen) >= head_count) + return; + + posts.push_back(&post); +} + void set_account_value::operator()(post_t& post) { account_t * acct = post.reported_account(); -- cgit v1.2.3