aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/StringUtil.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/StringUtil.cc')
-rw-r--r--src/FbTk/StringUtil.cc15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc
index 9b4928b..1bd9b8d 100644
--- a/src/FbTk/StringUtil.cc
+++ b/src/FbTk/StringUtil.cc
@@ -214,8 +214,7 @@ string basename(const string &filename) {
214 214
215string::size_type removeFirstWhitespace(string &str) { 215string::size_type removeFirstWhitespace(string &str) {
216 string::size_type first_pos = str.find_first_not_of(" \t"); 216 string::size_type first_pos = str.find_first_not_of(" \t");
217 if (first_pos != string::npos) 217 str.erase(0, first_pos);
218 str.erase(0, first_pos);
219 return first_pos; 218 return first_pos;
220} 219}
221 220
@@ -223,13 +222,9 @@ string::size_type removeFirstWhitespace(string &str) {
223string::size_type removeTrailingWhitespace(string &str) { 222string::size_type removeTrailingWhitespace(string &str) {
224 // strip trailing whitespace 223 // strip trailing whitespace
225 string::size_type first_pos = str.find_last_not_of(" \t"); 224 string::size_type first_pos = str.find_last_not_of(" \t");
226 if (first_pos != string::npos) { 225 string::size_type last_pos = str.find_first_of(" \t", first_pos);
227 string::size_type last_pos = str.find_first_of(" \t", first_pos); 226 if (last_pos != string::npos)
228 while (last_pos != string::npos) { 227 str.erase(last_pos);
229 str.erase(last_pos);
230 last_pos = str.find_first_of(" \t", last_pos);
231 }
232 }
233 return first_pos; 228 return first_pos;
234} 229}
235 230
@@ -240,8 +235,6 @@ void getFirstWord(const std::string &in, std::string &word, std::string &rest) {
240 if (second_pos != string::npos) { 235 if (second_pos != string::npos) {
241 rest = word.substr(second_pos); 236 rest = word.substr(second_pos);
242 word.erase(second_pos); 237 word.erase(second_pos);
243 removeFirstWhitespace(rest);
244 removeTrailingWhitespace(rest);
245 } 238 }
246} 239}
247 240