ERR: ReplaceString didn't work properly if replace was longer than with as

length added to start pos on next search was replaceLength  instead
of withLength
This commit is contained in:
John Biddiscombe 2002-04-08 19:31:21 -04:00
parent 2c276fcb13
commit 7d8d326d93
1 changed files with 2 additions and 1 deletions

View File

@ -182,6 +182,7 @@ void cmSystemTools::ReplaceString(std::string& source,
const char* with)
{
std::string::size_type lengthReplace = strlen(replace);
std::string::size_type lengthWith = strlen(with);
std::string rest;
std::string::size_type start = source.find(replace);
while(start != std::string::npos)
@ -190,7 +191,7 @@ void cmSystemTools::ReplaceString(std::string& source,
source = source.substr(0, start);
source += with;
source += rest;
start = source.find(replace, start + lengthReplace );
start = source.find(replace, start + lengthWith );
}
}