diff options
author | md5 | 2011-05-14 14:57:33 +0300 |
---|---|---|
committer | md5 | 2011-05-14 14:58:29 +0300 |
commit | cd54d761e10f5c8f24c5508ae22381ed71018abc (patch) | |
tree | bb8b5b01631f007993af4bd74d6100299d42206d /engines | |
parent | 8db0bb927421622a5496c78351c1230584a17a97 (diff) | |
download | scummvm-rg350-cd54d761e10f5c8f24c5508ae22381ed71018abc.tar.gz scummvm-rg350-cd54d761e10f5c8f24c5508ae22381ed71018abc.tar.bz2 scummvm-rg350-cd54d761e10f5c8f24c5508ae22381ed71018abc.zip |
SWORD25 (LUA): Disabled a lot of non-portable LUA functions
sword25 doesn't use these (thankfully)
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sword25/util/lua/lauxlib.cpp | 7 | ||||
-rw-r--r-- | engines/sword25/util/lua/liolib.cpp | 20 | ||||
-rw-r--r-- | engines/sword25/util/lua/loslib.cpp | 26 | ||||
-rw-r--r-- | engines/sword25/util/lua/luaconf.h | 27 |
4 files changed, 9 insertions, 71 deletions
diff --git a/engines/sword25/util/lua/lauxlib.cpp b/engines/sword25/util/lua/lauxlib.cpp index 53c0556625..526b1c84ab 100644 --- a/engines/sword25/util/lua/lauxlib.cpp +++ b/engines/sword25/util/lua/lauxlib.cpp @@ -6,7 +6,6 @@ #include <ctype.h> -#include <errno.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -541,11 +540,7 @@ static const char *getF (lua_State *L, void *ud, size_t *size) { static int errfile (lua_State *L, const char *what, int fnameindex) { - const char *serr = strerror(errno); - const char *filename = lua_tostring(L, fnameindex) + 1; - lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); - lua_remove(L, fnameindex); - return LUA_ERRFILE; + return luaL_error(L, "LUA function errfile has been removed in ScummVM"); } diff --git a/engines/sword25/util/lua/liolib.cpp b/engines/sword25/util/lua/liolib.cpp index aa44dcafa3..f9bad30aed 100644 --- a/engines/sword25/util/lua/liolib.cpp +++ b/engines/sword25/util/lua/liolib.cpp @@ -5,7 +5,6 @@ */ -#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -28,25 +27,12 @@ static const char *const fnames[] = {"input", "output"}; static int pushresult (lua_State *L, int i, const char *filename) { - int en = errno; /* calls to Lua API may change this value */ - if (i) { - lua_pushboolean(L, 1); - return 1; - } - else { - lua_pushnil(L); - if (filename) - lua_pushfstring(L, "%s: %s", filename, strerror(en)); - else - lua_pushfstring(L, "%s", strerror(en)); - lua_pushinteger(L, en); - return 3; - } + return luaL_error(L, "LUA file I/O functions have been removed in ScummVM"); } static void fileerror (lua_State *L, int arg, const char *filename) { - lua_pushfstring(L, "%s: %s", filename, strerror(errno)); + lua_pushfstring(L, "%s: %s", filename, "LUA I/O error descriptions have been removed in ScummVM"); luaL_argerror(L, arg, lua_tostring(L, -1)); } @@ -392,7 +378,7 @@ static int io_readline (lua_State *L) { luaL_error(L, "file is already closed"); sucess = read_line(L, f); if (ferror(f)) - return luaL_error(L, "%s", strerror(errno)); + return luaL_error(L, "%s", "LUA I/O error descriptions have been removed in ScummVM"); if (sucess) return 1; else { /* EOF */ if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ diff --git a/engines/sword25/util/lua/loslib.cpp b/engines/sword25/util/lua/loslib.cpp index 035925ceb5..51266b522f 100644 --- a/engines/sword25/util/lua/loslib.cpp +++ b/engines/sword25/util/lua/loslib.cpp @@ -5,7 +5,6 @@ */ -#include <errno.h> #include <locale.h> #include <stdlib.h> #include <string.h> @@ -20,21 +19,6 @@ #include "lualib.h" -static int os_pushresult (lua_State *L, int i, const char *filename) { - int en = errno; /* calls to Lua API may change this value */ - if (i) { - lua_pushboolean(L, 1); - return 1; - } - else { - lua_pushnil(L); - lua_pushfstring(L, "%s: %s", filename, strerror(en)); - lua_pushinteger(L, en); - return 3; - } -} - - static int os_execute (lua_State *L) { lua_pushinteger(L, system(luaL_optstring(L, 1, NULL))); return 1; @@ -42,15 +26,15 @@ static int os_execute (lua_State *L) { static int os_remove (lua_State *L) { - const char *filename = luaL_checkstring(L, 1); - return os_pushresult(L, remove(filename) == 0, filename); + // Removed in ScummVM, does nothing. It's called when loading games (perhaps + // to delete the savegame thumbnail?) + return 1; } static int os_rename (lua_State *L) { - const char *fromname = luaL_checkstring(L, 1); - const char *toname = luaL_checkstring(L, 2); - return os_pushresult(L, rename(fromname, toname) == 0, fromname); + // Removed in ScummVM, does nothing. + return 1; } diff --git a/engines/sword25/util/lua/luaconf.h b/engines/sword25/util/lua/luaconf.h index ddd6c8184e..29411d5af1 100644 --- a/engines/sword25/util/lua/luaconf.h +++ b/engines/sword25/util/lua/luaconf.h @@ -646,33 +646,6 @@ union luai_Cast { double l_d; long l_l; }; /* -@@ lua_tmpnam is the function that the OS library uses to create a -@* temporary name. -@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. -** CHANGE them if you have an alternative to tmpnam (which is considered -** insecure) or if you want the original tmpnam anyway. By default, Lua -** uses tmpnam except when POSIX is available, where it uses mkstemp. -*/ -#if defined(loslib_c) || defined(luaall_c) - -#if defined(LUA_USE_MKSTEMP) -#include <unistd.h> -#define LUA_TMPNAMBUFSIZE 32 -#define lua_tmpnam(b,e) { \ - strcpy(b, "/tmp/lua_XXXXXX"); \ - e = mkstemp(b); \ - if (e != -1) close(e); \ - e = (e == -1); } - -#else -#define LUA_TMPNAMBUFSIZE L_tmpnam -#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } -#endif - -#endif - - -/* @@ lua_popen spawns a new process connected to the current one through @* the file streams. ** CHANGE it if you have a way to implement it in your system. |