diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-02-22 11:17:24 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-02-22 11:17:24 -0300 |
commit | bb5627f3a4c9c8bf25b836f07708067b1170dde5 (patch) | |
tree | 93c929292eca22fa8fdd1512f5a9a1d88d872297 /ldo.c | |
parent | 21107d7c2c2615b92fae723bbb3dad2127ed1c64 (diff) | |
download | lua-bb5627f3a4c9c8bf25b836f07708067b1170dde5.tar.gz lua-bb5627f3a4c9c8bf25b836f07708067b1170dde5.tar.bz2 lua-bb5627f3a4c9c8bf25b836f07708067b1170dde5.zip |
better control over calls to _ALERT and _ERRORMESSAGE (to avoid error
loops)
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.32 1999/02/12 19:23:02 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.33 1999/02/22 13:51:44 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -235,7 +235,8 @@ void luaD_travstack (int (*fn)(TObject *)) | |||
235 | 235 | ||
236 | static void message (char *s) { | 236 | static void message (char *s) { |
237 | TObject *em = &(luaS_new("_ERRORMESSAGE")->u.s.globalval); | 237 | TObject *em = &(luaS_new("_ERRORMESSAGE")->u.s.globalval); |
238 | if (ttype(em) != LUA_T_NIL) { | 238 | if (ttype(em) == LUA_T_PROTO || ttype(em) == LUA_T_CPROTO || |
239 | ttype(em) == LUA_T_CLOSURE) { | ||
239 | *L->stack.top = *em; | 240 | *L->stack.top = *em; |
240 | incr_top; | 241 | incr_top; |
241 | lua_pushstring(s); | 242 | lua_pushstring(s); |
@@ -246,14 +247,12 @@ static void message (char *s) { | |||
246 | /* | 247 | /* |
247 | ** Reports an error, and jumps up to the available recover label | 248 | ** Reports an error, and jumps up to the available recover label |
248 | */ | 249 | */ |
249 | void lua_error (char *s) | 250 | void lua_error (char *s) { |
250 | { | ||
251 | if (s) message(s); | 251 | if (s) message(s); |
252 | if (L->errorJmp) | 252 | if (L->errorJmp) |
253 | longjmp(*((jmp_buf *)L->errorJmp), 1); | 253 | longjmp(*((jmp_buf *)L->errorJmp), 1); |
254 | else { | 254 | else { |
255 | lua_pushstring("lua: exit(1). Unable to recover.\n"); | 255 | message("exit(1). Unable to recover.\n"); |
256 | lua_call("_ALERT"); | ||
257 | exit(1); | 256 | exit(1); |
258 | } | 257 | } |
259 | } | 258 | } |