Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkAtomics.h" | 10 #include "SkAtomics.h" |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 617 | 617 |
| 618 SkString SkStringPrintf(const char* format, ...) { | 618 SkString SkStringPrintf(const char* format, ...) { |
| 619 SkString formattedOutput; | 619 SkString formattedOutput; |
| 620 char buffer[kBufferSize]; | 620 char buffer[kBufferSize]; |
| 621 SK_UNUSED int length; | 621 SK_UNUSED int length; |
| 622 ARGS_TO_BUFFER(format, buffer, kBufferSize, length); | 622 ARGS_TO_BUFFER(format, buffer, kBufferSize, length); |
| 623 formattedOutput.set(buffer); | 623 formattedOutput.set(buffer); |
| 624 return formattedOutput; | 624 return formattedOutput; |
| 625 } | 625 } |
| 626 | 626 |
| 627 void SkStrSplit(const char* str, const char* delimiters, SkTArray<SkString>* out ) { | 627 void SkStrSplit(const char* str, const char* delimiters, SkStrSplitResult result Behavior, |
| 628 const char* end = str + strlen(str); | 628 SkTArray<SkString>* out) { |
| 629 while (str != end) { | 629 if (resultBehavior != kAll_SkStrSplitResult) { |
|
scroggo
2015/12/07 13:27:52
Why not
if (resultBehavior == kNonEmpty_SkStrSpli
Kimmo Kinnunen
2015/12/08 09:07:51
Done.
| |
| 630 // Skip any delimiters. | |
| 631 str += strspn(str, delimiters); | |
| 632 } | |
| 633 if (!*str) { | |
| 634 return; | |
| 635 } | |
| 636 | |
| 637 while (true) { | |
| 630 // Find a token. | 638 // Find a token. |
| 631 const size_t len = strcspn(str, delimiters); | 639 const size_t len = strcspn(str, delimiters); |
| 632 out->push_back().set(str, len); | 640 if (resultBehavior == kAll_SkStrSplitResult || len > 0) { |
| 633 str += len; | 641 out->push_back().set(str, len); |
| 634 // Skip any delimiters. | 642 str += len; |
| 635 str += strspn(str, delimiters); | 643 } |
| 644 | |
| 645 if (!*str) { | |
| 646 return; | |
| 647 } | |
| 648 if (resultBehavior != kAll_SkStrSplitResult) { | |
| 649 // Skip any delimiters. | |
| 650 str += strspn(str, delimiters); | |
| 651 } else { | |
| 652 // Skip one delimiter. | |
| 653 str += 1; | |
| 654 } | |
| 636 } | 655 } |
| 637 } | 656 } |
| 638 | 657 |
| 639 #undef VSNPRINTF | 658 #undef VSNPRINTF |
| 640 #undef SNPRINTF | 659 #undef SNPRINTF |
| OLD | NEW |