summaryrefslogtreecommitdiff
path: root/src/textual.cc
diff options
context:
space:
mode:
authorChristopher Zimmermann <madroach@gmerlin.de>2021-08-29 21:36:17 +0200
committerJohn Wiegley <johnw@newartisans.com>2022-02-03 09:07:50 -0800
commit1a70b33b4f8b6f8d4844b1b30dde568ae311d0ac (patch)
tree3e642a6bb5ee851bf70cd81fd9d74769308c79f3 /src/textual.cc
parent28ed7b1c48b90bb57dca2ea238a758272d9d5d51 (diff)
downloadfork-ledger-1a70b33b4f8b6f8d4844b1b30dde568ae311d0ac.tar.gz
fork-ledger-1a70b33b4f8b6f8d4844b1b30dde568ae311d0ac.tar.bz2
fork-ledger-1a70b33b4f8b6f8d4844b1b30dde568ae311d0ac.zip
check that commodity format uses correct symbol
closes 1948
Diffstat (limited to 'src/textual.cc')
-rw-r--r--src/textual.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/textual.cc b/src/textual.cc
index 3b6ef5f4..bc91ef52 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -1126,13 +1126,16 @@ void instance_t::commodity_value_directive(commodity_t& comm, string expr_str)
comm.set_value_expr(expr_t(expr_str));
}
-void instance_t::commodity_format_directive(commodity_t&, string format)
+void instance_t::commodity_format_directive(commodity_t& comm, string format)
{
// jww (2012-02-27): A format specified this way should turn off
// observational formatting.
trim(format);
amount_t amt;
amt.parse(format);
+ if (amt.commodity() != comm)
+ throw_(parse_error, _f("commodity directive symbol %1% and format directive symbol %2% should be the same") %
+ comm.symbol() % amt.commodity().symbol());
amt.commodity().add_flags(COMMODITY_STYLE_NO_MIGRATE);
VERIFY(amt.valid());
}