Fixed a bug exposed when doing something like this: <program> -notanoption --help

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2001-07-25 18:40:49 +00:00
parent b2d11bad7e
commit 3805e4ccfa
2 changed files with 10 additions and 6 deletions

View File

@ -49,7 +49,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
const char *Value = "";
const char *ArgName = "";
if (argv[i][0] != '-') { // Unnamed argument?
Handler = getOpts()[""];
map<string, Option*>::iterator I = getOpts().find("");
Handler = I != getOpts().end() ? I->second : 0;
Value = argv[i];
} else { // We start with a - or --, eat dashes
ArgName = argv[i]+1;
@ -63,8 +64,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
++Value; // Advance to value...
if (*ArgName != 0) {
string ArgNameStr(ArgName, ArgNameEnd); // Extract arg name part
Handler = getOpts()[ArgNameStr];
// Extract arg name part
map<string, Option*>::iterator I = getOpts().find(string(ArgName, ArgNameEnd));
Handler = I != getOpts().end() ? I->second : 0;
}
}

View File

@ -49,7 +49,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
const char *Value = "";
const char *ArgName = "";
if (argv[i][0] != '-') { // Unnamed argument?
Handler = getOpts()[""];
map<string, Option*>::iterator I = getOpts().find("");
Handler = I != getOpts().end() ? I->second : 0;
Value = argv[i];
} else { // We start with a - or --, eat dashes
ArgName = argv[i]+1;
@ -63,8 +64,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
++Value; // Advance to value...
if (*ArgName != 0) {
string ArgNameStr(ArgName, ArgNameEnd); // Extract arg name part
Handler = getOpts()[ArgNameStr];
// Extract arg name part
map<string, Option*>::iterator I = getOpts().find(string(ArgName, ArgNameEnd));
Handler = I != getOpts().end() ? I->second : 0;
}
}