mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-27 13:40:43 +00:00
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:
parent
b2d11bad7e
commit
3805e4ccfa
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user