# HG changeset patch # User jbe # Date 1420746956 -3600 # Node ID 3b3f0ecc4ac42c8fc99f2314d43e9abc1152bb5d # Parent 6016547c6410fe0a2d814d5d571c4944faee7819 Lua 5.3 (rc4) compatibility; Code cleanup for Lua 5.3 diff -r 6016547c6410 -r 3b3f0ecc4ac4 moonbridge.c --- a/moonbridge.c Thu Jan 08 20:07:17 2015 +0100 +++ b/moonbridge.c Thu Jan 08 20:55:56 2015 +0100 @@ -986,7 +986,11 @@ /* Lua function to close both input and output stream from/to peer */ static int moonbr_child_lua_close_both_streams(lua_State *L) { int timeout = 0; - if (!lua_isnoneornil(L, 2)) timeout = luaL_checkint(L, 2); + if (!lua_isnoneornil(L, 2)) { + lua_Integer n = luaL_checkinteger(L, 2); + luaL_argcheck(L, n >= 0 && n <= INT_MAX, 2, "out of range"); + timeout = n; + } if (moonbr_child_peersocket_fd == -1) { luaL_error(L, "Connection with peer has already been explicitly closed"); } @@ -2333,8 +2337,12 @@ for (i=0; ilistener_count; i++) { struct moonbr_listener *listener = &pool->listener[i]; lua_settop(L, 2); +#if LUA_VERSION_NUM >= 503 + lua_geti(L, 2, i+1); +#else lua_pushinteger(L, i+1); lua_gettable(L, 2); +#endif lua_getfield(L, 3, "proto"); proto = lua_tostring(L, -1); if (proto && !strcmp(proto, "interval")) {