From: g0dil Date: Thu, 27 Nov 2008 12:12:40 +0000 (+0000) Subject: Scheduler/Console: Fix option parsing bug (closes: #14841) X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=01dd08650770a91d832126763adcd409558ce434;p=senf.git Scheduler/Console: Fix option parsing bug (closes: #14841) Scheduler/Console: Add additional information to exceptions thrown while parsing command line arguments git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@985 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Scheduler/Console/Executor.test.cc b/Scheduler/Console/Executor.test.cc index 705622e..e2ff88a 100644 --- a/Scheduler/Console/Executor.test.cc +++ b/Scheduler/Console/Executor.test.cc @@ -271,7 +271,6 @@ BOOST_AUTO_UNIT_TEST(executorAuto) BOOST_CHECK_EQUAL( os.str(), "testCommand\n" ); } - commands.clear(); senf::console::root().remove("tdir1"); senf::console::root().remove("dir2"); diff --git a/Scheduler/Console/ProgramOptions.cc b/Scheduler/Console/ProgramOptions.cc index 63bcfb1..0efbd7e 100644 --- a/Scheduler/Console/ProgramOptions.cc +++ b/Scheduler/Console/ProgramOptions.cc @@ -60,7 +60,13 @@ prefix_ void senf::console::detail::ProgramOptionsSource::v_parse(RestrictedExec break; } else if (boost::algorithm::starts_with(arg, std::string("--")) && arg.size() > 2) - parseLongOption(arg.substr(2), executor); + try { + parseLongOption(arg.substr(2), executor); + } + catch (senf::ExceptionMixin & e) { + e << "\nwhile parsing command line option: " << arg; + throw; + } else if (boost::algorithm::starts_with(arg, std::string("-")) && arg.size() > 1) { for (std::string::size_type i (1); icompletions(key)); if (has_one_elt(completions)) key = completions.begin()->first; - else + else { + e -= 1; continue; + } } path.push_back(WordToken(key)); if (e < name.size()) @@ -135,7 +149,7 @@ senf::console::detail::ProgramOptionsSource::parseLongOption(std::string const & b = name.size(); } } - + cmd.command(path); parser_.parseArguments(value, cmd); executor(std::cerr, cmd);