diff --git a/src/lua/trigger.cc b/src/lua/trigger.cc index 8cae6a8a7f2846c78263af1fdd2c17bf8a31793e..7968b7963c3b73dc9e97891b24d418bcdcb2e1fe 100644 --- a/src/lua/trigger.cc +++ b/src/lua/trigger.cc @@ -58,17 +58,18 @@ lbox_trigger_find(struct lua_State *L, int index, return NULL; } -void -lbox_trigger_table(struct lua_State *L, struct rlist *list) +int +lbox_list_all_triggers(struct lua_State *L, struct rlist *list) { struct trigger *trigger; - uint32_t count = 1; + int count = 1; lua_newtable(L); rlist_foreach_entry_reverse(trigger, list, link) { lua_rawgeti(L, LUA_REGISTRYINDEX, (intptr_t) trigger->data); lua_rawseti(L, -2, count); count++; } + return 1; } void @@ -78,7 +79,8 @@ lbox_trigger_check_input(struct lua_State *L, int top) /* Push optional arguments. */ while (lua_gettop(L) < top) lua_pushnil(L); - /* (nil, function) is OK, + /* + * (nil, function) is OK, * (function, nil), is OK, * (function, function) is OK, * no arguments is OK, @@ -97,12 +99,14 @@ int lbox_trigger_reset(struct lua_State *L, int top, struct rlist *list, trigger_f run) { + /** + * If the stack is empty, pushes nils for optional + * arguments + */ lbox_trigger_check_input(L, top); - // if no args - return triggers table - if(lua_isnil(L, top) && lua_isnil(L, top - 1)){ - lbox_trigger_table(L, list); - return 1; - } + /* If no args - return triggers table */ + if (lua_isnil(L, top) && lua_isnil(L, top - 1) + return lbox_list_all_triggers(L, list); struct trigger *trg = lbox_trigger_find(L, top, list, run); diff --git a/test-run b/test-run index c762d879d5661ffc8711cdea2d37448a3ffa59ad..fce3f1494a655dd8b66a498bd9bce155cee6cefe 160000 --- a/test-run +++ b/test-run @@ -1 +1 @@ -Subproject commit c762d879d5661ffc8711cdea2d37448a3ffa59ad +Subproject commit fce3f1494a655dd8b66a498bd9bce155cee6cefe