diff options
-rw-r--r-- | doc/ledger3.texi | 96 | ||||
-rw-r--r-- | src/amount.cc | 8 | ||||
-rw-r--r-- | src/annotate.cc | 4 | ||||
-rw-r--r-- | src/iterators.cc | 8 |
4 files changed, 84 insertions, 32 deletions
diff --git a/doc/ledger3.texi b/doc/ledger3.texi index a57d8376..c7613c0e 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -7857,48 +7857,100 @@ More complicated expressions are possible using: @table @code -@item NUM -A plain integer represents a commodity-less amount. - -@item @{AMOUNT@} -An amount in braces can be any kind of amount supported by ledger, +@item "amount == COMMODITY AMOUNT" +The amount can be any kind of amount supported by ledger, with or without a commodity. Use this for decimal values. @item /REGEX/ -@itemx W/REGEX/ +@itemx account =~ /REGEX/ A regular expression that matches against an account's full name. If a posting, this will match against the account affected by the posting. -@item //REGEX/ -@itemx p/REGEX/ +@item @@/REGEX/ +@itemx expr payee =~ /REGEX/ A regular expression that matches against a transaction's payee name. -@item ///REGEX/ -@itemx w/REGEX/ -A regular expression that matches against an account's base name. If -a posting, this will match against the account affected by the -posting. +@item %/REGEX/ +@itemx tag(REGEX) +A regular expression that matches against a transaction's tags. + +@itemx expr date =~ /REGEX/ +Useful for specifying a date in plain terms. For example, you could say +@samp{expr date =~ /2014/}. + + +@item expr comment =~ /REGEX/ +A regular expression that matches against a posting's comment field. This +searches only a posting's field, not the transaction's note or comment field. +For example, @samp{ledger reg "expr" "comment =~ /landline/"} will match: + +@smallexample +2014/1/29 Phone bill + Assets:Checking $50.00 + Expenses:Phone $-50.00 ; landline bill +@end smallexample + +but will not match: + +@smallexample +2014/1/29 Phone bill ; landline bill + ; landline bill + Assets:Checking $50.00 + Expenses:Phone $-50.00 +@end smallexample + +To match the latter, use @samp{ledger reg "expr" "note =~ /landline/"} +instead. + +@item expr note =~ /REGEX/ +A regular expression that matches against a transaction's note field. +This searches all comments in the transaction, including comments on +individual postings. Thus, @samp{ledger reg "expr" "note =~ /landline/"} will +match both all the three examples below: + +@smallexample +2014/1/29 Phone bill + Assets:Checking $50.00 + Expenses:Phone $-50.00 ; landline bill +@end smallexample + +@smallexample +2014/1/29 Phone bill ; landline bill + Assets:Checking $50.00 + Expenses:Phone $-50.00 +@end smallexample + +@smallexample +2014/1/29 Phone bill + ; landline bill + Assets:Checking $50.00 + Expenses:Phone $-50.00 +@end smallexample -@item c/REGEX/ -A regular expression that matches against the transaction code (the -text that occurs between parentheses before the payee). -@item e/REGEX/ -A regular expression that matches against a posting's note or -comment field. @item (EXPR) A sub-expression is nested in parenthesis. This can be useful passing more complicated arguments to functions, or for overriding the natural precedence order of operators. -@item [DATE] -Useful for specifying a date in plain terms. For example, you could say -@samp{[2004/06/01]}. + +@itemx expr base =~ /REGEX/ +A regular expression that matches against an account's base name. If +a posting, this will match against the account affected by the +posting. + +@itemx expr code =~ /REGEX/ +A regular expression that matches against the transaction code (the +text that occurs between parentheses before the payee). @end table +The @samp{query} command can be used to see how Ledger interprets your query. +This can be useful if you are not getting the results you expect. See +@pxref{Pre-Commands} for more. + @menu * Miscellaneous:: @end menu diff --git a/src/amount.cc b/src/amount.cc index 7bf4dfc6..5d74c22e 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -301,7 +301,7 @@ void amount_t::_copy(const amount_t& amt) quantity = new bigint_t(*amt.quantity); } else { quantity = amt.quantity; - DEBUG("amounts.refs", + DEBUG("amount.refs", quantity << " refc++, now " << (quantity->refc + 1)); quantity->refc++; } @@ -339,7 +339,7 @@ void amount_t::_release() { VERIFY(valid()); - DEBUG("amounts.refs", quantity << " refc--, now " << (quantity->refc - 1)); + DEBUG("amount.refs", quantity << " refc--, now " << (quantity->refc - 1)); if (--quantity->refc == 0) { if (quantity->has_flags(BIGINT_BULK_ALLOC)) @@ -928,7 +928,7 @@ void amount_t::annotate(const annotation_t& details) } assert(this_base); - DEBUG("amounts.commodities", "Annotating commodity for amount " + DEBUG("amount.commodities", "Annotating commodity for amount " << *this << std::endl << details); if (commodity_t * ann_comm = @@ -939,7 +939,7 @@ void amount_t::annotate(const annotation_t& details) assert(false); #endif - DEBUG("amounts.commodities", "Annotated amount is " << *this); + DEBUG("amount.commodities", "Annotated amount is " << *this); } bool amount_t::has_annotation() const diff --git a/src/annotate.cc b/src/annotate.cc index 0cb7a24e..89363dd5 100644 --- a/src/annotate.cc +++ b/src/annotate.cc @@ -187,8 +187,8 @@ void annotation_t::parse(std::istream& in) } while (true); #if DEBUG_ON - if (SHOW_DEBUG("amounts.commodities") && *this) { - DEBUG("amounts.commodities", + if (SHOW_DEBUG("amount.commodities") && *this) { + DEBUG("amount.commodities", "Parsed commodity annotations: " << std::endl << *this); } #endif diff --git a/src/iterators.cc b/src/iterators.cc index f02c5f04..fd6cde69 100644 --- a/src/iterators.cc +++ b/src/iterators.cc @@ -204,9 +204,9 @@ void sorted_accounts_iterator::push_back(account_t& account) compare_items<account_t>(sort_cmp)); #if DEBUG_ON - if (SHOW_DEBUG("accounts.sorted")) { + if (SHOW_DEBUG("account.sorted")) { foreach (account_t * acct, accounts_list.back()) - DEBUG("accounts.sorted", + DEBUG("account.sorted", "Account (flat): " << acct->fullname()); } #endif @@ -237,9 +237,9 @@ void sorted_accounts_iterator::sort_accounts(account_t& account, compare_items<account_t>(sort_cmp)); #if DEBUG_ON - if (SHOW_DEBUG("accounts.sorted")) { + if (SHOW_DEBUG("account.sorted")) { foreach (account_t * acct, deque) - DEBUG("accounts.sorted", "Account: " << acct->fullname()); + DEBUG("account.sorted", "Account: " << acct->fullname()); } #endif } |