[Scummvm-cvs-logs] scummvm master -> d136e20d6e1851b1261db83787fea9d5fb42cd89
somaen
einarjohants at gmail.com
Sun Mar 24 18:56:37 CET 2013
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
d136e20d6e WINTERMUTE: Replace WMELite's String-Split-function with code from WME.
Commit: d136e20d6e1851b1261db83787fea9d5fb42cd89
https://github.com/scummvm/scummvm/commit/d136e20d6e1851b1261db83787fea9d5fb42cd89
Author: Einar Johan Trøan Sømåen (einarjohants at gmail.com)
Date: 2013-03-24T10:55:33-07:00
Commit Message:
WINTERMUTE: Replace WMELite's String-Split-function with code from WME.
Changed paths:
engines/wintermute/base/scriptables/script_ext_string.cpp
diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp
index 6b4a615..3752412 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);
More information about the Scummvm-git-logs
mailing list