aboutsummaryrefslogtreecommitdiff
path: root/ltablib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-27 15:47:32 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-27 15:47:32 -0300
commit34b00c16e28c2bbc3e633b4007de956130905ed6 (patch)
treefca960c3f8f1945a052a776722ccef4944b748fa /ltablib.c
parent12110dec0eda3813b7609051aedb0cde932fbf93 (diff)
downloadlua-34b00c16e28c2bbc3e633b4007de956130905ed6.tar.gz
lua-34b00c16e28c2bbc3e633b4007de956130905ed6.tar.bz2
lua-34b00c16e28c2bbc3e633b4007de956130905ed6.zip
removed compatibility code with older versions
Diffstat (limited to 'ltablib.c')
-rw-r--r--ltablib.c28
1 files changed, 1 insertions, 27 deletions
diff --git a/ltablib.c b/ltablib.c
index 982821ed..22bfae42 100644
--- a/ltablib.c
+++ b/ltablib.c
@@ -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)
62static 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
79static int tinsert (lua_State *L) { 61static 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
426static const luaL_Reg tab_funcs[] = { 408static 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
441LUAMOD_API int luaopen_table (lua_State *L) { 420LUAMOD_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