diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2008-02-13 16:06:44 -0330 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2008-02-13 16:06:44 -0330 |
commit | 4c5ce7e037cec0cd633e1f0648e3c9f5c928ae1d (patch) | |
tree | 52ceee9bdc146f9d3586b478e006b573c12ed0bd /cpp/src | |
parent | Bug 2387 (diff) | |
download | ice-4c5ce7e037cec0cd633e1f0648e3c9f5c928ae1d.tar.bz2 ice-4c5ce7e037cec0cd633e1f0648e3c9f5c928ae1d.tar.xz ice-4c5ce7e037cec0cd633e1f0648e3c9f5c928ae1d.zip |
minor change to trim
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceUtil/StringUtil.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp index 2d56cf06a93..e087e5586dc 100644 --- a/cpp/src/IceUtil/StringUtil.cpp +++ b/cpp/src/IceUtil/StringUtil.cpp @@ -371,13 +371,15 @@ string IceUtilInternal::trim(const string& s) { static const string delim = " \t\r\n"; - if(s.length() != 0) + string::size_type beg = s.find_first_not_of(delim); + if(beg == string::npos) { - string::size_type beg = s.find_first_not_of(delim); - string::size_type end = s.find_last_not_of(delim); - return s.substr(beg, end - beg + 1); + return ""; + } + else + { + return s.substr(beg, s.find_last_not_of(delim) - beg + 1); } - return s; } // |