From 68813448cbac88cff9c7f60021a0e255e2445375 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 1 Mar 2006 04:46:21 +0000 Subject: Added support for unlimited factoids. --- textual.cc | 10 +++------- valexpr.cc | 9 +++------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/textual.cc b/textual.cc index 1857ddbf..2ea2aae6 100644 --- a/textual.cc +++ b/textual.cc @@ -650,8 +650,7 @@ unsigned int textual_parser_t::parse(std::istream& in, #endif // TIMELOG_SUPPORT case 'D': { // a default commodity for "entry" - amount_t amt; - amt.parse(skip_ws(line + 1)); + amount_t amt(skip_ws(line + 1)); commodity_t::default_commodity = &amt.commodity(); break; } @@ -669,8 +668,6 @@ unsigned int textual_parser_t::parse(std::istream& in, break; case 'P': { // a pricing entry - std::time_t date; - char * date_field = skip_ws(line + 1); char * time_field = next_element(date_field); if (! time_field) break; @@ -682,6 +679,7 @@ unsigned int textual_parser_t::parse(std::istream& in, date_buffer[std::strlen(date_field)] = ' '; std::strcpy(&date_buffer[std::strlen(date_field) + 1], time_field); + std::time_t date; struct std::tm when; if (strptime(date_buffer, "%Y/%m/%d %H:%M:%S", &when)) { date = std::mktime(&when); @@ -690,10 +688,8 @@ unsigned int textual_parser_t::parse(std::istream& in, } std::string symbol; - amount_t price; - parse_symbol(symbol_and_price, symbol); - price.parse(symbol_and_price); + amount_t price(symbol_and_price); commodity_t * commodity = commodity_t::find_commodity(symbol, true); commodity->add_price(date, price); diff --git a/valexpr.cc b/valexpr.cc index 8222da40..a5cb481f 100644 --- a/valexpr.cc +++ b/valexpr.cc @@ -1279,8 +1279,7 @@ void init_value_expr() globals->define("P", node); globals->define("val", node); globals->define("value", node); - node = parse_boolean_expr("current_value(x)=P(x,m)", globals); - delete node; + value_auto_ptr cval(parse_boolean_expr("current_value(x)=P(x,m)", globals)); // Macros node = parse_value_expr("P(a,d)"); @@ -1299,10 +1298,8 @@ void init_value_expr() globals->define("G", node); globals->define("gain_total", node); - node = parse_boolean_expr("min(x,y)=xy?x:y", globals); - delete node; + value_auto_ptr minx(parse_boolean_expr("min(x,y)=xy?x:y", globals)); } value_expr_t * parse_value_expr(std::istream& in, scope_t * scope, -- cgit v1.2.3