summaryrefslogtreecommitdiff
path: root/src/common/string_util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/string_util.cpp')
-rw-r--r--src/common/string_util.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index a3c7f479e..b0c65d47d 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -279,12 +279,17 @@ std::string TabsToSpaces(int tab_size, const std::string &in)
279 279
280std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest) 280std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest)
281{ 281{
282 while(1) 282 size_t pos = 0;
283
284 if (src == dest)
285 return result;
286
287 while ((pos = result.find(src, pos)) != std::string::npos)
283 { 288 {
284 size_t pos = result.find(src);
285 if (pos == std::string::npos) break;
286 result.replace(pos, src.size(), dest); 289 result.replace(pos, src.size(), dest);
290 pos += dest.length();
287 } 291 }
292
288 return result; 293 return result;
289} 294}
290 295