|
@@ -1,5 +1,5 @@
|
|
/*
|
|
/*
|
|
-** $Id: lauxlib.c,v 1.87 2002/10/04 14:31:40 roberto Exp roberto $
|
|
|
|
|
|
+** $Id: lauxlib.c,v 1.88 2002/10/16 20:41:35 roberto Exp roberto $
|
|
** Auxiliary functions for building Lua libraries
|
|
** Auxiliary functions for building Lua libraries
|
|
** See Copyright Notice in lua.h
|
|
** See Copyright Notice in lua.h
|
|
*/
|
|
*/
|
|
@@ -422,9 +422,14 @@ LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
|
|
static void callalert (lua_State *L, int status) {
|
|
static void callalert (lua_State *L, int status) {
|
|
if (status != 0) {
|
|
if (status != 0) {
|
|
lua_getglobal(L, "_ALERT");
|
|
lua_getglobal(L, "_ALERT");
|
|
- lua_insert(L, -2);
|
|
|
|
- lua_call(L, 1, 0);
|
|
|
|
- lua_pop(L, 1);
|
|
|
|
|
|
+ if (lua_isfunction(L, -1)) {
|
|
|
|
+ lua_insert(L, -2);
|
|
|
|
+ lua_call(L, 1, 0);
|
|
|
|
+ }
|
|
|
|
+ else { /* no _ALERT function; print it on stderr */
|
|
|
|
+ fprintf(stderr, "%s\n", lua_tostring(L, -2));
|
|
|
|
+ lua_pop(L, 2); /* remove error message and _ALERT */
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|