moonbridge

changeset 65:8090fe97518a

Second table to io.poll(...) is optional
author jbe
date Sat Apr 04 03:22:06 2015 +0200 (2015-04-04)
parents 5df424e74383
children 3d1f23f1dbc6
files moonbridge.c
line diff
     1.1 --- a/moonbridge.c	Sat Apr 04 01:38:25 2015 +0200
     1.2 +++ b/moonbridge.c	Sat Apr 04 03:22:06 2015 +0200
     1.3 @@ -2295,23 +2295,25 @@
     1.4    } else {
     1.5      idx_tbl = 2;
     1.6    }
     1.7 -  luaL_checktype(L, idx_tbl, LUA_TTABLE);
     1.8 -  for (i=1; ; i++) {
     1.9 +  if (!lua_isnoneornil(L, idx_tbl)) {
    1.10 +    luaL_checktype(L, idx_tbl, LUA_TTABLE);
    1.11 +    for (i=1; ; i++) {
    1.12  #if LUA_VERSION_NUM >= 503
    1.13 -    if (lua_geti(L, idx_tbl, i) == LUA_TNIL) break;
    1.14 +      if (lua_geti(L, idx_tbl, i) == LUA_TNIL) break;
    1.15  #else
    1.16 -    lua_pushinteger(L, i);
    1.17 -    lua_gettable(L, idx_tbl);
    1.18 -    if (lua_isnil(L, -1)) break;
    1.19 +      lua_pushinteger(L, i);
    1.20 +      lua_gettable(L, idx_tbl);
    1.21 +      if (lua_isnil(L, -1)) break;
    1.22  #endif
    1.23 -    fd = lua_tointegerx(L, -1, &isnum);
    1.24 -    if (!isnum) luaL_error(L, "File descriptor is not an integer");
    1.25 -    FD_SET(fd, &writefds);
    1.26 -    if (fd+1 > nfds) nfds = fd+1;
    1.27 -    lua_pop(L, 1);
    1.28 +      fd = lua_tointegerx(L, -1, &isnum);
    1.29 +      if (!isnum) luaL_error(L, "File descriptor is not an integer");
    1.30 +      FD_SET(fd, &writefds);
    1.31 +      if (fd+1 > nfds) nfds = fd+1;
    1.32 +      lua_pop(L, 1);
    1.33 +    }
    1.34 +    lua_pop(L, 2);
    1.35 +    if (!idx_timeout && !lua_isnoneornil(L, 3)) idx_timeout = 3;
    1.36    }
    1.37 -  lua_pop(L, 2);
    1.38 -  if (!idx_timeout && !lua_isnoneornil(L, 3)) idx_timeout = 3;
    1.39    if (idx_timeout) {
    1.40      luaL_argcheck(
    1.41        L,

Impressum / About Us