mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-21 01:08:25 +00:00
SWORD25 (LUA): Disabled a lot of non-portable LUA functions
sword25 doesn't use these (thankfully)
This commit is contained in:
parent
8db0bb9274
commit
cd54d761e1
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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? */
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -645,33 +645,6 @@ union luai_Cast { double l_d; long l_l; };
|
||||
#define LUA_MAXCAPTURES 32
|
||||
|
||||
|
||||
/*
|
||||
@@ 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.
|
||||
|
Loading…
Reference in New Issue
Block a user