Fixed multiple warnings in parser
This commit is contained in:
parent
26d079e53b
commit
0aa5a83536
@ -52,31 +52,19 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
int i, j;
|
int i, j;
|
||||||
int status;
|
int status;
|
||||||
int count;
|
int count;
|
||||||
int length;
|
size_t length;
|
||||||
int index;
|
|
||||||
BOOL match;
|
|
||||||
BOOL found;
|
|
||||||
BOOL argument;
|
|
||||||
BOOL escaped;
|
|
||||||
BOOL notescaped;
|
BOOL notescaped;
|
||||||
char* sigil;
|
char* sigil;
|
||||||
int sigil_length;
|
size_t sigil_length;
|
||||||
int sigil_index;
|
|
||||||
char* keyword;
|
char* keyword;
|
||||||
int keyword_length;
|
SSIZE_T keyword_length;
|
||||||
int keyword_index;
|
SSIZE_T keyword_index;
|
||||||
char* separator;
|
char* separator;
|
||||||
int separator_length;
|
|
||||||
int separator_index;
|
|
||||||
char* value;
|
char* value;
|
||||||
int value_length;
|
|
||||||
int value_index;
|
|
||||||
int toggle;
|
int toggle;
|
||||||
|
|
||||||
status = 0;
|
status = 0;
|
||||||
match = FALSE;
|
|
||||||
found = FALSE;
|
|
||||||
argument = FALSE;
|
|
||||||
escaped = TRUE;
|
|
||||||
notescaped = FALSE;
|
notescaped = FALSE;
|
||||||
|
|
||||||
if (!argv)
|
if (!argv)
|
||||||
@ -90,8 +78,8 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
|
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
index = i;
|
BOOL found = FALSE;
|
||||||
escaped = TRUE;
|
BOOL escaped = TRUE;
|
||||||
|
|
||||||
if (preFilter)
|
if (preFilter)
|
||||||
{
|
{
|
||||||
@ -110,10 +98,8 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sigil_index = 0;
|
sigil = (char*) argv[i];
|
||||||
sigil_length = 0;
|
length = strlen(argv[i]);
|
||||||
sigil = (char*) &argv[i][sigil_index];
|
|
||||||
length = (int) strlen(argv[i]);
|
|
||||||
|
|
||||||
if ((sigil[0] == '/') && (flags & COMMAND_LINE_SIGIL_SLASH))
|
if ((sigil[0] == '/') && (flags & COMMAND_LINE_SIGIL_SLASH))
|
||||||
{
|
{
|
||||||
@ -162,12 +148,12 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
{
|
{
|
||||||
if ((flags & COMMAND_LINE_IGN_UNKNOWN_KEYWORD))
|
if ((flags & COMMAND_LINE_IGN_UNKNOWN_KEYWORD))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return COMMAND_LINE_ERROR_NO_KEYWORD;
|
return COMMAND_LINE_ERROR_NO_KEYWORD;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyword_index = sigil_index + sigil_length;
|
keyword_index = sigil_length;
|
||||||
keyword = (char*) &argv[i][keyword_index];
|
keyword = (char*) &argv[i][keyword_index];
|
||||||
|
|
||||||
toggle = -1;
|
toggle = -1;
|
||||||
|
|
||||||
if (flags & COMMAND_LINE_SIGIL_ENABLE_DISABLE)
|
if (flags & COMMAND_LINE_SIGIL_ENABLE_DISABLE)
|
||||||
@ -196,31 +182,24 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
|
|
||||||
if (separator)
|
if (separator)
|
||||||
{
|
{
|
||||||
separator_length = 1;
|
SSIZE_T separator_index = (separator - argv[i]);
|
||||||
separator_index = (int)(separator - argv[i]);
|
SSIZE_T value_index = separator_index + 1;
|
||||||
keyword_length = (int)(separator - keyword);
|
keyword_length = (separator - keyword);
|
||||||
value_index = separator_index + separator_length;
|
|
||||||
value = (char*) &argv[i][value_index];
|
value = (char*) &argv[i][value_index];
|
||||||
value_length = (length - value_index);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
separator_length = 0;
|
|
||||||
separator_index = -1;
|
|
||||||
keyword_length = (length - keyword_index);
|
keyword_length = (length - keyword_index);
|
||||||
value_index = -1;
|
|
||||||
value = NULL;
|
value = NULL;
|
||||||
value_length = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!escaped)
|
if (!escaped)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
found = FALSE;
|
|
||||||
|
|
||||||
for (j = 0; options[j].Name != NULL; j++)
|
for (j = 0; options[j].Name != NULL; j++)
|
||||||
{
|
{
|
||||||
match = FALSE;
|
BOOL match = FALSE;
|
||||||
|
|
||||||
if (strncmp(options[j].Name, keyword, keyword_length) == 0)
|
if (strncmp(options[j].Name, keyword, keyword_length) == 0)
|
||||||
{
|
{
|
||||||
@ -241,10 +220,11 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
found = match;
|
found = match;
|
||||||
options[j].Index = index;
|
options[j].Index = i;
|
||||||
|
|
||||||
if ((flags & COMMAND_LINE_SEPARATOR_SPACE) && ((i + 1) < argc))
|
if ((flags & COMMAND_LINE_SEPARATOR_SPACE) && ((i + 1) < argc))
|
||||||
{
|
{
|
||||||
|
BOOL argument;
|
||||||
int value_present = 1;
|
int value_present = 1;
|
||||||
|
|
||||||
if (flags & COMMAND_LINE_SIGIL_DASH)
|
if (flags & COMMAND_LINE_SIGIL_DASH)
|
||||||
@ -270,20 +250,14 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
argument = TRUE;
|
argument = TRUE;
|
||||||
else
|
else
|
||||||
argument = FALSE;
|
argument = FALSE;
|
||||||
|
|
||||||
if (value_present && argument)
|
if (value_present && argument)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
value_index = 0;
|
value = (char*) argv[i];
|
||||||
length = (int) strlen(argv[i]);
|
|
||||||
value = (char*) &argv[i][value_index];
|
|
||||||
value_length = (length - value_index);
|
|
||||||
}
|
}
|
||||||
else if (!value_present && (options[j].Flags & COMMAND_LINE_VALUE_OPTIONAL))
|
else if (!value_present && (options[j].Flags & COMMAND_LINE_VALUE_OPTIONAL))
|
||||||
{
|
{
|
||||||
value_index = 0;
|
|
||||||
value = NULL;
|
value = NULL;
|
||||||
value_length = 0;
|
|
||||||
}
|
}
|
||||||
else if (!value_present && argument)
|
else if (!value_present && argument)
|
||||||
return COMMAND_LINE_ERROR;
|
return COMMAND_LINE_ERROR;
|
||||||
@ -299,9 +273,7 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
if (value && (options[j].Flags & COMMAND_LINE_VALUE_FLAG))
|
if (value && (options[j].Flags & COMMAND_LINE_VALUE_FLAG))
|
||||||
{
|
{
|
||||||
i--;
|
i--;
|
||||||
value_index = -1;
|
|
||||||
value = NULL;
|
value = NULL;
|
||||||
value_length = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,7 +334,6 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
|||||||
else if (options[j].Flags & COMMAND_LINE_PRINT_BUILDCONFIG)
|
else if (options[j].Flags & COMMAND_LINE_PRINT_BUILDCONFIG)
|
||||||
return COMMAND_LINE_STATUS_PRINT_BUILDCONFIG;
|
return COMMAND_LINE_STATUS_PRINT_BUILDCONFIG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found && (flags & COMMAND_LINE_IGN_UNKNOWN_KEYWORD) == 0)
|
if (!found && (flags & COMMAND_LINE_IGN_UNKNOWN_KEYWORD) == 0)
|
||||||
return COMMAND_LINE_ERROR_NO_KEYWORD;
|
return COMMAND_LINE_ERROR_NO_KEYWORD;
|
||||||
}
|
}
|
||||||
@ -406,7 +377,7 @@ int CommandLineClearArgumentsW(COMMAND_LINE_ARGUMENT_W* options)
|
|||||||
|
|
||||||
COMMAND_LINE_ARGUMENT_A* CommandLineFindArgumentA(COMMAND_LINE_ARGUMENT_A* options, LPCSTR Name)
|
COMMAND_LINE_ARGUMENT_A* CommandLineFindArgumentA(COMMAND_LINE_ARGUMENT_A* options, LPCSTR Name)
|
||||||
{
|
{
|
||||||
size_t i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; options[i].Name != NULL; i++)
|
for (i = 0; options[i].Name != NULL; i++)
|
||||||
{
|
{
|
||||||
@ -425,7 +396,7 @@ COMMAND_LINE_ARGUMENT_A* CommandLineFindArgumentA(COMMAND_LINE_ARGUMENT_A* optio
|
|||||||
|
|
||||||
COMMAND_LINE_ARGUMENT_W* CommandLineFindArgumentW(COMMAND_LINE_ARGUMENT_W* options, LPCWSTR Name)
|
COMMAND_LINE_ARGUMENT_W* CommandLineFindArgumentW(COMMAND_LINE_ARGUMENT_W* options, LPCWSTR Name)
|
||||||
{
|
{
|
||||||
size_t i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; options[i].Name != NULL; i++)
|
for (i = 0; options[i].Name != NULL; i++)
|
||||||
{
|
{
|
||||||
@ -446,9 +417,6 @@ COMMAND_LINE_ARGUMENT_A* CommandLineFindNextArgumentA(COMMAND_LINE_ARGUMENT_A* a
|
|||||||
{
|
{
|
||||||
COMMAND_LINE_ARGUMENT_A* nextArgument;
|
COMMAND_LINE_ARGUMENT_A* nextArgument;
|
||||||
|
|
||||||
if (!argument)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
nextArgument = &argument[1];
|
nextArgument = &argument[1];
|
||||||
|
|
||||||
if (nextArgument->Name == NULL)
|
if (nextArgument->Name == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user