From 8aff877874eae8e60e05bc8631624be918090239 Mon Sep 17 00:00:00 2001 From: Martchus Date: Mon, 27 Nov 2017 10:30:14 +0100 Subject: [PATCH] Fix comparing sibling name with denoted name --- application/argumentparser.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/application/argumentparser.cpp b/application/argumentparser.cpp index 7c5a71b..191f7f3 100644 --- a/application/argumentparser.cpp +++ b/application/argumentparser.cpp @@ -191,8 +191,16 @@ void ArgumentReader::read(ArgumentVector &args) for (auto parentArgument = parentPath.crbegin(), pathEnd = parentPath.crend();; ++parentArgument) { for (Argument *sibling : (parentArgument != pathEnd ? (*parentArgument)->subArguments() : parser.m_mainArgs)) { if (sibling->occurrences() < sibling->maxOccurrences()) { - if ((argDenotationType == Abbreviation && (sibling->abbreviation() && sibling->abbreviation() == *argDenotation)) - || (sibling->name() && !strncmp(sibling->name(), argDenotation, argDenotationLength))) { + // check whether the denoted abbreviation matches the sibling's abbreviatiopn + if (argDenotationType == Abbreviation && (sibling->abbreviation() && sibling->abbreviation() == *argDenotation)) { + return; + } + // check whether the denoted name matches the sibling's name + if (!sibling->name()) { + continue; + } + const auto siblingNameLength = strlen(sibling->name()); + if (argDenotationLength == siblingNameLength && !strncmp(sibling->name(), argDenotation, argDenotationLength)) { return; } }