From 35b85950a7e144da1c1390e6cd5dcae5adea61bc Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Tue, 24 May 2016 13:13:42 +0000 Subject: MirLua: fix Every function in m_schedule git-svn-id: http://svn.miranda-ng.org/main/trunk@16868 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/m_schedule.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/plugins/MirLua/src/m_schedule.cpp b/plugins/MirLua/src/m_schedule.cpp index 3ee8b70663..c501de84a9 100644 --- a/plugins/MirLua/src/m_schedule.cpp +++ b/plugins/MirLua/src/m_schedule.cpp @@ -525,16 +525,6 @@ static int fluent_Sunday(lua_State *L) return 1; } -static const luaL_Reg scheduleEvery2Api[] = -{ - { "Seconds", fluent_Seconds }, - { "Minutes", fluent_Minutes }, - { "Hours", fluent_Hours }, - { "Days", fluent_Days }, - - { NULL, NULL } -}; - static const luaL_Reg scheduleEvery1Api[] = { { "Second", fluent_Second }, @@ -553,6 +543,16 @@ static const luaL_Reg scheduleEvery1Api[] = { NULL, NULL } }; +static const luaL_Reg scheduleEvery2Api[] = +{ + { "Seconds", fluent_Seconds }, + { "Minutes", fluent_Minutes }, + { "Hours", fluent_Hours }, + { "Days", fluent_Days }, + + { NULL, NULL } +}; + /***********************************************/ static int schedule_At(lua_State *L) @@ -579,6 +579,10 @@ static int schedule_Every(lua_State *L) { int interval = luaL_optinteger(L, 1, 0); + const luaL_Reg *funcs = lua_isnone(L, 1) + ? scheduleEvery1Api + : scheduleEvery2Api; + lua_newtable(L); lua_pushinteger(L, interval); lua_setfield(L, -2, "Interval"); @@ -587,9 +591,6 @@ static int schedule_Every(lua_State *L) lua_pushvalue(L, -1); lua_setfield(L, -2, "__index"); lua_pushvalue(L, -2); - const luaL_Reg *funcs = lua_isnoneornil(L, 1) - ? scheduleEvery1Api - : scheduleEvery2Api; luaL_setfuncs(L, funcs, 1); lua_setmetatable(L, -2); -- cgit v1.2.3