Skip to content

Commit 00dddd8

Browse files
Merge pull request #305 from truemedian/luvi-resume
mark bundle files as "files", use luaL_traceback
2 parents 3eca540 + 3efe8db commit 00dddd8

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

src/lua/luvibundle.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ local function buildBundle(options, bundle)
194194
local compile = options.strip or options.compile
195195

196196
if compile and isLua and name:lower() ~= 'package.lua' then
197-
local fn, err = load(ctx, child)
197+
local fn, err = load(ctx, '@' .. child)
198198
if fn then
199199
ctx = string.dump(fn, options.strip)
200200
elseif not options.force then
@@ -333,7 +333,7 @@ local function commonBundle(bundlePaths, mainPath, args)
333333
if not path then path = name + ".lua" end
334334
package.preload[name] = function (...)
335335
local lua = assert(bundle.readfile(path))
336-
return assert(loadstring(lua, "bundle:" .. path))(...)
336+
return assert(loadstring(lua, "@bundle:" .. path))(...)
337337
end
338338
end
339339

@@ -360,7 +360,7 @@ local function commonBundle(bundlePaths, mainPath, args)
360360
else
361361
local main = bundle.readfile(mainPath)
362362
if not main then error("Missing " .. mainPath .. " in " .. bundle.base) end
363-
local fn = assert(loadstring(main, "bundle:" .. mainPath))
363+
local fn = assert(loadstring(main, "@bundle:" .. mainPath))
364364
return fn(unpack(args))
365365
end
366366
end

src/luvi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838

3939
#if (LUA_VERSION_NUM < 503)
4040
#include "compat-5.3.h"
41+
#ifndef WITH_PLAIN_LUA
42+
#undef luaL_traceback /* luajit has its own version */
43+
#endif
4144
#endif
4245

4346
#ifdef WITH_OPENSSL

src/main.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,7 @@ int luvi_custom(lua_State* L);
3232
static int luvi_traceback(lua_State *L) {
3333
if (!lua_isstring(L, 1)) /* 'message' not a string? */
3434
return 1; /* keep it intact */
35-
lua_pushglobaltable(L);
36-
lua_getfield(L, -1, "debug");
37-
lua_remove(L, -2);
38-
if (!lua_istable(L, -1)) {
39-
lua_pop(L, 1);
40-
return 1;
41-
}
42-
lua_getfield(L, -1, "traceback");
43-
if (!lua_isfunction(L, -1)) {
44-
lua_pop(L, 2);
45-
return 1;
46-
}
47-
lua_pushvalue(L, 1); /* pass error message */
48-
lua_pushinteger(L, 2); /* skip this function and traceback */
49-
lua_call(L, 2, 1); /* call debug.traceback */
35+
luaL_traceback(L, L, lua_tostring(L, -1), 1);
5036
return 1;
5137
}
5238

0 commit comments

Comments
 (0)