summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commodity.h2
-rw-r--r--src/filters.cc14
-rw-r--r--src/item.cc6
-rw-r--r--src/pool.cc2
-rw-r--r--src/pool.h2
-rw-r--r--src/report.cc2
-rw-r--r--src/report.h5
-rw-r--r--src/scope.cc24
-rw-r--r--src/scope.h2
9 files changed, 41 insertions, 18 deletions
diff --git a/src/commodity.h b/src/commodity.h
index d5f18844..3370f3f2 100644
--- a/src/commodity.h
+++ b/src/commodity.h
@@ -185,7 +185,7 @@ protected:
symbol(_symbol), precision(0), searched(false) {
TRACE_CTOR(base_t, "const string&");
}
- ~base_t() {
+ virtual ~base_t() {
TRACE_DTOR(base_t);
}
diff --git a/src/filters.cc b/src/filters.cc
index 39097c58..0084fac7 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -430,12 +430,22 @@ changed_value_posts::changed_value_posts(post_handler_ptr handler,
display_total_expr = report.HANDLER(display_total_).expr;
changed_values_only = report.HANDLED(revalued_only);
+ string gains_equity_account_name;
+ if (report.HANDLED(unrealized_gains_))
+ gains_equity_account_name = report.HANDLER(unrealized_gains_).str();
+ else
+ gains_equity_account_name = _("Equity:Unrealized Gains");
gains_equity_account =
- report.session.journal->master->find_account(_("Equity:Unrealized Gains"));
+ report.session.journal->master->find_account(gains_equity_account_name);
gains_equity_account->add_flags(ACCOUNT_GENERATED);
+ string losses_equity_account_name;
+ if (report.HANDLED(unrealized_losses_))
+ losses_equity_account_name = report.HANDLER(unrealized_losses_).str();
+ else
+ losses_equity_account_name = _("Equity:Unrealized Losses");
losses_equity_account =
- report.session.journal->master->find_account(_("Equity:Unrealized Losses"));
+ report.session.journal->master->find_account(losses_equity_account_name);
losses_equity_account->add_flags(ACCOUNT_GENERATED);
}
diff --git a/src/item.cc b/src/item.cc
index da6429ed..99d1d835 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -115,7 +115,8 @@ void item_t::set_tag(const string& tag,
assert(result.second);
}
-void item_t::parse_tags(const char * p, optional<date_t::year_type> current_year)
+void item_t::parse_tags(const char * p,
+ optional<date_t::year_type> current_year)
{
if (const char * b = std::strchr(p, '[')) {
if (*(b + 1) != '\0' &&
@@ -164,7 +165,8 @@ void item_t::parse_tags(const char * p, optional<date_t::year_type> current_year
}
}
-void item_t::append_note(const char * p, optional<date_t::year_type> current_year)
+void item_t::append_note(const char * p,
+ optional<date_t::year_type> current_year)
{
if (note) {
*note += '\n';
diff --git a/src/pool.cc b/src/pool.cc
index 9e06613f..00f4a3da 100644
--- a/src/pool.cc
+++ b/src/pool.cc
@@ -316,7 +316,7 @@ optional<price_point_t> commodity_pool_t::parse_price_directive(char * line)
price_point_t point;
point.when = datetime;
- point.price.parse(symbol_and_price);
+ point.price.parse(symbol_and_price, PARSE_NO_MIGRATE);
VERIFY(point.price.valid());
DEBUG("commodity.download", "Looking up symbol: " << symbol);
diff --git a/src/pool.h b/src/pool.h
index c3d701b9..85de73a9 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -84,7 +84,7 @@ public:
explicit commodity_pool_t();
- ~commodity_pool_t() {
+ virtual ~commodity_pool_t() {
TRACE_DTOR(commodity_pool_t);
foreach (commodities_map::value_type pair, commodities)
checked_delete(pair.second);
diff --git a/src/report.cc b/src/report.cc
index 4c157312..894e0d89 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -887,6 +887,8 @@ option_t<report_t> * report_t::lookup_option(const char * p)
OPT(unbudgeted);
else OPT(uncleared);
else OPT(unrealized);
+ else OPT(unrealized_gains_);
+ else OPT(unrealized_losses_);
else OPT(unround);
else OPT(unsorted);
break;
diff --git a/src/report.h b/src/report.h
index 354e31b6..d942038b 100644
--- a/src/report.h
+++ b/src/report.h
@@ -302,6 +302,8 @@ public:
HANDLER(unbudgeted).report(out);
HANDLER(uncleared).report(out);
HANDLER(unrealized).report(out);
+ HANDLER(unrealized_gains_).report(out);
+ HANDLER(unrealized_losses_).report(out);
HANDLER(unround).report(out);
HANDLER(unsorted).report(out);
HANDLER(weekly).report(out);
@@ -876,6 +878,9 @@ public:
OPTION(report_t, unrealized);
+ OPTION(report_t, unrealized_gains_);
+ OPTION(report_t, unrealized_losses_);
+
OPTION_(report_t, unround, DO() {
parent->HANDLER(display_amount_)
.set_expr(string("--unround"), "unrounded(amount_expr)");
diff --git a/src/scope.cc b/src/scope.cc
index 99f6b669..64736ca3 100644
--- a/src/scope.cc
+++ b/src/scope.cc
@@ -42,15 +42,18 @@ void symbol_scope_t::define(const symbol_t::kind_t kind,
{
DEBUG("scope.symbols", "Defining '" << name << "' = " << def);
+ if (! symbols)
+ symbols = symbol_map();
+
std::pair<symbol_map::iterator, bool> result
- = symbols.insert(symbol_map::value_type(symbol_t(kind, name, def), def));
+ = symbols->insert(symbol_map::value_type(symbol_t(kind, name, def), def));
if (! result.second) {
- symbol_map::iterator i = symbols.find(symbol_t(kind, name));
- assert(i != symbols.end());
- symbols.erase(i);
+ symbol_map::iterator i = symbols->find(symbol_t(kind, name));
+ assert(i != symbols->end());
+ symbols->erase(i);
- result = symbols.insert(symbol_map::value_type(symbol_t(kind, name, def),
- def));
+ result = symbols->insert(symbol_map::value_type(symbol_t(kind, name, def),
+ def));
if (! result.second)
throw_(compile_error,
_("Redefinition of '%1' in the same scope") << name);
@@ -60,10 +63,11 @@ void symbol_scope_t::define(const symbol_t::kind_t kind,
expr_t::ptr_op_t symbol_scope_t::lookup(const symbol_t::kind_t kind,
const string& name)
{
- symbol_map::const_iterator i = symbols.find(symbol_t(kind, name));
- if (i != symbols.end())
- return (*i).second;
-
+ if (symbols) {
+ symbol_map::const_iterator i = symbols->find(symbol_t(kind, name));
+ if (i != symbols->end())
+ return (*i).second;
+ }
return child_scope_t::lookup(kind, name);
}
diff --git a/src/scope.h b/src/scope.h
index 44ca3229..93f80230 100644
--- a/src/scope.h
+++ b/src/scope.h
@@ -172,7 +172,7 @@ class symbol_scope_t : public child_scope_t
{
typedef std::map<symbol_t, expr_t::ptr_op_t> symbol_map;
- symbol_map symbols;
+ optional<symbol_map> symbols;
public:
explicit symbol_scope_t() {