details (removed silly use of 'luaL_opt' + better error messages

in cases of "table expected")
This commit is contained in:
Roberto Ierusalimschy 2016-02-08 10:55:19 -02:00
parent fd51651684
commit f79b4568ae

View File

@ -1,5 +1,5 @@
/* /*
** $Id: ltablib.c,v 1.90 2015/11/25 12:48:57 roberto Exp roberto $ ** $Id: ltablib.c,v 1.91 2015/12/14 11:57:38 roberto Exp roberto $
** Library for Table Manipulation ** Library for Table Manipulation
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -53,7 +53,7 @@ static void checktab (lua_State *L, int arg, int what) {
lua_pop(L, n); /* pop metatable and tested metamethods */ lua_pop(L, n); /* pop metatable and tested metamethods */
} }
else else
luaL_argerror(L, arg, "table expected"); /* force an error */ luaL_checktype(L, arg, LUA_TTABLE); /* force an error */
} }
} }
@ -172,7 +172,7 @@ static int tconcat (lua_State *L) {
size_t lsep; size_t lsep;
const char *sep = luaL_optlstring(L, 2, "", &lsep); const char *sep = luaL_optlstring(L, 2, "", &lsep);
lua_Integer i = luaL_optinteger(L, 3, 1); lua_Integer i = luaL_optinteger(L, 3, 1);
last = luaL_opt(L, luaL_checkinteger, 4, last); last = luaL_optinteger(L, 4, last);
luaL_buffinit(L, &b); luaL_buffinit(L, &b);
for (; i < last; i++) { for (; i < last; i++) {
addfield(L, &b, i); addfield(L, &b, i);