diff options
author | Alan Bram <alan.bram@cornell.edu> | 2021-04-05 19:22:33 -0700 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2021-04-10 11:37:53 -0700 |
commit | 8a87a8bd33cb428afc9472d5a8eb94ed07bf32aa (patch) | |
tree | 2a168375619426ac60de34ca0bb9a2e176bfdbc3 /src/draft.cc | |
parent | 8475839e4aff10de27893aed372fee19df449f4a (diff) | |
download | fork-ledger-8a87a8bd33cb428afc9472d5a8eb94ed07bf32aa.tar.gz fork-ledger-8a87a8bd33cb428afc9472d5a8eb94ed07bf32aa.tar.bz2 fork-ledger-8a87a8bd33cb428afc9472d5a8eb94ed07bf32aa.zip |
Fix using day-of-week names for `xact` command
Also fix end-of-command boundary checks for keywords "at", "to", etc.
Diffstat (limited to 'src/draft.cc')
-rw-r--r-- | src/draft.cc | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/draft.cc b/src/draft.cc index 12d7faf7..0ece892e 100644 --- a/src/draft.cc +++ b/src/draft.cc @@ -108,7 +108,7 @@ void draft_t::parse_args(const value_t& args) check_for_date = false; } else if (check_for_date && - bool(weekday = string_to_day_of_week(what[0]))) { + bool(weekday = string_to_day_of_week((*begin).to_string()))) { #if defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 7 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" @@ -127,35 +127,35 @@ void draft_t::parse_args(const value_t& args) string arg = (*begin).to_string(); if (arg == "at") { - if (begin == end) + if (++begin == end) throw std::runtime_error(_("Invalid xact command arguments")); - tmpl->payee_mask = (*++begin).to_string(); + tmpl->payee_mask = (*begin).to_string(); } else if (arg == "to" || arg == "from") { if (! post || post->account_mask) { tmpl->posts.push_back(xact_template_t::post_template_t()); post = &tmpl->posts.back(); } - if (begin == end) + if (++begin == end) throw std::runtime_error(_("Invalid xact command arguments")); - post->account_mask = mask_t((*++begin).to_string()); + post->account_mask = mask_t((*begin).to_string()); post->from = arg == "from"; } else if (arg == "on") { - if (begin == end) + if (++begin == end) throw std::runtime_error(_("Invalid xact command arguments")); - tmpl->date = parse_date((*++begin).to_string()); + tmpl->date = parse_date((*begin).to_string()); check_for_date = false; } else if (arg == "code") { - if (begin == end) + if (++begin == end) throw std::runtime_error(_("Invalid xact command arguments")); - tmpl->code = (*++begin).to_string(); + tmpl->code = (*begin).to_string(); } else if (arg == "note") { - if (begin == end) + if (++begin == end) throw std::runtime_error(_("Invalid xact command arguments")); - tmpl->note = (*++begin).to_string(); + tmpl->note = (*begin).to_string(); } else if (arg == "rest") { ; // just ignore this argument @@ -163,9 +163,9 @@ void draft_t::parse_args(const value_t& args) else if (arg == "@" || arg == "@@") { amount_t cost; post->cost_operator = arg; - if (begin == end) + if (++begin == end) throw std::runtime_error(_("Invalid xact command arguments")); - arg = (*++begin).to_string(); + arg = (*begin).to_string(); if (! cost.parse(arg, PARSE_SOFT_FAIL | PARSE_NO_MIGRATE)) throw std::runtime_error(_("Invalid xact command arguments")); post->cost = cost; |