summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lauxlib.js17
-rw-r--r--src/ldblib.js2
2 files changed, 13 insertions, 6 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js
index 3808c7e..24d2203 100644
--- a/src/lauxlib.js
+++ b/src/lauxlib.js
@@ -853,11 +853,18 @@ const luaL_dofile = function(L, filename) {
return (luaL_loadfile(L, filename) || lua.lua_pcall(L, 0, lua.LUA_MULTRET, 0));
};
-const lua_writestringerror = function(s) {
- if (WEB) {
- process.stderr.write(s);
- } else {
- console.error(s);
+const lua_writestringerror = function() {
+ for (let i=0; i<arguments.length; i++) {
+ let a = arguments[i];
+ if (WEB) {
+ if (typeof a !== "string")
+ a = lua.to_jsstring(a);
+ console.error(a);
+ } else {
+ if (typeof a !== "string")
+ a = Uint8Array.from(a);
+ process.stderr.write(a);
+ }
}
};
diff --git a/src/ldblib.js b/src/ldblib.js
index 441dec0..2faa9f0 100644
--- a/src/ldblib.js
+++ b/src/ldblib.js
@@ -416,7 +416,7 @@ if (!WEB) {
let buffer = lua.to_luastring(input);
if (lauxlib.luaL_loadbuffer(L, buffer, buffer.length, lua.to_luastring("=(debug command)", true))
|| lua.lua_pcall(L, 0, 0, 0)) {
- lauxlib.lua_writestringerror(`${lua.lua_tojsstring(L, -1)}\n`);
+ lauxlib.lua_writestringerror(lua.lua_toluastring(L, -1), "\n");
}
lua.lua_settop(L, 0); /* remove eventual returns */
}