diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/common.h | 6 | ||||
| -rw-r--r-- | src/common/string_util.cpp | 11 |
2 files changed, 8 insertions, 9 deletions
diff --git a/src/common/common.h b/src/common/common.h index cb69eabe4..9f3016d34 100644 --- a/src/common/common.h +++ b/src/common/common.h | |||
| @@ -20,11 +20,6 @@ | |||
| 20 | 20 | ||
| 21 | #define STACKALIGN | 21 | #define STACKALIGN |
| 22 | 22 | ||
| 23 | #if __cplusplus >= 201103L || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__) | ||
| 24 | #define HAVE_CXX11_SYNTAX 1 | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #if HAVE_CXX11_SYNTAX | ||
| 28 | // An inheritable class to disallow the copy constructor and operator= functions | 23 | // An inheritable class to disallow the copy constructor and operator= functions |
| 29 | class NonCopyable | 24 | class NonCopyable |
| 30 | { | 25 | { |
| @@ -36,7 +31,6 @@ private: | |||
| 36 | NonCopyable(NonCopyable&); | 31 | NonCopyable(NonCopyable&); |
| 37 | NonCopyable& operator=(NonCopyable& other); | 32 | NonCopyable& operator=(NonCopyable& other); |
| 38 | }; | 33 | }; |
| 39 | #endif | ||
| 40 | 34 | ||
| 41 | #include "common/log.h" | 35 | #include "common/log.h" |
| 42 | #include "common/common_types.h" | 36 | #include "common/common_types.h" |
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 | ||