[cmake-commits] king committed cmIfCommand.cxx 1.71 1.72
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Oct 25 10:31:30 EDT 2006
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv29774
Modified Files:
cmIfCommand.cxx
Log Message:
BUG: For LESS, GREATER, and EQUAL check that the arguments can actually be converted to numbers. Also force the conversion results to be stored in memory to make sure they both use the same precision. This addresses bug#3966.
Index: cmIfCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.cxx,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- cmIfCommand.cxx 23 Oct 2006 21:14:19 -0000 1.71
+++ cmIfCommand.cxx 25 Oct 2006 14:31:26 -0000 1.72
@@ -394,9 +394,29 @@
{
def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile);
+ double lhs;
+ if(sscanf(def, "%lg", &lhs) != 1)
+ {
+ cmOStringStream error;
+ error << "could not convert \"" << def << "\" to a number";
+ delete [] *errorString;
+ *errorString = new char[error.str().size() + 1];
+ strcpy(*errorString, error.str().c_str());
+ return false;
+ }
+ double rhs;
+ if(sscanf(def2, "%lg", &rhs) != 1)
+ {
+ cmOStringStream error;
+ error << "could not convert \"" << def2 << "\" to a number";
+ delete [] *errorString;
+ *errorString = new char[error.str().size() + 1];
+ strcpy(*errorString, error.str().c_str());
+ return false;
+ }
if (*(argP1) == "LESS")
{
- if(atof(def) < atof(def2))
+ if(lhs < rhs)
{
*arg = "1";
}
@@ -407,7 +427,7 @@
}
else if (*(argP1) == "GREATER")
{
- if(atof(def) > atof(def2))
+ if(lhs > rhs)
{
*arg = "1";
}
@@ -418,7 +438,7 @@
}
else
{
- if(atof(def) == atof(def2))
+ if(lhs == rhs)
{
*arg = "1";
}
More information about the Cmake-commits
mailing list