Remove strtok from adb.
Also fix android::base::Split to behave like Java, Python, and google3.
(cherry picked from commit 8d5fa6da44d56511b3e173bc463cbc65ff221b4a)
Change-Id: I9388ae37ee8dd4a4a6c2a9a19f068b70d9a78353
diff --git a/base/strings.cpp b/base/strings.cpp
index 6f698d9..d3375d9 100644
--- a/base/strings.cpp
+++ b/base/strings.cpp
@@ -32,24 +32,17 @@
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) {