From 86fd99c9d0d8ed46f3eb89a7bf0d17eadef574e8 Mon Sep 17 00:00:00 2001 From: Martin Michlmayr Date: Wed, 14 May 2014 17:52:05 -0400 Subject: Ensure that directives have arguments if they need one Ensure that account, commodity and payee directives have arguments if they need one. Bug fix for #785 --- src/textual.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/textual.cc b/src/textual.cc index 60250007..a1b17c14 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -918,6 +918,10 @@ void instance_t::account_directive(char * line) char * b = next_element(q); string keyword(q); + // Ensure there's an argument for the directives that need one. + if (! b && keyword != "default") + throw_(parse_error, _f("Account directive '%1%' requires an argument") % keyword); + if (keyword == "alias") { account_alias_directive(account, b); } @@ -1034,6 +1038,9 @@ void instance_t::payee_directive(char * line) char * b = next_element(p); string keyword(p); + if (! b) + throw_(parse_error, _f("Payee directive '%1%' requires an argument") % keyword); + if (keyword == "alias") payee_alias_directive(payee, b); if (keyword == "uuid") @@ -1073,6 +1080,10 @@ void instance_t::commodity_directive(char * line) char * b = next_element(q); string keyword(q); + // Ensure there's an argument for the directives that need one. + if (! b && keyword != "nomarket" && keyword != "default") + throw_(parse_error, _f("Commodity directive '%1%' requires an argument") % keyword); + if (keyword == "alias") commodity_alias_directive(*commodity, b); else if (keyword == "value") -- cgit v1.2.3