From 3801463c9f99fdbf0b1a115f5a5f55d211c08de1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 8 Sep 2010 12:03:42 -0400 Subject: Use built-ins for readability and maintainability --- Source/cmCommandArgumentParserHelper.cxx | 5 +++-- Source/cmMakefile.cxx | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index c0a8127..54af13b 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -132,8 +132,9 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) { const char* srcRoot = this->Makefile->GetDefinition("CMAKE_SOURCE_DIR"); const char* binRoot = this->Makefile->GetDefinition("CMAKE_BINARY_DIR"); - if (this->CheckSystemVars || strstr(this->FileName, srcRoot) == this->FileName || - strstr(this->FileName, binRoot) == this->FileName) + if (this->CheckSystemVars || + cmSystemTools::IsSubDirectory(this->FileName, this->Makefile->GetHomeDirectory()) || + cmSystemTools::IsSubDirectory(this->FileName, this->Makefile->GetHomeOutputDirectory())) { cmOStringStream msg; msg << this->FileName << ":" << this->FileLine << ":" << diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 33c61a7..c15f5b3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -778,7 +778,7 @@ void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg) this->Internal->VarUsageStack.push(std::set()); } } - this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars(); + this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars(); } bool cmMakefile::NeedBackwardsCompatibility(unsigned int major, @@ -3394,9 +3394,9 @@ void cmMakefile::PopScope() if (this->WarnUnused && usage.find(*it) == usage.end()) { const char* cdir = this->ListFileStack.back().c_str(); - const char* srcRoot = this->GetDefinition("CMAKE_SOURCE_DIR"); - const char* binRoot = this->GetDefinition("CMAKE_BINARY_DIR"); - if (this->CheckSystemVars || strstr(cdir, srcRoot) == cdir || strstr(cdir, binRoot) == cdir) + if (this->CheckSystemVars || + cmSystemTools::IsSubDirectory(cdir, this->GetHomeDirectory()) || + cmSystemTools::IsSubDirectory(cdir, this->GetHomeOutputDirectory())) { cmOStringStream m; m << "unused variable \'" << *it << "\'"; -- cgit v0.12