From: John L. <jr...@us...> - 2008-01-18 03:43:06
|
Update of /cvsroot/wxlua/wxLua/modules/lua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv27192/wxLua/modules/lua/src Modified Files: Makefile lapi.c lauxlib.c lbaselib.c ldo.c liolib.c lparser.c lstate.c lstate.h lua.c lua.h luaconf.h Log Message: Update the Lua source to 5.1.3-rc1 Use <set var="VARS_DONT_ELIMINATE" append="1">THREADING</set> so it doesn't get stripped out by bakefile. Index: liolib.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/liolib.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** liolib.c 12 Jun 2006 03:50:37 -0000 1.2 --- liolib.c 18 Jan 2008 03:43:00 -0000 1.3 *************** *** 107,112 **** static int io_fclose (lua_State *L) { FILE **p = topfile(L); ! int ok = (fclose(*p) == 0); ! *p = NULL; return pushresult(L, ok, NULL); } --- 107,115 ---- static int io_fclose (lua_State *L) { FILE **p = topfile(L); ! int ok = 0; ! if (*p != stdin && *p != stdout && *p != stderr) { ! ok = (fclose(*p) == 0); ! *p = NULL; ! } return pushresult(L, ok, NULL); } *************** *** 130,135 **** static int io_gc (lua_State *L) { FILE *f = *topfile(L); ! /* ignore closed files and standard files */ ! if (f != NULL && f != stdin && f != stdout && f != stderr) aux_close(L); return 0; --- 133,137 ---- static int io_gc (lua_State *L) { FILE *f = *topfile(L); ! if (f != NULL) /* ignore closed files */ aux_close(L); return 0; Index: lbaselib.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lbaselib.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** lbaselib.c 25 Apr 2007 02:52:20 -0000 1.3 --- lbaselib.c 18 Jan 2008 03:43:00 -0000 1.4 *************** *** 478,490 **** */ static int auxresume (lua_State *L, lua_State *co, int narg) { ! int status; if (!lua_checkstack(co, narg)) luaL_error(L, "too many arguments to resume"); ! if (lua_status(co) == 0 && lua_gettop(co) == 0) { ! lua_pushliteral(L, "cannot resume dead coroutine"); return -1; /* error flag */ } lua_xmove(L, co, narg); status = lua_resume(co, narg); if (status == 0 || status == LUA_YIELD) { --- 478,526 ---- */ + #define CO_RUN 0 /* running */ + #define CO_SUS 1 /* suspended */ + #define CO_NOR 2 /* 'normal' (it resumed another coroutine) */ + #define CO_DEAD 3 + + static const char *const statnames[] = + {"running", "suspended", "normal", "dead"}; + + static int costatus (lua_State *L, lua_State *co) { + if (L == co) return CO_RUN; + switch (lua_status(co)) { + case LUA_YIELD: + return CO_SUS; + case 0: { + lua_Debug ar; + if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ + return CO_NOR; /* it is running */ + else if (lua_gettop(co) == 0) + return CO_DEAD; + else + return CO_SUS; /* initial state */ + } + default: /* some error occured */ + return CO_DEAD; + } + } + + + static int luaB_costatus (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + luaL_argcheck(L, co, 1, "coroutine expected"); + lua_pushstring(L, statnames[costatus(L, co)]); + return 1; + } + static int auxresume (lua_State *L, lua_State *co, int narg) { ! int status = costatus(L, co); if (!lua_checkstack(co, narg)) luaL_error(L, "too many arguments to resume"); ! if (status != CO_SUS) { ! lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]); return -1; /* error flag */ } lua_xmove(L, co, narg); + lua_setlevel(L, co); status = lua_resume(co, narg); if (status == 0 || status == LUA_YIELD) { *************** *** 557,588 **** - static int luaB_costatus (lua_State *L) { - lua_State *co = lua_tothread(L, 1); - luaL_argcheck(L, co, 1, "coroutine expected"); - if (L == co) lua_pushliteral(L, "running"); - else { - switch (lua_status(co)) { - case LUA_YIELD: - lua_pushliteral(L, "suspended"); - break; - case 0: { - lua_Debug ar; - if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ - lua_pushliteral(L, "normal"); /* it is running */ - else if (lua_gettop(co) == 0) - lua_pushliteral(L, "dead"); - else - lua_pushliteral(L, "suspended"); /* initial state */ - break; - } - default: /* some error occured */ - lua_pushliteral(L, "dead"); - break; - } - } - return 1; - } - - static int luaB_corunning (lua_State *L) { if (lua_pushthread(L)) --- 593,596 ---- Index: lua.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lua.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** lua.h 25 Apr 2007 02:52:20 -0000 1.3 --- lua.h 18 Jan 2008 03:43:00 -0000 1.4 *************** *** 18,24 **** #define LUA_VERSION "Lua 5.1" ! #define LUA_RELEASE "Lua 5.1.2" #define LUA_VERSION_NUM 501 ! #define LUA_COPYRIGHT "Copyright (C) 1994-2007 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" --- 18,24 ---- #define LUA_VERSION "Lua 5.1" ! #define LUA_RELEASE "Lua 5.1.3" #define LUA_VERSION_NUM 501 ! #define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" *************** *** 246,250 **** ! /* ** =============================================================== ** some useful macros --- 246,250 ---- ! /* ** =============================================================== ** some useful macros *************** *** 295,298 **** --- 295,301 ---- + /* hack */ + LUA_API void lua_setlevel (lua_State *from, lua_State *to); + /* *************** *** 360,364 **** /****************************************************************************** ! * Copyright (C) 1994-2007 Lua.org, PUC-Rio. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining --- 363,367 ---- /****************************************************************************** ! * Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining Index: lauxlib.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lauxlib.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lauxlib.c 12 Jun 2006 03:50:37 -0000 1.2 --- lauxlib.c 18 Jan 2008 03:43:00 -0000 1.3 *************** *** 245,249 **** int size = libsize(l); /* check whether lib already exists */ ! luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", size); lua_getfield(L, -1, libname); /* get _LOADED[libname] */ if (!lua_istable(L, -1)) { /* not found? */ --- 245,249 ---- int size = libsize(l); /* check whether lib already exists */ ! luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); lua_getfield(L, -1, libname); /* get _LOADED[libname] */ if (!lua_istable(L, -1)) { /* not found? */ Index: Makefile =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/Makefile,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile 25 Apr 2007 02:52:20 -0000 1.7 --- Makefile 18 Jan 2008 03:43:00 -0000 1.8 *************** *** 149,154 **** lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ ltm.h lzio.h lmem.h ldo.h ! loadlib.o: loadlib.c lauxlib.h lua.h luaconf.h lobject.h llimits.h \ ! lualib.h lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \ ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h --- 149,153 ---- lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ ltm.h lzio.h lmem.h ldo.h ! loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \ ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h Index: lparser.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lparser.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** lparser.c 1 Aug 2007 19:15:31 -0000 1.5 --- lparser.c 18 Jan 2008 03:43:00 -0000 1.6 *************** *** 940,944 **** check_conflict(ls, lh, &nv.v); luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls, ! "variable names"); assignment(ls, &nv, nvars+1); } --- 940,944 ---- check_conflict(ls, lh, &nv.v); luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls, ! "variables in assignment"); assignment(ls, &nv, nvars+1); } Index: lua.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lua.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** lua.c 10 Dec 2007 05:39:05 -0000 1.3 --- lua.c 18 Jan 2008 03:43:00 -0000 1.4 *************** *** 75,78 **** --- 75,80 ---- static int traceback (lua_State *L) { + if (!lua_isstring(L, 1)) /* 'message' not a string? */ + return 1; /* keep it intact */ lua_getfield(L, LUA_GLOBALSINDEX, "debug"); if (!lua_istable(L, -1)) { Index: luaconf.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/luaconf.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** luaconf.h 25 Apr 2007 02:52:20 -0000 1.3 --- luaconf.h 18 Jan 2008 03:43:00 -0000 1.4 *************** *** 443,447 **** ** functions to consume unlimited stack space. */ ! #define LUAI_MAXCSTACK 2048 --- 443,449 ---- ** functions to consume unlimited stack space. */ ! #define LUAI_MCS_AUX ((int)(INT_MAX / (4*sizeof(LUA_NUMBER)))) ! #define LUAI_MAXCSTACK (LUAI_MCS_AUX > SHRT_MAX ? SHRT_MAX : LUAI_MCS_AUX) ! Index: lapi.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lapi.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** lapi.c 10 Dec 2007 05:39:05 -0000 1.4 --- lapi.c 18 Jan 2008 03:43:00 -0000 1.5 *************** *** 124,127 **** --- 124,132 ---- + LUA_API void lua_setlevel (lua_State *from, lua_State *to) { + to->nCcalls = from->nCcalls; + } + + LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { lua_CFunction old; Index: lstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lstate.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lstate.h 29 Mar 2006 05:48:11 -0000 1.2 --- lstate.h 18 Jan 2008 03:43:00 -0000 1.3 *************** *** 113,116 **** --- 113,117 ---- int size_ci; /* size of array `base_ci' */ unsigned short nCcalls; /* number of nested C calls */ + unsigned short baseCcalls; /* nested C calls when resuming coroutine */ lu_byte hookmask; lu_byte allowhook; Index: ldo.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/ldo.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ldo.c 12 Jun 2006 03:50:37 -0000 1.3 --- ldo.c 18 Jan 2008 03:43:00 -0000 1.4 *************** *** 84,88 **** luaF_close(L, L->base); /* close eventual pending closures */ luaD_seterrorobj(L, status, L->base); ! L->nCcalls = 0; L->allowhook = 1; restore_stack_limit(L); --- 84,88 ---- luaF_close(L, L->base); /* close eventual pending closures */ luaD_seterrorobj(L, status, L->base); ! L->nCcalls = L->baseCcalls; L->allowhook = 1; restore_stack_limit(L); *************** *** 366,370 **** ** When returns, all the results are on the stack, starting at the original ** function position. ! */ void luaD_call (lua_State *L, StkId func, int nResults) { if (++L->nCcalls >= LUAI_MAXCCALLS) { --- 366,370 ---- ** When returns, all the results are on the stack, starting at the original ** function position. ! */ void luaD_call (lua_State *L, StkId func, int nResults) { if (++L->nCcalls >= LUAI_MAXCCALLS) { *************** *** 418,429 **** int status; lua_lock(L); ! if (L->status != LUA_YIELD) { ! if (L->status != 0) ! return resume_error(L, "cannot resume dead coroutine"); ! else if (L->ci != L->base_ci) ! return resume_error(L, "cannot resume non-suspended coroutine"); ! } luai_userstateresume(L, nargs); ! lua_assert(L->errfunc == 0 && L->nCcalls == 0); status = luaD_rawrunprotected(L, resume, L->top - nargs); if (status != 0) { /* error? */ --- 418,428 ---- int status; lua_lock(L); ! if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) ! return resume_error(L, "cannot resume non-suspended coroutine"); ! if (L->nCcalls >= LUAI_MAXCCALLS) ! return resume_error(L, "C stack overflow"); luai_userstateresume(L, nargs); ! lua_assert(L->errfunc == 0); ! L->baseCcalls = ++L->nCcalls; status = luaD_rawrunprotected(L, resume, L->top - nargs); if (status != 0) { /* error? */ *************** *** 432,437 **** L->ci->top = L->top; } ! else status = L->status; lua_unlock(L); return status; --- 431,439 ---- L->ci->top = L->top; } ! else { ! lua_assert(L->nCcalls == L->baseCcalls); status = L->status; + } + --L->nCcalls; lua_unlock(L); return status; *************** *** 442,446 **** luai_userstateyield(L, nresults); lua_lock(L); ! if (L->nCcalls > 0) luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); L->base = L->top - nresults; /* protect stack slots below */ --- 444,448 ---- luai_userstateyield(L, nresults); lua_lock(L); ! if (L->nCcalls > L->baseCcalls) luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); L->base = L->top - nresults; /* protect stack slots below */ Index: lstate.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lstate.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** lstate.c 6 Dec 2006 06:58:23 -0000 1.6 --- lstate.c 18 Jan 2008 03:43:00 -0000 1.7 *************** *** 94,98 **** L->openupval = NULL; L->size_ci = 0; ! L->nCcalls = 0; L->status = 0; L->base_ci = L->ci = NULL; --- 94,98 ---- L->openupval = NULL; L->size_ci = 0; ! L->nCcalls = L->baseCcalls = 0; L->status = 0; L->base_ci = L->ci = NULL; *************** *** 206,210 **** L->ci = L->base_ci; L->base = L->top = L->ci->base; ! L->nCcalls = 0; } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); lua_assert(G(L)->tmudata == NULL); --- 206,210 ---- L->ci = L->base_ci; L->base = L->top = L->ci->base; ! L->nCcalls = L->baseCcalls = 0; } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); lua_assert(G(L)->tmudata == NULL); |