From: Petr Špaček Date: Thu, 11 Apr 2019 13:13:21 +0000 (+0200) Subject: table_print: simplify vararg handling X-Git-Tag: v4.0.0~9^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4dfbec6cfa2dfaaccc3e2f7219fb49c6db0cb691;p=thirdparty%2Fknot-resolver.git table_print: simplify vararg handling --- diff --git a/daemon/lua/sandbox.lua.in b/daemon/lua/sandbox.lua.in index 7ba776cd2..b09c87f87 100644 --- a/daemon/lua/sandbox.lua.in +++ b/daemon/lua/sandbox.lua.in @@ -389,20 +389,15 @@ local function funcsign(f) local debuginfo = debug.getinfo(2) if debuginfo.what == 'C' then -- names N/A table.insert(func_args, '?') - end - if debug.getlocal(2, -1) then - -- vararg function + elseif debuginfo.isvararg then table.insert(func_args, "...") end debug.sethook(oldhook) error('aborting the call to introspected function') end end - oldhook = debug.sethook(hook, "c") -- invoke hook() on function call - -- fake arguments, necessary to detect vararg functions - local fakearg = {} - for _ = 1, 64 do fakearg[#fakearg + 1] = true end - f(unpack(fakearg)) -- huh? + oldhook = debug.sethook(hook, "c") -- invoke hook() on function call + f(unpack({})) -- huh? end) return "(" .. table.concat(func_args, ", ") .. ")" end