summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorBenjamin Nash <benash@umich.edu>2005-06-23 16:27:17 -0400
committerBenjamin Nash <benash@umich.edu>2005-06-23 16:27:17 -0400
commit0460a78829c000f033d703bb814ca39a835014a0 (patch)
treeb3a9f74af1d4a33559f21c5b5ed11a3052911b6c /base
parente8bcecd0a04638e9d9e6306cbe515c40e9ba0817 (diff)
parentcad549d7aaefece708495842f2be5e6532a27bb7 (diff)
downloadgem5-0460a78829c000f033d703bb814ca39a835014a0.tar.xz
Merge m5read@m5.eecs.umich.edu:/bk/m5
into zed.eecs.umich.edu:/z/benash/bk/m5 --HG-- extra : convert_revision : a0a8fea7224913ef106dc733182abd938feab64d
Diffstat (limited to 'base')
-rw-r--r--base/str.cc23
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;
}
}