Commit 0aab5980 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'gicv-stdstring'

46855d00

 cmCacheManager::GetInitializedCacheValue(): Return as const std::string*
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2357
parents 62b56b5e 46855d00
...@@ -127,15 +127,15 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, ...@@ -127,15 +127,15 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
} }
this->CacheMajorVersion = 0; this->CacheMajorVersion = 0;
this->CacheMinorVersion = 0; this->CacheMinorVersion = 0;
if (const char* cmajor = if (const std::string* cmajor =
this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION")) { this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION")) {
unsigned int v = 0; unsigned int v = 0;
if (sscanf(cmajor, "%u", &v) == 1) { if (sscanf(cmajor->c_str(), "%u", &v) == 1) {
this->CacheMajorVersion = v; this->CacheMajorVersion = v;
} }
if (const char* cminor = if (const std::string* cminor =
this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION")) { this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION")) {
if (sscanf(cminor, "%u", &v) == 1) { if (sscanf(cminor->c_str(), "%u", &v) == 1) {
this->CacheMinorVersion = v; this->CacheMinorVersion = v;
} }
} }
...@@ -153,18 +153,20 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, ...@@ -153,18 +153,20 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
} }
// check to make sure the cache directory has not // check to make sure the cache directory has not
// been moved // been moved
const char* oldDir = this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR"); const std::string* oldDir =
this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
if (internal && oldDir) { if (internal && oldDir) {
std::string currentcwd = path; std::string currentcwd = path;
std::string oldcwd = oldDir; std::string oldcwd = *oldDir;
cmSystemTools::ConvertToUnixSlashes(currentcwd); cmSystemTools::ConvertToUnixSlashes(currentcwd);
currentcwd += "/CMakeCache.txt"; currentcwd += "/CMakeCache.txt";
oldcwd += "/CMakeCache.txt"; oldcwd += "/CMakeCache.txt";
if (!cmSystemTools::SameFile(oldcwd, currentcwd)) { if (!cmSystemTools::SameFile(oldcwd, currentcwd)) {
const std::string* dir =
this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
std::ostringstream message; std::ostringstream message;
message << "The current CMakeCache.txt directory " << currentcwd message << "The current CMakeCache.txt directory " << currentcwd
<< " is different than the directory " << " is different than the directory " << (dir ? *dir : "")
<< this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR")
<< " where CMakeCache.txt was created. This may result " << " where CMakeCache.txt was created. This may result "
"in binaries being created in the wrong place. If you " "in binaries being created in the wrong place. If you "
"are not sure, reedit the CMakeCache.txt"; "are not sure, reedit the CMakeCache.txt";
...@@ -512,12 +514,12 @@ cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char* key) ...@@ -512,12 +514,12 @@ cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char* key)
return CacheIterator(*this, key); return CacheIterator(*this, key);
} }
const char* cmCacheManager::GetInitializedCacheValue( const std::string* cmCacheManager::GetInitializedCacheValue(
const std::string& key) const const std::string& key) const
{ {
CacheEntryMap::const_iterator i = this->Cache.find(key); CacheEntryMap::const_iterator i = this->Cache.find(key);
if (i != this->Cache.end() && i->second.Initialized) { if (i != this->Cache.end() && i->second.Initialized) {
return i->second.Value.c_str(); return &i->second.Value;
} }
return nullptr; return nullptr;
} }
......
...@@ -126,7 +126,7 @@ public: ...@@ -126,7 +126,7 @@ public:
int GetSize() { return static_cast<int>(this->Cache.size()); } int GetSize() { return static_cast<int>(this->Cache.size()); }
///! Get a value from the cache given a key ///! Get a value from the cache given a key
const char* GetInitializedCacheValue(const std::string& key) const; const std::string* GetInitializedCacheValue(const std::string& key) const;
const char* GetCacheEntryValue(const std::string& key) const char* GetCacheEntryValue(const std::string& key)
{ {
......
...@@ -142,7 +142,8 @@ const char* cmState::GetCacheEntryValue(std::string const& key) const ...@@ -142,7 +142,8 @@ const char* cmState::GetCacheEntryValue(std::string const& key) const
const char* cmState::GetInitializedCacheValue(std::string const& key) const const char* cmState::GetInitializedCacheValue(std::string const& key) const
{ {
return this->CacheManager->GetInitializedCacheValue(key); const std::string* p = this->CacheManager->GetInitializedCacheValue(key);
return p ? p->c_str() : nullptr;
} }
cmStateEnums::CacheEntryType cmState::GetCacheEntryType( cmStateEnums::CacheEntryType cmState::GetCacheEntryType(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment