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"
This commit is contained in:
Daniel Pfeifer
2016-05-24 22:58:11 +02:00
parent 2a1a2033af
commit 5cec953e6a
17 changed files with 36 additions and 36 deletions

View File

@@ -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;