aboutsummaryrefslogtreecommitdiff
path: root/ltablib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-12-17 10:15:34 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-12-17 10:15:34 -0200
commitfe0d54d37edd3d28d42a01db013e04cc12e97f2f (patch)
tree70f8549d61cdf30c9a6640756fc33dcda7928927 /ltablib.c
parentc9af0768fc009bac1c2eb929a81e39b74f8956a5 (diff)
downloadlua-fe0d54d37edd3d28d42a01db013e04cc12e97f2f.tar.gz
lua-fe0d54d37edd3d28d42a01db013e04cc12e97f2f.tar.bz2
lua-fe0d54d37edd3d28d42a01db013e04cc12e97f2f.zip
table library respects '#' metamethods
Diffstat (limited to 'ltablib.c')
-rw-r--r--ltablib.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ltablib.c b/ltablib.c
index f1fb9cdd..64d13f2f 100644
--- a/ltablib.c
+++ b/ltablib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltablib.c,v 1.57 2010/10/25 19:01:37 roberto Exp roberto $ 2** $Id: ltablib.c,v 1.58 2010/11/23 17:21:14 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*/
@@ -17,7 +17,7 @@
17 17
18 18
19#define aux_getn(L,n) \ 19#define aux_getn(L,n) \
20 (luaL_checktype(L, n, LUA_TTABLE), (int)lua_rawlen(L, n)) 20 (luaL_checktype(L, n, LUA_TTABLE), luaL_len(L, n))
21 21
22 22
23static int deprecatedfunc (lua_State *L) { 23static int deprecatedfunc (lua_State *L) {
@@ -104,7 +104,7 @@ static int tconcat (lua_State *L) {
104 const char *sep = luaL_optlstring(L, 2, "", &lsep); 104 const char *sep = luaL_optlstring(L, 2, "", &lsep);
105 luaL_checktype(L, 1, LUA_TTABLE); 105 luaL_checktype(L, 1, LUA_TTABLE);
106 i = luaL_optint(L, 3, 1); 106 i = luaL_optint(L, 3, 1);
107 last = luaL_opt(L, luaL_checkint, 4, (int)lua_rawlen(L, 1)); 107 last = luaL_opt(L, luaL_checkint, 4, luaL_len(L, 1));
108 luaL_buffinit(L, &b); 108 luaL_buffinit(L, &b);
109 for (; i < last; i++) { 109 for (; i < last; i++) {
110 addfield(L, &b, i); 110 addfield(L, &b, i);
@@ -143,7 +143,7 @@ static int unpack (lua_State *L) {
143 int i, e, n; 143 int i, e, n;
144 luaL_checktype(L, 1, LUA_TTABLE); 144 luaL_checktype(L, 1, LUA_TTABLE);
145 i = luaL_optint(L, 2, 1); 145 i = luaL_optint(L, 2, 1);
146 e = luaL_opt(L, luaL_checkint, 3, (int)lua_rawlen(L, 1)); 146 e = luaL_opt(L, luaL_checkint, 3, luaL_len(L, 1));
147 if (i > e) return 0; /* empty range */ 147 if (i > e) return 0; /* empty range */
148 n = e - i + 1; /* number of elements */ 148 n = e - i + 1; /* number of elements */
149 if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ 149 if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */