From 7d82192a5d9e87b14625ba3aff2413e09da827be Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 19 Nov 2010 10:14:42 +0200 Subject: Fix bug in option passing between driver and plugin This requires new option description functionality from CLI. --- odb/odb.cxx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'odb/odb.cxx') diff --git a/odb/odb.cxx b/odb/odb.cxx index c45f3b9..5bc6605 100644 --- a/odb/odb.cxx +++ b/odb/odb.cxx @@ -389,6 +389,7 @@ main (int argc, char* argv[]) // Encode plugin options. // + cli::options const& desc (options::description ()); for (size_t i (0); i < end; ++i) { string k, v; @@ -401,21 +402,30 @@ main (int argc, char* argv[]) continue; } - if (a.size () > 2) + cli::options::const_iterator it (desc.find (a)); + + if (it == desc.end ()) + { + e << argv[0] << ": ice: unexpected option '" << a << "'" << endl; + return 1; + } + + if (a.size () > 2 && a[0] == '-' && a[1] == '-') k = string (a, 2); // long format else k = string (a, 1); // short format // If there are more arguments then we may have a value. // - if (i + 1 < end) + if (!it->flag ()) { - a = plugin_args[i + 1]; - if (!(a.size () > 1 && a[0] == '-')) + if (i + 1 == end) { - v = a; - ++i; + e << argv[0] << ": ice: expected argument for '" << a << "'" << endl; + return 1; } + + v = plugin_args[++i]; } args.push_back (encode_plugin_option (k, v)); -- cgit v1.1