summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Michlmayr <tbm@cyrius.com>2020-04-27 19:52:38 +0800
committerMartin Michlmayr <tbm@cyrius.com>2020-04-27 19:54:36 +0800
commitea39b7751e5cee47a674d99d0efbc713a1c3273e (patch)
treea25b48de1c7a7bf3ce9c8a64904e93233ca42f73
parent466ed19374903299a3ad21213d3a91e18559f9db (diff)
downloadfork-ledger-ea39b7751e5cee47a674d99d0efbc713a1c3273e.tar.gz
fork-ledger-ea39b7751e5cee47a674d99d0efbc713a1c3273e.tar.bz2
fork-ledger-ea39b7751e5cee47a674d99d0efbc713a1c3273e.zip
Ensure that apply directives have an argument
The directive `apply account` and similar directives (fixed, year...) require an argument. Ensure that an argument is given. Fixes #553 Fixes #1854
-rw-r--r--src/textual.cc2
-rw-r--r--test/regress/553.test20
2 files changed, 22 insertions, 0 deletions
diff --git a/src/textual.cc b/src/textual.cc
index 16054445..1c476532 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -810,6 +810,8 @@ void instance_t::apply_directive(char * line)
{
char * b = next_element(line);
string keyword(line);
+ if (! b)
+ throw_(parse_error, _f("Directive 'apply %1%' requires an argument") % keyword);
if (keyword == "account")
apply_account_directive(b);
else if (keyword == "tag")
diff --git a/test/regress/553.test b/test/regress/553.test
new file mode 100644
index 00000000..d7a833af
--- /dev/null
+++ b/test/regress/553.test
@@ -0,0 +1,20 @@
+# Test for missing arguments
+apply account
+apply tag
+apply fixed
+apply rate
+apply year
+
+test -f - bal -> 5
+__ERROR__
+While parsing file "", line 2:
+Error: Directive 'apply account' requires an argument
+While parsing file "", line 3:
+Error: Directive 'apply tag' requires an argument
+While parsing file "", line 4:
+Error: Directive 'apply fixed' requires an argument
+While parsing file "", line 5:
+Error: Directive 'apply rate' requires an argument
+While parsing file "", line 6:
+Error: Directive 'apply year' requires an argument
+end test