aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/basetypes/MCString.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/basetypes/MCString.cpp b/src/core/basetypes/MCString.cpp
index 7d7a740e..7c6539ac 100644
--- a/src/core/basetypes/MCString.cpp
+++ b/src/core/basetypes/MCString.cpp
@@ -2244,10 +2244,29 @@ Array * String::componentsSeparatedByString(String * separator)
p = mUnicodeChars;
while (1) {
UChar * location;
+#if 0
location = u_strstr(p, separator->unicodeCharacters());
if (location == NULL) {
break;
}
+#else
+ int remaining = length() - (int) (p - mUnicodeChars);
+ location = NULL;
+ while (location == NULL) {
+ location = (UChar *) memmem(p, remaining * sizeof(UChar), separator->unicodeCharacters(), separator->length() * sizeof(UChar));
+ if (location == NULL) {
+ break;
+ }
+ // If it's odd, it's an invalid location. Keep looking for the pattern.
+ if (((char *) location - (char *) p) % sizeof(UChar) != 0) {
+ p = (UChar *) (((char *) location) + 1);
+ location = NULL;
+ }
+ }
+ if (location == NULL) {
+ break;
+ }
+#endif
unsigned int length = (unsigned int) (location - p);
String * value = new String(p, length);