aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2016-07-15 19:21:09 +0300
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commit5f0f0193f921008bf2deb5e249e40936aada8483 (patch)
treee4bcf6883423ccd7c2bb5d5c4fb9a24e41eb3714
parente1b2759d06ddff1b959cc3c86203c73439d01b3c (diff)
downloadscummvm-rg350-5f0f0193f921008bf2deb5e249e40936aada8483.tar.gz
scummvm-rg350-5f0f0193f921008bf2deb5e249e40936aada8483.tar.bz2
scummvm-rg350-5f0f0193f921008bf2deb5e249e40936aada8483.zip
DIRECTOR: Lingo: Fix splitting code to sections
-rw-r--r--engines/director/lingo/lingo.cpp45
1 files changed, 27 insertions, 18 deletions
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 837dfa0b67..8302c5996e 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -106,25 +106,35 @@ Lingo::~Lingo() {
}
const char *Lingo::findNextDefinition(const char *s) {
- const char *res;
+ const char *res = s;
- if ((res = strstr(s, "\nmacro "))) {
- return res;
- } else if ((res = strstr(s, "\nfactory "))) {
- return res;
- } else if (_inFactory && (res = strstr(s, "method "))) {
- if (s == res)
+ while (*res) {
+ while (*res && (*res == ' ' || *res == '\t' || *res == '\n'))
+ res++;
+
+ if (!*res)
+ return NULL;
+
+ if (!strncmp(res, "macro ", 6)) {
+ warning("See macro");
+ return res;
+ }
+
+ if (!strncmp(res, "factory ", 8)) {
+ warning("See factory");
return res;
+ }
- // Check that this is the first token on the line
- const char *tres = res;
- while (tres > s && (*tres == ' ' || *tres == '\t') && *tres != '\n')
- tres--;
- if (*tres == '\n')
+ if (!strncmp(res, "method ", 7)) {
+ warning("See method");
return res;
+ }
+
+ while (*res && *res != '\n')
+ res++;
}
- return nullptr;
+ return NULL;
}
void Lingo::addCode(const char *code, ScriptType type, uint16 id) {
@@ -147,14 +157,13 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) {
if ((begin = findNextDefinition(code))) {
bool first = true;
- begin += 1;
+ while ((end = findNextDefinition(begin + 1))) {
- while ((end = findNextDefinition(begin))) {
if (first) {
begin = code;
first = false;
}
- Common::String chunk(begin, end + 1);
+ Common::String chunk(begin, end - 1);
if (chunk.hasPrefix("factory") || chunk.hasPrefix("method"))
_inFactory = true;
@@ -163,13 +172,13 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) {
else
_inFactory = false;
- debug(2, "Code chunk\n#####\n%s#####", chunk.c_str());
+ debug(2, "Code chunk:\n#####\n%s#####", chunk.c_str());
parse(chunk.c_str());
_currentScript->clear();
- begin = end + 1;
+ begin = end;
}
_hadError = true; // HACK: This is for preventing test execution