mirror of https://github.com/lua/lua
print error on stderr when _ALERT is not defined
This commit is contained in:
parent
81bc5711a8
commit
11886dc7b0
13
lauxlib.c
13
lauxlib.c
|
@ -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
|
||||
** 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) {
|
||||
if (status != 0) {
|
||||
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 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue