diff options
Diffstat (limited to '')
-rw-r--r-- | ldo.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -94,10 +94,6 @@ void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { | |||
94 | setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */ | 94 | setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */ |
95 | break; | 95 | break; |
96 | } | 96 | } |
97 | case LUA_ERRERR: { | ||
98 | setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); | ||
99 | break; | ||
100 | } | ||
101 | case LUA_OK: { /* special case only for closing upvalues */ | 97 | case LUA_OK: { /* special case only for closing upvalues */ |
102 | setnilvalue(s2v(oldtop)); /* no error message */ | 98 | setnilvalue(s2v(oldtop)); /* no error message */ |
103 | break; | 99 | break; |
@@ -120,6 +116,7 @@ l_noret luaD_throw (lua_State *L, int errcode) { | |||
120 | else { /* thread has no error handler */ | 116 | else { /* thread has no error handler */ |
121 | global_State *g = G(L); | 117 | global_State *g = G(L); |
122 | errcode = luaE_resetthread(L, errcode); /* close all upvalues */ | 118 | errcode = luaE_resetthread(L, errcode); /* close all upvalues */ |
119 | L->status = errcode; | ||
123 | if (g->mainthread->errorJmp) { /* main thread has a handler? */ | 120 | if (g->mainthread->errorJmp) { /* main thread has a handler? */ |
124 | setobjs2s(L, g->mainthread->top.p++, L->top.p - 1); /* copy error obj. */ | 121 | setobjs2s(L, g->mainthread->top.p++, L->top.p - 1); /* copy error obj. */ |
125 | luaD_throw(g->mainthread, errcode); /* re-throw in main thread */ | 122 | luaD_throw(g->mainthread, errcode); /* re-throw in main thread */ |
@@ -198,6 +195,16 @@ static void correctstack (lua_State *L) { | |||
198 | /* some space for error handling */ | 195 | /* some space for error handling */ |
199 | #define ERRORSTACKSIZE (LUAI_MAXSTACK + 200) | 196 | #define ERRORSTACKSIZE (LUAI_MAXSTACK + 200) |
200 | 197 | ||
198 | |||
199 | /* raise an error while running the message handler */ | ||
200 | l_noret luaD_errerr (lua_State *L) { | ||
201 | TString *msg = luaS_newliteral(L, "error in error handling"); | ||
202 | setsvalue2s(L, L->top.p, msg); | ||
203 | L->top.p++; /* assume EXTRA_STACK */ | ||
204 | luaD_throw(L, LUA_ERRERR); | ||
205 | } | ||
206 | |||
207 | |||
201 | /* | 208 | /* |
202 | ** Reallocate the stack to a new size, correcting all pointers into it. | 209 | ** Reallocate the stack to a new size, correcting all pointers into it. |
203 | ** In ISO C, any pointer use after the pointer has been deallocated is | 210 | ** In ISO C, any pointer use after the pointer has been deallocated is |
@@ -247,7 +254,7 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) { | |||
247 | a stack error; cannot grow further than that. */ | 254 | a stack error; cannot grow further than that. */ |
248 | lua_assert(stacksize(L) == ERRORSTACKSIZE); | 255 | lua_assert(stacksize(L) == ERRORSTACKSIZE); |
249 | if (raiseerror) | 256 | if (raiseerror) |
250 | luaD_throw(L, LUA_ERRERR); /* error inside message handler */ | 257 | luaD_errerr(L); /* error inside message handler */ |
251 | return 0; /* if not 'raiseerror', just signal it */ | 258 | return 0; /* if not 'raiseerror', just signal it */ |
252 | } | 259 | } |
253 | else if (n < LUAI_MAXSTACK) { /* avoids arithmetic overflows */ | 260 | else if (n < LUAI_MAXSTACK) { /* avoids arithmetic overflows */ |