From 3805e4ccfa6b908c5035256ea6ee51e219f029db Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 25 Jul 2001 18:40:49 +0000 Subject: [PATCH] Fixed a bug exposed when doing something like this: -notanoption --help git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 8 +++++--- support/lib/Support/CommandLine.cpp | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index db2c3f373f1..05845906887 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -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::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::iterator I = getOpts().find(string(ArgName, ArgNameEnd)); + Handler = I != getOpts().end() ? I->second : 0; } } diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index db2c3f373f1..05845906887 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -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::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::iterator I = getOpts().find(string(ArgName, ArgNameEnd)); + Handler = I != getOpts().end() ? I->second : 0; } }