Merge remote-tracking branch 'leira/empty_param_crash'

This commit is contained in:
Maxime Coste 2016-12-27 22:00:32 +00:00
commit 84c2ca1cdc
2 changed files with 3 additions and 3 deletions

View File

@ -421,7 +421,7 @@ void CommandManager::execute_single_command(CommandParameters params,
if (params.empty()) if (params.empty())
return; return;
ConstArrayView<String> param_view(params.begin()+1, params.end()); ParameterList param_view(params.begin()+1, params.end());
auto command_it = find_command(context, params[0]); auto command_it = find_command(context, params[0]);
if (command_it == m_commands.end()) if (command_it == m_commands.end())
throw command_not_found(params[0]); throw command_not_found(params[0]);

View File

@ -23,7 +23,7 @@ ParametersParser::ParametersParser(ParameterList params,
{ {
if (not only_pos and params[i] == "--") if (not only_pos and params[i] == "--")
only_pos = true; only_pos = true;
else if (not only_pos and params[i][0_byte] == '-') else if (not only_pos and params[i].length() > 0 and params[i][0_byte] == '-')
{ {
auto it = m_desc.switches.find(params[i].substr(1_byte)); auto it = m_desc.switches.find(params[i].substr(1_byte));
if (it == m_desc.switches.end()) if (it == m_desc.switches.end())
@ -36,7 +36,7 @@ ParametersParser::ParametersParser(ParameterList params,
throw missing_option_value(it->key); throw missing_option_value(it->key);
} }
} }
else else // positional
{ {
if (desc.flags & ParameterDesc::Flags::SwitchesOnlyAtStart) if (desc.flags & ParameterDesc::Flags::SwitchesOnlyAtStart)
only_pos = true; only_pos = true;