summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2016-05-24 20:58:11 (GMT)
committerDaniel Pfeifer <daniel@pfeifer-mail.de>2016-05-24 21:22:20 (GMT)
commit5cec953e6aafd4c132a7b6c0a929d95c1dee79ea (patch)
tree09cf2f4a8f28c5ca8a7e648486fc10e1ae5e2d89
parent2a1a2033afe73da08af46e12ed77a8f55a89417f (diff)
downloadCMake-5cec953e6aafd4c132a7b6c0a929d95c1dee79ea.zip
CMake-5cec953e6aafd4c132a7b6c0a929d95c1dee79ea.tar.gz
CMake-5cec953e6aafd4c132a7b6c0a929d95c1dee79ea.tar.bz2
Use std::replace for replacing chars in strings.
Find uses of `cmSystemTools::ReplaceString` where both `replace` and `with` are string literals with a size of one. Automate with: git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\2', '\3');|g" git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\\\\\\\\\");|std::replace(\1.begin(), \1.end(), '\2', '\\\\\\\\');|g" git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\\\\\\\\\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\\\\\\\\', '\2');|g"
-rw-r--r--Source/CPack/cmCPackNSISGenerator.cxx10
-rw-r--r--Source/CPack/cmCPackRPMGenerator.cxx4
-rw-r--r--Source/cmBuildNameCommand.cxx12
-rw-r--r--Source/cmCreateTestSourceList.cxx6
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx4
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx8
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx2
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx2
-rw-r--r--Source/cmInstallExportGenerator.cxx4
-rw-r--r--Source/cmLocalGenerator.cxx4
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx2
-rw-r--r--Source/cmNinjaTargetGenerator.cxx2
-rw-r--r--Source/cmQtAutoGenerators.cxx2
-rw-r--r--Source/cmSeparateArgumentsCommand.cxx2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx2
-rw-r--r--Source/cmVisualStudioWCEPlatformParser.cxx4
17 files changed, 36 insertions, 36 deletions
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index 4d48cb5..9fa588d 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -74,7 +74,7 @@ int cmCPackNSISGenerator::PackageFiles()
// Strip off the component part of the path.
fileN = fileN.substr(fileN.find('/') + 1, std::string::npos);
}
- cmSystemTools::ReplaceString(fileN, "/", "\\");
+ std::replace(fileN.begin(), fileN.end(), '/', '\\');
str << " Delete \"$INSTDIR\\" << fileN << "\"" << std::endl;
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: " << str.str()
@@ -104,7 +104,7 @@ int cmCPackNSISGenerator::PackageFiles()
fileN = fileN.substr(slash + 1, std::string::npos);
}
}
- cmSystemTools::ReplaceString(fileN, "/", "\\");
+ std::replace(fileN.begin(), fileN.end(), '/', '\\');
dstr << " RMDir \"$INSTDIR\\" << fileN << "\"" << std::endl;
if (!componentName.empty()) {
this->Components[componentName].Directories.push_back(fileN);
@@ -548,7 +548,7 @@ void cmCPackNSISGenerator::CreateMenuLinks(std::ostringstream& str,
// Convert / to \ in filenames, but not in urls:
//
if (!url) {
- cmSystemTools::ReplaceString(sourceName, "/", "\\");
+ std::replace(sourceName.begin(), sourceName.end(), '/', '\\');
}
++it;
@@ -790,13 +790,13 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
for (pathIt = component->Files.begin(); pathIt != component->Files.end();
++pathIt) {
path = *pathIt;
- cmSystemTools::ReplaceString(path, "/", "\\");
+ std::replace(path.begin(), path.end(), '/', '\\');
macrosOut << " Delete \"$INSTDIR\\" << path << "\"\n";
}
for (pathIt = component->Directories.begin();
pathIt != component->Directories.end(); ++pathIt) {
path = *pathIt;
- cmSystemTools::ReplaceString(path, "/", "\\");
+ std::replace(path.begin(), path.end(), '/', '\\');
macrosOut << " RMDir \"$INSTDIR\\" << path << "\"\n";
}
macrosOut << " noremove_" << component->Name << ":\n";
diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx
index fc6603a..a4b9a47 100644
--- a/Source/CPack/cmCPackRPMGenerator.cxx
+++ b/Source/CPack/cmCPackRPMGenerator.cxx
@@ -34,13 +34,13 @@ int cmCPackRPMGenerator::InitializeInternal()
*/
if (this->GetOption("CPACK_PACKAGE_NAME")) {
std::string packageName = this->GetOption("CPACK_PACKAGE_NAME");
- cmSystemTools::ReplaceString(packageName, " ", "-");
+ std::replace(packageName.begin(), packageName.end(), ' ', '-');
this->SetOption("CPACK_PACKAGE_NAME", packageName.c_str());
}
/* same for CPACK_PACKAGE_FILE_NAME */
if (this->GetOption("CPACK_PACKAGE_FILE_NAME")) {
std::string packageName = this->GetOption("CPACK_PACKAGE_FILE_NAME");
- cmSystemTools::ReplaceString(packageName, " ", "-");
+ std::replace(packageName.begin(), packageName.end(), ' ', '-');
this->SetOption("CPACK_PACKAGE_FILE_NAME", packageName.c_str());
}
return this->Superclass::InitializeInternal();
diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx
index 7ed96ab..27234d7 100644
--- a/Source/cmBuildNameCommand.cxx
+++ b/Source/cmBuildNameCommand.cxx
@@ -32,9 +32,9 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args,
cmsys::RegularExpression reg("[()/]");
if (reg.find(cacheValue)) {
std::string cv = cacheValue;
- cmSystemTools::ReplaceString(cv, "/", "_");
- cmSystemTools::ReplaceString(cv, "(", "_");
- cmSystemTools::ReplaceString(cv, ")", "_");
+ std::replace(cv.begin(), cv.end(), '/', '_');
+ std::replace(cv.begin(), cv.end(), '(', '_');
+ std::replace(cv.begin(), cv.end(), ')', '_');
this->Makefile->AddCacheDefinition(args[0], cv.c_str(), "Name of build.",
cmState::STRING);
}
@@ -57,9 +57,9 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args,
this->Makefile->ExpandVariablesInString(compiler);
buildname += "-";
buildname += cmSystemTools::GetFilenameName(compiler);
- cmSystemTools::ReplaceString(buildname, "/", "_");
- cmSystemTools::ReplaceString(buildname, "(", "_");
- cmSystemTools::ReplaceString(buildname, ")", "_");
+ std::replace(buildname.begin(), buildname.end(), '/', '_');
+ std::replace(buildname.begin(), buildname.end(), '(', '_');
+ std::replace(buildname.begin(), buildname.end(), ')', '_');
this->Makefile->AddCacheDefinition(args[0], buildname.c_str(),
"Name of build.", cmState::STRING);
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index 6f7cfbe..d8c629c 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -95,9 +95,9 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
func_name = cmSystemTools::GetFilenameWithoutLastExtension(*i);
}
cmSystemTools::ConvertToUnixSlashes(func_name);
- cmSystemTools::ReplaceString(func_name, " ", "_");
- cmSystemTools::ReplaceString(func_name, "/", "_");
- cmSystemTools::ReplaceString(func_name, ":", "_");
+ std::replace(func_name.begin(), func_name.end(), ' ', '_');
+ std::replace(func_name.begin(), func_name.end(), '/', '_');
+ std::replace(func_name.begin(), func_name.end(), ':', '_');
tests_func_name.push_back(func_name);
forwardDeclareCode += "int ";
forwardDeclareCode += func_name;
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index 8a80f46..0ae913e 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -214,7 +214,7 @@ void cmGlobalGhsMultiGenerator::OpenBuildFileStream()
this->GetCMakeInstance()->MarkCliAsUsed("GHS_OS_DIR");
}
std::string fOSDir(this->trimQuotes(osDir));
- cmSystemTools::ReplaceString(fOSDir, "\\", "/");
+ std::replace(fOSDir.begin(), fOSDir.end(), '\\', '/');
if (!fOSDir.empty() && ('c' == fOSDir[0] || 'C' == fOSDir[0])) {
this->OSDirRelative = false;
} else {
@@ -230,7 +230,7 @@ void cmGlobalGhsMultiGenerator::OpenBuildFileStream()
this->GetCMakeInstance()->MarkCliAsUsed("GHS_BSP_NAME");
}
std::string fBspName(this->trimQuotes(bspName));
- cmSystemTools::ReplaceString(fBspName, "\\", "/");
+ std::replace(fBspName.begin(), fBspName.end(), '\\', '/');
this->WriteMacros();
this->WriteHighLevelDirectives();
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index d65b463..af6e88c 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -113,9 +113,9 @@ std::string cmGlobalNinjaGenerator::EncodePath(const std::string& path)
std::string result = path;
#ifdef _WIN32
if (this->IsGCCOnWindows())
- cmSystemTools::ReplaceString(result, "\\", "/");
+ std::replace(result.begin(), result.end(), '\\', '/');
else
- cmSystemTools::ReplaceString(result, "/", "\\");
+ std::replace(result.begin(), result.end(), '/', '\\');
#endif
return EncodeLiteral(result);
}
@@ -742,7 +742,7 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path)
std::string convPath = ng->Convert(path, cmOutputConverter::HOME_OUTPUT);
convPath = this->NinjaOutputPath(convPath);
#ifdef _WIN32
- cmSystemTools::ReplaceString(convPath, "/", "\\");
+ std::replace(convPath.begin(), convPath.end(), '/', '\\');
#endif
return convPath;
}
@@ -755,7 +755,7 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaFolderRule(
std::string convPath = ng->Convert(path + "/all", cmOutputConverter::HOME);
convPath = this->NinjaOutputPath(convPath);
#ifdef _WIN32
- cmSystemTools::ReplaceString(convPath, "/", "\\");
+ std::replace(convPath.begin(), convPath.end(), '/', '\\');
#endif
return convPath;
}
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index cfe5e49..3f2dd17 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -457,7 +457,7 @@ void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout)
std::string fullName = iter->first;
std::string guid = this->GetGUID(fullName.c_str());
- cmSystemTools::ReplaceString(fullName, "/", "\\");
+ std::replace(fullName.begin(), fullName.end(), '/', '\\');
if (cmSystemTools::StringStartsWith(fullName.c_str(), prefix)) {
fullName = fullName.substr(skip_prefix);
}
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 8066201..1bec581 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -622,7 +622,7 @@ void WriteVSMacrosFileRegistryEntry(const std::string& nextAvailableSubKeyName,
DWORD dw = 0;
std::string s(macrosFile);
- cmSystemTools::ReplaceString(s, "/", "\\");
+ std::replace(s.begin(), s.end(), '/', '\\');
std::wstring ws = cmsys::Encoding::ToWide(s);
result =
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index efc239e..727df36 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -367,7 +367,7 @@ std::string cmGlobalXCodeGenerator::PostBuildMakeTarget(
std::string const& tName, std::string const& configName)
{
std::string target = tName;
- cmSystemTools::ReplaceString(target, " ", "_");
+ std::replace(target.begin(), target.end(), ' ', '_');
std::string out = "PostBuild." + target;
if (this->XcodeVersion > 20) {
out += "." + configName;
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index 31fd91a..2fef3a8 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -93,11 +93,11 @@ void cmInstallExportGenerator::ComputeTempDir()
dest[0] = '_';
}
// Avoid windows full paths by removing colons.
- cmSystemTools::ReplaceString(dest, ":", "_");
+ std::replace(dest.begin(), dest.end(), ':', '_');
// Avoid relative paths that go up the tree.
cmSystemTools::ReplaceString(dest, "../", "__/");
// Avoid spaces.
- cmSystemTools::ReplaceString(dest, " ", "_");
+ std::replace(dest.begin(), dest.end(), ' ', '_');
this->TempDir += dest;
}
}
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 0ff13d9..4a52f51 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2309,13 +2309,13 @@ std::string& cmLocalGenerator::CreateSafeUniqueObjectFileName(
ssin.erase(0, ssin.find_first_not_of("/"));
// Avoid full paths by removing colons.
- cmSystemTools::ReplaceString(ssin, ":", "_");
+ std::replace(ssin.begin(), ssin.end(), ':', '_');
// Avoid relative paths that go up the tree.
cmSystemTools::ReplaceString(ssin, "../", "__/");
// Avoid spaces.
- cmSystemTools::ReplaceString(ssin, " ", "_");
+ std::replace(ssin.begin(), ssin.end(), ' ', '_');
// Mangle the name if necessary.
if (this->Makefile->IsOn("CMAKE_MANGLE_OBJECT_FILE_NAMES")) {
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 88c6d61..defac95 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1190,7 +1190,7 @@ std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable(
// if this there is no value for this->MakefileVariableSize then
// the string must have bad characters in it
if (!this->MakefileVariableSize) {
- cmSystemTools::ReplaceString(ret, ".", "_");
+ std::replace(ret.begin(), ret.end(), '.', '_');
cmSystemTools::ReplaceString(ret, "-", "__");
cmSystemTools::ReplaceString(ret, "+", "___");
int ni = 0;
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 4d58242..4a252f3 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -134,7 +134,7 @@ void cmNinjaTargetGenerator::AddIncludeFlags(std::string& languageFlags,
// needed by cmcldeps
false, this->GetConfigName());
if (this->GetGlobalGenerator()->IsGCCOnWindows())
- cmSystemTools::ReplaceString(includeFlags, "\\", "/");
+ std::replace(includeFlags.begin(), includeFlags.end(), '\\', '/');
this->LocalGenerator->AppendFlags(languageFlags, includeFlags);
}
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index cb1801f..ac64397 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -1303,7 +1303,7 @@ bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile,
const std::string& qrcOutputFile)
{
std::string relName = this->SourceRelativePath(qrcInputFile);
- cmSystemTools::ReplaceString(relName, "/", "_");
+ std::replace(relName.begin(), relName.end(), '/', '_');
relName += cmsys::SystemTools::GetFilenameWithoutLastExtension(qrcInputFile);
const ::std::string qrcBuildFile = this->Builddir + qrcOutputFile;
diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx
index 3438321..440b635 100644
--- a/Source/cmSeparateArgumentsCommand.cxx
+++ b/Source/cmSeparateArgumentsCommand.cxx
@@ -62,7 +62,7 @@ bool cmSeparateArgumentsCommand::InitialPass(
// Original space-replacement version of command.
if (const char* def = this->Makefile->GetDefinition(var)) {
std::string value = def;
- cmSystemTools::ReplaceString(value, " ", ";");
+ std::replace(value.begin(), value.end(), ' ', ';');
this->Makefile->AddDefinition(var, value.c_str());
}
} else {
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 3d93e69..7dd642a 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2207,7 +2207,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
libs = libs.substr(0, pos + 1);
}
// Replace spaces in libs with ;
- cmSystemTools::ReplaceString(libs, " ", ";");
+ std::replace(libs.begin(), libs.end(), ' ', ';');
std::vector<std::string> libVec;
cmSystemTools::ExpandListArgument(libs, libVec);
diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx
index 4f5e7c0..bc6b0bf 100644
--- a/Source/cmVisualStudioWCEPlatformParser.cxx
+++ b/Source/cmVisualStudioWCEPlatformParser.cxx
@@ -141,8 +141,8 @@ std::string cmVisualStudioWCEPlatformParser::FixPaths(
cmSystemTools::ReplaceString(ret, "$(PATH)", "%PATH%");
cmSystemTools::ReplaceString(ret, "$(VCInstallDir)", VcInstallDir.c_str());
cmSystemTools::ReplaceString(ret, "$(VSInstallDir)", VsInstallDir.c_str());
- cmSystemTools::ReplaceString(ret, "\\", "/");
+ std::replace(ret.begin(), ret.end(), '\\', '/');
cmSystemTools::ReplaceString(ret, "//", "/");
- cmSystemTools::ReplaceString(ret, "/", "\\");
+ std::replace(ret.begin(), ret.end(), '/', '\\');
return ret;
}