diff options
Diffstat (limited to 'CPP/Common/CommandLineParser.cpp')
-rw-r--r-- | CPP/Common/CommandLineParser.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/CPP/Common/CommandLineParser.cpp b/CPP/Common/CommandLineParser.cpp index 1bf41736..1c7f2654 100644 --- a/CPP/Common/CommandLineParser.cpp +++ b/CPP/Common/CommandLineParser.cpp @@ -11,7 +11,7 @@ static bool IsString1PrefixedByString2_NoCase(const wchar_t *u, const char *a) char c = *a; if (c == 0) return true; - if (MyCharLower_Ascii(c) != MyCharLower_Ascii(*u)) + if ((unsigned char)MyCharLower_Ascii(c) != MyCharLower_Ascii(*u)) return false; a++; u++; @@ -135,24 +135,28 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms) switch (form.Type) { case NSwitchType::kMinus: - if (rem != 0) + if (rem == 1) { sw.WithMinus = (s[pos] == '-'); if (sw.WithMinus) - pos++; + return true; + ErrorMessage = "Incorrect switch postfix:"; + return false; } break; case NSwitchType::kChar: - if (rem != 0) + if (rem == 1) { wchar_t c = s[pos]; if (c <= 0x7F) { sw.PostCharIndex = FindCharPosInString(form.PostCharSet, (char)c); if (sw.PostCharIndex >= 0) - pos++; + return true; } + ErrorMessage = "Incorrect switch postfix:"; + return false; } break; @@ -160,6 +164,7 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms) sw.PostStrings.Add((const wchar_t *)s + pos); return true; } + if (pos != s.Len()) { ErrorMessage = "Too long switch:"; |