removed compatibility code with older versions
This commit is contained in:
28
ltablib.c
28
ltablib.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ltablib.c,v 1.93 2016/02/25 19:41:54 roberto Exp roberto $
|
||||
** $Id: ltablib.c,v 1.94 2018/02/25 12:48:16 roberto Exp roberto $
|
||||
** Library for Table Manipulation
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -58,24 +58,6 @@ static void checktab (lua_State *L, int arg, int what) {
|
||||
}
|
||||
|
||||
|
||||
#if defined(LUA_COMPAT_MAXN)
|
||||
static int maxn (lua_State *L) {
|
||||
lua_Number max = 0;
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
lua_pushnil(L); /* first key */
|
||||
while (lua_next(L, 1)) {
|
||||
lua_pop(L, 1); /* remove value */
|
||||
if (lua_type(L, -1) == LUA_TNUMBER) {
|
||||
lua_Number v = lua_tonumber(L, -1);
|
||||
if (v > max) max = v;
|
||||
}
|
||||
}
|
||||
lua_pushnumber(L, max);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static int tinsert (lua_State *L) {
|
||||
lua_Integer e = aux_getn(L, 1, TAB_RW) + 1; /* first empty element */
|
||||
lua_Integer pos; /* where to insert new element */
|
||||
@@ -425,9 +407,6 @@ static int sort (lua_State *L) {
|
||||
|
||||
static const luaL_Reg tab_funcs[] = {
|
||||
{"concat", tconcat},
|
||||
#if defined(LUA_COMPAT_MAXN)
|
||||
{"maxn", maxn},
|
||||
#endif
|
||||
{"insert", tinsert},
|
||||
{"pack", pack},
|
||||
{"unpack", unpack},
|
||||
@@ -440,11 +419,6 @@ static const luaL_Reg tab_funcs[] = {
|
||||
|
||||
LUAMOD_API int luaopen_table (lua_State *L) {
|
||||
luaL_newlib(L, tab_funcs);
|
||||
#if defined(LUA_COMPAT_UNPACK)
|
||||
/* _G.unpack = table.unpack */
|
||||
lua_getfield(L, -1, "unpack");
|
||||
lua_setglobal(L, "unpack");
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user