diff options
author | Nathan Binkert <binkertn@umich.edu> | 2005-06-22 09:52:14 -0400 |
---|---|---|
committer | Nathan Binkert <binkertn@umich.edu> | 2005-06-22 09:52:14 -0400 |
commit | 1331a723c3113497deb63d0503ab49709d64b0c2 (patch) | |
tree | 051e5b1bbcf4965cecc9a6c4504c32caafb4a564 /base/str.cc | |
parent | 2c2f5f86d7658d959ff135121b77226ebefeec66 (diff) | |
parent | c95e1281fc5ecfe3f65a59fa426f16a54b2a6a50 (diff) | |
download | gem5-1331a723c3113497deb63d0503ab49709d64b0c2.tar.xz |
Merge zizzer.eecs.umich.edu:/bk/m5
into ziff.eecs.umich.edu:/z/binkertn/research/m5/head
--HG--
extra : convert_revision : 9dc37bbcc1dd5669f6de4e35a7c37e54d0af5c05
Diffstat (limited to 'base/str.cc')
-rw-r--r-- | base/str.cc | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/base/str.cc b/base/str.cc index 3a11bb17d..15f44dad2 100644 --- a/base/str.cc +++ b/base/str.cc @@ -26,11 +26,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <iostream> - -#include <string.h> #include <ctype.h> +#include <cstring> +#include <iostream> #include <string> #include <vector> @@ -75,15 +74,17 @@ tokenize(vector<string>& v, const string &s, char token, bool ignore) string::size_type first = 0; string::size_type last = s.find_first_of(token); - if (ignore) { - if (last == first) { - while (last == first) - last = s.find_first_of(token, ++first); + if (s.empty()) + return; - if (last == string::npos) { - v.push_back(s); - return; - } + if (ignore && last == first) { + while (last == first) + last = s.find_first_of(token, ++first); + + if (last == string::npos) { + if (first != s.size()) + v.push_back(s.substr(first)); + return; } } |