diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-22 15:07:55 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-22 15:07:55 -0300 |
commit | 11886dc7b0f6fdc69d45fa019b23f9aa9094e91c (patch) | |
tree | ffb4470be1b4e1ee3b85375db129c239682574c4 | |
parent | 81bc5711a8b71ced34eef8750deb0ce4475d5cd5 (diff) | |
download | lua-11886dc7b0f6fdc69d45fa019b23f9aa9094e91c.tar.gz lua-11886dc7b0f6fdc69d45fa019b23f9aa9094e91c.tar.bz2 lua-11886dc7b0f6fdc69d45fa019b23f9aa9094e91c.zip |
print error on stderr when _ALERT is not defined
-rw-r--r-- | lauxlib.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.87 2002/10/04 14:31:40 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.88 2002/10/16 20:41:35 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -422,9 +422,14 @@ LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, | |||
422 | static void callalert (lua_State *L, int status) { | 422 | static void callalert (lua_State *L, int status) { |
423 | if (status != 0) { | 423 | if (status != 0) { |
424 | lua_getglobal(L, "_ALERT"); | 424 | lua_getglobal(L, "_ALERT"); |
425 | lua_insert(L, -2); | 425 | if (lua_isfunction(L, -1)) { |
426 | lua_call(L, 1, 0); | 426 | lua_insert(L, -2); |
427 | lua_pop(L, 1); | 427 | lua_call(L, 1, 0); |
428 | } | ||
429 | else { /* no _ALERT function; print it on stderr */ | ||
430 | fprintf(stderr, "%s\n", lua_tostring(L, -2)); | ||
431 | lua_pop(L, 2); /* remove error message and _ALERT */ | ||
432 | } | ||
428 | } | 433 | } |
429 | } | 434 | } |
430 | 435 | ||