diff options
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 21 |
1 files changed, 5 insertions, 16 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.144 2004/05/31 18:50:30 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.145 2004/06/02 14:20:08 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 | */ |
@@ -180,22 +180,11 @@ static int luaB_gcinfo (lua_State *L) { | |||
180 | 180 | ||
181 | static int luaB_collectgarbage (lua_State *L) { | 181 | static int luaB_collectgarbage (lua_State *L) { |
182 | static const char *const opts[] = {"stop", "restart", "collect", "count", | 182 | static const char *const opts[] = {"stop", "restart", "collect", "count", |
183 | NULL}; | 183 | "step", NULL}; |
184 | static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, | 184 | static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, |
185 | LUA_GCCOLLECT, LUA_GCCOUNT}; | 185 | LUA_GCCOLLECT, LUA_GCCOUNT, LUA_GCSTEP}; |
186 | int o; | 186 | int o = luaL_findstring(luaL_optstring(L, 1, "collect"), opts); |
187 | int ex; | 187 | int ex = luaL_optint(L, 2, 0); |
188 | #if 1 | ||
189 | if (lua_isnumber(L, 1)) { | ||
190 | int v = lua_tointeger(L, 1); | ||
191 | lua_settop(L, 0); | ||
192 | if (v == 0) lua_pushstring(L, "collect"); | ||
193 | else if (v >= 10000) lua_pushstring(L, "stop"); | ||
194 | else lua_pushstring(L, "restart"); | ||
195 | } | ||
196 | #endif | ||
197 | o = luaL_findstring(luaL_optstring(L, 1, "collect"), opts); | ||
198 | ex = luaL_optint(L, 2, 0); | ||
199 | luaL_argcheck(L, o >= 0, 1, "invalid option"); | 188 | luaL_argcheck(L, o >= 0, 1, "invalid option"); |
200 | lua_pushinteger(L, lua_gc(L, optsnum[o], ex)); | 189 | lua_pushinteger(L, lua_gc(L, optsnum[o], ex)); |
201 | return 1; | 190 | return 1; |