From 11886dc7b0f6fdc69d45fa019b23f9aa9094e91c Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 22 Oct 2002 15:07:55 -0300 Subject: [PATCH] print error on stderr when _ALERT is not defined --- lauxlib.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lauxlib.c b/lauxlib.c index 0524125e..5e55ddac 100644 --- 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 */ + } } }