summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2005-02-15 00:45:30 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:00 -0400
commitd0997fa821557eaf65c9137d0b8adc0f231dc2f2 (patch)
treee5225bc39679859a7b93ddbd95666a8af345a874
parent547be3056d652726699a2a4fcd656495c3a53c07 (diff)
downloadfork-ledger-d0997fa821557eaf65c9137d0b8adc0f231dc2f2.tar.gz
fork-ledger-d0997fa821557eaf65c9137d0b8adc0f231dc2f2.tar.bz2
fork-ledger-d0997fa821557eaf65c9137d0b8adc0f231dc2f2.zip
Changed truncate_entries so that --head and --tail can be used at the
same time.
-rw-r--r--main.cc4
-rw-r--r--walk.cc14
-rw-r--r--walk.h8
3 files changed, 13 insertions, 13 deletions
diff --git a/main.cc b/main.cc
index 908b05b4..6bd1201f 100644
--- a/main.cc
+++ b/main.cc
@@ -78,9 +78,7 @@ chain_xact_handlers(const std::string& command,
if (config.head_entries || config.tail_entries)
ptrs.push_back(formatter =
new truncate_entries(formatter,
- config.head_entries ?
- config.head_entries :
- config.tail_entries,
+ config.head_entries,
config.tail_entries));
// filter_transactions will only pass through transactions
diff --git a/walk.cc b/walk.cc
index a402ebf5..9381daa6 100644
--- a/walk.cc
+++ b/walk.cc
@@ -85,18 +85,20 @@ void truncate_entries::flush()
}
bool print = false;
- if (tailwise) {
- if (count > 0 && l - i <= count)
- print = true;
- else if (count < 0 && l - i > - count)
- print = true;
- } else {
+ if (head_count) {
if (count > 0 && i < count)
print = true;
else if (count < 0 && i >= - count)
print = true;
}
+ if (! print && tail_count) {
+ if (count > 0 && l - i <= count)
+ print = true;
+ else if (count < 0 && l - i > - count)
+ print = true;
+ }
+
if (print)
item_handler<transaction_t>::operator()(**x);
}
diff --git a/walk.h b/walk.h
index c8e15a88..2896b28b 100644
--- a/walk.h
+++ b/walk.h
@@ -147,16 +147,16 @@ class ignore_transactions : public item_handler<transaction_t>
class truncate_entries : public item_handler<transaction_t>
{
- int count;
- bool tailwise;
+ int head_count;
+ int tail_count;
transactions_list xacts;
public:
truncate_entries(item_handler<transaction_t> * handler,
- int _count, bool _tailwise = false)
+ int _head_count, int _tail_count)
: item_handler<transaction_t>(handler),
- count(_count), tailwise(_tailwise) {}
+ head_count(_head_count), tail_count(_tail_count) {}
virtual void flush();
virtual void operator()(transaction_t& xact) {