diff options
Diffstat (limited to 'src/common/string_util.cpp')
| -rw-r--r-- | src/common/string_util.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index bd4c33391..9199e30bc 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -3,17 +3,13 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <cstdlib> | ||
| 7 | #include <cstdio> | ||
| 8 | 6 | ||
| 9 | #include "common/common.h" | 7 | #include "common/common.h" |
| 10 | #include "common/common_paths.h" | ||
| 11 | #include "common/string_util.h" | 8 | #include "common/string_util.h" |
| 12 | 9 | ||
| 13 | #ifdef _WIN32 | 10 | #ifdef _WIN32 |
| 14 | #include <Windows.h> | 11 | #include <Windows.h> |
| 15 | #else | 12 | #else |
| 16 | #include <cerrno> | ||
| 17 | #include <iconv.h> | 13 | #include <iconv.h> |
| 18 | #endif | 14 | #endif |
| 19 | 15 | ||
| @@ -281,12 +277,17 @@ std::string TabsToSpaces(int tab_size, const std::string &in) | |||
| 281 | 277 | ||
| 282 | std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest) | 278 | std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest) |
| 283 | { | 279 | { |
| 284 | while(1) | 280 | size_t pos = 0; |
| 281 | |||
| 282 | if (src == dest) | ||
| 283 | return result; | ||
| 284 | |||
| 285 | while ((pos = result.find(src, pos)) != std::string::npos) | ||
| 285 | { | 286 | { |
| 286 | size_t pos = result.find(src); | ||
| 287 | if (pos == std::string::npos) break; | ||
| 288 | result.replace(pos, src.size(), dest); | 287 | result.replace(pos, src.size(), dest); |
| 288 | pos += dest.length(); | ||
| 289 | } | 289 | } |
| 290 | |||
| 290 | return result; | 291 | return result; |
| 291 | } | 292 | } |
| 292 | 293 | ||