libwinpr-utils: fix parsing of optional arguments with the space separator

This commit is contained in:
Marc-André Moreau 2013-02-19 18:05:20 -05:00
parent 22c804e6ad
commit f75b3f5d51
1 changed files with 21 additions and 2 deletions

View File

@ -209,8 +209,27 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
if ((flags & COMMAND_LINE_SEPARATOR_SPACE) && ((i + 1) < argc))
{
if ((options[j].Flags & COMMAND_LINE_VALUE_REQUIRED) ||
(options[j].Flags & COMMAND_LINE_VALUE_OPTIONAL))
int value_present = 1;
if (flags & COMMAND_LINE_SIGIL_DASH)
{
if (strncmp(argv[i + 1], "-", 1) == 0)
value_present = 0;
}
if (flags & COMMAND_LINE_SIGIL_DOUBLE_DASH)
{
if (strncmp(argv[i + 1], "--", 2) == 0)
value_present = 0;
}
if (flags & COMMAND_LINE_SIGIL_SLASH)
{
if (strncmp(argv[i + 1], "/", 1) == 0)
value_present = 0;
}
if (value_present)
{
i++;
value_index = 0;