[Scummvm-cvs-logs] scummvm master -> cd54d761e10f5c8f24c5508ae22381ed71018abc

bluegr md5 at scummvm.org
Sat May 14 14:00:45 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
cd54d761e1 SWORD25 (LUA): Disabled a lot of non-portable LUA functions


Commit: cd54d761e10f5c8f24c5508ae22381ed71018abc
    https://github.com/scummvm/scummvm/commit/cd54d761e10f5c8f24c5508ae22381ed71018abc
Author: md5 (md5 at scummvm.org)
Date: 2011-05-14T04:58:29-07:00

Commit Message:
SWORD25 (LUA): Disabled a lot of non-portable LUA functions

sword25 doesn't use these (thankfully)

Changed paths:
    engines/sword25/util/lua/lauxlib.cpp
    engines/sword25/util/lua/liolib.cpp
    engines/sword25/util/lua/loslib.cpp
    engines/sword25/util/lua/luaconf.h



diff --git a/engines/sword25/util/lua/lauxlib.cpp b/engines/sword25/util/lua/lauxlib.cpp
index 53c0556..526b1c8 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 aa44dca..f9bad30 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 035925c..51266b5 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 ddd6c81..29411d5 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.






More information about the Scummvm-git-logs mailing list