diff options
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.220 2009/10/23 12:50:25 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.221 2009/10/23 19:12:19 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -177,20 +177,21 @@ static int luaB_gcinfo (lua_State *L) { | |||
177 | 177 | ||
178 | static int luaB_collectgarbage (lua_State *L) { | 178 | static int luaB_collectgarbage (lua_State *L) { |
179 | static const char *const opts[] = {"stop", "restart", "collect", | 179 | static const char *const opts[] = {"stop", "restart", "collect", |
180 | "count", "step", "setpause", "setstepmul", NULL}; | 180 | "count", "step", "setpause", "setstepmul", "isrunning", NULL}; |
181 | static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, | 181 | static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, |
182 | LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; | 182 | LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, |
183 | int o = luaL_checkoption(L, 1, "collect", opts); | 183 | LUA_GCISRUNNING}; |
184 | int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; | ||
184 | int ex = luaL_optint(L, 2, 0); | 185 | int ex = luaL_optint(L, 2, 0); |
185 | int res = lua_gc(L, optsnum[o], ex); | 186 | int res = lua_gc(L, o, ex); |
186 | switch (optsnum[o]) { | 187 | switch (o) { |
187 | case LUA_GCCOUNT: { | 188 | case LUA_GCCOUNT: { |
188 | int b = lua_gc(L, LUA_GCCOUNTB, 0); | 189 | int b = lua_gc(L, LUA_GCCOUNTB, 0); |
189 | lua_pushnumber(L, res + ((lua_Number)b/1024)); | 190 | lua_pushnumber(L, res + ((lua_Number)b/1024)); |
190 | lua_pushinteger(L, b); | 191 | lua_pushinteger(L, b); |
191 | return 2; | 192 | return 2; |
192 | } | 193 | } |
193 | case LUA_GCSTEP: { | 194 | case LUA_GCSTEP: case LUA_GCISRUNNING: { |
194 | lua_pushboolean(L, res); | 195 | lua_pushboolean(L, res); |
195 | return 1; | 196 | return 1; |
196 | } | 197 | } |