From 2895a2321f686a69418313f14c1df116e4f1738e Mon Sep 17 00:00:00 2001 From: daurnimator Date: Fri, 5 May 2017 11:13:12 +1000 Subject: src/lauxlib.js: Use lua_pushfstring (fixes missing fields in tracebacks) --- src/lauxlib.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/lauxlib.js b/src/lauxlib.js index 8616736..c0f1ecf 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -74,19 +74,17 @@ const pushglobalfuncname = function(L, ar) { } }; -const sv = s => s ? s : []; - const pushfuncname = function(L, ar) { if (pushglobalfuncname(L, ar)) { /* try first a global name */ - lua.lua_pushstring(L, lua.to_luastring("function '", true).concat(lua.lua_tostring(L, -1)).concat(["'".charCodeAt(0)])); + lua.lua_pushfstring(L, lua.to_luastring("function '%s'"), lua.lua_tostring(L, -1)); lua.lua_remove(L, -2); /* remove name */ } else if (ar.namewhat) /* is there a name from code? */ - lua.lua_pushstring(L, sv(ar.namewhat).concat(" ".charCodeAt(0), "'".charCodeAt(0), ...sv(ar.name.value), "'".charCodeAt(0))); /* use it */ + lua.lua_pushfstring(L, lua.to_luastring("%s '%s'"), ar.namewhat, ar.name); /* use it */ else if (ar.what && ar.what[0] === 'm'.charCodeAt(0)) /* main? */ lua.lua_pushliteral(L, "main chunk"); else if (ar.what && ar.what[0] != 'C'.charCodeAt(0)) /* for Lua functions, use */ - lua.lua_pushstring(L, lua.to_luastring("function <", true).concat(...sv(ar.short_src), ':'.charCodeAt(0), ...lua.to_luastring(`${ar.linedefined}>`))); + lua.lua_pushfstring(L, lua.to_luastring("function <%s:%d>"), ar.short_src, ar.linedefined); else /* nothing left... */ lua.lua_pushliteral(L, "?"); }; -- cgit v1.2.3-54-g00ecf