BUG: It cannot be an error if the values do not convert. The docs say that if the values do not convert the test is false.

This commit is contained in:
Brad King 2006-10-25 10:57:26 -04:00
parent d563ab6677
commit b7e04e69ae
1 changed files with 4 additions and 17 deletions

View File

@ -395,26 +395,13 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile); def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile); def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile);
double lhs; 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; double rhs;
if(sscanf(def2, "%lg", &rhs) != 1) if(sscanf(def, "%lg", &lhs) != 1 ||
sscanf(def2, "%lg", &rhs) != 1)
{ {
cmOStringStream error; *arg = "0";
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") else if (*(argP1) == "LESS")
{ {
if(lhs < rhs) if(lhs < rhs)
{ {