From 5dc8f6bccb89bc952d924cf615435c0185168a27 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 16 Feb 2009 17:30:34 -0400 Subject: Report better errors if options are missing args --- src/option.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/option.cc') 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, -- cgit v1.2.3