mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-25 17:20:48 +00:00
Do not use "" as a sentinal for a missing argument! This fixes PR560.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21850 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -97,7 +97,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
|
|||||||
// Enforce value requirements
|
// Enforce value requirements
|
||||||
switch (Handler->getValueExpectedFlag()) {
|
switch (Handler->getValueExpectedFlag()) {
|
||||||
case ValueRequired:
|
case ValueRequired:
|
||||||
if (Value == 0 || *Value == 0) { // No value specified?
|
if (Value == 0) { // No value specified?
|
||||||
if (i+1 < argc) { // Steal the next argument, like for '-o filename'
|
if (i+1 < argc) { // Steal the next argument, like for '-o filename'
|
||||||
Value = argv[++i];
|
Value = argv[++i];
|
||||||
} else {
|
} else {
|
||||||
@@ -106,7 +106,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ValueDisallowed:
|
case ValueDisallowed:
|
||||||
if (*Value != 0)
|
if (Value)
|
||||||
return Handler->error(" does not allow a value! '" +
|
return Handler->error(" does not allow a value! '" +
|
||||||
std::string(Value) + "' specified.");
|
std::string(Value) + "' specified.");
|
||||||
break;
|
break;
|
||||||
@@ -121,7 +121,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run the handler now!
|
// Run the handler now!
|
||||||
return Handler->addOccurrence(i, ArgName, Value);
|
return Handler->addOccurrence(i, ArgName, Value ? Value : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ProvidePositionalOption(Option *Handler, const std::string &Arg,
|
static bool ProvidePositionalOption(Option *Handler, const std::string &Arg,
|
||||||
@@ -268,11 +268,11 @@ static Option *LookupOption(const char *&Arg, const char *&Value) {
|
|||||||
|
|
||||||
const char *ArgEnd = Arg;
|
const char *ArgEnd = Arg;
|
||||||
while (*ArgEnd && *ArgEnd != '=')
|
while (*ArgEnd && *ArgEnd != '=')
|
||||||
++ArgEnd; // Scan till end of argument name...
|
++ArgEnd; // Scan till end of argument name.
|
||||||
|
|
||||||
|
if (*ArgEnd == '=') // If we have an equals sign...
|
||||||
|
Value = ArgEnd+1; // Get the value, not the equals
|
||||||
|
|
||||||
Value = ArgEnd;
|
|
||||||
if (*Value) // If we have an equals sign...
|
|
||||||
++Value; // Advance to value...
|
|
||||||
|
|
||||||
if (*Arg == 0) return 0;
|
if (*Arg == 0) return 0;
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
bool DashDashFound = false; // Have we read '--'?
|
bool DashDashFound = false; // Have we read '--'?
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
Option *Handler = 0;
|
Option *Handler = 0;
|
||||||
const char *Value = "";
|
const char *Value = 0;
|
||||||
const char *ArgName = "";
|
const char *ArgName = "";
|
||||||
|
|
||||||
// Check to see if this is a positional argument. This argument is
|
// Check to see if this is a positional argument. This argument is
|
||||||
@@ -429,7 +429,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
"Option can not be cl::Grouping AND cl::ValueRequired!");
|
"Option can not be cl::Grouping AND cl::ValueRequired!");
|
||||||
int Dummy;
|
int Dummy;
|
||||||
ErrorParsing |= ProvideOption(PGOpt, RealArgName.c_str(),
|
ErrorParsing |= ProvideOption(PGOpt, RealArgName.c_str(),
|
||||||
"", 0, 0, Dummy);
|
0, 0, 0, Dummy);
|
||||||
|
|
||||||
// Get the next grouping option...
|
// Get the next grouping option...
|
||||||
PGOpt = getOptionPred(RealName, Length, isGrouping);
|
PGOpt = getOptionPred(RealName, Length, isGrouping);
|
||||||
@@ -450,7 +450,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
|
|
||||||
// Check to see if this option accepts a comma separated list of values. If
|
// Check to see if this option accepts a comma separated list of values. If
|
||||||
// it does, we have to split up the value into multiple values...
|
// it does, we have to split up the value into multiple values...
|
||||||
if (Handler->getMiscFlags() & CommaSeparated) {
|
if (Value && Handler->getMiscFlags() & CommaSeparated) {
|
||||||
std::string Val(Value);
|
std::string Val(Value);
|
||||||
std::string::size_type Pos = Val.find(',');
|
std::string::size_type Pos = Val.find(',');
|
||||||
|
|
||||||
@@ -591,7 +591,8 @@ bool Option::error(std::string Message, const char *ArgName) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Option::addOccurrence(unsigned pos, const char *ArgName, const std::string &Value) {
|
bool Option::addOccurrence(unsigned pos, const char *ArgName,
|
||||||
|
const std::string &Value) {
|
||||||
NumOccurrences++; // Increment the number of times we have been seen
|
NumOccurrences++; // Increment the number of times we have been seen
|
||||||
|
|
||||||
switch (getNumOccurrencesFlag()) {
|
switch (getNumOccurrencesFlag()) {
|
||||||
|
Reference in New Issue
Block a user