aboutsummaryrefslogtreecommitdiff
path: root/lbuiltin.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbuiltin.c')
-rw-r--r--lbuiltin.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/lbuiltin.c b/lbuiltin.c
index 6c13ad32..db7e473c 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -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*/
89static void luaB_alert (void) { 88static 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*/
98static void error_message (void) { 97static 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