summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-05 11:13:12 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-05 11:13:12 +1000
commit2895a2321f686a69418313f14c1df116e4f1738e (patch)
tree1f0c7640e8a4819a987f4540388c25bb020ad220 /src
parentb600ba0123b8af27d2d25e7655b311163afaec91 (diff)
downloadfengari-2895a2321f686a69418313f14c1df116e4f1738e.tar.gz
fengari-2895a2321f686a69418313f14c1df116e4f1738e.tar.bz2
fengari-2895a2321f686a69418313f14c1df116e4f1738e.zip
src/lauxlib.js: Use lua_pushfstring (fixes missing fields in tracebacks)
Diffstat (limited to 'src')
-rw-r--r--src/lauxlib.js8
1 files changed, 3 insertions, 5 deletions
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 <file:line> */
- 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, "?");
};