fixed vararg usage for lua 5.1/5.2. Fixes #1

This commit is contained in:
Thijs Schreijer
2013-09-14 22:16:37 +02:00
parent be92620a79
commit 53b97cc350

View File

@@ -32,6 +32,7 @@
local math = math
local os = os
local unpack = unpack or table.unpack
local pack = table.pack or function(...) return { n = select('#', ...), ... } end
local setmetatable = setmetatable
local getmetatable = getmetatable
--[[ EXTRA FUNCTIONS ]]--
@@ -403,6 +404,7 @@
end
--#end -- not DATE_OBJECT_AFX
local function date_from(...)
local arg = pack(...)
local y, m, d = fix(arg[1]), getmontharg(arg[2]), fix(arg[3])
local h, r, s, t = tonumber(arg[4] or 0), tonumber(arg[5] or 0), tonumber(arg[6] or 0), tonumber(arg[7] or 0)
if y and m and d and h and r and s and t then
@@ -700,9 +702,9 @@
end
function date:__call(...)
local n = arg.n
if n > 1 then return (date_from(unpack(arg)))
elseif n == 0 then return (date_getdobj(false))
local arg = pack(...)
if arg.n > 1 then return (date_from(...))
elseif arg.n == 0 then return (date_getdobj(false))
else local o, r = date_getdobj(arg[1]); return r and o:copy() or o end
end