summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/textual.cc11
-rw-r--r--test/regress/785.test85
2 files changed, 96 insertions, 0 deletions
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")
diff --git a/test/regress/785.test b/test/regress/785.test
new file mode 100644
index 00000000..706d7a84
--- /dev/null
+++ b/test/regress/785.test
@@ -0,0 +1,85 @@
+
+account AA
+ alias
+
+account BB
+ default
+
+account CC
+ note
+
+account DD
+ payee
+
+account EE
+ value
+
+account FF
+ assert
+
+account GG
+ check
+
+account HH
+ eval
+
+account II
+ expr
+
+commodity AAA
+ alias
+
+commodity BBB
+ default
+
+commodity CCC
+ nomarket
+
+commodity DDD
+ value
+
+commodity EEE
+ format
+
+commodity FFF
+ note
+
+payee FOO
+ alias
+ uuid fooo
+
+payee BAR
+ uuid
+
+test source -> 14
+__ERROR__
+While parsing file "$FILE", line 3:
+Error: Account directive 'alias' requires an argument
+While parsing file "$FILE", line 9:
+Error: Account directive 'note' requires an argument
+While parsing file "$FILE", line 12:
+Error: Account directive 'payee' requires an argument
+While parsing file "$FILE", line 15:
+Error: Account directive 'value' requires an argument
+While parsing file "$FILE", line 18:
+Error: Account directive 'assert' requires an argument
+While parsing file "$FILE", line 21:
+Error: Account directive 'check' requires an argument
+While parsing file "$FILE", line 24:
+Error: Account directive 'eval' requires an argument
+While parsing file "$FILE", line 27:
+Error: Account directive 'expr' requires an argument
+While parsing file "$FILE", line 30:
+Error: Commodity directive 'alias' requires an argument
+While parsing file "$FILE", line 39:
+Error: Commodity directive 'value' requires an argument
+While parsing file "$FILE", line 42:
+Error: Commodity directive 'format' requires an argument
+While parsing file "$FILE", line 45:
+Error: Commodity directive 'note' requires an argument
+While parsing file "$FILE", line 48:
+Error: Payee directive 'alias' requires an argument
+While parsing file "$FILE", line 52:
+Error: Payee directive 'uuid' requires an argument
+end test
+