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/generate.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/generate.cc') diff --git a/src/generate.cc b/src/generate.cc index c1eb1d14..9b4c2ee7 100644 --- a/src/generate.cc +++ b/src/generate.cc @@ -171,10 +171,10 @@ void generate_posts_iterator::generate_commodity(std::ostream& out) generate_string(buf, six_gen(), true); comm = buf.str(); } - while (comm == "h" || comm == "m" || comm == "s" || - comm == "and" || comm == "div" || comm == "false" || - comm == "or" || comm == "not" || comm == "true" || - comm == "if" || comm == "else"); + while (comm == "h" || comm == "m" || comm == "s" || comm == "and" || + comm == "any" || comm == "all" || comm == "div" || + comm == "false" || comm == "or" || comm == "not" || + comm == "true" || comm == "if" || comm == "else"); out << comm; } -- cgit v1.2.3