Permalink
Browse files

Fixed several bugs related to 'common' arguments.

  • Loading branch information...
1 parent ab4073b commit 7cbd3c0f47524198ee25f417fba5acb0c690da44 Benjamin Dobell committed Jun 11, 2011
Showing with 26 additions and 23 deletions.
  1. +26 −23 heimdall/source/InterfaceManager.cpp
@@ -56,12 +56,12 @@ string InterfaceManager::dumpArgumentNames[kDumpArgCount * 2] = {
string InterfaceManager::commonArgumentNames[kCommonArgCount * 2] = {
// --- Long Names ---
- "-verbose", "-no-reboot"
+ "-verbose", "-no-reboot",
"-delay",
// --- Short Names ---
- "v", "nobt"
+ "v", "nobt",
"d"
};
@@ -216,34 +216,37 @@ bool InterfaceManager::GetArguments(int argc, char **argv, map<string, string>&
continue;
}
- // Check if the argument is a valid regular argument
- for (int i = actionValuelessArgumentCount; i < actionArgumentCount; i++)
+ if (argumentNames != nullptr)
{
- // Support for --<integer> and -<integer> parameters.
- if (argumentName.length() > 1 && argumentNames[i].compare("-%d") == 0)
+ // Check if the argument is a valid regular argument
+ for (int i = actionValuelessArgumentCount; i < actionArgumentCount; i++)
{
- if (atoi(argumentName.substr(1).c_str()) > 0 || argumentName.compare("-0") == 0)
+ // Support for --<integer> and -<integer> parameters.
+ if (argumentName.length() > 1 && argumentNames[i].compare("-%d") == 0)
{
- valid = true;
- break;
+ if (atoi(argumentName.substr(1).c_str()) > 0 || argumentName.compare("-0") == 0)
+ {
+ valid = true;
+ break;
+ }
}
- }
- else if (argumentNames[i].compare("%d") == 0)
- {
- if (atoi(argumentName.c_str()) > 0 || argumentName.compare("0") == 0)
+ else if (argumentNames[i].compare("%d") == 0)
+ {
+ if (atoi(argumentName.c_str()) > 0 || argumentName.compare("0") == 0)
+ {
+ argumentName = "-" + argumentName;
+ valid = true;
+ break;
+ }
+ }
+
+ if (argumentName == argumentNames[i] || argumentName == argumentNames[actionArgumentCount + i])
{
- argumentName = "-" + argumentName;
+ argumentName = argumentNames[i];
valid = true;
break;
}
}
-
- if (argumentName == argumentNames[i] || argumentName == argumentNames[actionArgumentCount + i])
- {
- argumentName = argumentNames[i];
- valid = true;
- break;
- }
}
if (!valid)
@@ -252,15 +255,15 @@ bool InterfaceManager::GetArguments(int argc, char **argv, map<string, string>&
for (int i = commonValuelessArgumentCount; i < commonArgumentCount; i++)
{
// Support for --<integer> and -<integer> parameters.
- if (argumentName.length() > 1 && argumentNames[i].compare("-%d"))
+ if (argumentName.length() > 1 && commonArgumentNames[i].compare("-%d"))
{
if (atoi(argumentName.substr(1).c_str()) > 0 || argumentName.compare("-0") == 0)
{
valid = true;
break;
}
}
- else if (argumentNames[i].compare("%d"))
+ else if (commonArgumentNames[i].compare("%d"))
{
if (atoi(argumentName.c_str()) > 0 || argumentName.compare("0") == 0)
{

0 comments on commit 7cbd3c0

Please sign in to comment.