From 42820bafe8433cbba4158ea7a2e11f40e9d2c635 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 4 May 2017 16:20:15 +1000 Subject: src/lauxlib.js: Use lua_pushvfstring --- src/lauxlib.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/lauxlib.js b/src/lauxlib.js index ff8a500..d9846c8 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -183,18 +183,10 @@ const luaL_where = function(L, level) { lua.lua_pushstring(L, []); }; -const luaL_error = function(L, fmt, ...args) { - let i = 0; - - fmt = lua.to_jsstring(fmt); - // TODO: bypassing lua_pushvstring for now - fmt = fmt.replace(/(^%[sfIpdcU]|([^%])%[sfIpdcU])/g, function (m, p1, p2, off) { - return p2 ? p2 + args[i++] : args[i++]; - }); - fmt = lua.to_luastring(fmt); - - lua.lua_pushstring(L, fmt); - +const luaL_error = function(L, fmt, ...argp) { + luaL_where(L, 1); + lua.lua_pushvfstring(L, fmt, argp); + lua.lua_concat(L, 2); return lua.lua_error(L); }; -- cgit v1.2.3-70-g09d2