summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Stakhovsky <vvs31415@gitlab.org>2019-01-28 14:00:28 (GMT)
committerVitaly Stakhovsky <vvs31415@gitlab.org>2019-01-28 14:09:59 (GMT)
commit2fc69ba0b33e8f5f1b6301f37fc1479fba420b93 (patch)
tree3e870a7ce9eac0b8d2eeaab9aa537efba4941b41
parent1593e16d881bf74fd8981e1290d20f28191f1f0e (diff)
downloadCMake-2fc69ba0b33e8f5f1b6301f37fc1479fba420b93.zip
CMake-2fc69ba0b33e8f5f1b6301f37fc1479fba420b93.tar.gz
CMake-2fc69ba0b33e8f5f1b6301f37fc1479fba420b93.tar.bz2
cmFileTimeComparison: use std::string arguments
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx3
-rw-r--r--Source/cmDepends.cxx8
-rw-r--r--Source/cmDependsC.cxx3
-rw-r--r--Source/cmFileTimeComparison.cxx27
-rw-r--r--Source/cmFileTimeComparison.h7
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx6
-rw-r--r--Source/cmake.cxx13
7 files changed, 33 insertions, 34 deletions
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index d07bd21..948547f 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -513,8 +513,7 @@ public:
// Order files by modification time. Use lexicographic order
// among files with the same time.
int result;
- if (this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) &&
- result != 0) {
+ if (this->FTC->FileTimeCompare(l, r, &result) && result != 0) {
return result < 0;
}
return l < r;
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 976ba57..7d1d316 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -156,8 +156,8 @@ bool cmDepends::CheckDependencies(
// * if the depender does not exist, but the dependee is newer than the
// depends file
bool regenerate = false;
- const char* dependee = this->Dependee + 1;
- const char* depender = this->Depender;
+ const std::string dependee(this->Dependee + 1);
+ const std::string depender(this->Depender);
if (currentDependencies != nullptr) {
currentDependencies->push_back(dependee);
}
@@ -195,8 +195,8 @@ bool cmDepends::CheckDependencies(
// The dependee exists, but the depender doesn't. Regenerate if the
// internalDepends file is older than the dependee.
int result = 0;
- if ((!this->FileComparison->FileTimeCompare(
- internalDependsFileName.c_str(), dependee, &result) ||
+ if ((!this->FileComparison->FileTimeCompare(internalDependsFileName,
+ dependee, &result) ||
result < 0)) {
// The depends-file is older than the dependee.
regenerate = true;
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index f6ac4f2..ea24f09 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -268,8 +268,7 @@ void cmDependsC::ReadCacheFile()
haveFileName = true;
int newer = 0;
cmFileTimeComparison comp;
- bool res = comp.FileTimeCompare(this->CacheFileName.c_str(),
- line.c_str(), &newer);
+ bool res = comp.FileTimeCompare(this->CacheFileName, line, &newer);
if (res && newer == 1) // cache is newer than the parsed file
{
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx
index 8f6993d..8b3911e 100644
--- a/Source/cmFileTimeComparison.cxx
+++ b/Source/cmFileTimeComparison.cxx
@@ -21,9 +21,10 @@ class cmFileTimeComparisonInternal
{
public:
// Internal comparison method.
- inline bool FileTimeCompare(const char* f1, const char* f2, int* result);
+ inline bool FileTimeCompare(const std::string& f1, const std::string& f2,
+ int* result);
- bool FileTimesDiffer(const char* f1, const char* f2);
+ bool FileTimesDiffer(const std::string& f1, const std::string& f2);
private:
typedef std::unordered_map<std::string, cmFileTimeComparison_Type>
@@ -31,14 +32,14 @@ private:
FileStatsMap Files;
// Internal methods to lookup and compare modification times.
- inline bool Stat(const char* fname, cmFileTimeComparison_Type* st);
+ inline bool Stat(const std::string& fname, cmFileTimeComparison_Type* st);
inline int Compare(cmFileTimeComparison_Type* st1,
cmFileTimeComparison_Type* st2);
inline bool TimesDiffer(cmFileTimeComparison_Type* st1,
cmFileTimeComparison_Type* st2);
};
-bool cmFileTimeComparisonInternal::Stat(const char* fname,
+bool cmFileTimeComparisonInternal::Stat(const std::string& fname,
cmFileTimeComparison_Type* st)
{
// Use the stored time if available.
@@ -51,7 +52,7 @@ bool cmFileTimeComparisonInternal::Stat(const char* fname,
#if !defined(_WIN32) || defined(__CYGWIN__)
// POSIX version. Use the stat function.
- int res = ::stat(fname, st);
+ int res = ::stat(fname.c_str(), st);
if (res != 0) {
return false;
}
@@ -83,13 +84,14 @@ cmFileTimeComparison::~cmFileTimeComparison()
delete this->Internals;
}
-bool cmFileTimeComparison::FileTimeCompare(const char* f1, const char* f2,
- int* result)
+bool cmFileTimeComparison::FileTimeCompare(const std::string& f1,
+ const std::string& f2, int* result)
{
return this->Internals->FileTimeCompare(f1, f2, result);
}
-bool cmFileTimeComparison::FileTimesDiffer(const char* f1, const char* f2)
+bool cmFileTimeComparison::FileTimesDiffer(const std::string& f1,
+ const std::string& f2)
{
return this->Internals->FileTimesDiffer(f1, f2);
}
@@ -199,8 +201,9 @@ bool cmFileTimeComparisonInternal::TimesDiffer(cmFileTimeComparison_Type* s1,
#endif
}
-bool cmFileTimeComparisonInternal::FileTimeCompare(const char* f1,
- const char* f2, int* result)
+bool cmFileTimeComparisonInternal::FileTimeCompare(const std::string& f1,
+ const std::string& f2,
+ int* result)
{
// Get the modification time for each file.
cmFileTimeComparison_Type s1;
@@ -215,8 +218,8 @@ bool cmFileTimeComparisonInternal::FileTimeCompare(const char* f1,
return false;
}
-bool cmFileTimeComparisonInternal::FileTimesDiffer(const char* f1,
- const char* f2)
+bool cmFileTimeComparisonInternal::FileTimesDiffer(const std::string& f1,
+ const std::string& f2)
{
// Get the modification time for each file.
cmFileTimeComparison_Type s1;
diff --git a/Source/cmFileTimeComparison.h b/Source/cmFileTimeComparison.h
index 114989b..5f74e34 100644
--- a/Source/cmFileTimeComparison.h
+++ b/Source/cmFileTimeComparison.h
@@ -5,6 +5,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <string>
+
class cmFileTimeComparisonInternal;
/** \class cmFileTimeComparison
@@ -24,13 +26,14 @@ public:
* When true is returned, result has -1, 0, +1 for
* f1 older, same, or newer than f2.
*/
- bool FileTimeCompare(const char* f1, const char* f2, int* result);
+ bool FileTimeCompare(const std::string& f1, const std::string& f2,
+ int* result);
/**
* Compare file modification times. Return true unless both files
* exist and have modification times less than 1 second apart.
*/
- bool FileTimesDiffer(const char* f1, const char* f2);
+ bool FileTimesDiffer(const std::string& f1, const std::string& f2);
protected:
cmFileTimeComparisonInternal* Internals;
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 7cb98b9..173ac7a 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1278,8 +1278,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
this->GlobalGenerator->GetCMakeInstance()->GetFileComparison();
{
int result;
- if (!ftc->FileTimeCompare(internalDependFile.c_str(), tgtInfo.c_str(),
- &result) ||
+ if (!ftc->FileTimeCompare(internalDependFile, tgtInfo, &result) ||
result < 0) {
if (verbose) {
std::ostringstream msg;
@@ -1299,8 +1298,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
dirInfoFile += "/CMakeDirectoryInformation.cmake";
{
int result;
- if (!ftc->FileTimeCompare(internalDependFile.c_str(), dirInfoFile.c_str(),
- &result) ||
+ if (!ftc->FileTimeCompare(internalDependFile, dirInfoFile, &result) ||
result < 0) {
if (verbose) {
std::ostringstream msg;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 744b8fc..10cbb6e 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2146,8 +2146,7 @@ int cmake::CheckBuildSystem()
std::string dep_newest = *dep++;
for (; dep != depends.end(); ++dep) {
int result = 0;
- if (this->FileComparison->FileTimeCompare(dep_newest.c_str(), dep->c_str(),
- &result)) {
+ if (this->FileComparison->FileTimeCompare(dep_newest, *dep, &result)) {
if (result < 0) {
dep_newest = *dep;
}
@@ -2166,8 +2165,7 @@ int cmake::CheckBuildSystem()
std::string out_oldest = *out++;
for (; out != outputs.end(); ++out) {
int result = 0;
- if (this->FileComparison->FileTimeCompare(out_oldest.c_str(), out->c_str(),
- &result)) {
+ if (this->FileComparison->FileTimeCompare(out_oldest, *out, &result)) {
if (result > 0) {
out_oldest = *out;
}
@@ -2184,8 +2182,8 @@ int cmake::CheckBuildSystem()
// If any output is older than any dependency then rerun.
{
int result = 0;
- if (!this->FileComparison->FileTimeCompare(out_oldest.c_str(),
- dep_newest.c_str(), &result) ||
+ if (!this->FileComparison->FileTimeCompare(out_oldest, dep_newest,
+ &result) ||
result < 0) {
if (verbose) {
std::ostringstream msg;
@@ -2446,8 +2444,7 @@ static bool cmakeCheckStampFile(const std::string& stampName, bool verbose)
while (cmSystemTools::GetLineFromStream(fin, dep)) {
int result;
if (!dep.empty() && dep[0] != '#' &&
- (!ftc.FileTimeCompare(stampDepends.c_str(), dep.c_str(), &result) ||
- result < 0)) {
+ (!ftc.FileTimeCompare(stampDepends, dep, &result) || result < 0)) {
// The stamp depends file is older than this dependency. The
// build system is really out of date.
std::cout << "CMake is re-running because " << stampName