diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-12-28 15:42:34 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-12-28 15:42:34 -0200 |
commit | 437a5b07d415e1a74160ddfd804017171d6cc5cb (patch) | |
tree | 861f9a56ae175eaed91c163409c33ab85bee7ff9 /lbaselib.c | |
parent | ba7da13ec5938f978c37d63aa40a3e340b301f79 (diff) | |
download | lua-437a5b07d415e1a74160ddfd804017171d6cc5cb.tar.gz lua-437a5b07d415e1a74160ddfd804017171d6cc5cb.tar.bz2 lua-437a5b07d415e1a74160ddfd804017171d6cc5cb.zip |
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.
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -43,6 +43,13 @@ static int luaB_print (lua_State *L) { | |||
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | ||
46 | static int luaB_warn (lua_State *L) { | ||
47 | const char *msg = luaL_checkstring(L, 1); | ||
48 | lua_warning(L, msg); | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | |||
46 | #define SPACECHARS " \f\n\r\t\v" | 53 | #define SPACECHARS " \f\n\r\t\v" |
47 | 54 | ||
48 | static const char *b_str2int (const char *s, int base, lua_Integer *pn) { | 55 | static const char *b_str2int (const char *s, int base, lua_Integer *pn) { |
@@ -482,6 +489,7 @@ static const luaL_Reg base_funcs[] = { | |||
482 | {"pairs", luaB_pairs}, | 489 | {"pairs", luaB_pairs}, |
483 | {"pcall", luaB_pcall}, | 490 | {"pcall", luaB_pcall}, |
484 | {"print", luaB_print}, | 491 | {"print", luaB_print}, |
492 | {"warn", luaB_warn}, | ||
485 | {"rawequal", luaB_rawequal}, | 493 | {"rawequal", luaB_rawequal}, |
486 | {"rawlen", luaB_rawlen}, | 494 | {"rawlen", luaB_rawlen}, |
487 | {"rawget", luaB_rawget}, | 495 | {"rawget", luaB_rawget}, |