moonbridge
changeset 3:3b3f0ecc4ac4
Lua 5.3 (rc4) compatibility; Code cleanup for Lua 5.3
author | jbe |
---|---|
date | Thu Jan 08 20:55:56 2015 +0100 (2015-01-08) |
parents | 6016547c6410 |
children | 583e2ad140dc |
files | moonbridge.c |
line diff
1.1 --- a/moonbridge.c Thu Jan 08 20:07:17 2015 +0100 1.2 +++ b/moonbridge.c Thu Jan 08 20:55:56 2015 +0100 1.3 @@ -986,7 +986,11 @@ 1.4 /* Lua function to close both input and output stream from/to peer */ 1.5 static int moonbr_child_lua_close_both_streams(lua_State *L) { 1.6 int timeout = 0; 1.7 - if (!lua_isnoneornil(L, 2)) timeout = luaL_checkint(L, 2); 1.8 + if (!lua_isnoneornil(L, 2)) { 1.9 + lua_Integer n = luaL_checkinteger(L, 2); 1.10 + luaL_argcheck(L, n >= 0 && n <= INT_MAX, 2, "out of range"); 1.11 + timeout = n; 1.12 + } 1.13 if (moonbr_child_peersocket_fd == -1) { 1.14 luaL_error(L, "Connection with peer has already been explicitly closed"); 1.15 } 1.16 @@ -2333,8 +2337,12 @@ 1.17 for (i=0; i<pool->listener_count; i++) { 1.18 struct moonbr_listener *listener = &pool->listener[i]; 1.19 lua_settop(L, 2); 1.20 +#if LUA_VERSION_NUM >= 503 1.21 + lua_geti(L, 2, i+1); 1.22 +#else 1.23 lua_pushinteger(L, i+1); 1.24 lua_gettable(L, 2); 1.25 +#endif 1.26 lua_getfield(L, 3, "proto"); 1.27 proto = lua_tostring(L, -1); 1.28 if (proto && !strcmp(proto, "interval")) {