summaryrefslogtreecommitdiffstats
path: root/base/strings.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-04-24 23:02:00 -0700
committerElliott Hughes <enh@google.com>2015-04-27 19:42:20 -0700
commit8d5fa6da44d56511b3e173bc463cbc65ff221b4a (patch)
tree684c19a54a0f82c7edd0005dd3cf2de86e4d409e /base/strings.cpp
parent06d2128f8729f3349f5ba588829c6f992a793c22 (diff)
downloadsystem_core-8d5fa6da44d56511b3e173bc463cbc65ff221b4a.tar.gz
system_core-8d5fa6da44d56511b3e173bc463cbc65ff221b4a.tar.bz2
system_core-8d5fa6da44d56511b3e173bc463cbc65ff221b4a.zip
Remove strtok from adb.
Also fix android::base::Split to behave like Java, Python, and google3. Change-Id: Ifbffd4e92950a79e7aea5d153c95fe0980648417
Diffstat (limited to 'base/strings.cpp')
-rw-r--r--base/strings.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/base/strings.cpp b/base/strings.cpp
index 6f698d9a7..d3375d9fa 100644
--- a/base/strings.cpp
+++ b/base/strings.cpp
@@ -32,24 +32,17 @@ std::vector<std::string> Split(const std::string& s,
const std::string& delimiters) {
CHECK_NE(delimiters.size(), 0U);
- std::vector<std::string> split;
- if (s.size() == 0) {
- // Split("", d) returns {} rather than {""}.
- return split;
- }
+ std::vector<std::string> result;
size_t base = 0;
size_t found;
do {
found = s.find_first_of(delimiters, base);
- if (found != base) {
- split.push_back(s.substr(base, found - base));
- }
-
+ result.push_back(s.substr(base, found - base));
base = found + 1;
} while (found != s.npos);
- return split;
+ return result;
}
std::string Trim(const std::string& s) {