From 437a5b07d415e1a74160ddfd804017171d6cc5cb Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 28 Dec 2018 15:42:34 -0200 Subject: Added a warning system to Lua The warning system is just a way for Lua to emit warnings, messages to the programmer that do not interfere with the running program. --- lbaselib.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lbaselib.c') diff --git a/lbaselib.c b/lbaselib.c index 7c0ebfec..26683a1d 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -43,6 +43,13 @@ static int luaB_print (lua_State *L) { } +static int luaB_warn (lua_State *L) { + const char *msg = luaL_checkstring(L, 1); + lua_warning(L, msg); + return 0; +} + + #define SPACECHARS " \f\n\r\t\v" static const char *b_str2int (const char *s, int base, lua_Integer *pn) { @@ -482,6 +489,7 @@ static const luaL_Reg base_funcs[] = { {"pairs", luaB_pairs}, {"pcall", luaB_pcall}, {"print", luaB_print}, + {"warn", luaB_warn}, {"rawequal", luaB_rawequal}, {"rawlen", luaB_rawlen}, {"rawget", luaB_rawget}, -- cgit v1.2.3-55-g6feb