aboutsummaryrefslogtreecommitdiffhomepage
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.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index bd4c3339..9199e30b 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -3,17 +3,13 @@
// Refer to the license.txt file included.
#include <algorithm>
-#include <cstdlib>
-#include <cstdio>
#include "common/common.h"
-#include "common/common_paths.h"
#include "common/string_util.h"
#ifdef _WIN32
#include <Windows.h>
#else
- #include <cerrno>
#include <iconv.h>
#endif
@@ -281,12 +277,17 @@ std::string TabsToSpaces(int tab_size, const std::string &in)
std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest)
{
- while(1)
+ size_t pos = 0;
+
+ if (src == dest)
+ return result;
+
+ while ((pos = result.find(src, pos)) != std::string::npos)
{
- size_t pos = result.find(src);
- if (pos == std::string::npos) break;
result.replace(pos, src.size(), dest);
+ pos += dest.length();
}
+
return result;
}