From a9f3e379f4aabc4936962853335e16910d816329 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 5 Nov 2008 11:15:57 +0100 Subject: [PATCH] luaa: new warning function Signed-off-by: Julien Danjou --- luaa.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/luaa.h b/luaa.h index 340dc5cb..02e87d94 100644 --- a/luaa.h +++ b/luaa.h @@ -321,6 +321,25 @@ luaA_dofunction(lua_State *L, luaA_ref f, int nargs, int nret) return false; } +/** Print a warning about some Lua code. + * This is less mean than luaL_error() which setjmp via lua_error() and kills + * everything. This only warn, it's up to you to then do what's should be done. + * \param L The Lua VM state. + * \param fmt The warning message. + */ +static inline void __attribute__ ((format(printf, 2, 3))) +luaA_warn(lua_State *L, const char *fmt, ...) +{ + va_list ap; + luaL_where(L, 1); + fprintf(stderr, "%sW: ", lua_tostring(L, -1)); + lua_pop(L, 1); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + int luaA_otable_index(lua_State *); /** Create a new object table with a metatable. -- 2.11.4.GIT