diff options
-rw-r--r-- | amount.cc | 19 | ||||
-rw-r--r-- | amount.h | 2 | ||||
-rw-r--r-- | balance.cc | 2 | ||||
-rw-r--r-- | config.cc | 8 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | format.cc | 7 | ||||
-rw-r--r-- | ledger.texi | 19 | ||||
-rw-r--r-- | main.cc | 10 |
8 files changed, 39 insertions, 32 deletions
@@ -585,15 +585,17 @@ amount_t amount_t::round(unsigned int prec) const } } -std::ostream& operator<<(std::ostream& out, const amount_t& amt) +std::ostream& operator<<(std::ostream& _out, const amount_t& amt) { + if (! amt.quantity) + return _out; + + std::ostringstream out; + mpz_t quotient; mpz_t rquotient; mpz_t remainder; - if (! amt.quantity) - return out; - mpz_init(quotient); mpz_init(rquotient); mpz_init(remainder); @@ -710,14 +712,9 @@ std::ostream& operator<<(std::ostream& out, const amount_t& amt) mpz_clear(rquotient); mpz_clear(remainder); - return out; -} + _out << out.str(); -amount_t::operator std::string() const -{ - std::ostringstream s; - s << *this; - return s.str(); + return _out; } void parse_quantity(std::istream& in, std::string& value) @@ -162,8 +162,6 @@ class amount_t negate(); } - operator std::string() const; - void parse(std::istream& in); void parse(const std::string& str) { std::istringstream stream(str); @@ -75,7 +75,7 @@ void balance_t::write(std::ostream& out, out.width(width); out.fill(' '); - out << std::right << std::string(**i); + out << std::right << **i; } if (first) { @@ -60,7 +60,7 @@ Basic options:\n\ --cache FILE use FILE as a binary cache when --file is not used\n\ -f, --file FILE read ledger data from FILE\n\ -o, --output FILE write output to FILE\n\ - -p, --set-price CONV specify a commodity conversion: \"COMM=AMOUNT\"\n\ + -z, --set-price CONV specify a commodity conversion: \"COMM=AMOUNT\"\n\ -a, --account NAME specify the default account (useful with QIF files)\n\n\ Report filtering:\n\ -b, --begin-date DATE set report begin date\n\ @@ -80,7 +80,7 @@ Output customization:\n\ -n, --collapse register: collapse entries with multiple transactions\n\ -s, --subtotal balance: show sub-accounts; register: show subtotals\n\ -S, --sort EXPR sort report according to the value expression EXPR\n\ - -z, --interval STR report by interval, based on interval expression STR\n\ + -p, --interval STR report by interval (period), based on STR\n\ --dow show a days-of-the-week report\n\ -W, --weekly show weekly sub-totals\n\ -M, --monthly show monthly sub-totals\n\ @@ -149,7 +149,7 @@ OPT_BEGIN(output, "o:") { config->output_file = optarg; } OPT_END(output); -OPT_BEGIN(set_price, "p:") { +OPT_BEGIN(set_price, "z:") { if (std::strchr(optarg, '=')) config->price_settings.push_back(optarg); else @@ -260,7 +260,7 @@ OPT_BEGIN(related, "r") { config->show_related = true; } OPT_END(related); -OPT_BEGIN(interval, "z:") { +OPT_BEGIN(interval, "p:") { config->interval_text = optarg; } OPT_END(interval); diff --git a/configure.ac b/configure.ac index 8fe779ab..c5f319f1 100644 --- a/configure.ac +++ b/configure.ac @@ -13,8 +13,8 @@ AC_PROG_MAKE_SET AC_PROG_RANLIB # Checks for libraries. -AC_CHECK_LIB([gmp], [__gmpz_add]) -AC_CHECK_LIB([pcre], [pcre_compile]) +AC_CHECK_LIB([gmp], [__gmpz_add],, [AC_MSG_FAILURE("Could not find libgmp!")]) +AC_CHECK_LIB([pcre], [pcre_compile],, [AC_MSG_FAILURE("Could not find libpcre!")]) AC_CHECK_LIB([xmlparse], [XML_ParserCreate]) # Checks for header files. @@ -223,7 +223,7 @@ void format_t::format_elements(std::ostream& out, out << *((unsigned int *) value.data); break; case value_t::AMOUNT: - out << std::string(*((amount_t *) value.data)); + out << *((amount_t *) value.data); break; case value_t::BALANCE: ((balance_t *) value.data)->write(out, elem->min_width, @@ -337,8 +337,9 @@ void format_t::format_elements(std::ostream& out, } if (! use_disp) - disp = std::string(details.xact->amount); - out << disp; + out << details.xact->amount; + else + out << disp; // jww (2004-07-31): this should be handled differently if (! details.xact->note.empty()) diff --git a/ledger.texi b/ledger.texi index 7bc0d8cf..6085999c 100644 --- a/ledger.texi +++ b/ledger.texi @@ -336,9 +336,8 @@ your init file. entries on or after @samp{DATE}. Only entries after that date will be calculated, which means that the running total in the balance report will always start at zero with the first matching entry. (Note: This -is different from using @samp{--display} to constrain the entries -displayed, in which case the running total includes the undisplayed -entries). +is different from using @samp{--display} to constrain what is +displayed). @sp 1 @@ -446,9 +445,19 @@ transaction that matched. @sp 1 -@samp{--limit EXPR} (@samp{-l EXPR}) +@samp{--limit EXPR} (@samp{-l EXPR}) limits which transactions take +part in the calculations of a report. -@samp{--display EXPR} (@samp{-d EXPR}) +@samp{--display EXPR} (@samp{-d EXPR}) limits which transactions or +accounts or actually displayed in a report. They might still be +calculated, and be part of the running total of a register report, for +example, but they will not be displayed. This is useful for seeing +last month's checking transactions, against a running balance that +includes all past transactions: + +@example +ledger -d "d>=[2004/8]" reg checking +@end example @sp 1 @@ -500,8 +500,9 @@ int main(int argc, char * argv[], char * envp[]) // filter_transactions will only pass through transactions // matching the `display_predicate'. - formatter.reset(new filter_transactions(formatter.release(), - config->display_predicate)); + if (! config->display_predicate.empty()) + formatter.reset(new filter_transactions(formatter.release(), + config->display_predicate)); // calc_transactions computes the running total. When this // appears will determine, for example, whether filtered @@ -560,8 +561,9 @@ int main(int argc, char * argv[], char * envp[]) // This filter_transactions will only pass through transactions // matching the `predicate'. - formatter.reset(new filter_transactions(formatter.release(), - config->predicate)); + if (! config->predicate.empty()) + formatter.reset(new filter_transactions(formatter.release(), + config->predicate)); // Once the filters are chained, walk `journal's entries and start // feeding each transaction that matches `predicate' to the chain. |