summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/filters.cc4
-rw-r--r--src/filters.h8
-rw-r--r--src/report.cc19
-rw-r--r--src/report.h16
4 files changed, 30 insertions, 17 deletions
diff --git a/src/filters.cc b/src/filters.cc
index 03063264..4ccdf66c 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -46,6 +46,8 @@ pass_down_xacts::pass_down_xacts(xact_handler_ptr handler,
for (xact_t * xact = iter(); xact; xact = iter())
item_handler<xact_t>::operator()(*xact);
+
+ item_handler<xact_t>::flush();
}
void truncate_entries::flush()
@@ -749,6 +751,8 @@ pass_down_accounts::pass_down_accounts(acct_handler_ptr handler,
for (account_t * account = iter(); account; account = iter())
if (pred(*account))
item_handler<account_t>::operator()(*account);
+
+ item_handler<account_t>::flush();
}
} // namespace ledger
diff --git a/src/filters.h b/src/filters.h
index eda50732..31c89b48 100644
--- a/src/filters.h
+++ b/src/filters.h
@@ -111,11 +111,11 @@ public:
}
virtual void flush();
+
virtual void operator()(xact_t& xact) {
- if (tail_count == 0 && head_count > 0 &&
- xacts.size() >= static_cast<unsigned int>(head_count))
- return;
- xacts.push_back(&xact);
+ if (! (tail_count == 0 && head_count > 0 &&
+ static_cast<int>(xacts.size()) >= head_count))
+ xacts.push_back(&xact);
}
};
diff --git a/src/report.cc b/src/report.cc
index 42a9b186..e0ee8c1a 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -305,7 +305,6 @@ void report_t::xacts_report(xact_handler_ptr handler)
{
session_xacts_iterator walker(session);
pass_down_xacts(chain_xact_handlers(handler), walker);
- handler->flush();
if (DO_VERIFY())
session.clean_xacts();
@@ -315,7 +314,6 @@ void report_t::entry_report(xact_handler_ptr handler, entry_t& entry)
{
entry_xacts_iterator walker(entry);
pass_down_xacts(chain_xact_handlers(handler), walker);
- handler->flush();
if (DO_VERIFY())
session.clean_xacts(entry);
@@ -341,7 +339,6 @@ void report_t::accounts_report(acct_handler_ptr handler)
sorted_accounts_iterator walker(*session.master, sort_string);
pass_down_accounts(handler, walker, expr_t("total"));
}
- handler->flush();
if (DO_VERIFY()) {
session.clean_xacts();
@@ -373,7 +370,7 @@ namespace {
#endif
std::ostringstream out;
- args[0].dump(out, *first_width, *latter_width);
+ args[0].strip_annotations().dump(out, *first_width, *latter_width);
return string_value(out.str());
}
}
@@ -409,6 +406,11 @@ expr_t::ptr_op_t report_t::lookup(const string& name)
return MAKE_FUNCTOR(report_t::option_format_);
break;
+ case 'h':
+ if (std::strcmp(p, "head_") == 0)
+ return MAKE_FUNCTOR(report_t::option_head_);
+ break;
+
case 'j':
if (! (*p + 1))
return MAKE_FUNCTOR(report_t::option_amount_data);
@@ -420,19 +422,22 @@ expr_t::ptr_op_t report_t::lookup(const string& name)
break;
case 'l':
- if (std::strcmp(p, "l_") || std::strcmp(p, "limit_"))
+ if (std::strcmp(p, "l_") == 0
+ || std::strcmp(p, "limit_") == 0)
return MAKE_FUNCTOR(report_t::option_limit_);
break;
case 't':
- if (std::strcmp(p, "t_"))
+ if (std::strcmp(p, "t_") == 0)
return MAKE_FUNCTOR(report_t::option_amount_);
else if (std::strcmp(p, "total_") == 0)
return MAKE_FUNCTOR(report_t::option_total_);
+ else if (std::strcmp(p, "tail_") == 0)
+ return MAKE_FUNCTOR(report_t::option_tail_);
break;
case 'T':
- if (std::strcmp(p, "T_"))
+ if (std::strcmp(p, "T_") == 0)
return MAKE_FUNCTOR(report_t::option_total_);
break;
}
diff --git a/src/report.h b/src/report.h
index 6142a289..ec4b194f 100644
--- a/src/report.h
+++ b/src/report.h
@@ -107,8 +107,8 @@ public:
unsigned long budget_flags;
- int head_entries;
- int tail_entries;
+ long head_entries;
+ long tail_entries;
bool show_collapsed;
bool show_subtotal;
@@ -424,15 +424,19 @@ public:
value_t option_wide(call_scope_t& args) { // w
config->register_format = config->wide_register_format;
}
+#endif
- value_t option_head(call_scope_t& args) { // :
- report->head_entries = std::atoi(optarg);
+ value_t option_head_(call_scope_t& args) { // :
+ head_entries = *var_t<long>(args, 0);
+ return true;
}
- value_t option_tail(call_scope_t& args) { // :
- report->tail_entries = std::atoi(optarg);
+ value_t option_tail_(call_scope_t& args) { // :
+ tail_entries = *var_t<long>(args, 0);
+ return true;
}
+#if 0
value_t option_pager(call_scope_t& args) { // :
config->pager = optarg;
}