diff options
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -37,9 +37,20 @@ static int luaB_print (lua_State *L) { | |||
37 | } | 37 | } |
38 | 38 | ||
39 | 39 | ||
40 | /* | ||
41 | ** Creates a warning with all given arguments. | ||
42 | ** Check first for errors; otherwise an error may interrupt | ||
43 | ** the composition of a warning, leaving it unfinished. | ||
44 | */ | ||
40 | static int luaB_warn (lua_State *L) { | 45 | static int luaB_warn (lua_State *L) { |
41 | const char *msg = luaL_checkstring(L, 1); | 46 | int n = lua_gettop(L); /* number of arguments */ |
42 | lua_warning(L, msg, lua_toboolean(L, 2)); | 47 | int i; |
48 | luaL_checkstring(L, 1); /* at least one argument */ | ||
49 | for (i = 2; i <= n; i++) | ||
50 | luaL_checkstring(L, i); /* make sure all arguments are strings */ | ||
51 | for (i = 1; i <= n; i++) /* compose warning */ | ||
52 | lua_warning(L, lua_tostring(L, i), 1); | ||
53 | lua_warning(L, "", 0); /* close warning */ | ||
43 | return 0; | 54 | return 0; |
44 | } | 55 | } |
45 | 56 | ||