summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-07-23 19:40:01 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-07-23 19:40:01 -0400
commit7409b050bee226fb7bb0b89a10d9c206d8797d70 (patch)
tree75c1e96e8b8dfc1bbfe0123eb6521b4b88d391fc
parent90af21852458919a08420e86542a2ab2283cd4e9 (diff)
downloadfork-ledger-7409b050bee226fb7bb0b89a10d9c206d8797d70.tar.gz
fork-ledger-7409b050bee226fb7bb0b89a10d9c206d8797d70.tar.bz2
fork-ledger-7409b050bee226fb7bb0b89a10d9c206d8797d70.zip
More fixes to restore parsing capability.
-rw-r--r--textual.cc36
-rw-r--r--valexpr.h2
2 files changed, 22 insertions, 16 deletions
diff --git a/textual.cc b/textual.cc
index 2d3bff0a..f89da45f 100644
--- a/textual.cc
+++ b/textual.cc
@@ -62,21 +62,23 @@ namespace {
}
#endif
- if (! expr::compute_amount(expr, amount, xact))
- throw new parse_error("Amount expression failed to compute");
+ if (expr) {
+ if (! expr::compute_amount(expr, amount, xact))
+ throw new parse_error("Amount expression failed to compute");
#if 0
- if (expr->kind == expr::node_t::VALUE) {
- expr = NULL;
- } else {
- DEBUG_IF("ledger.textual.parse") {
- std::cout << "Value expression tree:" << std::endl;
- ledger::dump_value_expr(std::cout, expr.get());
+ if (expr->kind == expr::node_t::VALUE) {
+ expr = NULL;
+ } else {
+ DEBUG_IF("ledger.textual.parse") {
+ std::cout << "Value expression tree:" << std::endl;
+ ledger::dump_value_expr(std::cout, expr.get());
+ }
}
- }
#else
- expr = value_expr();
+ expr = value_expr();
#endif
+ }
DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"The transaction amount is " << xact->amount);
@@ -178,12 +180,16 @@ transaction_t * parse_transaction(char * line, account_t * account,
EXPR_PARSE_NO_REDUCE);
saw_amount = true;
- xact->amount.reduce();
- DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
- "Reduced amount is " << xact->amount);
+ if (! xact->amount.is_null()) {
+ xact->amount.reduce();
+ DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
+ "Reduced amount is " << xact->amount);
+ }
- unsigned long end = (long)in.tellg();
- xact->amount_expr.expr_str = string(line, beg, end - beg);
+ if (xact->amount_expr) {
+ unsigned long end = (long)in.tellg();
+ xact->amount_expr.expr_str = string(line, beg, end - beg);
+ }
}
catch (error * err) {
err_desc = "While parsing transaction amount:";
diff --git a/valexpr.h b/valexpr.h
index 45f44b2e..c5796b88 100644
--- a/valexpr.h
+++ b/valexpr.h
@@ -794,7 +794,7 @@ public:
}
operator bool() const throw() {
- return ptr != NULL;
+ return ptr.get() != NULL;
}
operator string() const throw() {
return expr_str;