diff options
| -rw-r--r-- | src/common/string_util.cpp | 13 | ||||
| -rw-r--r-- | src/common/string_util.h | 2 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index f3ad3d68a..2099eebb8 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -168,15 +168,14 @@ void SplitString(const std::string& str, const char delim, std::vector<std::stri | |||
| 168 | output.pop_back(); | 168 | output.pop_back(); |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | std::string TabsToSpaces(int tab_size, const std::string& in) { | 171 | std::string TabsToSpaces(int tab_size, std::string in) { |
| 172 | const std::string spaces(tab_size, ' '); | ||
| 173 | std::string out(in); | ||
| 174 | |||
| 175 | size_t i = 0; | 172 | size_t i = 0; |
| 176 | while (out.npos != (i = out.find('\t'))) | ||
| 177 | out.replace(i, 1, spaces); | ||
| 178 | 173 | ||
| 179 | return out; | 174 | while ((i = in.find('\t')) != std::string::npos) { |
| 175 | in.replace(i, 1, tab_size, ' '); | ||
| 176 | } | ||
| 177 | |||
| 178 | return in; | ||
| 180 | } | 179 | } |
| 181 | 180 | ||
| 182 | std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest) { | 181 | std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest) { |
diff --git a/src/common/string_util.h b/src/common/string_util.h index daa071f83..4a2143b59 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h | |||
| @@ -57,7 +57,7 @@ static bool TryParse(const std::string& str, N* const output) { | |||
| 57 | return false; | 57 | return false; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | std::string TabsToSpaces(int tab_size, const std::string& in); | 60 | std::string TabsToSpaces(int tab_size, std::string in); |
| 61 | 61 | ||
| 62 | void SplitString(const std::string& str, char delim, std::vector<std::string>& output); | 62 | void SplitString(const std::string& str, char delim, std::vector<std::string>& output); |
| 63 | 63 | ||