aboutsummaryrefslogtreecommitdiff
path: root/lbuiltin.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbuiltin.c')
-rw-r--r--lbuiltin.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lbuiltin.c b/lbuiltin.c
index e0c9627b..99853e43 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.89 1999/12/27 17:33:22 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.90 1999/12/28 19:23:41 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*/
@@ -106,8 +106,9 @@ void luaB__ALERT (lua_State *L) {
106void luaB__ERRORMESSAGE (lua_State *L) { 106void luaB__ERRORMESSAGE (lua_State *L) {
107 lua_Object al = lua_rawgetglobal(L, "_ALERT"); 107 lua_Object al = lua_rawgetglobal(L, "_ALERT");
108 if (lua_isfunction(L, al)) { /* avoid error loop if _ALERT is not defined */ 108 if (lua_isfunction(L, al)) { /* avoid error loop if _ALERT is not defined */
109 char buff[600]; 109 const char *s = luaL_check_string(L, 1);
110 sprintf(buff, "error: %.500s\n", luaL_check_string(L, 1)); 110 char *buff = luaL_openspace(L, strlen(s)+sizeof("error: \n"));
111 strcpy(buff, "error: "); strcat(buff, s); strcat(buff, "\n");
111 lua_pushstring(L, buff); 112 lua_pushstring(L, buff);
112 lua_callfunction(L, al); 113 lua_callfunction(L, al);
113 } 114 }
@@ -169,7 +170,7 @@ void luaB_tonumber (lua_State *L) {
169 170
170 171
171void luaB_error (lua_State *L) { 172void luaB_error (lua_State *L) {
172 lua_error(L, lua_getstring(L, lua_getparam(L, 1))); 173 lua_error(L, luaL_opt_string(L, 1, NULL));
173} 174}
174 175
175void luaB_setglobal (lua_State *L) { 176void luaB_setglobal (lua_State *L) {
@@ -231,6 +232,8 @@ void luaB_settagmethod (lua_State *L) {
231 int tag = luaL_check_int(L, 1); 232 int tag = luaL_check_int(L, 1);
232 const char *event = luaL_check_string(L, 2); 233 const char *event = luaL_check_string(L, 2);
233 lua_Object nf = luaL_nonnullarg(L, 3); 234 lua_Object nf = luaL_nonnullarg(L, 3);
235 luaL_arg_check(L, lua_isnil(L, nf) || lua_isfunction(L, nf), 3,
236 "function or nil expected");
234#ifndef LUA_COMPAT_GC 237#ifndef LUA_COMPAT_GC
235 if (strcmp(event, "gc") == 0 && tag != LUA_T_NIL) 238 if (strcmp(event, "gc") == 0 && tag != LUA_T_NIL)
236 lua_error(L, "cannot set this tag method from Lua"); 239 lua_error(L, "cannot set this tag method from Lua");