summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-17 20:32:14 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-17 20:32:14 -0400
commitbf8c4a74a146f6777b5ea57c9e8a1aea6b100951 (patch)
tree880d3d596a535e91897ea24a1d0b22bd228861d9
parent57ee0f1b7d5d8d528222e92a8fb128f008dff828 (diff)
downloadfork-ledger-bf8c4a74a146f6777b5ea57c9e8a1aea6b100951.tar.gz
fork-ledger-bf8c4a74a146f6777b5ea57c9e8a1aea6b100951.tar.bz2
fork-ledger-bf8c4a74a146f6777b5ea57c9e8a1aea6b100951.zip
small changes
-rw-r--r--config.cc2
-rw-r--r--valexpr.cc35
-rw-r--r--valexpr.h2
3 files changed, 15 insertions, 24 deletions
diff --git a/config.cc b/config.cc
index 275143c8..ddacbc32 100644
--- a/config.cc
+++ b/config.cc
@@ -176,7 +176,7 @@ OPT_BEGIN(end_date, "e:") {
OPT_BEGIN(current, "c") {
if (! config->predicate.empty())
config->predicate += "&";
- config->predicate += "(d<N)";
+ config->predicate += "(d<=N)";
} OPT_END(current);
OPT_BEGIN(cleared, "C") {
diff --git a/valexpr.cc b/valexpr.cc
index 9971bae7..febc47fe 100644
--- a/valexpr.cc
+++ b/valexpr.cc
@@ -144,10 +144,6 @@ void value_expr_t::compute(balance_t& result, const details_t& details) const
result = (unsigned int) now;
break;
- case TODAY:
- result = (unsigned int) now;
- break;
-
case CLEARED:
if (details.entry) {
result = details.entry->state == entry_t::CLEARED;
@@ -190,9 +186,7 @@ void value_expr_t::compute(balance_t& result, const details_t& details) const
break;
case DEPTH:
- if (details.xact)
- result = details.xact->account->depth - 1;
- else if (details.account)
+ if (details.account)
result = details.account->depth - 1;
break;
@@ -252,25 +246,21 @@ void value_expr_t::compute(balance_t& result, const details_t& details) const
assert(left);
left->compute(result, details);
- std::time_t moment = -1;
+ std::time_t moment = now;
if (right) {
switch (right->type) {
case DATE:
if (details.entry)
moment = details.entry->date;
- else
- moment = now;
break;
- case TODAY:
- moment = now;
+ case CONSTANT_T:
+ moment = right->constant_t;
break;
default:
throw compute_error("Invalid date passed to P(value,date)");
}
- } else {
- moment = now;
}
result = result.value(moment);
break;
@@ -315,9 +305,8 @@ void value_expr_t::compute(balance_t& result, const details_t& details) const
case O_GTE: {
assert(left);
assert(right);
- left->compute(result, details);
- balance_t temp = result;
- result = 0;
+ balance_t temp;
+ left->compute(temp, details);
right->compute(result, details);
switch (type) {
case O_EQ: result = temp == result; break;
@@ -336,9 +325,8 @@ void value_expr_t::compute(balance_t& result, const details_t& details) const
case O_DIV: {
assert(left);
assert(right);
- right->compute(result, details);
- balance_t temp = result;
- result = 0;
+ balance_t temp;
+ right->compute(temp, details);
left->compute(result, details);
switch (type) {
case O_ADD: result += temp; break;
@@ -390,10 +378,14 @@ value_expr_t * parse_value_term(std::istream& in)
in.get(c);
switch (c) {
// Basic terms
+ case 'N':
+ node = new value_expr_t(value_expr_t::CONSTANT_T);
+ node->constant_t = now;
+ break;
+
case 'a': node = new value_expr_t(value_expr_t::AMOUNT); break;
case 'c': node = new value_expr_t(value_expr_t::COST); break;
case 'd': node = new value_expr_t(value_expr_t::DATE); break;
- case 'N': node = new value_expr_t(value_expr_t::TODAY); break;
case 'X': node = new value_expr_t(value_expr_t::CLEARED); break;
case 'R': node = new value_expr_t(value_expr_t::REAL); break;
case 'n': node = new value_expr_t(value_expr_t::INDEX); break;
@@ -727,7 +719,6 @@ void dump_value_expr(std::ostream& out, const value_expr_t * node)
case value_expr_t::AMOUNT: out << "AMOUNT"; break;
case value_expr_t::COST: out << "COST"; break;
case value_expr_t::DATE: out << "DATE"; break;
- case value_expr_t::TODAY: out << "TODAY"; break;
case value_expr_t::CLEARED: out << "CLEARED"; break;
case value_expr_t::REAL: out << "REAL"; break;
case value_expr_t::INDEX: out << "INDEX"; break;
diff --git a/valexpr.h b/valexpr.h
index d6d590bc..0ecd3443 100644
--- a/valexpr.h
+++ b/valexpr.h
@@ -2,6 +2,7 @@
#define _EXPR_H
#include "ledger.h"
+#include "value.h"
#include "error.h"
namespace ledger {
@@ -49,7 +50,6 @@ struct value_expr_t
AMOUNT,
COST,
DATE,
- TODAY,
CLEARED,
REAL,
INDEX,