[Cmake-commits] [cmake-commits] martink committed cmIfCommand.cxx 1.86 1.87 cmIfCommand.h 1.47 1.48 cmWhileCommand.cxx 1.12 1.13
cmake-commits at cmake.org
cmake-commits at cmake.org
Sat Jun 28 11:16:39 EDT 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv5293/Source
Modified Files:
cmIfCommand.cxx cmIfCommand.h cmWhileCommand.cxx
Log Message:
BUG: fix memory leak and cleanup error string code
Index: cmWhileCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmWhileCommand.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -C 2 -d -r1.12 -r1.13
*** cmWhileCommand.cxx 1 Mar 2008 02:33:33 -0000 1.12
--- cmWhileCommand.cxx 28 Jun 2008 15:16:36 -0000 1.13
***************
*** 40,49 ****
if (!this->Depth)
{
! char* errorString = 0;
std::vector<std::string> expandedArguments;
mf.ExpandArguments(this->Args, expandedArguments);
bool isTrue =
! cmIfCommand::IsTrue(expandedArguments,&errorString,&mf);
this->Executing = true;
--- 40,49 ----
if (!this->Depth)
{
! std::string errorString;
std::vector<std::string> expandedArguments;
mf.ExpandArguments(this->Args, expandedArguments);
bool isTrue =
! cmIfCommand::IsTrue(expandedArguments,errorString,&mf);
this->Executing = true;
***************
*** 70,74 ****
mf.ExpandArguments(this->Args, expandedArguments);
isTrue =
! cmIfCommand::IsTrue(expandedArguments,&errorString,&mf);
}
mf.RemoveFunctionBlocker(lff);
--- 70,74 ----
mf.ExpandArguments(this->Args, expandedArguments);
isTrue =
! cmIfCommand::IsTrue(expandedArguments,errorString,&mf);
}
mf.RemoveFunctionBlocker(lff);
Index: cmIfCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.cxx,v
retrieving revision 1.86
retrieving revision 1.87
diff -C 2 -d -r1.86 -r1.87
*** cmIfCommand.cxx 26 Jun 2008 17:01:34 -0000 1.86
--- cmIfCommand.cxx 28 Jun 2008 15:16:36 -0000 1.87
***************
*** 77,81 ****
else
{
! char* errorString = 0;
std::vector<std::string> expandedArguments;
--- 77,81 ----
else
{
! std::string errorString;
std::vector<std::string> expandedArguments;
***************
*** 83,89 ****
expandedArguments);
bool isTrue =
! cmIfCommand::IsTrue(expandedArguments,&errorString,&mf);
! if (errorString)
{
std::string err = "had incorrect arguments: ";
--- 83,89 ----
expandedArguments);
bool isTrue =
! cmIfCommand::IsTrue(expandedArguments,errorString,&mf);
! if (errorString.size())
{
std::string err = "had incorrect arguments: ";
***************
*** 100,104 ****
err += ").";
cmSystemTools::Error(err.c_str());
- delete [] errorString;
return false;
}
--- 100,103 ----
***************
*** 184,195 ****
cmExecutionStatus &)
{
! char* errorString = 0;
std::vector<std::string> expandedArguments;
this->Makefile->ExpandArguments(args, expandedArguments);
bool isTrue =
! cmIfCommand::IsTrue(expandedArguments,&errorString,this->Makefile);
! if (errorString)
{
std::string err = "had incorrect arguments: ";
--- 183,194 ----
cmExecutionStatus &)
{
! std::string errorString;
std::vector<std::string> expandedArguments;
this->Makefile->ExpandArguments(args, expandedArguments);
bool isTrue =
! cmIfCommand::IsTrue(expandedArguments,errorString,this->Makefile);
! if (errorString.size())
{
std::string err = "had incorrect arguments: ";
***************
*** 206,210 ****
err += ").";
this->SetError(err.c_str());
- delete [] errorString;
return false;
}
--- 205,208 ----
***************
*** 291,295 ****
bool HandleLevel0(std::list<std::string> &newArgs,
cmMakefile *makefile,
! char **errorString)
{
int reducible;
--- 289,293 ----
bool HandleLevel0(std::list<std::string> &newArgs,
cmMakefile *makefile,
! std::string &errorString)
{
int reducible;
***************
*** 321,329 ****
if (depth)
{
! cmOStringStream error;
! error << "mismatched parenthesis in condition";
! delete [] *errorString;
! *errorString = new char[error.str().size() + 1];
! strcpy(*errorString, error.str().c_str());
return false;
}
--- 319,323 ----
if (depth)
{
! errorString = "mismatched parenthesis in condition";
return false;
}
***************
*** 366,370 ****
bool HandleLevel1(std::list<std::string> &newArgs,
cmMakefile *makefile,
! char **)
{
int reducible;
--- 360,364 ----
bool HandleLevel1(std::list<std::string> &newArgs,
cmMakefile *makefile,
! std::string &)
{
int reducible;
***************
*** 443,447 ****
bool HandleLevel2(std::list<std::string> &newArgs,
cmMakefile *makefile,
! char **errorString)
{
int reducible;
--- 437,441 ----
bool HandleLevel2(std::list<std::string> &newArgs,
cmMakefile *makefile,
! std::string &errorString)
{
int reducible;
***************
*** 469,475 ****
cmOStringStream error;
error << "Regular expression \"" << rex << "\" cannot compile";
! delete [] *errorString;
! *errorString = new char[error.str().size() + 1];
! strcpy(*errorString, error.str().c_str());
return false;
}
--- 463,467 ----
cmOStringStream error;
error << "Regular expression \"" << rex << "\" cannot compile";
! errorString = error.str();
return false;
}
***************
*** 578,582 ****
bool HandleLevel3(std::list<std::string> &newArgs,
cmMakefile *makefile,
! char **)
{
int reducible;
--- 570,574 ----
bool HandleLevel3(std::list<std::string> &newArgs,
cmMakefile *makefile,
! std::string &)
{
int reducible;
***************
*** 609,613 ****
bool HandleLevel4(std::list<std::string> &newArgs,
cmMakefile *makefile,
! char **)
{
int reducible;
--- 601,605 ----
bool HandleLevel4(std::list<std::string> &newArgs,
cmMakefile *makefile,
! std::string &)
{
int reducible;
***************
*** 670,686 ****
bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
! char **errorString, cmMakefile *makefile)
{
- // check for the different signatures
const char *def;
! const char* msg = "Unknown arguments specified";
! *errorString = new char[strlen(msg) + 1];
! strcpy(*errorString, msg);
// handle empty invocation
if (args.size() < 1)
{
- delete [] *errorString;
- *errorString = 0;
return false;
}
--- 662,673 ----
bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
! std::string &errorString, cmMakefile *makefile)
{
const char *def;
! errorString = "";
// handle empty invocation
if (args.size() < 1)
{
return false;
}
***************
*** 721,726 ****
if (newArgs.size() == 1)
{
- delete [] *errorString;
- *errorString = 0;
if (*newArgs.begin() == "0")
{
--- 708,711 ----
***************
*** 737,741 ****
}
}
!
return true;
}
--- 722,731 ----
}
}
! else
! {
! errorString = "Unknown arguments specified";
! return false;
! }
!
return true;
}
Index: cmIfCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -C 2 -d -r1.47 -r1.48
*** cmIfCommand.h 20 Mar 2008 22:25:59 -0000 1.47
--- cmIfCommand.h 28 Jun 2008 15:16:36 -0000 1.48
***************
*** 185,189 ****
// an error, the errorString will be set.
static bool IsTrue(const std::vector<std::string> &args,
! char** errorString, cmMakefile *mf);
// Get a definition from the makefile. If it doesn't exist,
--- 185,189 ----
// an error, the errorString will be set.
static bool IsTrue(const std::vector<std::string> &args,
! std::string &errorString, cmMakefile *mf);
// Get a definition from the makefile. If it doesn't exist,
More information about the Cmake-commits
mailing list