summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/cmCPackGenerator.cxx3
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx12
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx8
-rw-r--r--Source/cmFileCommand.cxx84
-rw-r--r--Source/cmSystemTools.cxx27
-rw-r--r--Source/cmSystemTools.h16
-rw-r--r--Source/cmake.cxx2
7 files changed, 78 insertions, 74 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index b4c05ab..71808ab 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -387,8 +387,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
}
/* If it is not a symlink then do a plain copy */
else if (!(cmSystemTools::CopyFileIfDifferent(inFile, filePath) &&
- cmSystemTools::CopyFileTime(inFile.c_str(),
- filePath.c_str()))) {
+ cmSystemTools::CopyFileTime(inFile, filePath))) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem copying file: " << inFile << " -> "
<< filePath << std::endl);
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 3b93422..10928e0 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -223,7 +223,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file,
checkDir = fBinDir;
}
std::string ndc = cmSystemTools::FileExistsInParentDirectories(
- ".NoDartCoverage", fFile.c_str(), checkDir.c_str());
+ ".NoDartCoverage", fFile, checkDir);
if (!ndc.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Found: " << ndc << " so skip coverage of " << file
@@ -254,8 +254,8 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file,
return true;
}
- ndc = cmSystemTools::FileExistsInParentDirectories(
- ".NoDartCoverage", fFile.c_str(), checkDir.c_str());
+ ndc = cmSystemTools::FileExistsInParentDirectories(".NoDartCoverage", fFile,
+ checkDir);
if (!ndc.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Found: " << ndc << " so skip coverage of: " << file
@@ -1058,8 +1058,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
this->Quiet);
std::vector<std::string> lines;
-
- cmSystemTools::Split(output.c_str(), lines);
+ cmsys::SystemTools::Split(output, lines);
for (std::string const& line : lines) {
std::string sourceFile;
@@ -1435,8 +1434,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
this->Quiet);
std::vector<std::string> lines;
-
- cmSystemTools::Split(output.c_str(), lines);
+ cmsys::SystemTools::Split(output, lines);
for (std::string const& line : lines) {
std::string sourceFile;
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index 8ba59d3..954f5bb 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -725,7 +725,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
cmsys::RegularExpression leakWarning("(Direct|Indirect) leak of .*");
int defects = 0;
std::vector<std::string> lines;
- cmSystemTools::Split(str.c_str(), lines);
+ cmsys::SystemTools::Split(str, lines);
std::ostringstream ostr;
log.clear();
for (std::string const& l : lines) {
@@ -755,7 +755,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
const std::string& str, std::string& log, std::vector<int>& results)
{
std::vector<std::string> lines;
- cmSystemTools::Split(str.c_str(), lines);
+ cmsys::SystemTools::Split(str, lines);
std::ostringstream ostr;
log.clear();
@@ -798,7 +798,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
const std::string& str, std::string& log, std::vector<int>& results)
{
std::vector<std::string> lines;
- cmSystemTools::Split(str.c_str(), lines);
+ cmsys::SystemTools::Split(str, lines);
bool unlimitedOutput = false;
if (str.find("CTEST_FULL_OUTPUT") != std::string::npos ||
this->CustomMaximumFailedTestOutputSize == 0) {
@@ -937,7 +937,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
log.clear();
auto sttime = std::chrono::steady_clock::now();
std::vector<std::string> lines;
- cmSystemTools::Split(str.c_str(), lines);
+ cmsys::SystemTools::Split(str, lines);
cmCTestOptionalLog(this->CTest, DEBUG,
"Start test: " << lines.size() << std::endl, this->Quiet);
std::vector<std::string>::size_type cc;
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index fb3a1bc..446ed52 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -223,7 +223,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
bool writable = false;
// Set permissions to writable
- if (cmSystemTools::GetPermissions(fileName.c_str(), mode)) {
+ if (cmSystemTools::GetPermissions(fileName, mode)) {
#if defined(_MSC_VER) || defined(__MINGW32__)
writable = (mode & S_IWRITE) != 0;
mode_t newMode = mode | S_IWRITE;
@@ -232,7 +232,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
mode_t newMode = mode | S_IWUSR | S_IWGRP;
#endif
if (!writable) {
- cmSystemTools::SetPermissions(fileName.c_str(), newMode);
+ cmSystemTools::SetPermissions(fileName, newMode);
}
}
// If GetPermissions fails, pretend like it is ok. File open will fail if
@@ -259,7 +259,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
}
file.close();
if (mode && !writable) {
- cmSystemTools::SetPermissions(fileName.c_str(), mode);
+ cmSystemTools::SetPermissions(fileName, mode);
}
return true;
}
@@ -393,7 +393,7 @@ bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args)
#else
std::ostringstream e;
e << args[0] << " not available during bootstrap";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
#endif
}
@@ -523,7 +523,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
maxlen = len;
arg_mode = arg_none;
} else if (arg_mode == arg_regex) {
- if (!regex.compile(args[i].c_str())) {
+ if (!regex.compile(args[i])) {
std::ostringstream e;
e << "STRINGS option REGEX value \"" << args[i]
<< "\" could not be compiled.";
@@ -1105,7 +1105,7 @@ protected:
MatchProperties Properties;
std::string RegexString;
MatchRule(std::string const& regex)
- : Regex(regex.c_str())
+ : Regex(regex)
, RegexString(regex)
{
}
@@ -1113,14 +1113,13 @@ protected:
std::vector<MatchRule> MatchRules;
// Get the properties from rules matching this input file.
- MatchProperties CollectMatchProperties(const char* file)
+ MatchProperties CollectMatchProperties(const std::string& file)
{
// Match rules are case-insensitive on some platforms.
#if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
- std::string lower = cmSystemTools::LowerCase(file);
- const char* file_to_match = lower.c_str();
+ const std::string file_to_match = cmSystemTools::LowerCase(file);
#else
- const char* file_to_match = file;
+ const std::string& file_to_match = file;
#endif
// Collect properties from all matching rules.
@@ -1139,14 +1138,13 @@ protected:
return result;
}
- bool SetPermissions(const char* toFile, mode_t permissions)
+ bool SetPermissions(const std::string& toFile, mode_t permissions)
{
if (permissions) {
#ifdef WIN32
if (Makefile->IsOn("CMAKE_CROSSCOMPILING")) {
// Store the mode in an NTFS alternate stream.
- std::string mode_t_adt_filename =
- std::string(toFile) + ":cmake_mode_t";
+ std::string mode_t_adt_filename = toFile + ":cmake_mode_t";
// Writing to an NTFS alternate stream changes the modification
// time, so we need to save and restore its original value.
@@ -1189,12 +1187,13 @@ protected:
return true;
}
- bool InstallSymlink(const char* fromFile, const char* toFile);
- bool InstallFile(const char* fromFile, const char* toFile,
+ bool InstallSymlink(const std::string& fromFile, const std::string& toFile);
+ bool InstallFile(const std::string& fromFile, const std::string& toFile,
MatchProperties match_properties);
- bool InstallDirectory(const char* source, const char* destination,
+ bool InstallDirectory(const std::string& source,
+ const std::string& destination,
MatchProperties match_properties);
- virtual bool Install(const char* fromFile, const char* toFile);
+ virtual bool Install(const std::string& fromFile, const std::string& toFile);
virtual std::string const& ToName(std::string const& fromName)
{
return fromName;
@@ -1206,8 +1205,8 @@ protected:
TypeDir,
TypeLink
};
- virtual void ReportCopy(const char*, Type, bool) {}
- virtual bool ReportMissing(const char* fromFile)
+ virtual void ReportCopy(const std::string&, Type, bool) {}
+ virtual bool ReportMissing(const std::string& fromFile)
{
// The input file does not exist and installation is not optional.
std::ostringstream e;
@@ -1551,16 +1550,17 @@ bool cmFileCopier::Run(std::vector<std::string> const& args)
fromFile += fromName;
}
- if (!this->Install(fromFile.c_str(), toFile.c_str())) {
+ if (!this->Install(fromFile, toFile)) {
return false;
}
}
return true;
}
-bool cmFileCopier::Install(const char* fromFile, const char* toFile)
+bool cmFileCopier::Install(const std::string& fromFile,
+ const std::string& toFile)
{
- if (!*fromFile) {
+ if (fromFile.empty()) {
std::ostringstream e;
e << "INSTALL encountered an empty string input file name.";
this->FileCommand->SetError(e.str());
@@ -1590,7 +1590,8 @@ bool cmFileCopier::Install(const char* fromFile, const char* toFile)
return this->ReportMissing(fromFile);
}
-bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile)
+bool cmFileCopier::InstallSymlink(const std::string& fromFile,
+ const std::string& toFile)
{
// Read the original symlink.
std::string symlinkTarget;
@@ -1637,7 +1638,8 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile)
return true;
}
-bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile,
+bool cmFileCopier::InstallFile(const std::string& fromFile,
+ const std::string& toFile,
MatchProperties match_properties)
{
// Determine whether we will copy the file.
@@ -1690,8 +1692,8 @@ bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile,
return this->SetPermissions(toFile, permissions);
}
-bool cmFileCopier::InstallDirectory(const char* source,
- const char* destination,
+bool cmFileCopier::InstallDirectory(const std::string& source,
+ const std::string& destination,
MatchProperties match_properties)
{
// Inform the user about this directory installation.
@@ -1748,7 +1750,7 @@ bool cmFileCopier::InstallDirectory(const char* source,
// Load the directory contents to traverse it recursively.
cmsys::Directory dir;
- if (source && *source) {
+ if (!source.empty()) {
dir.Load(source);
}
unsigned long numFiles = static_cast<unsigned long>(dir.GetNumberOfFiles());
@@ -1761,7 +1763,7 @@ bool cmFileCopier::InstallDirectory(const char* source,
std::string toPath = destination;
toPath += "/";
toPath += dir.GetFile(fileNum);
- if (!this->Install(fromPath.c_str(), toPath.c_str())) {
+ if (!this->Install(fromPath, toPath)) {
return false;
}
}
@@ -1829,7 +1831,7 @@ protected:
return this->Rename.empty() ? fromName : this->Rename;
}
- void ReportCopy(const char* toFile, Type type, bool copy) override
+ void ReportCopy(const std::string& toFile, Type type, bool copy) override
{
if (!this->MessageNever && (copy || !this->MessageLazy)) {
std::string message = (copy ? "Installing: " : "Up-to-date: ");
@@ -1841,14 +1843,14 @@ protected:
this->ManifestAppend(toFile);
}
}
- bool ReportMissing(const char* fromFile) override
+ bool ReportMissing(const std::string& fromFile) override
{
return (this->Optional || this->cmFileCopier::ReportMissing(fromFile));
}
- bool Install(const char* fromFile, const char* toFile) override
+ bool Install(const std::string& fromFile, const std::string& toFile) override
{
// Support installing from empty source to make a directory.
- if (this->InstallType == cmInstallType_DIRECTORY && !*fromFile) {
+ if (this->InstallType == cmInstallType_DIRECTORY && fromFile.empty()) {
return this->InstallDirectory(fromFile, toFile, MatchProperties());
}
return this->cmFileCopier::Install(fromFile, toFile);
@@ -2138,7 +2140,7 @@ bool cmFileCommand::HandleRPathChangeCommand(
std::vector<std::string> const& args)
{
// Evaluate arguments.
- const char* file = nullptr;
+ std::string file;
const char* oldRPath = nullptr;
const char* newRPath = nullptr;
enum Doing
@@ -2157,7 +2159,7 @@ bool cmFileCommand::HandleRPathChangeCommand(
} else if (args[i] == "FILE") {
doing = DoingFile;
} else if (doing == DoingFile) {
- file = args[i].c_str();
+ file = args[i];
doing = DoingNone;
} else if (doing == DoingOld) {
oldRPath = args[i].c_str();
@@ -2172,7 +2174,7 @@ bool cmFileCommand::HandleRPathChangeCommand(
return false;
}
}
- if (!file) {
+ if (file.empty()) {
this->SetError("RPATH_CHANGE not given FILE option.");
return false;
}
@@ -2228,7 +2230,7 @@ bool cmFileCommand::HandleRPathRemoveCommand(
std::vector<std::string> const& args)
{
// Evaluate arguments.
- const char* file = nullptr;
+ std::string file;
enum Doing
{
DoingNone,
@@ -2239,7 +2241,7 @@ bool cmFileCommand::HandleRPathRemoveCommand(
if (args[i] == "FILE") {
doing = DoingFile;
} else if (doing == DoingFile) {
- file = args[i].c_str();
+ file = args[i];
doing = DoingNone;
} else {
std::ostringstream e;
@@ -2248,7 +2250,7 @@ bool cmFileCommand::HandleRPathRemoveCommand(
return false;
}
}
- if (!file) {
+ if (file.empty()) {
this->SetError("RPATH_REMOVE not given FILE option.");
return false;
}
@@ -2292,7 +2294,7 @@ bool cmFileCommand::HandleRPathCheckCommand(
std::vector<std::string> const& args)
{
// Evaluate arguments.
- const char* file = nullptr;
+ std::string file;
const char* rpath = nullptr;
enum Doing
{
@@ -2307,7 +2309,7 @@ bool cmFileCommand::HandleRPathCheckCommand(
} else if (args[i] == "FILE") {
doing = DoingFile;
} else if (doing == DoingFile) {
- file = args[i].c_str();
+ file = args[i];
doing = DoingNone;
} else if (doing == DoingRPath) {
rpath = args[i].c_str();
@@ -2319,7 +2321,7 @@ bool cmFileCommand::HandleRPathCheckCommand(
return false;
}
}
- if (!file) {
+ if (file.empty()) {
this->SetError("RPATH_CHECK not given FILE option.");
return false;
}
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 2d7bce4..a5d191d 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -897,7 +897,7 @@ std::string cmSystemTools::PrintSingleCommand(
}
bool cmSystemTools::DoesFileExistWithExtensions(
- const char* name, const std::vector<std::string>& headerExts)
+ const std::string& name, const std::vector<std::string>& headerExts)
{
std::string hname;
@@ -912,9 +912,9 @@ bool cmSystemTools::DoesFileExistWithExtensions(
return false;
}
-std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
- const char* directory,
- const char* toplevel)
+std::string cmSystemTools::FileExistsInParentDirectories(
+ const std::string& fname, const std::string& directory,
+ const std::string& toplevel)
{
std::string file = fname;
cmSystemTools::ConvertToUnixSlashes(file);
@@ -926,7 +926,7 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
if (cmSystemTools::FileExists(path)) {
return path;
}
- if (dir.size() < strlen(toplevel)) {
+ if (dir.size() < toplevel.size()) {
break;
}
prevDir = dir;
@@ -2081,7 +2081,8 @@ void cmSystemTools::DoNotInheritStdPipes()
#endif
}
-bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile)
+bool cmSystemTools::CopyFileTime(const std::string& fromFile,
+ const std::string& toFile)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
cmSystemToolsWindowsHandle hFrom = CreateFileW(
@@ -2102,14 +2103,14 @@ bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile)
return SetFileTime(hTo, &timeCreation, &timeLastAccess, &timeLastWrite) != 0;
#else
struct stat fromStat;
- if (stat(fromFile, &fromStat) < 0) {
+ if (stat(fromFile.c_str(), &fromStat) < 0) {
return false;
}
struct utimbuf buf;
buf.actime = fromStat.st_atime;
buf.modtime = fromStat.st_mtime;
- return utime(toFile, &buf) >= 0;
+ return utime(toFile.c_str(), &buf) >= 0;
#endif
}
@@ -2123,7 +2124,8 @@ void cmSystemTools::FileTimeDelete(cmSystemToolsFileTime* t)
delete t;
}
-bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t)
+bool cmSystemTools::FileTimeGet(const std::string& fname,
+ cmSystemToolsFileTime* t)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
cmSystemToolsWindowsHandle h = CreateFileW(
@@ -2138,7 +2140,7 @@ bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t)
}
#else
struct stat st;
- if (stat(fname, &st) < 0) {
+ if (stat(fname.c_str(), &st) < 0) {
return false;
}
t->timeBuf.actime = st.st_atime;
@@ -2147,7 +2149,8 @@ bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t)
return true;
}
-bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t)
+bool cmSystemTools::FileTimeSet(const std::string& fname,
+ const cmSystemToolsFileTime* t)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
cmSystemToolsWindowsHandle h = CreateFileW(
@@ -2159,7 +2162,7 @@ bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t)
return SetFileTime(h, &t->timeCreation, &t->timeLastAccess,
&t->timeLastWrite) != 0;
#else
- return utime(fname, &t->timeBuf) >= 0;
+ return utime(fname.c_str(), &t->timeBuf) >= 0;
#endif
}
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 88758a6..ba6de51 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -144,16 +144,16 @@ public:
static bool IsPathToFramework(const char* value);
static bool DoesFileExistWithExtensions(
- const char* name, const std::vector<std::string>& sourceExts);
+ const std::string& name, const std::vector<std::string>& sourceExts);
/**
* Check if the given file exists in one of the parent directory of the
* given file or directory and if it does, return the name of the file.
* Toplevel specifies the top-most directory to where it will look.
*/
- static std::string FileExistsInParentDirectories(const char* fname,
- const char* directory,
- const char* toplevel);
+ static std::string FileExistsInParentDirectories(
+ const std::string& fname, const std::string& directory,
+ const std::string& toplevel);
static void Glob(const std::string& directory, const std::string& regexp,
std::vector<std::string>& files);
@@ -443,13 +443,15 @@ public:
/** Copy the file create/access/modify times from the file named by
the first argument to that named by the second. */
- static bool CopyFileTime(const char* fromFile, const char* toFile);
+ static bool CopyFileTime(const std::string& fromFile,
+ const std::string& toFile);
/** Save and restore file times. */
static cmSystemToolsFileTime* FileTimeNew();
static void FileTimeDelete(cmSystemToolsFileTime*);
- static bool FileTimeGet(const char* fname, cmSystemToolsFileTime* t);
- static bool FileTimeSet(const char* fname, cmSystemToolsFileTime* t);
+ static bool FileTimeGet(const std::string& fname, cmSystemToolsFileTime* t);
+ static bool FileTimeSet(const std::string& fname,
+ const cmSystemToolsFileTime* t);
/** Random seed generation. */
static unsigned int RandomSeed();
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 8023298..614ee2e 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1105,7 +1105,7 @@ std::string cmake::FindCacheFile(const std::string& binaryDir)
if (cmSystemTools::FileExists(cmakeFiles)) {
std::string cachePathFound =
cmSystemTools::FileExistsInParentDirectories("CMakeCache.txt",
- cachePath.c_str(), "/");
+ cachePath, "/");
if (!cachePathFound.empty()) {
cachePath = cmSystemTools::GetFilenamePath(cachePathFound);
}