diff options
Diffstat (limited to 'ltablib.c')
-rw-r--r-- | ltablib.c | 28 |
1 files changed, 1 insertions, 27 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltablib.c,v 1.93 2016/02/25 19:41:54 roberto Exp roberto $ | 2 | ** $Id: ltablib.c,v 1.94 2018/02/25 12:48:16 roberto Exp roberto $ |
3 | ** Library for Table Manipulation | 3 | ** Library for Table Manipulation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -58,24 +58,6 @@ static void checktab (lua_State *L, int arg, int what) { | |||
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | #if defined(LUA_COMPAT_MAXN) | ||
62 | static int maxn (lua_State *L) { | ||
63 | lua_Number max = 0; | ||
64 | luaL_checktype(L, 1, LUA_TTABLE); | ||
65 | lua_pushnil(L); /* first key */ | ||
66 | while (lua_next(L, 1)) { | ||
67 | lua_pop(L, 1); /* remove value */ | ||
68 | if (lua_type(L, -1) == LUA_TNUMBER) { | ||
69 | lua_Number v = lua_tonumber(L, -1); | ||
70 | if (v > max) max = v; | ||
71 | } | ||
72 | } | ||
73 | lua_pushnumber(L, max); | ||
74 | return 1; | ||
75 | } | ||
76 | #endif | ||
77 | |||
78 | |||
79 | static int tinsert (lua_State *L) { | 61 | static int tinsert (lua_State *L) { |
80 | lua_Integer e = aux_getn(L, 1, TAB_RW) + 1; /* first empty element */ | 62 | lua_Integer e = aux_getn(L, 1, TAB_RW) + 1; /* first empty element */ |
81 | lua_Integer pos; /* where to insert new element */ | 63 | lua_Integer pos; /* where to insert new element */ |
@@ -425,9 +407,6 @@ static int sort (lua_State *L) { | |||
425 | 407 | ||
426 | static const luaL_Reg tab_funcs[] = { | 408 | static const luaL_Reg tab_funcs[] = { |
427 | {"concat", tconcat}, | 409 | {"concat", tconcat}, |
428 | #if defined(LUA_COMPAT_MAXN) | ||
429 | {"maxn", maxn}, | ||
430 | #endif | ||
431 | {"insert", tinsert}, | 410 | {"insert", tinsert}, |
432 | {"pack", pack}, | 411 | {"pack", pack}, |
433 | {"unpack", unpack}, | 412 | {"unpack", unpack}, |
@@ -440,11 +419,6 @@ static const luaL_Reg tab_funcs[] = { | |||
440 | 419 | ||
441 | LUAMOD_API int luaopen_table (lua_State *L) { | 420 | LUAMOD_API int luaopen_table (lua_State *L) { |
442 | luaL_newlib(L, tab_funcs); | 421 | luaL_newlib(L, tab_funcs); |
443 | #if defined(LUA_COMPAT_UNPACK) | ||
444 | /* _G.unpack = table.unpack */ | ||
445 | lua_getfield(L, -1, "unpack"); | ||
446 | lua_setglobal(L, "unpack"); | ||
447 | #endif | ||
448 | return 1; | 422 | return 1; |
449 | } | 423 | } |
450 | 424 | ||