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 /liolib.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 'liolib.c')
-rw-r--r-- | liolib.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 1.29 1999/01/04 12:41:12 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 1.30 1999/02/05 15:22:43 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -459,7 +459,7 @@ static void errorfb (void) { | |||
459 | char buff[MAXMESSAGE]; | 459 | char buff[MAXMESSAGE]; |
460 | int level = 1; /* skip level 0 (it's this function) */ | 460 | int level = 1; /* skip level 0 (it's this function) */ |
461 | lua_Object func; | 461 | lua_Object func; |
462 | sprintf(buff, "lua: %.200s\n", lua_getstring(lua_getparam(1))); | 462 | sprintf(buff, "lua error: %.200s\n", lua_getstring(lua_getparam(1))); |
463 | while ((func = lua_stackedfunction(level++)) != LUA_NOOBJECT) { | 463 | while ((func = lua_stackedfunction(level++)) != LUA_NOOBJECT) { |
464 | char *name; | 464 | char *name; |
465 | int currentline; | 465 | int currentline; |
@@ -496,8 +496,11 @@ static void errorfb (void) { | |||
496 | sprintf(buff+strlen(buff), " [in chunk %.50s]", chunkname); | 496 | sprintf(buff+strlen(buff), " [in chunk %.50s]", chunkname); |
497 | strcat(buff, "\n"); | 497 | strcat(buff, "\n"); |
498 | } | 498 | } |
499 | lua_pushstring(buff); | 499 | func = lua_rawgetglobal("_ALERT"); |
500 | lua_call("_ALERT"); | 500 | if (lua_isfunction(func)) { /* avoid error loop if _ALERT is not defined */ |
501 | lua_pushstring(buff); | ||
502 | lua_callfunction(func); | ||
503 | } | ||
501 | } | 504 | } |
502 | 505 | ||
503 | 506 | ||