mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-11 13:45:25 +00:00
DIRECTOR: Lingo: Fix splitting code to sections
This commit is contained in:
parent
e1b2759d06
commit
5f0f0193f9
@ -106,25 +106,35 @@ Lingo::~Lingo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *Lingo::findNextDefinition(const char *s) {
|
const char *Lingo::findNextDefinition(const char *s) {
|
||||||
const char *res;
|
const char *res = s;
|
||||||
|
|
||||||
if ((res = strstr(s, "\nmacro "))) {
|
while (*res) {
|
||||||
return res;
|
while (*res && (*res == ' ' || *res == '\t' || *res == '\n'))
|
||||||
} else if ((res = strstr(s, "\nfactory "))) {
|
res++;
|
||||||
return res;
|
|
||||||
} else if (_inFactory && (res = strstr(s, "method "))) {
|
|
||||||
if (s == res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
// Check that this is the first token on the line
|
if (!*res)
|
||||||
const char *tres = res;
|
return NULL;
|
||||||
while (tres > s && (*tres == ' ' || *tres == '\t') && *tres != '\n')
|
|
||||||
tres--;
|
if (!strncmp(res, "macro ", 6)) {
|
||||||
if (*tres == '\n')
|
warning("See macro");
|
||||||
return res;
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strncmp(res, "factory ", 8)) {
|
||||||
|
warning("See factory");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
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))) {
|
if ((begin = findNextDefinition(code))) {
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
begin += 1;
|
while ((end = findNextDefinition(begin + 1))) {
|
||||||
|
|
||||||
while ((end = findNextDefinition(begin))) {
|
|
||||||
if (first) {
|
if (first) {
|
||||||
begin = code;
|
begin = code;
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
Common::String chunk(begin, end + 1);
|
Common::String chunk(begin, end - 1);
|
||||||
|
|
||||||
if (chunk.hasPrefix("factory") || chunk.hasPrefix("method"))
|
if (chunk.hasPrefix("factory") || chunk.hasPrefix("method"))
|
||||||
_inFactory = true;
|
_inFactory = true;
|
||||||
@ -163,13 +172,13 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) {
|
|||||||
else
|
else
|
||||||
_inFactory = false;
|
_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());
|
parse(chunk.c_str());
|
||||||
|
|
||||||
_currentScript->clear();
|
_currentScript->clear();
|
||||||
|
|
||||||
begin = end + 1;
|
begin = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
_hadError = true; // HACK: This is for preventing test execution
|
_hadError = true; // HACK: This is for preventing test execution
|
||||||
|
Loading…
x
Reference in New Issue
Block a user