summaryrefslogtreecommitdiff
path: root/src/loadlib.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-01-07 02:52:40 +1100
committerdaurnimator <quae@daurnimator.com>2018-01-07 03:34:56 +1100
commite46d3e7d8d7226d49aad05f5a9c639c77d53bb04 (patch)
treefe3e99cbfce31d7d3495c0f861cbdc0aad67167a /src/loadlib.js
parent6ffe07fc5d16ee9acdcd6651d433ce13b193cd15 (diff)
downloadfengari-e46d3e7d8d7226d49aad05f5a9c639c77d53bb04.tar.gz
fengari-e46d3e7d8d7226d49aad05f5a9c639c77d53bb04.tar.bz2
fengari-e46d3e7d8d7226d49aad05f5a9c639c77d53bb04.zip
Introduce luastring_indexOf as Uint8Array.indexOf doesn't exist everywhere
Diffstat (limited to 'src/loadlib.js')
-rw-r--r--src/loadlib.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/loadlib.js b/src/loadlib.js
index 0be1742..c859798 100644
--- a/src/loadlib.js
+++ b/src/loadlib.js
@@ -265,7 +265,7 @@ const addtoclib = function(L, path, plib) {
const pushnexttemplate = function(L, path) {
while (path[0] === lua.LUA_PATH_SEP.charCodeAt(0)) path = path.slice(1); /* skip separators */
if (path.length === 0) return null; /* no more templates */
- let l = path.indexOf(lua.LUA_PATH_SEP.charCodeAt(0)); /* find next separator */
+ let l = lua.luastring_indexOf(path, lua.LUA_PATH_SEP.charCodeAt(0)); /* find next separator */
if (l < 0) l = path.length;
lua.lua_pushlstring(L, path, l); /* template */
return path.slice(l);
@@ -340,7 +340,7 @@ const searcher_Lua = function(L) {
const loadfunc = function(L, filename, modname) {
let openfunc;
modname = lauxlib.luaL_gsub(L, modname, lua.to_luastring("."), LUA_OFSEP);
- let mark = modname.indexOf(LUA_IGMARK.charCodeAt(0));
+ let mark = lua.luastring_indexOf(modname, LUA_IGMARK.charCodeAt(0));
if (mark >= 0) {
openfunc = lua.lua_pushlstring(L, modname, mark);
openfunc = lua.lua_pushfstring(L, lua.to_luastring("%s%s"), LUA_POF, openfunc);
@@ -361,7 +361,7 @@ const searcher_C = function(L) {
const searcher_Croot = function(L) {
let name = lauxlib.luaL_checkstring(L, 1);
- let p = name.indexOf('.'.charCodeAt(0));
+ let p = lua.luastring_indexOf(name, '.'.charCodeAt(0));
let stat;
if (p < 0) return 0; /* is root */
lua.lua_pushlstring(L, name, p);