diff options
author | daurnimator <quae@daurnimator.com> | 2017-06-09 16:40:10 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-06-09 16:40:21 +1000 |
commit | 6de7c8c76cd90940278984f49198f281c6af274c (patch) | |
tree | 931ca064a59cb5f85d12fc993571eebfb5523190 /src/loadlib.js | |
parent | 2a95440f071782b829d0823103fd2d737dd42957 (diff) | |
download | fengari-6de7c8c76cd90940278984f49198f281c6af274c.tar.gz fengari-6de7c8c76cd90940278984f49198f281c6af274c.tar.bz2 fengari-6de7c8c76cd90940278984f49198f281c6af274c.zip |
src/loadlib.js: Use luaL_Buffer to build searchpath error message
Diffstat (limited to 'src/loadlib.js')
-rw-r--r-- | src/loadlib.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/loadlib.js b/src/loadlib.js index 81706e5..d376c7a 100644 --- a/src/loadlib.js +++ b/src/loadlib.js @@ -208,7 +208,8 @@ const pushnexttemplate = function(L, path) { }; const searchpath = function(L, name, path, sep, dirsep) { - let msg = []; /* to build error message */ + let msg = new lauxlib.luaL_Buffer(); /* to build error message */ + lauxlib.luaL_buffinit(L, msg); if (sep[0] !== 0) /* non-empty separator? */ name = lauxlib.luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ while ((path = pushnexttemplate(L, path)) !== null) { @@ -216,10 +217,11 @@ const searchpath = function(L, name, path, sep, dirsep) { lua.lua_remove(L, -2); /* remove path template */ if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ - lua.lua_remove(L, -1); /* remove file name */ - msg.push(...lua.to_luastring(`\n\tno file '${lua.to_jsstring(filename)}'`)); + lua.lua_pushfstring(L, lua.to_luastring("\n\tno file '%s'"), filename); + lua.lua_remove(L, -2); /* remove file name */ + lauxlib.luaL_addvalue(msg); } - lua.lua_pushstring(L, msg); /* create error message */ + lauxlib.luaL_pushresult(msg); /* create error message */ return null; /* not found */ }; |