Commit 653b8946 authored by Pavel Solodovnikov's avatar Pavel Solodovnikov
Browse files

Reduce raw string pointers usage.

* Change some functions to take `std::string` instead of
  `const char*` in the following classes: `cmMakeFile`, `cmake`,
  `cmCoreTryCompile`, `cmSystemTools`,  `cmState`, `cmLocalGenerator`
  and a few others.
* Greatly reduce using of `const char*` overloads for
  `cmSystemTools::MakeDirectory` and `cmSystemTools::RelativePath`.
* Remove many redundant `c_str()` conversions throughout the code.
parent 4499cc8b
...@@ -239,8 +239,7 @@ int cmCPackArchiveGenerator::PackageFiles() ...@@ -239,8 +239,7 @@ int cmCPackArchiveGenerator::PackageFiles()
cmWorkingDirectory workdir(toplevel); cmWorkingDirectory workdir(toplevel);
for (std::string const& file : files) { for (std::string const& file : files) {
// Get the relative path to the file // Get the relative path to the file
std::string rp = std::string rp = cmSystemTools::RelativePath(toplevel, file);
cmSystemTools::RelativePath(toplevel.c_str(), file.c_str());
archive.Add(rp, 0, nullptr, false); archive.Add(rp, 0, nullptr, false);
if (!archive) { if (!archive) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< " cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< "
......
...@@ -187,7 +187,7 @@ int cmCPackGenerator::InstallProject() ...@@ -187,7 +187,7 @@ int cmCPackGenerator::InstallProject()
const char* tempInstallDirectory = tempInstallDirectoryStr.c_str(); const char* tempInstallDirectory = tempInstallDirectoryStr.c_str();
int res = 1; int res = 1;
if (!cmsys::SystemTools::MakeDirectory(bareTempInstallDirectory.c_str())) { if (!cmsys::SystemTools::MakeDirectory(bareTempInstallDirectory)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating temporary directory: " "Problem creating temporary directory: "
<< (tempInstallDirectory ? tempInstallDirectory : "(NULL)") << (tempInstallDirectory ? tempInstallDirectory : "(NULL)")
...@@ -374,15 +374,14 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( ...@@ -374,15 +374,14 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
continue; continue;
} }
std::string filePath = tempDir; std::string filePath = tempDir;
filePath += "/" + subdir + "/" + filePath += "/" + subdir + "/" + cmSystemTools::RelativePath(top, gf);
cmSystemTools::RelativePath(top.c_str(), gf.c_str());
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: "
<< inFile << " -> " << filePath << std::endl); << inFile << " -> " << filePath << std::endl);
/* If the file is a symlink we will have to re-create it */ /* If the file is a symlink we will have to re-create it */
if (cmSystemTools::FileIsSymlink(inFile)) { if (cmSystemTools::FileIsSymlink(inFile)) {
std::string targetFile; std::string targetFile;
std::string inFileRelative = std::string inFileRelative =
cmSystemTools::RelativePath(top.c_str(), inFile.c_str()); cmSystemTools::RelativePath(top, inFile);
cmSystemTools::ReadSymlink(inFile, targetFile); cmSystemTools::ReadSymlink(inFile, targetFile);
symlinkedFiles.emplace_back(std::move(targetFile), symlinkedFiles.emplace_back(std::move(targetFile),
std::move(inFileRelative)); std::move(inFileRelative));
...@@ -772,9 +771,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( ...@@ -772,9 +771,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
} }
// Remember the list of files before installation // Remember the list of files before installation
// of the current component (if we are in component install) // of the current component (if we are in component install)
const char* InstallPrefix = tempInstallDirectory.c_str(); std::string const& InstallPrefix = tempInstallDirectory;
std::vector<std::string> filesBefore; std::vector<std::string> filesBefore;
std::string findExpr(InstallPrefix); std::string findExpr = tempInstallDirectory;
if (componentInstall) { if (componentInstall) {
cmsys::Glob glB; cmsys::Glob glB;
findExpr += "/*"; findExpr += "/*";
...@@ -829,8 +828,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( ...@@ -829,8 +828,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
std::string localFileName; std::string localFileName;
// Populate the File field of each component // Populate the File field of each component
for (fit = result.begin(); fit != diff; ++fit) { for (fit = result.begin(); fit != diff; ++fit) {
localFileName = localFileName = cmSystemTools::RelativePath(InstallPrefix, *fit);
cmSystemTools::RelativePath(InstallPrefix, fit->c_str());
localFileName = localFileName =
localFileName.substr(localFileName.find_first_not_of('/')); localFileName.substr(localFileName.find_first_not_of('/'));
Components[installComponent].Files.push_back(localFileName); Components[installComponent].Files.push_back(localFileName);
......
...@@ -62,8 +62,7 @@ int cmCPackNSISGenerator::PackageFiles() ...@@ -62,8 +62,7 @@ int cmCPackNSISGenerator::PackageFiles()
std::ostringstream str; std::ostringstream str;
for (std::string const& file : files) { for (std::string const& file : files) {
std::string outputDir = "$INSTDIR"; std::string outputDir = "$INSTDIR";
std::string fileN = std::string fileN = cmSystemTools::RelativePath(toplevel, file);
cmSystemTools::RelativePath(toplevel.c_str(), file.c_str());
if (!this->Components.empty()) { if (!this->Components.empty()) {
const std::string::size_type pos = fileN.find('/'); const std::string::size_type pos = fileN.find('/');
...@@ -90,8 +89,7 @@ int cmCPackNSISGenerator::PackageFiles() ...@@ -90,8 +89,7 @@ int cmCPackNSISGenerator::PackageFiles()
std::ostringstream dstr; std::ostringstream dstr;
for (std::string const& dir : dirs) { for (std::string const& dir : dirs) {
std::string componentName; std::string componentName;
std::string fileN = std::string fileN = cmSystemTools::RelativePath(toplevel, dir);
cmSystemTools::RelativePath(toplevel.c_str(), dir.c_str());
if (fileN.empty()) { if (fileN.empty()) {
continue; continue;
} }
...@@ -669,8 +667,8 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( ...@@ -669,8 +667,8 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY"); uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
uploadDirectory += "/CPackUploads"; uploadDirectory += "/CPackUploads";
} }
if (!cmSystemTools::FileExists(uploadDirectory.c_str())) { if (!cmSystemTools::FileExists(uploadDirectory)) {
if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str())) { if (!cmSystemTools::MakeDirectory(uploadDirectory)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Unable to create NSIS upload directory " "Unable to create NSIS upload directory "
<< uploadDirectory << std::endl); << uploadDirectory << std::endl);
...@@ -683,7 +681,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( ...@@ -683,7 +681,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
cmCPackLogger(cmCPackLog::LOG_OUTPUT, cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"- Building downloaded component archive: " << archiveFile "- Building downloaded component archive: " << archiveFile
<< std::endl); << std::endl);
if (cmSystemTools::FileExists(archiveFile.c_str(), true)) { if (cmSystemTools::FileExists(archiveFile, true)) {
if (!cmSystemTools::RemoveFile(archiveFile)) { if (!cmSystemTools::RemoveFile(archiveFile)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Unable to remove archive file " cmCPackLogger(cmCPackLog::LOG_ERROR, "Unable to remove archive file "
<< archiveFile << std::endl); << archiveFile << std::endl);
......
...@@ -260,7 +260,7 @@ int main(int argc, char const* const* argv) ...@@ -260,7 +260,7 @@ int main(int argc, char const* const* argv)
globalMF.AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str()); globalMF.AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
} }
if (cmSystemTools::FileExists(cpackConfigFile.c_str())) { if (cmSystemTools::FileExists(cpackConfigFile)) {
cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile); cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Read CPack configuration file: " << cpackConfigFile "Read CPack configuration file: " << cpackConfigFile
......
...@@ -193,7 +193,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) ...@@ -193,7 +193,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
out << "Internal cmake changing into directory: " << this->BinaryDir out << "Internal cmake changing into directory: " << this->BinaryDir
<< std::endl; << std::endl;
if (!cmSystemTools::FileIsDirectory(this->BinaryDir)) { if (!cmSystemTools::FileIsDirectory(this->BinaryDir)) {
cmSystemTools::MakeDirectory(this->BinaryDir.c_str()); cmSystemTools::MakeDirectory(this->BinaryDir);
} }
cmWorkingDirectory workdir(this->BinaryDir); cmWorkingDirectory workdir(this->BinaryDir);
...@@ -280,7 +280,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) ...@@ -280,7 +280,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
cmCTestTestHandler::FindExecutable(this->CTest, this->TestCommand.c_str(), cmCTestTestHandler::FindExecutable(this->CTest, this->TestCommand.c_str(),
resultingConfig, extraPaths, failed); resultingConfig, extraPaths, failed);
if (!cmSystemTools::FileExists(fullPath.c_str())) { if (!cmSystemTools::FileExists(fullPath)) {
out << "Could not find path to executable, perhaps it was not built: " out << "Could not find path to executable, perhaps it was not built: "
<< this->TestCommand << "\n"; << this->TestCommand << "\n";
out << "tried to find it in these places:\n"; out << "tried to find it in these places:\n";
...@@ -358,7 +358,7 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments( ...@@ -358,7 +358,7 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
idx++; idx++;
this->BinaryDir = allArgs[idx]; this->BinaryDir = allArgs[idx];
// dir must exist before CollapseFullPath is called // dir must exist before CollapseFullPath is called
cmSystemTools::MakeDirectory(this->BinaryDir.c_str()); cmSystemTools::MakeDirectory(this->BinaryDir);
this->BinaryDir = cmSystemTools::CollapseFullPath(this->BinaryDir); this->BinaryDir = cmSystemTools::CollapseFullPath(this->BinaryDir);
this->SourceDir = cmSystemTools::CollapseFullPath(this->SourceDir); this->SourceDir = cmSystemTools::CollapseFullPath(this->SourceDir);
} else { } else {
......
...@@ -709,7 +709,7 @@ cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler) ...@@ -709,7 +709,7 @@ cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler)
if (this->Handler->UseCTestLaunch) { if (this->Handler->UseCTestLaunch) {
// Enable launcher fragments. // Enable launcher fragments.
cmSystemTools::MakeDirectory(launchDir.c_str()); cmSystemTools::MakeDirectory(launchDir);
this->WriteLauncherConfig(); this->WriteLauncherConfig();
std::string launchEnv = "CTEST_LAUNCH_LOGS="; std::string launchEnv = "CTEST_LAUNCH_LOGS=";
launchEnv += launchDir; launchEnv += launchDir;
......
...@@ -57,7 +57,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() ...@@ -57,7 +57,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
} }
const std::string cmakelists_file = source_dir + "/CMakeLists.txt"; const std::string cmakelists_file = source_dir + "/CMakeLists.txt";
if (!cmSystemTools::FileExists(cmakelists_file.c_str())) { if (!cmSystemTools::FileExists(cmakelists_file)) {
std::ostringstream e; std::ostringstream e;
e << "CMakeLists.txt file does not exist [" << cmakelists_file << "]"; e << "CMakeLists.txt file does not exist [" << cmakelists_file << "]";
this->SetError(e.str()); this->SetError(e.str());
......
...@@ -240,7 +240,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file, ...@@ -240,7 +240,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file,
// If it is the same as fileDir, then ignore, otherwise check. // If it is the same as fileDir, then ignore, otherwise check.
std::string relPath; std::string relPath;
if (!checkDir.empty()) { if (!checkDir.empty()) {
relPath = cmSystemTools::RelativePath(checkDir.c_str(), fFile.c_str()); relPath = cmSystemTools::RelativePath(checkDir, fFile);
} else { } else {
relPath = fFile; relPath = fFile;
} }
...@@ -450,7 +450,7 @@ int cmCTestCoverageHandler::ProcessHandler() ...@@ -450,7 +450,7 @@ int cmCTestCoverageHandler::ProcessHandler()
"Process file: " << fullFileName << std::endl, "Process file: " << fullFileName << std::endl,
this->Quiet); this->Quiet);
if (!cmSystemTools::FileExists(fullFileName.c_str())) { if (!cmSystemTools::FileExists(fullFileName)) {
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find file: " << fullFileName << std::endl); "Cannot find file: " << fullFileName << std::endl);
continue; continue;
...@@ -718,7 +718,7 @@ int cmCTestCoverageHandler::HandleCoberturaCoverage( ...@@ -718,7 +718,7 @@ int cmCTestCoverageHandler::HandleCoberturaCoverage(
// build the find file string with the directory from above // build the find file string with the directory from above
coverageXMLFile += "/coverage.xml"; coverageXMLFile += "/coverage.xml";
if (cmSystemTools::FileExists(coverageXMLFile.c_str())) { if (cmSystemTools::FileExists(coverageXMLFile)) {
// If file exists, parse it // If file exists, parse it
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Parsing Cobertura XML file: " << coverageXMLFile "Parsing Cobertura XML file: " << coverageXMLFile
...@@ -741,7 +741,7 @@ int cmCTestCoverageHandler::HandleMumpsCoverage( ...@@ -741,7 +741,7 @@ int cmCTestCoverageHandler::HandleMumpsCoverage(
cmParseGTMCoverage cov(*cont, this->CTest); cmParseGTMCoverage cov(*cont, this->CTest);
std::string coverageFile = std::string coverageFile =
this->CTest->GetBinaryDir() + "/gtm_coverage.mcov"; this->CTest->GetBinaryDir() + "/gtm_coverage.mcov";
if (cmSystemTools::FileExists(coverageFile.c_str())) { if (cmSystemTools::FileExists(coverageFile)) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Parsing Cache Coverage: " << coverageFile << std::endl, "Parsing Cache Coverage: " << coverageFile << std::endl,
this->Quiet); this->Quiet);
...@@ -754,7 +754,7 @@ int cmCTestCoverageHandler::HandleMumpsCoverage( ...@@ -754,7 +754,7 @@ int cmCTestCoverageHandler::HandleMumpsCoverage(
this->Quiet); this->Quiet);
cmParseCacheCoverage ccov(*cont, this->CTest); cmParseCacheCoverage ccov(*cont, this->CTest);
coverageFile = this->CTest->GetBinaryDir() + "/cache_coverage.cmcov"; coverageFile = this->CTest->GetBinaryDir() + "/cache_coverage.cmcov";
if (cmSystemTools::FileExists(coverageFile.c_str())) { if (cmSystemTools::FileExists(coverageFile)) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Parsing Cache Coverage: " << coverageFile << std::endl, "Parsing Cache Coverage: " << coverageFile << std::endl,
this->Quiet); this->Quiet);
...@@ -975,7 +975,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( ...@@ -975,7 +975,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
std::string testingDir = this->CTest->GetBinaryDir() + "/Testing"; std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
std::string tempDir = testingDir + "/CoverageInfo"; std::string tempDir = testingDir + "/CoverageInfo";
cmSystemTools::MakeDirectory(tempDir.c_str()); cmSystemTools::MakeDirectory(tempDir);
cmWorkingDirectory workdir(tempDir); cmWorkingDirectory workdir(tempDir);
int gcovStyle = 0; int gcovStyle = 0;
...@@ -1646,7 +1646,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( ...@@ -1646,7 +1646,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
std::string testingDir = this->CTest->GetBinaryDir() + "/Testing"; std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
std::string tempDir = testingDir + "/CoverageInfo"; std::string tempDir = testingDir + "/CoverageInfo";
cmSystemTools::MakeDirectory(tempDir.c_str()); cmSystemTools::MakeDirectory(tempDir);
int file_count = 0; int file_count = 0;
for (std::string const& file : files) { for (std::string const& file : files) {
...@@ -1742,11 +1742,11 @@ std::string cmCTestCoverageHandler::FindFile( ...@@ -1742,11 +1742,11 @@ std::string cmCTestCoverageHandler::FindFile(
cmSystemTools::GetFilenameWithoutLastExtension(fileName); cmSystemTools::GetFilenameWithoutLastExtension(fileName);
// First check in source and binary directory // First check in source and binary directory
std::string fullName = cont->SourceDir + "/" + fileNameNoE + ".py"; std::string fullName = cont->SourceDir + "/" + fileNameNoE + ".py";
if (cmSystemTools::FileExists(fullName.c_str())) { if (cmSystemTools::FileExists(fullName)) {
return fullName; return fullName;
} }
fullName = cont->BinaryDir + "/" + fileNameNoE + ".py"; fullName = cont->BinaryDir + "/" + fileNameNoE + ".py";
if (cmSystemTools::FileExists(fullName.c_str())) { if (cmSystemTools::FileExists(fullName)) {
return fullName; return fullName;
} }
return ""; return "";
...@@ -2012,7 +2012,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( ...@@ -2012,7 +2012,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
} }
std::string file = sourceFile; std::string file = sourceFile;
coveredFileNames.insert(file); coveredFileNames.insert(file);
if (!cmSystemTools::FileIsFullPath(sourceFile.c_str())) { if (!cmSystemTools::FileIsFullPath(sourceFile)) {
// file will be relative to the binary dir // file will be relative to the binary dir
file = cont->BinaryDir; file = cont->BinaryDir;
file += "/"; file += "/";
......
...@@ -113,7 +113,7 @@ std::string cmCTestGIT::FindGitDir() ...@@ -113,7 +113,7 @@ std::string cmCTestGIT::FindGitDir()
// are a Windows application. Run "cygpath" to get Windows path. // are a Windows application. Run "cygpath" to get Windows path.
std::string cygpath_exe = cmSystemTools::GetFilenamePath(git); std::string cygpath_exe = cmSystemTools::GetFilenamePath(git);
cygpath_exe += "/cygpath.exe"; cygpath_exe += "/cygpath.exe";
if (cmSystemTools::FileExists(cygpath_exe.c_str())) { if (cmSystemTools::FileExists(cygpath_exe)) {
char const* cygpath[] = { cygpath_exe.c_str(), "-w", git_dir.c_str(), char const* cygpath[] = { cygpath_exe.c_str(), "-w", git_dir.c_str(),
0 }; 0 };
OneLineParser cygpath_out(this, "cygpath-out> ", git_dir_line); OneLineParser cygpath_out(this, "cygpath-out> ", git_dir_line);
...@@ -249,7 +249,7 @@ bool cmCTestGIT::UpdateImpl() ...@@ -249,7 +249,7 @@ bool cmCTestGIT::UpdateImpl()
if (this->GetGitVersion() < cmCTestGITVersion(1, 6, 5, 0)) { if (this->GetGitVersion() < cmCTestGITVersion(1, 6, 5, 0)) {
recursive = nullptr; recursive = nullptr;
// No need to require >= 1.6.5 if there are no submodules. // No need to require >= 1.6.5 if there are no submodules.
if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) { if (cmSystemTools::FileExists(top_dir + "/.gitmodules")) {
this->Log << "Git < 1.6.5 cannot update submodules recursively\n"; this->Log << "Git < 1.6.5 cannot update submodules recursively\n";
} }
} }
...@@ -258,7 +258,7 @@ bool cmCTestGIT::UpdateImpl() ...@@ -258,7 +258,7 @@ bool cmCTestGIT::UpdateImpl()
if (this->GetGitVersion() < cmCTestGITVersion(1, 8, 1, 0)) { if (this->GetGitVersion() < cmCTestGITVersion(1, 8, 1, 0)) {
sync_recursive = nullptr; sync_recursive = nullptr;
// No need to require >= 1.8.1 if there are no submodules. // No need to require >= 1.8.1 if there are no submodules.
if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) { if (cmSystemTools::FileExists(top_dir + "/.gitmodules")) {
this->Log << "Git < 1.8.1 cannot synchronize submodules recursively\n"; this->Log << "Git < 1.8.1 cannot synchronize submodules recursively\n";
} }
} }
...@@ -553,15 +553,15 @@ private: ...@@ -553,15 +553,15 @@ private:
void DoHeaderLine() void DoHeaderLine()
{ {
// Look for header fields that we need. // Look for header fields that we need.
if (cmHasLiteralPrefix(this->Line.c_str(), "commit ")) { if (cmHasLiteralPrefix(this->Line, "commit ")) {
this->Rev.Rev = this->Line.c_str() + 7; this->Rev.Rev = this->Line.c_str() + 7;
} else if (cmHasLiteralPrefix(this->Line.c_str(), "author ")) { } else if (cmHasLiteralPrefix(this->Line, "author ")) {
Person author; Person author;
this->ParsePerson(this->Line.c_str() + 7, author); this->ParsePerson(this->Line.c_str() + 7, author);
this->Rev.Author = author.Name; this->Rev.Author = author.Name;
this->Rev.EMail = author.EMail; this->Rev.EMail = author.EMail;
this->Rev.Date = this->FormatDateTime(author); this->Rev.Date = this->FormatDateTime(author);
} else if (cmHasLiteralPrefix(this->Line.c_str(), "committer ")) { } else if (cmHasLiteralPrefix(this->Line, "committer ")) {
Person committer; Person committer;
this->ParsePerson(this->Line.c_str() + 10, committer); this->ParsePerson(this->Line.c_str() + 10, committer);
this->Rev.Committer = committer.Name; this->Rev.Committer = committer.Name;
......
...@@ -377,11 +377,10 @@ void cmCTestLaunch::WriteXMLAction(cmXMLWriter& xml) ...@@ -377,11 +377,10 @@ void cmCTestLaunch::WriteXMLAction(cmXMLWriter& xml)
cmSystemTools::ConvertToUnixSlashes(source); cmSystemTools::ConvertToUnixSlashes(source);
// If file is in source tree use its relative location. // If file is in source tree use its relative location.
if (cmSystemTools::FileIsFullPath(this->SourceDir.c_str()) && if (cmSystemTools::FileIsFullPath(this->SourceDir) &&
cmSystemTools::FileIsFullPath(source.c_str()) && cmSystemTools::FileIsFullPath(source) &&
cmSystemTools::IsSubDirectory(source, this->SourceDir)) { cmSystemTools::IsSubDirectory(source, this->SourceDir)) {
source = source = cmSystemTools::RelativePath(this->SourceDir, source);
cmSystemTools::RelativePath(this->SourceDir.c_str(), source.c_str());
} }
xml.Element("SourceFile", source); xml.Element("SourceFile", source);
...@@ -629,8 +628,7 @@ void cmCTestLaunch::LoadConfig() ...@@ -629,8 +628,7 @@ void cmCTestLaunch::LoadConfig()
cmMakefile mf(&gg, cm.GetCurrentSnapshot()); cmMakefile mf(&gg, cm.GetCurrentSnapshot());
std::string fname = this->LogDir; std::string fname = this->LogDir;
fname += "CTestLaunchConfig.cmake"; fname += "CTestLaunchConfig.cmake";
if (cmSystemTools::FileExists(fname.c_str()) && if (cmSystemTools::FileExists(fname) && mf.ReadListFile(fname.c_str())) {
mf.ReadListFile(fname.c_str())) {
this->SourceDir = mf.GetSafeDefinition("CTEST_SOURCE_DIRECTORY"); this->SourceDir = mf.GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
cmSystemTools::ConvertToUnixSlashes(this->SourceDir); cmSystemTools::ConvertToUnixSlashes(this->SourceDir);
} }
......
...@@ -163,7 +163,7 @@ void cmCTestMemCheckHandler::GenerateTestCommand( ...@@ -163,7 +163,7 @@ void cmCTestMemCheckHandler::GenerateTestCommand(
std::string index; std::string index;
std::ostringstream stream; std::ostringstream stream;
std::string memcheckcommand = std::string memcheckcommand =
cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str()); cmSystemTools::ConvertToOutputPath(this->MemoryTester);
stream << test; stream << test;
index = stream.str(); index = stream.str();
for (std::string arg : this->MemoryTesterDynamicOptions) { for (std::string arg : this->MemoryTesterDynamicOptions) {
...@@ -426,7 +426,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() ...@@ -426,7 +426,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
this->MemoryTester.clear(); this->MemoryTester.clear();
// Setup the command // Setup the command
if (cmSystemTools::FileExists( if (cmSystemTools::FileExists(
this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str())) { this->CTest->GetCTestConfiguration("MemoryCheckCommand"))) {
this->MemoryTester = this->MemoryTester =
this->CTest->GetCTestConfiguration("MemoryCheckCommand"); this->CTest->GetCTestConfiguration("MemoryCheckCommand");
std::string testerName = std::string testerName =
...@@ -443,17 +443,15 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() ...@@ -443,17 +443,15 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
this->MemoryTesterStyle = cmCTestMemCheckHandler::UNKNOWN; this->MemoryTesterStyle = cmCTestMemCheckHandler::UNKNOWN;
} }
} else if (cmSystemTools::FileExists( } else if (cmSystemTools::FileExists(
this->CTest->GetCTestConfiguration("PurifyCommand").c_str())) { this->CTest->GetCTestConfiguration("PurifyCommand"))) {
this->MemoryTester = this->CTest->GetCTestConfiguration("PurifyCommand"); this->MemoryTester = this->CTest->GetCTestConfiguration("PurifyCommand");
this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY; this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
} else if (cmSystemTools::FileExists( } else if (cmSystemTools::FileExists(
this->CTest->GetCTestConfiguration("ValgrindCommand") this->CTest->GetCTestConfiguration("ValgrindCommand"))) {
.c_str())) {
this->MemoryTester = this->CTest->GetCTestConfiguration("ValgrindCommand"); this->MemoryTester = this->CTest->GetCTestConfiguration("ValgrindCommand");
this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND; this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
} else if (cmSystemTools::FileExists( } else if (cmSystemTools::FileExists(
this->CTest->GetCTestConfiguration("BoundsCheckerCommand") this->CTest->GetCTestConfiguration("BoundsCheckerCommand"))) {
.c_str())) {
this->MemoryTester = this->MemoryTester =
this->CTest->GetCTestConfiguration("BoundsCheckerCommand"); this->CTest->GetCTestConfiguration("BoundsCheckerCommand");
this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
...@@ -537,9 +535,8 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() ...@@ -537,9 +535,8 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
} }
if (!this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile") if (!this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
.empty()) { .empty()) {
if (!cmSystemTools::FileExists( if (!cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile") "MemoryCheckSuppressionFile"))) {
.c_str())) {
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find memory checker suppression file: " "Cannot find memory checker suppression file: "
<< this->CTest->GetCTestConfiguration( << this->CTest->GetCTestConfiguration(
...@@ -560,9 +557,8 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() ...@@ -560,9 +557,8 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
#ifdef _WIN32 #ifdef _WIN32
if (this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile") if (this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
.size()) { .size()) {
if (!cmSystemTools::FileExists( if (!cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile") "MemoryCheckSuppressionFile"))) {
.c_str())) {
cmCTestLog( cmCTestLog(
this->CTest, ERROR_MESSAGE, this->CTest, ERROR_MESSAGE,
"Cannot find memory checker suppression file: " "Cannot find memory checker suppression file: "
...@@ -1093,7 +1089,7 @@ void cmCTestMemCheckHandler::TestOutputFileNames( ...@@ -1093,7 +1089,7 @@ void cmCTestMemCheckHandler::TestOutputFileNames(
files = g.GetFiles(); files = g.GetFiles();
return; return;
} }
} else if (!cmSystemTools::FileExists(ofile.c_str())) { } else if (!cmSystemTools::FileExists(ofile)) {
std::string log = "Cannot find memory tester output file: " + ofile; std::string log = "Cannot find memory tester output file: " + ofile;
cmCTestLog(this->CTest, ERROR_MESSAGE, log << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, log << std::endl);
ofile.clear(); ofile.clear();
......
...@@ -413,7 +413,7 @@ void cmCTestMultiProcessHandler::UpdateCostData() ...@@ -413,7 +413,7 @@ void cmCTestMultiProcessHandler::UpdateCostData()
PropertiesMap temp = this->Properties; PropertiesMap temp = this->Properties;
if (cmSystemTools::FileExists(fname.c_str())) { if (cmSystemTools::FileExists(fname)) {
cmsys::ifstream fin;