summaryrefslogtreecommitdiff
path: root/src/option.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-16 17:30:34 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-16 17:30:34 -0400
commit5dc8f6bccb89bc952d924cf615435c0185168a27 (patch)
treeca23445faa855ff1fa52171072b7903d4aea3cdc /src/option.cc
parentb7f2a95c1f630d1246afa4b7f847435d62c9341e (diff)
downloadfork-ledger-5dc8f6bccb89bc952d924cf615435c0185168a27.tar.gz
fork-ledger-5dc8f6bccb89bc952d924cf615435c0185168a27.tar.bz2
fork-ledger-5dc8f6bccb89bc952d924cf615435c0185168a27.zip
Report better errors if options are missing args
Diffstat (limited to 'src/option.cc')
-rw-r--r--src/option.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/option.cc b/src/option.cc
index 1a68d2a8..f8e6a713 100644
--- a/src/option.cc
+++ b/src/option.cc
@@ -194,8 +194,8 @@ strings_list process_arguments(strings_list args, scope_t& scope)
if (! opt.first)
throw_(option_error, "illegal option --" << name);
- if (opt.second && value == NULL) {
- value = (*++i).c_str();
+ if (opt.second && ++i != args.end() && value == NULL) {
+ value = (*i).c_str();
DEBUG("option.args", " read option value from arg: " << value);
if (value == NULL)
throw_(option_error, "missing option argument for --" << name);
@@ -222,8 +222,8 @@ strings_list process_arguments(strings_list args, scope_t& scope)
foreach (op_bool_char_tuple& o, option_queue) {
const char * value = NULL;
- if (o.truth) {
- value = (*++i).c_str();
+ if (o.truth && ++i != args.end()) {
+ value = (*i).c_str();
DEBUG("option.args", " read option value from arg: " << value);
if (value == NULL)
throw_(option_error,