An update will be applied December 9th, between 12PM and 1:00PM EST (UTC -5:00). The site may be slow during that time.

Commit acda926a authored by jrp2014's avatar jrp2014 Committed by Brad King
Browse files

Replace some uses of sprintf with std::to_string

parent 41854103
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <string>
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmMessenger.h" #include "cmMessenger.h"
...@@ -243,19 +244,18 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger) ...@@ -243,19 +244,18 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
} }
// before writing the cache, update the version numbers // before writing the cache, update the version numbers
// to the // to the
char temp[1024]; this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION",
sprintf(temp, "%d", cmVersion::GetMinorVersion()); std::to_string(cmVersion::GetMajorVersion()).c_str(),
this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", temp, "Major version of cmake used to create the "
"Minor version of cmake used to create the "
"current loaded cache", "current loaded cache",
cmStateEnums::INTERNAL); cmStateEnums::INTERNAL);
sprintf(temp, "%d", cmVersion::GetMajorVersion()); this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION",
this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", temp, std::to_string(cmVersion::GetMinorVersion()).c_str(),
"Major version of cmake used to create the " "Minor version of cmake used to create the "
"current loaded cache", "current loaded cache",
cmStateEnums::INTERNAL); cmStateEnums::INTERNAL);
sprintf(temp, "%d", cmVersion::GetPatchVersion()); this->AddCacheEntry("CMAKE_CACHE_PATCH_VERSION",
this->AddCacheEntry("CMAKE_CACHE_PATCH_VERSION", temp, std::to_string(cmVersion::GetPatchVersion()).c_str(),
"Patch version of cmake used to create the " "Patch version of cmake used to create the "
"current loaded cache", "current loaded cache",
cmStateEnums::INTERNAL); cmStateEnums::INTERNAL);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <algorithm> #include <algorithm>
#include <assert.h> #include <assert.h>
#include <iterator> #include <iterator>
#include <stdio.h> #include <string>
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
#include "cmDefinitions.h" #include "cmDefinitions.h"
...@@ -328,15 +328,14 @@ void cmStateSnapshot::SetDefaultDefinitions() ...@@ -328,15 +328,14 @@ void cmStateSnapshot::SetDefaultDefinitions()
this->SetDefinition("CMAKE_HOST_SOLARIS", "1"); this->SetDefinition("CMAKE_HOST_SOLARIS", "1");
#endif #endif
char temp[1024]; this->SetDefinition("CMAKE_MAJOR_VERSION",
sprintf(temp, "%d", cmVersion::GetMinorVersion()); std::to_string(cmVersion::GetMajorVersion()));
this->SetDefinition("CMAKE_MINOR_VERSION", temp); this->SetDefinition("CMAKE_MINOR_VERSION",
sprintf(temp, "%d", cmVersion::GetMajorVersion()); std::to_string(cmVersion::GetMinorVersion()));
this->SetDefinition("CMAKE_MAJOR_VERSION", temp); this->SetDefinition("CMAKE_PATCH_VERSION",
sprintf(temp, "%d", cmVersion::GetPatchVersion()); std::to_string(cmVersion::GetPatchVersion()));
this->SetDefinition("CMAKE_PATCH_VERSION", temp); this->SetDefinition("CMAKE_TWEAK_VERSION",
sprintf(temp, "%d", cmVersion::GetTweakVersion()); std::to_string(cmVersion::GetTweakVersion()));
this->SetDefinition("CMAKE_TWEAK_VERSION", temp);
this->SetDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion()); this->SetDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion());
this->SetDefinition("CMAKE_FILES_DIRECTORY", this->SetDefinition("CMAKE_FILES_DIRECTORY",
......
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