summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/IFW/cmCPackIFWRepository.cxx2
-rw-r--r--Source/CPack/cmCPackGenerator.cxx3
-rw-r--r--Source/CPack/cpack.cxx3
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx4
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx2
-rw-r--r--Source/CTest/cmCTestRunTest.cxx4
-rw-r--r--Source/CTest/cmCTestSVN.cxx2
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx10
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx4
-rw-r--r--Source/CTest/cmParseCoberturaCoverage.cxx4
-rw-r--r--Source/CTest/cmParseDelphiCoverage.cxx3
-rw-r--r--Source/CTest/cmParseJacocoCoverage.cxx2
-rw-r--r--Source/cmCTest.cxx6
-rw-r--r--Source/cmDependsJavaParserHelper.cxx2
-rw-r--r--Source/cmFindLibraryCommand.cxx4
-rw-r--r--Source/cmFindProgramCommand.cxx4
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx4
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx4
-rw-r--r--Source/cmLoadCommandCommand.cxx2
-rw-r--r--Source/cmLocalGenerator.cxx4
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx6
-rw-r--r--Source/cmOutputRequiredFilesCommand.cxx2
-rw-r--r--Source/cmPolicies.cxx2
-rw-r--r--Source/cmServer.cxx2
-rw-r--r--Source/cmSystemTools.cxx2
-rw-r--r--Source/cmVariableWatch.cxx35
-rw-r--r--Source/cmVariableWatch.h3
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx4
-rw-r--r--Source/kwsys/kwsysPlatformTestsCXX.cxx6
30 files changed, 71 insertions, 66 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 5d065cd..666293c 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 9)
-set(CMake_VERSION_PATCH 20170920)
+set(CMake_VERSION_PATCH 20170922)
#set(CMake_VERSION_RC 1)
diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx
index 87e7089..a01fc4e 100644
--- a/Source/CPack/IFW/cmCPackIFWRepository.cxx
+++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx
@@ -162,7 +162,7 @@ protected:
void CharacterDataHandler(const char* data, int length) override
{
std::string content(data, data + length);
- if (content == "" || content == " " || content == " " ||
+ if (content.empty() || content == " " || content == " " ||
content == "\n") {
return;
}
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index e72fcc1..f56b5fa 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -999,8 +999,7 @@ int cmCPackGenerator::DoPackage()
/* Generate checksum file */
if (crypto.get() != nullptr) {
std::string hashFile(this->GetOption("CPACK_OUTPUT_FILE_PREFIX"));
- hashFile +=
- "/" + filename.substr(0, filename.rfind(this->GetOutputExtension()));
+ hashFile += "/" + filename;
hashFile += "." + cmSystemTools::LowerCase(algo);
cmsys::ofstream outF(hashFile.c_str());
if (!outF) {
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 33d03e5..cc51c60 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -350,13 +350,14 @@ int main(int argc, char const* const* argv)
}
if (!mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
+ !mf->GetDefinition("CPACK_INSTALL_SCRIPT") &&
!mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
!mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS")) {
cmCPack_Log(
&log, cmCPackLog::LOG_ERROR,
"Please specify build tree of the project that uses CMake "
"using CPACK_INSTALL_CMAKE_PROJECTS, specify "
- "CPACK_INSTALL_COMMANDS, or specify "
+ "CPACK_INSTALL_COMMANDS, CPACK_INSTALL_SCRIPT, or "
"CPACK_INSTALLED_DIRECTORIES."
<< std::endl);
parsed = 0;
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index 28fc113..1da42d4 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -260,11 +260,11 @@ std::string cmCTestBuildHandler::GetMakeCommand()
"MakeCommand:" << makeCommand << "\n", this->Quiet);
std::string configType = this->CTest->GetConfigType();
- if (configType == "") {
+ if (configType.empty()) {
configType =
this->CTest->GetCTestConfiguration("DefaultCTestConfigurationType");
}
- if (configType == "") {
+ if (configType.empty()) {
configType = "Release";
}
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index c853373..6a7bdc0 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -491,7 +491,7 @@ void cmCTestMultiProcessHandler::ReadCostData()
}
// Next part of the file is the failed tests
while (std::getline(fin, line)) {
- if (line != "") {
+ if (!line.empty()) {
this->LastTestsFailed.push_back(line);
}
}
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 56a9cb8..abdb643 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -494,7 +494,7 @@ bool cmCTestRunTest::StartTest(size_t total)
}
}
// log and return if we did not find the executable
- if (this->ActualCommand == "") {
+ if (this->ActualCommand.empty()) {
// if the command was not found create a TestResult object
// that has that information
this->TestProcess = new cmProcess;
@@ -595,7 +595,7 @@ double cmCTestRunTest::ResolveTimeout()
{
double timeout = this->TestProperties->Timeout;
- if (this->CTest->GetStopTime() == "") {
+ if (this->CTest->GetStopTime().empty()) {
return timeout;
}
struct tm* lctime;
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index 087eb38..ce96224 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -410,7 +410,7 @@ void cmCTestSVN::DoRevisionSVN(Revision const& revision,
// Ignore changes in the old revision for external repositories
if (revision.Rev == revision.SVNInfo->OldRevision &&
- revision.SVNInfo->LocalPath != "") {
+ !revision.SVNInfo->LocalPath.empty()) {
return;
}
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 137cea9..e51e168 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -496,11 +496,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
? ""
: this->GetOption("RetryCount");
- int delay = retryDelay == ""
+ int delay = retryDelay.empty()
? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryDelay")
.c_str())
: atoi(retryDelay.c_str());
- int count = retryCount == ""
+ int count = retryCount.empty()
? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryCount")
.c_str())
: atoi(retryCount.c_str());
@@ -1032,14 +1032,14 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
? ""
: this->GetOption("RetryCount");
unsigned long retryDelay = 0;
- if (retryDelayString != "") {
+ if (!retryDelayString.empty()) {
if (!cmSystemTools::StringToULong(retryDelayString.c_str(), &retryDelay)) {
cmCTestLog(this->CTest, WARNING, "Invalid value for 'RETRY_DELAY' : "
<< retryDelayString << std::endl);
}
}
unsigned long retryCount = 0;
- if (retryCountString != "") {
+ if (!retryCountString.empty()) {
if (!cmSystemTools::StringToULong(retryCountString.c_str(), &retryCount)) {
cmCTestLog(this->CTest, WARNING, "Invalid value for 'RETRY_DELAY' : "
<< retryCountString << std::endl);
@@ -1361,7 +1361,7 @@ int cmCTestSubmitHandler::ProcessHandler()
std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
- if (dropMethod == "" || dropMethod == "ftp") {
+ if (dropMethod.empty() || dropMethod == "ftp") {
ofs << "Using drop method: FTP" << std::endl;
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
" Using FTP submit method" << std::endl
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index f3404a5..5896014 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -1596,7 +1596,7 @@ std::string cmCTestTestHandler::FindExecutable(
// wasn't specified
if (fullPath.empty() && filepath.empty()) {
std::string const path = cmSystemTools::FindProgram(filename.c_str());
- if (path != "") {
+ if (!path.empty()) {
resultingConfig.clear();
return path;
}
@@ -1802,7 +1802,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
if (fileNameSubstring != pattern) {
continue;
}
- if (logName == "") {
+ if (logName.empty()) {
logName = fileName;
} else {
// if multiple matching logs were found we use the most recently
diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx
index 3e85339..61ce7d4 100644
--- a/Source/CTest/cmParseCoberturaCoverage.cxx
+++ b/Source/CTest/cmParseCoberturaCoverage.cxx
@@ -78,7 +78,7 @@ protected:
}
}
- if (this->CurFileName == "") {
+ if (this->CurFileName.empty()) {
// Check if this is a path that is relative to our source or
// binary directories.
for (std::string const& filePath : FilePaths) {
@@ -91,7 +91,7 @@ protected:
}
cmsys::ifstream fin(this->CurFileName.c_str());
- if (this->CurFileName == "" || !fin) {
+ if (this->CurFileName.empty() || !fin) {
this->CurFileName =
this->Coverage.BinaryDir + "/" + atts[tagCount + 1];
fin.open(this->CurFileName.c_str());
diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx
index 4b781a6..6d82cb2 100644
--- a/Source/CTest/cmParseDelphiCoverage.cxx
+++ b/Source/CTest/cmParseDelphiCoverage.cxx
@@ -71,7 +71,8 @@ public:
}
}
// Based up what was found, add a line to the coverageVector
- if (!beginSet.empty() && line != "" && !blockComFlag && !lineComFlag) {
+ if (!beginSet.empty() && !line.empty() && !blockComFlag &&
+ !lineComFlag) {
coverageVector.push_back(0);
} else {
coverageVector.push_back(-1);
diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx
index 56d07e7..7acb5ca 100644
--- a/Source/CTest/cmParseJacocoCoverage.cxx
+++ b/Source/CTest/cmParseJacocoCoverage.cxx
@@ -36,7 +36,7 @@ protected:
} else if (name == "sourcefile") {
std::string fileName = atts[1];
- if (this->PackagePath == "") {
+ if (this->PackagePath.empty()) {
if (!this->FindPackagePath(fileName)) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: "
<< this->PackageName << "/" << fileName << std::endl);
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index d60ce55..ba50986 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -147,7 +147,7 @@ std::string cmCTest::CurrentTime()
std::string cmCTest::GetCostDataFile()
{
std::string fname = this->GetCTestConfiguration("CostDataFile");
- if (fname == "") {
+ if (fname.empty()) {
fname = this->GetBinaryDir() + "/Testing/Temporary/CTestCostData.txt";
}
return fname;
@@ -1235,7 +1235,7 @@ std::string cmCTest::SafeBuildIdField(const std::string& value)
{
std::string safevalue(value);
- if (safevalue != "") {
+ if (!safevalue.empty()) {
// Disallow non-filename and non-space whitespace characters.
// If they occur, replace them with ""
//
@@ -1254,7 +1254,7 @@ std::string cmCTest::SafeBuildIdField(const std::string& value)
}
}
- if (safevalue == "") {
+ if (safevalue.empty()) {
safevalue = "(empty)";
}
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx
index 85dfc7d..f227cf2 100644
--- a/Source/cmDependsJavaParserHelper.cxx
+++ b/Source/cmDependsJavaParserHelper.cxx
@@ -310,7 +310,7 @@ void cmDependsJavaParserHelper::Error(const char* str)
void cmDependsJavaParserHelper::UpdateCombine(const char* str1,
const char* str2)
{
- if (this->CurrentCombine == "" && str1 != nullptr) {
+ if (this->CurrentCombine.empty() && str1 != nullptr) {
this->CurrentCombine = str1;
}
this->CurrentCombine += ".";
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index 09a9648..b8b51ba 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -68,8 +68,8 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn,
this->AddArchitecturePaths("x32");
}
- std::string library = this->FindLibrary();
- if (library != "") {
+ std::string const library = this->FindLibrary();
+ if (!library.empty()) {
// Save the value in the cache
this->Makefile->AddCacheDefinition(this->VariableName, library.c_str(),
this->VariableDocumentation.c_str(),
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index a5dc1c6..2059b3d 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -97,8 +97,8 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn,
return true;
}
- std::string result = FindProgram();
- if (result != "") {
+ std::string const result = FindProgram();
+ if (!result.empty()) {
// Save the value in the cache
this->Makefile->AddCacheDefinition(this->VariableName, result.c_str(),
this->VariableDocumentation.c_str(),
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 15ddeff..be40126 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -230,7 +230,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
// The all and preinstall rules might never have any dependencies
// added to them.
- if (this->EmptyRuleHackDepends != "") {
+ if (!this->EmptyRuleHackDepends.empty()) {
depends.push_back(this->EmptyRuleHackDepends);
}
@@ -438,7 +438,7 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2(
// Work-around for makes that drop rules that have no dependencies
// or commands.
- if (depends.empty() && this->EmptyRuleHackDepends != "") {
+ if (depends.empty() && !this->EmptyRuleHackDepends.empty()) {
depends.push_back(this->EmptyRuleHackDepends);
}
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index ece2a77..0651536 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -150,7 +150,7 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
{
std::string dir = this->GetUserMacrosDirectory();
- if (dir != "") {
+ if (!dir.empty()) {
std::string src = cmSystemTools::GetCMakeRoot();
src += "/Templates/" CMAKE_VSMACROS_FILENAME;
@@ -190,7 +190,7 @@ void cmGlobalVisualStudioGenerator::CallVisualStudioMacro(
// - the CMake vsmacros file is registered
// - there were .sln/.vcproj files changed during generation
//
- if (dir != "") {
+ if (!dir.empty()) {
std::string macrosFile = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME;
std::string nextSubkeyName;
if (cmSystemTools::FileExists(macrosFile.c_str()) &&
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index 2850032..6bfac17 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -197,7 +197,7 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
// Try to find the program.
std::string fullPath = cmSystemTools::FindFile(moduleName, path);
- if (fullPath == "") {
+ if (fullPath.empty()) {
std::ostringstream e;
e << "Attempt to load command failed from file \"" << moduleName << "\"";
this->SetError(e.str());
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index e1662ac..1a088ea 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1410,7 +1410,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
// If the input name is the empty string, there is no real
// dependency. Short-circuit the other checks:
- if (name == "") {
+ if (name.empty()) {
return false;
}
@@ -2096,7 +2096,7 @@ void cmLocalGenerator::GenerateTargetInstallRules(
}
// Install this target if a destination is given.
- if (l->Target->GetInstallPath() != "") {
+ if (!l->Target->GetInstallPath().empty()) {
// Compute the full install destination. Note that converting
// to unix slashes also removes any trailing slash.
// We also skip over the leading slash given by the user.
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index c978936..a1771ee 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1591,7 +1591,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
// If the group has a name, write the header.
std::string name = sg->GetName();
- if (name != "") {
+ if (!name.empty()) {
this->WriteVCProjBeginGroup(fout, name.c_str(), "");
}
@@ -1709,7 +1709,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
}
// If the group has a name, write the footer.
- if (name != "") {
+ if (!name.empty()) {
this->WriteVCProjEndGroup(fout);
}
@@ -2006,7 +2006,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFooter(
i != props.end(); ++i) {
if (i->find("VS_GLOBAL_") == 0) {
std::string name = i->substr(10);
- if (name != "") {
+ if (!name.empty()) {
/* clang-format off */
fout << "\t\t<Global\n"
<< "\t\t\tName=\"" << name << "\"\n"
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index c430298..cde9037 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -510,7 +510,7 @@ void cmOutputRequiredFilesCommand::ListDependencies(
// now recurse with info's dependencies
for (cmDependInformation* d : info->DependencySet) {
if (visited->find(d) == visited->end()) {
- if (info->FullPath != "") {
+ if (!info->FullPath.empty()) {
std::string tmp = d->FullPath;
std::string::size_type pos = tmp.rfind('.');
if (pos != std::string::npos && (tmp.substr(pos) != ".h")) {
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index a1f346a..e7d1b72 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -140,7 +140,7 @@ static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
*defaultSetting = cmPolicies::NEW;
} else if (defaultValue == "OLD") {
*defaultSetting = cmPolicies::OLD;
- } else if (defaultValue == "") {
+ } else if (defaultValue.empty()) {
*defaultSetting = cmPolicies::WARN;
} else {
std::ostringstream e;
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index 30d0f51..e923c22 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -84,7 +84,7 @@ void cmServer::ProcessRequest(cmConnection* connection,
const cmServerRequest request(this, connection, value[kTYPE_KEY].asString(),
value[kCOOKIE_KEY].asString(), value);
- if (request.Type == "") {
+ if (request.Type.empty()) {
cmServerResponse response(request);
response.SetError("No type given in request.");
this->WriteResponse(connection, response, nullptr);
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 5f2737d..58adc43 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1375,7 +1375,7 @@ std::string cmSystemTools::CollapseCombinedPath(std::string const& dir,
if (fileComponents.empty()) {
return dir;
}
- if (fileComponents[0] != "") {
+ if (!fileComponents[0].empty()) {
// File is not a relative path.
return file;
}
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index 0e072b8..bd5d19c 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -2,11 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmVariableWatch.h"
-#include "cmAlgorithms.h"
-
-#include "cm_auto_ptr.hxx"
-#include <algorithm>
+#include <memory>
#include <utility>
+#include <vector>
static const char* const cmVariableWatchAccessStrings[] = {
"READ_ACCESS", "UNKNOWN_READ_ACCESS", "UNKNOWN_DEFINED_ACCESS",
@@ -25,35 +23,27 @@ cmVariableWatch::cmVariableWatch()
{
}
-template <typename C>
-void deleteAllSecond(typename C::value_type it)
-{
- cmDeleteAll(it.second);
-}
-
cmVariableWatch::~cmVariableWatch()
{
- std::for_each(this->WatchMap.begin(), this->WatchMap.end(),
- deleteAllSecond<cmVariableWatch::StringToVectorOfPairs>);
}
bool cmVariableWatch::AddWatch(const std::string& variable, WatchMethod method,
void* client_data /*=0*/,
DeleteData delete_data /*=0*/)
{
- CM_AUTO_PTR<cmVariableWatch::Pair> p(new cmVariableWatch::Pair);
+ auto p = std::make_shared<cmVariableWatch::Pair>();
p->Method = method;
p->ClientData = client_data;
p->DeleteDataCall = delete_data;
cmVariableWatch::VectorOfPairs& vp = this->WatchMap[variable];
- for (cmVariableWatch::Pair* pair : vp) {
+ for (auto& pair : vp) {
if (pair->Method == method && client_data &&
client_data == pair->ClientData) {
// Callback already exists
return false;
}
}
- vp.push_back(p.release());
+ vp.push_back(std::move(p));
return true;
}
@@ -70,7 +60,6 @@ void cmVariableWatch::RemoveWatch(const std::string& variable,
// If client_data is NULL, we want to disconnect all watches against
// the given method; otherwise match ClientData as well.
(!client_data || (client_data == (*it)->ClientData))) {
- delete *it;
vp->erase(it);
return;
}
@@ -84,9 +73,17 @@ bool cmVariableWatch::VariableAccessed(const std::string& variable,
cmVariableWatch::StringToVectorOfPairs::const_iterator mit =
this->WatchMap.find(variable);
if (mit != this->WatchMap.end()) {
- const cmVariableWatch::VectorOfPairs* vp = &mit->second;
- for (cmVariableWatch::Pair* it : *vp) {
- it->Method(variable, access_type, it->ClientData, newValue, mf);
+ // The strategy here is to copy the list of callbacks, and ignore
+ // new callbacks that existing ones may add.
+ std::vector<std::weak_ptr<Pair>> vp(mit->second.begin(),
+ mit->second.end());
+ for (auto& weak_it : vp) {
+ // In the case where a callback was removed, the weak_ptr will not be
+ // lockable, and so this ensures we don't attempt to call into freed
+ // memory
+ if (auto it = weak_it.lock()) {
+ it->Method(variable, access_type, it->ClientData, newValue, mf);
+ }
}
return true;
}
diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h
index 05a0a56..27d1b12 100644
--- a/Source/cmVariableWatch.h
+++ b/Source/cmVariableWatch.h
@@ -6,6 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
+#include <memory> // IWYU pragma: keep
#include <string>
#include <vector>
@@ -79,7 +80,7 @@ protected:
}
};
- typedef std::vector<Pair*> VectorOfPairs;
+ typedef std::vector<std::shared_ptr<Pair>> VectorOfPairs;
typedef std::map<std::string, VectorOfPairs> StringToVectorOfPairs;
StringToVectorOfPairs WatchMap;
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 99b9bce..8dce028 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -407,7 +407,7 @@ void cmVisualStudio10TargetGenerator::Generate()
continue;
std::string globalKey = keyIt->substr(strlen(prefix));
// Skip invalid or separately-handled properties.
- if (globalKey == "" || globalKey == "PROJECT_TYPES" ||
+ if (globalKey.empty() || globalKey == "PROJECT_TYPES" ||
globalKey == "ROOTNAMESPACE" || globalKey == "KEYWORD") {
continue;
}
@@ -614,7 +614,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences()
++i) {
if (i->first.find("VS_DOTNET_REFERENCE_") == 0) {
std::string name = i->first.substr(20);
- if (name != "") {
+ if (!name.empty()) {
std::string path = i->second.GetValue();
if (!cmsys::SystemTools::FileIsFullPath(path)) {
path = std::string(this->GeneratorTarget->Target->GetMakefile()
diff --git a/Source/kwsys/kwsysPlatformTestsCXX.cxx b/Source/kwsys/kwsysPlatformTestsCXX.cxx
index 01c6951..e67d436 100644
--- a/Source/kwsys/kwsysPlatformTestsCXX.cxx
+++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx
@@ -265,6 +265,12 @@ int main()
#ifdef TEST_KWSYS_CXX_HAS_UTIMENSAT
#include <fcntl.h>
#include <sys/stat.h>
+#if defined(__APPLE__)
+#include <AvailabilityMacros.h>
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 101300
+#error "utimensat not available on macOS < 10.13"
+#endif
+#endif
int main()
{
struct timespec times[2] = { { 0, UTIME_OMIT }, { 0, UTIME_NOW } };