aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkString.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkString.cpp')
-rw-r--r--src/core/SkString.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp
index d93f662da3..b5655e0503 100644
--- a/src/core/SkString.cpp
+++ b/src/core/SkString.cpp
@@ -624,16 +624,35 @@ SkString SkStringPrintf(const char* format, ...) {
return formattedOutput;
}
-void SkStrSplit(const char* str, const char* delimiters, SkTArray<SkString>* out) {
- const char* end = str + strlen(str);
- while (str != end) {
- // Find a token.
- const size_t len = strcspn(str, delimiters);
- out->push_back().set(str, len);
- str += len;
+void SkStrSplit(const char* str, const char* delimiters, SkStrSplitMode splitMode,
+ SkTArray<SkString>* out) {
+ if (splitMode == kCoalesce_SkStrSplitMode) {
// Skip any delimiters.
str += strspn(str, delimiters);
}
+ if (!*str) {
+ return;
+ }
+
+ while (true) {
+ // Find a token.
+ const size_t len = strcspn(str, delimiters);
+ if (splitMode == kStrict_SkStrSplitMode || len > 0) {
+ out->push_back().set(str, len);
+ str += len;
+ }
+
+ if (!*str) {
+ return;
+ }
+ if (splitMode == kCoalesce_SkStrSplitMode) {
+ // Skip any delimiters.
+ str += strspn(str, delimiters);
+ } else {
+ // Skip one delimiter.
+ str += 1;
+ }
+ }
}
#undef VSNPRINTF