diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-05 15:10:52 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-05 15:10:52 -0200 |
commit | 56e50e8bc546884957fbe1d82ff78d27f1eef93c (patch) | |
tree | cfdadb1464784237dee37b6294aeabbab3088f96 /lbaselib.c | |
parent | 90569630d6755190c5f499c51e1d0e6ef41c6cd8 (diff) | |
download | lua-56e50e8bc546884957fbe1d82ff78d27f1eef93c.tar.gz lua-56e50e8bc546884957fbe1d82ff78d27f1eef93c.tar.bz2 lua-56e50e8bc546884957fbe1d82ff78d27f1eef93c.zip |
'collectgarbage' returns old mode when changing mode
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.317 2017/06/27 18:32:49 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.318 2017/11/16 13:19:06 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 | */ |
@@ -170,6 +170,12 @@ static int luaB_rawset (lua_State *L) { | |||
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | static int pushmode (lua_State *L, int oldmode) { | ||
174 | lua_pushstring(L, (oldmode == LUA_GCINC) ? "incremental" : "generational"); | ||
175 | return 1; | ||
176 | } | ||
177 | |||
178 | |||
173 | static int luaB_collectgarbage (lua_State *L) { | 179 | static int luaB_collectgarbage (lua_State *L) { |
174 | static const char *const opts[] = {"stop", "restart", "collect", | 180 | static const char *const opts[] = {"stop", "restart", "collect", |
175 | "count", "step", "setpause", "setstepmul", | 181 | "count", "step", "setpause", "setstepmul", |
@@ -206,15 +212,13 @@ static int luaB_collectgarbage (lua_State *L) { | |||
206 | case LUA_GCGEN: { | 212 | case LUA_GCGEN: { |
207 | int minormul = (int)luaL_optinteger(L, 2, 0); | 213 | int minormul = (int)luaL_optinteger(L, 2, 0); |
208 | int majormul = (int)luaL_optinteger(L, 3, 0); | 214 | int majormul = (int)luaL_optinteger(L, 3, 0); |
209 | lua_gc(L, o, minormul, majormul); | 215 | return pushmode(L, lua_gc(L, o, minormul, majormul)); |
210 | return 0; | ||
211 | } | 216 | } |
212 | case LUA_GCINC: { | 217 | case LUA_GCINC: { |
213 | int pause = (int)luaL_optinteger(L, 2, 0); | 218 | int pause = (int)luaL_optinteger(L, 2, 0); |
214 | int stepmul = (int)luaL_optinteger(L, 3, 0); | 219 | int stepmul = (int)luaL_optinteger(L, 3, 0); |
215 | int stepsize = (int)luaL_optinteger(L, 4, 0); | 220 | int stepsize = (int)luaL_optinteger(L, 4, 0); |
216 | lua_gc(L, o, pause, stepmul, stepsize); | 221 | return pushmode(L, lua_gc(L, o, pause, stepmul, stepsize)); |
217 | return 0; | ||
218 | } | 222 | } |
219 | default: { | 223 | default: { |
220 | int res = lua_gc(L, o); | 224 | int res = lua_gc(L, o); |