diff options
-rw-r--r-- | lbuiltin.c | 26 | ||||
-rw-r--r-- | ldo.c | 11 | ||||
-rw-r--r-- | liolib.c | 11 |
3 files changed, 24 insertions, 24 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbuiltin.c,v 1.50 1999/02/08 16:29:35 roberto Exp roberto $ | 2 | ** $Id: lbuiltin.c,v 1.51 1999/02/12 19:23:02 roberto Exp roberto $ |
3 | ** Built-in functions | 3 | ** Built-in functions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -82,9 +82,8 @@ static Hash *gethash (int arg) { | |||
82 | 82 | ||
83 | 83 | ||
84 | /* | 84 | /* |
85 | ** If your system does not support "stderr", remove this function and | 85 | ** If your system does not support "stderr", redefine this function, or |
86 | ** define your own "_ALERT" function. You *must* have an _ALERT function | 86 | ** redefine _ERRORMESSAGE so that it won't need _ALERT. |
87 | ** defined for Lua to work properly. | ||
88 | */ | 87 | */ |
89 | static void luaB_alert (void) { | 88 | static void luaB_alert (void) { |
90 | fputs(luaL_check_string(1), stderr); | 89 | fputs(luaL_check_string(1), stderr); |
@@ -96,10 +95,13 @@ static void luaB_alert (void) { | |||
96 | ** The library "iolib" redefines _ERRORMESSAGE for better error information. | 95 | ** The library "iolib" redefines _ERRORMESSAGE for better error information. |
97 | */ | 96 | */ |
98 | static void error_message (void) { | 97 | static void error_message (void) { |
99 | char buff[600]; | 98 | lua_Object al = lua_rawgetglobal("_ALERT"); |
100 | sprintf(buff, "lua error: %.500s\n", luaL_check_string(1)); | 99 | if (lua_isfunction(al)) { /* avoid error loop if _ALERT is not defined */ |
101 | lua_pushstring(buff); | 100 | char buff[600]; |
102 | lua_call("_ALERT"); | 101 | sprintf(buff, "lua error: %.500s\n", luaL_check_string(1)); |
102 | lua_pushstring(buff); | ||
103 | lua_callfunction(al); | ||
104 | } | ||
103 | } | 105 | } |
104 | 106 | ||
105 | 107 | ||
@@ -301,7 +303,6 @@ static void luaB_call (void) { | |||
301 | /* }====================================================== */ | 303 | /* }====================================================== */ |
302 | 304 | ||
303 | 305 | ||
304 | #ifdef EXTRALIB | ||
305 | /* | 306 | /* |
306 | ** {====================================================== | 307 | ** {====================================================== |
307 | ** "Extra" functions | 308 | ** "Extra" functions |
@@ -501,7 +502,6 @@ static void luaB_sort (void) { | |||
501 | } | 502 | } |
502 | 503 | ||
503 | /* }}===================================================== */ | 504 | /* }}===================================================== */ |
504 | #endif | ||
505 | 505 | ||
506 | 506 | ||
507 | /* | 507 | /* |
@@ -709,10 +709,9 @@ static struct luaL_reg builtin_funcs[] = { | |||
709 | {"tag", luaB_luatag}, | 709 | {"tag", luaB_luatag}, |
710 | {"tonumber", luaB_tonumber}, | 710 | {"tonumber", luaB_tonumber}, |
711 | {"tostring", luaB_tostring}, | 711 | {"tostring", luaB_tostring}, |
712 | {"type", luaB_type} | 712 | {"type", luaB_type}, |
713 | #ifdef EXTRALIB | ||
714 | /* "Extra" functions */ | 713 | /* "Extra" functions */ |
715 | ,{"assert", luaB_assert}, | 714 | {"assert", luaB_assert}, |
716 | {"foreach", luaB_foreach}, | 715 | {"foreach", luaB_foreach}, |
717 | {"foreachi", luaB_foreachi}, | 716 | {"foreachi", luaB_foreachi}, |
718 | {"foreachvar", luaB_foreachvar}, | 717 | {"foreachvar", luaB_foreachvar}, |
@@ -720,7 +719,6 @@ static struct luaL_reg builtin_funcs[] = { | |||
720 | {"sort", luaB_sort}, | 719 | {"sort", luaB_sort}, |
721 | {"tinsert", luaB_tinsert}, | 720 | {"tinsert", luaB_tinsert}, |
722 | {"tremove", luaB_tremove} | 721 | {"tremove", luaB_tremove} |
723 | #endif | ||
724 | }; | 722 | }; |
725 | 723 | ||
726 | 724 | ||
@@ -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 | } |
@@ -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 | ||