diff options
author | Eugene Sandulenko | 2016-08-02 10:58:56 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | dc498881ef721b9443f64914e9a42bcf5afc967f (patch) | |
tree | 144d52673ce072098caf1a6170ebd5e41ecbfa86 /engines/director/lingo | |
parent | 783ff8f8f259684c841af3d99a0df7542e16058e (diff) | |
download | scummvm-rg350-dc498881ef721b9443f64914e9a42bcf5afc967f.tar.gz scummvm-rg350-dc498881ef721b9443f64914e9a42bcf5afc967f.tar.bz2 scummvm-rg350-dc498881ef721b9443f64914e9a42bcf5afc967f.zip |
DIRECTOR: Lingo: Process extra or too few arguments for built-ins
Diffstat (limited to 'engines/director/lingo')
-rw-r--r-- | engines/director/lingo/lingo-code.cpp | 13 | ||||
-rw-r--r-- | engines/director/lingo/tests/math.lingo | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index 7b367d9720..344fbc2885 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -702,7 +702,20 @@ void Lingo::c_call() { Symbol *sym = g_lingo->_handlers[name]; + if (sym->nargs < nargs) { + warning("Incorrect number of arguments for function %s. Dropping extra %d", name.c_str(), nargs - sym->nargs); + for (int i = 0; i < nargs - sym->nargs; i++) + g_lingo->pop(); + } + if (sym->type == BLTIN) { + if (sym->nargs > 0 && nargs < sym->nargs) { + warning("Too few arguments for function %s. Expecting %d but got %d", name.c_str(), sym->nargs, nargs); + for (int i = 0; i < nargs; i++) + g_lingo->pop(); + + return; + } (*sym->u.func)(); return; diff --git a/engines/director/lingo/tests/math.lingo b/engines/director/lingo/tests/math.lingo index 9c0b2d57a3..6f8ecc374f 100644 --- a/engines/director/lingo/tests/math.lingo +++ b/engines/director/lingo/tests/math.lingo @@ -12,6 +12,8 @@ set x = 2 + 3 * (4 / 2) put x put power(2, 8) +put power(2, 8, 0) +put power(2) updatestage -- Type conversion |