summaryrefslogtreecommitdiff
path: root/lib/lua/src/lapi.c
diff options
context:
space:
mode:
authorpixel <pixel>2008-09-23 16:28:53 +0000
committerpixel <pixel>2008-09-23 16:28:53 +0000
commit23bfd2d061c11a136aee6c639dec88077fcf7864 (patch)
treed561444a40fa241d8beabc804d98a6a75543390c /lib/lua/src/lapi.c
parent88a8ad8c7d83cf009b9ca6756e5b4fb5c333435e (diff)
Upgrading to lua 5.1.4
Diffstat (limited to 'lib/lua/src/lapi.c')
-rw-r--r--lib/lua/src/lapi.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/lua/src/lapi.c b/lib/lua/src/lapi.c
index c2c898d..8614880 100644
--- a/lib/lua/src/lapi.c
+++ b/lib/lua/src/lapi.c
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 1.9 2008-07-02 16:35:51 pixel Exp $
+** $Id: lapi.c,v 1.10 2008-09-23 16:28:53 pixel Exp $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -93,15 +93,14 @@ void luaA_pushobject (lua_State *L, const TValue *o) {
LUA_API int lua_checkstack (lua_State *L, int size) {
- int res;
+ int res = 1;
lua_lock(L);
- if ((L->top - L->base + size) > LUAI_MAXCSTACK)
+ if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK)
res = 0; /* stack overflow */
- else {
+ else if (size > 0) {
luaD_checkstack(L, size);
if (L->ci->top < L->top + size)
L->ci->top = L->top + size;
- res = 1;
}
lua_unlock(L);
return res;
@@ -930,10 +929,13 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
g->GCthreshold = g->totalbytes - a;
else
g->GCthreshold = 0;
- while (g->GCthreshold <= g->totalbytes)
+ while (g->GCthreshold <= g->totalbytes) {
luaC_step(L);
- if (g->gcstate == GCSpause) /* end of cycle? */
- res = 1; /* signal it */
+ if (g->gcstate == GCSpause) { /* end of cycle? */
+ res = 1; /* signal it */
+ break;
+ }
+ }
break;
}
case LUA_GCSETPAUSE: {