BUG: fix incrementing past end

This commit is contained in:
Ken Martin 2005-11-17 09:32:07 -05:00
parent 1e2a08e452
commit 7321be8f6d

View File

@ -136,6 +136,22 @@ bool cmIfCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args)
return true; return true;
} }
void IncrementArguments(std::list<std::string> &newArgs,
std::list<std::string>::iterator &argP1,
std::list<std::string>::iterator &argP2)
{
if (argP1 != newArgs.end())
{
argP1++;
argP2 = argP1;
if (argP1 != newArgs.end())
{
argP2++;
}
}
}
// order of operations, // order of operations,
// EXISTS COMMAND DEFINED // EXISTS COMMAND DEFINED
// MATCHES LESS GREATER EQUAL STRLESS STRGREATER STREQUAL // MATCHES LESS GREATER EQUAL STRLESS STRGREATER STREQUAL
@ -207,9 +223,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
while (arg != newArgs.end()) while (arg != newArgs.end())
{ {
argP1 = arg; argP1 = arg;
argP1++; IncrementArguments(newArgs,argP1,argP2);
argP2 = argP1;
argP2++;
// does a file exist // does a file exist
if (*arg == "EXISTS" && argP1 != newArgs.end()) if (*arg == "EXISTS" && argP1 != newArgs.end())
{ {
@ -241,9 +255,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
} }
newArgs.erase(argP1); newArgs.erase(argP1);
argP1 = arg; argP1 = arg;
argP1++; IncrementArguments(newArgs,argP1,argP2);
argP2 = argP1;
argP2++;
reducible = 1; reducible = 1;
} }
// is a variable defined // is a variable defined
@ -260,9 +272,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
} }
newArgs.erase(argP1); newArgs.erase(argP1);
argP1 = arg; argP1 = arg;
argP1++; IncrementArguments(newArgs,argP1,argP2);
argP2 = argP1;
argP2++;
reducible = 1; reducible = 1;
} }
++arg; ++arg;
@ -281,9 +291,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
while (arg != newArgs.end()) while (arg != newArgs.end())
{ {
argP1 = arg; argP1 = arg;
argP1++; IncrementArguments(newArgs,argP1,argP2);
argP2 = argP1;
argP2++;
if (argP1 != newArgs.end() && argP2 != newArgs.end() && if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
*(argP1) == "MATCHES") *(argP1) == "MATCHES")
{ {
@ -310,9 +318,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
newArgs.erase(argP2); newArgs.erase(argP2);
newArgs.erase(argP1); newArgs.erase(argP1);
argP1 = arg; argP1 = arg;
argP1++; IncrementArguments(newArgs,argP1,argP2);
argP2 = argP1;
argP2++;
reducible = 1; reducible = 1;
} }
@ -321,9 +327,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
*arg = "0"; *arg = "0";
newArgs.erase(argP1); newArgs.erase(argP1);
argP1 = arg; argP1 = arg;
argP1++; IncrementArguments(newArgs,argP1,argP2);
argP2 = argP1;
argP2++;
reducible = 1; reducible = 1;
} }
@ -369,9 +373,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
newArgs.erase(argP2); newArgs.erase(argP2);
newArgs.erase(argP1); newArgs.erase(argP1);
argP1 = arg; argP1 = arg;
argP1++; IncrementArguments(newArgs,argP1,argP2);
argP2 = argP1;
argP2++;
reducible = 1; reducible = 1;
} }
@ -407,9 +409,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
newArgs.erase(argP2); newArgs.erase(argP2);
newArgs.erase(argP1); newArgs.erase(argP1);
argP1 = arg; argP1 = arg;
argP1++; IncrementArguments(newArgs,argP1,argP2);
argP2 = argP1;
argP2++;
reducible = 1; reducible = 1;
} }
@ -428,9 +428,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
while (arg != newArgs.end()) while (arg != newArgs.end())
{ {
argP1 = arg; argP1 = arg;
argP1++; IncrementArguments(newArgs,argP1,argP2);
argP2 = argP1;
argP2++;
if (argP1 != newArgs.end() && *arg == "NOT") if (argP1 != newArgs.end() && *arg == "NOT")
{ {
def = cmIfCommand::GetVariableOrNumber((argP1)->c_str(), makefile); def = cmIfCommand::GetVariableOrNumber((argP1)->c_str(), makefile);
@ -444,9 +442,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
} }
newArgs.erase(argP1); newArgs.erase(argP1);
argP1 = arg; argP1 = arg;
argP1++; IncrementArguments(newArgs,argP1,argP2);
argP2 = argP1;
argP2++;
reducible = 1; reducible = 1;
} }
++arg; ++arg;
@ -463,9 +459,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
while (arg != newArgs.end()) while (arg != newArgs.end())
{ {
argP1 = arg; argP1 = arg;
argP1++; IncrementArguments(newArgs,argP1,argP2);
argP2 = argP1;
argP2++;
if (argP1 != newArgs.end() && *(argP1) == "AND" && if (argP1 != newArgs.end() && *(argP1) == "AND" &&
argP2 != newArgs.end()) argP2 != newArgs.end())
{ {
@ -482,9 +476,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
newArgs.erase(argP2); newArgs.erase(argP2);
newArgs.erase(argP1); newArgs.erase(argP1);
argP1 = arg; argP1 = arg;
argP1++; IncrementArguments(newArgs,argP1,argP2);
argP2 = argP1;
argP2++;
reducible = 1; reducible = 1;
} }
@ -504,9 +496,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
newArgs.erase(argP2); newArgs.erase(argP2);
newArgs.erase(argP1); newArgs.erase(argP1);
argP1 = arg; argP1 = arg;
argP1++; IncrementArguments(newArgs,argP1,argP2);
argP2 = argP1;
argP2++;
reducible = 1; reducible = 1;
} }