summaryrefslogtreecommitdiffstats
path: root/Source/cmIfCommand.cxx
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2005-11-17 14:32:07 (GMT)
committerKen Martin <ken.martin@kitware.com>2005-11-17 14:32:07 (GMT)
commit7321be8f6d105691c8e13107e15ec6264e6f1353 (patch)
tree41be364b49fa780096e186725d893721027cdf43 /Source/cmIfCommand.cxx
parent1e2a08e4528d079f7050ac4a10d57fd7db2f6157 (diff)
downloadCMake-7321be8f6d105691c8e13107e15ec6264e6f1353.zip
CMake-7321be8f6d105691c8e13107e15ec6264e6f1353.tar.gz
CMake-7321be8f6d105691c8e13107e15ec6264e6f1353.tar.bz2
BUG: fix incrementing past end
Diffstat (limited to 'Source/cmIfCommand.cxx')
-rw-r--r--Source/cmIfCommand.cxx68
1 files changed, 29 insertions, 39 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index cf5bc82..9707112 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -136,6 +136,22 @@ bool cmIfCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args)
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,
// EXISTS COMMAND DEFINED
// MATCHES LESS GREATER EQUAL STRLESS STRGREATER STREQUAL
@@ -207,9 +223,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
while (arg != newArgs.end())
{
argP1 = arg;
- argP1++;
- argP2 = argP1;
- argP2++;
+ IncrementArguments(newArgs,argP1,argP2);
// does a file exist
if (*arg == "EXISTS" && argP1 != newArgs.end())
{
@@ -241,9 +255,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
}
newArgs.erase(argP1);
argP1 = arg;
- argP1++;
- argP2 = argP1;
- argP2++;
+ IncrementArguments(newArgs,argP1,argP2);
reducible = 1;
}
// is a variable defined
@@ -260,9 +272,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
}
newArgs.erase(argP1);
argP1 = arg;
- argP1++;
- argP2 = argP1;
- argP2++;
+ IncrementArguments(newArgs,argP1,argP2);
reducible = 1;
}
++arg;
@@ -281,9 +291,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
while (arg != newArgs.end())
{
argP1 = arg;
- argP1++;
- argP2 = argP1;
- argP2++;
+ IncrementArguments(newArgs,argP1,argP2);
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
*(argP1) == "MATCHES")
{
@@ -310,9 +318,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
newArgs.erase(argP2);
newArgs.erase(argP1);
argP1 = arg;
- argP1++;
- argP2 = argP1;
- argP2++;
+ IncrementArguments(newArgs,argP1,argP2);
reducible = 1;
}
@@ -321,9 +327,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
*arg = "0";
newArgs.erase(argP1);
argP1 = arg;
- argP1++;
- argP2 = argP1;
- argP2++;
+ IncrementArguments(newArgs,argP1,argP2);
reducible = 1;
}
@@ -369,9 +373,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
newArgs.erase(argP2);
newArgs.erase(argP1);
argP1 = arg;
- argP1++;
- argP2 = argP1;
- argP2++;
+ IncrementArguments(newArgs,argP1,argP2);
reducible = 1;
}
@@ -407,9 +409,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
newArgs.erase(argP2);
newArgs.erase(argP1);
argP1 = arg;
- argP1++;
- argP2 = argP1;
- argP2++;
+ IncrementArguments(newArgs,argP1,argP2);
reducible = 1;
}
@@ -428,9 +428,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
while (arg != newArgs.end())
{
argP1 = arg;
- argP1++;
- argP2 = argP1;
- argP2++;
+ IncrementArguments(newArgs,argP1,argP2);
if (argP1 != newArgs.end() && *arg == "NOT")
{
def = cmIfCommand::GetVariableOrNumber((argP1)->c_str(), makefile);
@@ -444,9 +442,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
}
newArgs.erase(argP1);
argP1 = arg;
- argP1++;
- argP2 = argP1;
- argP2++;
+ IncrementArguments(newArgs,argP1,argP2);
reducible = 1;
}
++arg;
@@ -463,9 +459,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
while (arg != newArgs.end())
{
argP1 = arg;
- argP1++;
- argP2 = argP1;
- argP2++;
+ IncrementArguments(newArgs,argP1,argP2);
if (argP1 != newArgs.end() && *(argP1) == "AND" &&
argP2 != newArgs.end())
{
@@ -482,9 +476,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
newArgs.erase(argP2);
newArgs.erase(argP1);
argP1 = arg;
- argP1++;
- argP2 = argP1;
- argP2++;
+ IncrementArguments(newArgs,argP1,argP2);
reducible = 1;
}
@@ -504,9 +496,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
newArgs.erase(argP2);
newArgs.erase(argP1);
argP1 = arg;
- argP1++;
- argP2 = argP1;
- argP2++;
+ IncrementArguments(newArgs,argP1,argP2);
reducible = 1;
}