Fix ParameterParser::position_from with arbitrary indices

This commit is contained in:
Maxime Coste 2018-06-28 19:48:11 +10:00
parent b4b335155e
commit d6b0297ac8

View File

@ -119,7 +119,7 @@ struct ParametersParser
ConstArrayView<String> positionals_from(size_t first) const ConstArrayView<String> positionals_from(size_t first) const
{ {
kak_assert(m_desc.flags & (ParameterDesc::Flags::SwitchesOnlyAtStart | ParameterDesc::Flags::SwitchesAsPositional)); kak_assert(m_desc.flags & (ParameterDesc::Flags::SwitchesOnlyAtStart | ParameterDesc::Flags::SwitchesAsPositional));
return m_params.subrange(m_positional_indices[first]); return m_params.subrange(first < m_positional_indices.size() ? m_positional_indices[first] : -1);
} }
iterator begin() const { return iterator(*this, 0); } iterator begin() const { return iterator(*this, 0); }