# HG changeset patch # User jbe # Date 1428110526 -7200 # Node ID 8090fe97518ad9702ad98298244df803a2d9047c # Parent 5df424e743835542568c58dc06a20cfcab374cd5 Second table to io.poll(...) is optional diff -r 5df424e74383 -r 8090fe97518a moonbridge.c --- a/moonbridge.c Sat Apr 04 01:38:25 2015 +0200 +++ b/moonbridge.c Sat Apr 04 03:22:06 2015 +0200 @@ -2295,23 +2295,25 @@ } else { idx_tbl = 2; } - luaL_checktype(L, idx_tbl, LUA_TTABLE); - for (i=1; ; i++) { + if (!lua_isnoneornil(L, idx_tbl)) { + luaL_checktype(L, idx_tbl, LUA_TTABLE); + for (i=1; ; i++) { #if LUA_VERSION_NUM >= 503 - if (lua_geti(L, idx_tbl, i) == LUA_TNIL) break; + if (lua_geti(L, idx_tbl, i) == LUA_TNIL) break; #else - lua_pushinteger(L, i); - lua_gettable(L, idx_tbl); - if (lua_isnil(L, -1)) break; + lua_pushinteger(L, i); + lua_gettable(L, idx_tbl); + if (lua_isnil(L, -1)) break; #endif - fd = lua_tointegerx(L, -1, &isnum); - if (!isnum) luaL_error(L, "File descriptor is not an integer"); - FD_SET(fd, &writefds); - if (fd+1 > nfds) nfds = fd+1; - lua_pop(L, 1); + fd = lua_tointegerx(L, -1, &isnum); + if (!isnum) luaL_error(L, "File descriptor is not an integer"); + FD_SET(fd, &writefds); + if (fd+1 > nfds) nfds = fd+1; + lua_pop(L, 1); + } + lua_pop(L, 2); + if (!idx_timeout && !lua_isnoneornil(L, 3)) idx_timeout = 3; } - lua_pop(L, 2); - if (!idx_timeout && !lua_isnoneornil(L, 3)) idx_timeout = 3; if (idx_timeout) { luaL_argcheck( L,