[syslinux:master] lua: the COM32 API supports only part of iolib

syslinux-bot for Ferenc Wágner wferi at niif.hu
Sun Mar 2 13:48:14 PST 2014


Commit-ID:  205a7c2944860ae8f62639f065bf63823cb3bc20
Gitweb:     http://www.syslinux.org/commit/205a7c2944860ae8f62639f065bf63823cb3bc20
Author:     Ferenc Wágner <wferi at niif.hu>
AuthorDate: Fri, 11 Oct 2013 12:40:21 +0200
Committer:  Ferenc Wágner <wferi at niif.hu>
CommitDate: Sat, 1 Mar 2014 17:40:34 +0100

lua: the COM32 API supports only part of iolib


---
 com32/lua/src/liolib.c | 20 ++++++++++++++++++++
 com32/lua/src/lua.h    |  5 +++++
 2 files changed, 25 insertions(+)

diff --git a/com32/lua/src/liolib.c b/com32/lua/src/liolib.c
index 3f80db1..6ff327b 100644
--- a/com32/lua/src/liolib.c
+++ b/com32/lua/src/liolib.c
@@ -252,11 +252,13 @@ static int io_popen (lua_State *L) {
 }
 
 
+#ifndef SYSLINUX
 static int io_tmpfile (lua_State *L) {
   LStream *p = newfile(L);
   p->f = tmpfile();
   return (p->f == NULL) ? luaL_fileresult(L, 0, NULL) : 1;
 }
+#endif
 
 
 static FILE *getiofile (lua_State *L, const char *findex) {
@@ -346,6 +348,7 @@ static int io_lines (lua_State *L) {
 */
 
 
+#ifndef SYSLINUX
 static int read_number (lua_State *L, FILE *f) {
   lua_Number d;
   if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) {
@@ -365,6 +368,13 @@ static int test_eof (lua_State *L, FILE *f) {
   lua_pushlstring(L, NULL, 0);
   return (c != EOF);
 }
+#else
+static int test_eof (lua_State *L, FILE *f) {
+  (void)f;
+  lua_pushlstring(L, NULL, 0);
+  return 1;
+}
+#endif
 
 
 static int read_line (lua_State *L, FILE *f, int chop) {
@@ -442,7 +452,11 @@ static int g_read (lua_State *L, FILE *f, int first) {
         luaL_argcheck(L, p && p[0] == '*', n, "invalid option");
         switch (p[1]) {
           case 'n':  /* number */
+#ifndef SYSLINUX
             success = read_number(L, f);
+#else
+            return luaL_argerror(L, n, "\"*number\" not supported");
+#endif
             break;
           case 'l':  /* line */
             success = read_line(L, f, 1);
@@ -542,6 +556,7 @@ static int f_write (lua_State *L) {
 }
 
 
+#ifndef SYSLINUX
 static int f_seek (lua_State *L) {
   static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
   static const char *const modenames[] = {"set", "cur", "end", NULL};
@@ -570,6 +585,7 @@ static int f_setvbuf (lua_State *L) {
   int res = setvbuf(f, NULL, mode[op], sz);
   return luaL_fileresult(L, res == 0, NULL);
 }
+#endif
 
 
 
@@ -595,7 +611,9 @@ static const luaL_Reg iolib[] = {
   {"output", io_output},
   {"popen", io_popen},
   {"read", io_read},
+#ifndef SYSLINUX
   {"tmpfile", io_tmpfile},
+#endif
   {"type", io_type},
   {"write", io_write},
   {NULL, NULL}
@@ -610,8 +628,10 @@ static const luaL_Reg flib[] = {
   {"flush", f_flush},
   {"lines", f_lines},
   {"read", f_read},
+#ifndef SYSLINUX
   {"seek", f_seek},
   {"setvbuf", f_setvbuf},
+#endif
   {"write", f_write},
   {"__gc", f_gc},
   {"__tostring", f_tostring},
diff --git a/com32/lua/src/lua.h b/com32/lua/src/lua.h
index eb0482b..1742aa9 100644
--- a/com32/lua/src/lua.h
+++ b/com32/lua/src/lua.h
@@ -15,6 +15,11 @@
 
 #include "luaconf.h"
 
+#ifdef SYSLINUX
+#define clearerr(x) (void)0
+#define feof(x) 0
+#define ferror(x) 0
+#endif
 
 #define LUA_VERSION_MAJOR	"5"
 #define LUA_VERSION_MINOR	"2"


More information about the Syslinux-commits mailing list