diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-03-29 14:39:57 +0200 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-03-30 09:57:53 +0200 |
commit | 456ab7b69f88859683c60cc2261e70d6dbadd8e8 (patch) | |
tree | 12baf4ae489e7afd4819ec94bc413c1c2a1db05d /src/lauxlib.js | |
parent | 2e5b595a2e04fe72555a565af4aae43560946473 (diff) | |
download | fengari-456ab7b69f88859683c60cc2261e70d6dbadd8e8.tar.gz fengari-456ab7b69f88859683c60cc2261e70d6dbadd8e8.tar.bz2 fengari-456ab7b69f88859683c60cc2261e70d6dbadd8e8.zip |
8-bit string internally tests
Lexing/Parsing is done on byte rather than js strings
Diffstat (limited to 'src/lauxlib.js')
-rw-r--r-- | src/lauxlib.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js index f60bd8c..9813095 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -55,7 +55,7 @@ const findfield = function(L, objidx, level) { const pushglobalfuncname = function(L, ar) { let top = lapi.lua_gettop(L); ldebug.lua_getinfo(L, 'f', ar); /* push function */ - lapi.lua_getfield(L, lua.LUA_REGISTRYINDEX, LUA_LOADED_TABLE); + lapi.lua_getfield(L, lua.LUA_REGISTRYINDEX, lua.to_luastring(LUA_LOADED_TABLE)); if (findfield(L, top + 1, 2)) { let name = lapi.lua_tostring(L, -1); if (name.jsstring().startsWith("_G.")) { @@ -333,7 +333,7 @@ const luaL_tolstring = function(L, idx) { ** Leaves resulting module on the top. */ const luaL_requiref = function(L, modname, openf, glb) { - luaL_getsubtable(L, lua.LUA_REGISTRYINDEX, LUA_LOADED_TABLE); + luaL_getsubtable(L, lua.LUA_REGISTRYINDEX, lua.to_luastring(LUA_LOADED_TABLE)); lapi.lua_getfield(L, -1, modname); /* LOADED[modname] */ if (!lapi.lua_toboolean(L, -1)) { /* package not already loaded? */ lapi.lua_pop(L, 1); /* remove field */ @@ -441,7 +441,7 @@ if (typeof require === "function") { lf.pos += bytes; } if (bytes > 0) - return lf.binary ? toDataView(lf.buff) : lf.buff; + return lf.binary ? toDataView(lf.buff) : lf.buff.slice(0, bytes); else return null; }; @@ -502,15 +502,16 @@ if (typeof require === "function") { }; const luaL_loadfilex = function(L, filename, mode) { + let jsfilename = lobject.jsstring(filename); let lf = new LoadF(); let fnameindex = lapi.lua_gettop(L) + 1; /* index of filename on the stack */ if (filename === null) { lapi.lua_pushliteral(L, "=stdin"); lf.f = process.stdin.fd; } else { - lapi.lua_pushliteral(L, `@${filename}`); + lapi.lua_pushliteral(L, `@${jsfilename}`); try { - lf.f = fs.openSync(filename, "r"); + lf.f = fs.openSync(jsfilename, "r"); } catch (e) { return errfile(L, lua.to_luastring("open"), fnameindex, e); } |