summaryrefslogtreecommitdiff
path: root/src/interactive.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-13 00:42:25 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-13 00:42:25 -0400
commit40f553228f5a28034c6635fdcb4c86af28a385ed (patch)
tree2c40305c9f9841a4c3d453a4a5c49ec69056b4b2 /src/interactive.cc
parent556211e623cad88213e5087b5c9c36e754d9aa02 (diff)
parentb1b4e2aadff5983d443d70c09ea86a41b015873f (diff)
downloadfork-ledger-40f553228f5a28034c6635fdcb4c86af28a385ed.tar.gz
fork-ledger-40f553228f5a28034c6635fdcb4c86af28a385ed.tar.bz2
fork-ledger-40f553228f5a28034c6635fdcb4c86af28a385ed.zip
Merge branch 'next'
Diffstat (limited to 'src/interactive.cc')
-rw-r--r--src/interactive.cc64
1 files changed, 33 insertions, 31 deletions
diff --git a/src/interactive.cc b/src/interactive.cc
index 9aeb5307..54c7fd6c 100644
--- a/src/interactive.cc
+++ b/src/interactive.cc
@@ -39,16 +39,16 @@ void interactive_t::verify_arguments() const
{
value_t::sequence_t::const_iterator i;
- const char * p = spec.c_str();
- const char * label = _("unknown");
- bool wrong_arg = false;
- bool dont_skip = false;
- bool optional = *p == '&';
- bool exit_loop = *p == '*';
- std::size_t offset = 1;
- bool is_seq = args.value().is_sequence();
+ const char * p = spec.c_str();
+ const char * label = _("unknown");
+ bool wrong_arg = false;
+ bool dont_skip = false;
+ bool optional = *p == '&';
+ bool exit_loop = *p == '*';
+ std::size_t offset = 1;
+ bool is_seq = args.value().is_sequence();
const value_t * next_arg = NULL;
- string vlabel;
+ string vlabel;
if (is_seq) {
i = args.begin();
@@ -61,45 +61,45 @@ void interactive_t::verify_arguments() const
for (; ! wrong_arg && ! exit_loop && *p && next_arg; p++) {
DEBUG("interactive.verify",
- "Want " << *p << " got: " << next_arg->label());
+ "Want " << *p << " got: " << next_arg->label());
wrong_arg = false;
switch (*p) {
case 'a':
label = _("an amount");
wrong_arg = (! next_arg->is_long() &&
- ! next_arg->is_amount() &&
- ! next_arg->is_balance());
+ ! next_arg->is_amount() &&
+ ! next_arg->is_balance());
break;
case 'b':
label = _("a boolean");
- wrong_arg = false; // booleans are converted
+ wrong_arg = false; // booleans are converted
break;
case 'd':
label = _("a date");
wrong_arg = (! next_arg->is_date() &&
- ! next_arg->is_datetime());
+ ! next_arg->is_datetime());
break;
case 't':
label = _("a date/time");
wrong_arg = (! next_arg->is_date() &&
- ! next_arg->is_datetime());
+ ! next_arg->is_datetime());
break;
case 'i':
case 'l':
label = _("an integer");
if (next_arg->is_long() ||
- (next_arg->is_amount() &&
- ! next_arg->as_amount().has_commodity())) {
+ (next_arg->is_amount() &&
+ ! next_arg->as_amount().has_commodity())) {
wrong_arg = false;
}
else if (next_arg->is_string()) {
wrong_arg = false;
for (const char * q = next_arg->as_string().c_str(); *q; q++) {
- if (! std::isdigit(*q) && *q != '-') {
- wrong_arg = true;
- break;
- }
+ if (! std::isdigit(*q) && *q != '-') {
+ wrong_arg = true;
+ break;
+ }
}
}
else {
@@ -143,19 +143,21 @@ void interactive_t::verify_arguments() const
if (wrong_arg && optional && next_arg->is_null())
wrong_arg = false;
- if (wrong_arg)
+ if (wrong_arg) {
vlabel = next_arg->label();
+ break;
+ }
if (! dont_skip) {
if (is_seq) {
- if (++i != args.end()) {
- next_arg = &(*i);
- offset++;
- } else {
- next_arg = NULL;
- }
+ if (++i != args.end()) {
+ next_arg = &(*i);
+ offset++;
+ } else {
+ next_arg = NULL;
+ }
} else {
- next_arg = NULL;
+ next_arg = NULL;
}
}
dont_skip = false;
@@ -168,8 +170,8 @@ void interactive_t::verify_arguments() const
if (wrong_arg) {
throw_(std::logic_error,
- _("Expected %1 for argument %2, but received %3")
- << label << offset << vlabel);
+ _("Expected %1 for argument %2, but received %3")
+ << label << offset << vlabel);
}
else if (*p && ! optional && ! next_arg) {
throw_(std::logic_error, _("Too few arguments to function"));