diff options
Diffstat (limited to 'src/lauxlib.js')
-rw-r--r-- | src/lauxlib.js | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js index 0491de5..9c4b98d 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -10,9 +10,9 @@ const LUA_FILEHANDLE = lua.to_luastring("FILE*", true); class luaL_Buffer { - constructor(L) { - this.L = L; - this.b = ""; + constructor() { + this.b = null; + this.L = null; } } @@ -211,21 +211,27 @@ const luaL_fileresult = function(L, stat, fname, e) { }; /* Unlike normal lua, we pass in an error object */ -const luaL_execresult = function(L, stat, e) { - let what = lua.to_luastring("exit"); /* type of termination */ - if (e && e.status === -1) /* error? */ - return luaL_fileresult(L, 0, null, e); - else { - if (e && e.signal) { - lua.lua_pushnil(L); - lua.lua_pushliteral(L, "signal"); - } else { - lua.lua_pushboolean(L, 1); - lua.lua_pushliteral(L, "exit"); - } - lua.lua_pushinteger(L, e ? e.status : 0); +const luaL_execresult = function(L, e) { + let what, stat; + if (e === null) { + lua.lua_pushboolean(L, 1); + lua.lua_pushliteral(L, "exit"); + lua.lua_pushinteger(L, 0); return 3; + } else if (e.status) { + what = "exit"; + stat = e.status; + } else if (e.signal) { + what = "signal"; + stat = e.signal; + } else { + /* XXX: node seems to have e.errno as a string instead of a number */ + return luaL_fileresult(L, 0, null, e); } + lua.lua_pushnil(L); + lua.lua_pushliteral(L, what); + lua.lua_pushinteger(L, stat); + return 3; }; const luaL_getmetatable = function(L, n) { |