From 4ec54b86f856c6e85446d065d2940b4244d71b8f Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 8 May 2010 02:06:06 -0400 Subject: Added any() and all() value expression macros any() matches an expression against every post in a transaction or account, and returns true if any of them are true. all() tests if all are true. For example: ledger -l 'account =~ /Expense/ & any(account =~ /MasterCard/)' reg This reports every posting affecting an Expense account (regex match), but only if some other posting in the same transaction affects the MasterCard account. Both functions also take a second boolean argument. If it is false, the "source" posting is not considered. For example: ledger -l 'any(/x/, false)' This matches any posting where a *different* posting in the same transaction contains the letter 'x'. --- src/commodity.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/commodity.cc') diff --git a/src/commodity.cc b/src/commodity.cc index e5f10e34..836a4269 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -428,7 +428,9 @@ namespace { { switch (buf[0]) { case 'a': - return std::strcmp(buf, "and") == 0; + return (std::strcmp(buf, "and") == 0 || + std::strcmp(buf, "any") == 0 || + std::strcmp(buf, "all") == 0); case 'd': return std::strcmp(buf, "div") == 0; case 'e': -- cgit v1.2.3