diff options
| -rw-r--r-- | src/common/string_util.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index c1f22bda3..e78aed75d 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -283,12 +283,17 @@ std::string TabsToSpaces(int tab_size, const std::string &in) | |||
| 283 | 283 | ||
| 284 | std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest) | 284 | std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest) |
| 285 | { | 285 | { |
| 286 | while(1) | 286 | size_t pos = 0; |
| 287 | |||
| 288 | if (src == dest) | ||
| 289 | return result; | ||
| 290 | |||
| 291 | while ((pos = result.find(src, pos)) != std::string::npos) | ||
| 287 | { | 292 | { |
| 288 | size_t pos = result.find(src); | ||
| 289 | if (pos == std::string::npos) break; | ||
| 290 | result.replace(pos, src.size(), dest); | 293 | result.replace(pos, src.size(), dest); |
| 294 | pos += dest.length(); | ||
| 291 | } | 295 | } |
| 296 | |||
| 292 | return result; | 297 | return result; |
| 293 | } | 298 | } |
| 294 | 299 | ||