aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2013-03-24 18:55:33 +0100
committerEinar Johan Trøan Sømåen2013-03-24 18:55:33 +0100
commitd136e20d6e1851b1261db83787fea9d5fb42cd89 (patch)
tree723704c16f42aaedf7d5ec4e9641eba64651dd10 /engines/wintermute
parentf17d69f23ec6246307a4d9d898511da7e762c61c (diff)
downloadscummvm-rg350-d136e20d6e1851b1261db83787fea9d5fb42cd89.tar.gz
scummvm-rg350-d136e20d6e1851b1261db83787fea9d5fb42cd89.tar.bz2
scummvm-rg350-d136e20d6e1851b1261db83787fea9d5fb42cd89.zip
WINTERMUTE: Replace WMELite's String-Split-function with code from WME.
Diffstat (limited to 'engines/wintermute')
-rw-r--r--engines/wintermute/base/scriptables/script_ext_string.cpp42
1 files changed, 19 insertions, 23 deletions
diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp
index 6b4a615509..3752412141 100644
--- a/engines/wintermute/base/scriptables/script_ext_string.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_string.cpp
@@ -295,30 +295,26 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
Common::Array<WideString> parts;
-
-
- Common::StringTokenizer tokenizer(str, delims);
- while (!tokenizer.empty()) {
- Common::String str2 = tokenizer.nextToken();
- parts.push_back(str2);
+ uint32 start = 0;
+ for(uint32 i = 0; i < str.size() + 1; i++) {
+ char ch = str.c_str()[i];
+ if(ch=='\0' || delims.contains(ch))
+ {
+ char *part = new char[i - start + 1];
+ if(i != start) {
+ strlcpy(part, str.c_str() + start, i - start + 1);
+ part[i - start] = '\0';
+ } else {
+ part[0] = '\0';
+ }
+ val = new ScValue(_gameRef, part);
+ array->push(val);
+ delete[] part;
+ delete val;
+ val = nullptr;
+ start = i + 1;
+ }
}
- // TODO: Clean this up
- /*do {
- pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start);
- //pos = str.find_first_of(delims, start);
- if (pos == start) {
- start = pos + 1;
- } else if (pos == str.size()) {
- parts.push_back(Common::String(str.c_str() + start));
- break;
- } else {
- parts.push_back(Common::String(str.c_str() + start, pos - start));
- start = pos + 1;
- }
- //start = str.find_first_not_of(delims, start);
- start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1;
-
- } while (pos != str.size());*/
for (Common::Array<WideString>::iterator it = parts.begin(); it != parts.end(); ++it) {
WideString &part = (*it);