commit 11886dc7b0f6fdc69d45fa019b23f9aa9094e91c
parent 81bc5711a8b71ced34eef8750deb0ce4475d5cd5
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Tue, 22 Oct 2002 15:07:33 -0300
print error on stderr when _ALERT is not defined
Diffstat:
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/lauxlib.c b/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 */
+ }
}
}