aboutsummaryrefslogtreecommitdiff
path: root/ltablib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-11-23 09:09:27 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-11-23 09:09:27 -0200
commitdc9ac5b8c2a3bc5410557db37d726a62b741ea0e (patch)
tree1c39958341a14a996c9042ff19dc43e341e6a4e0 /ltablib.c
parent146508b28e942fbfed5eedc6965857be558e9c57 (diff)
downloadlua-dc9ac5b8c2a3bc5410557db37d726a62b741ea0e.tar.gz
lua-dc9ac5b8c2a3bc5410557db37d726a62b741ea0e.tar.bz2
lua-dc9ac5b8c2a3bc5410557db37d726a62b741ea0e.zip
details (merging declarations with initialization)
Diffstat (limited to 'ltablib.c')
-rw-r--r--ltablib.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/ltablib.c b/ltablib.c
index d3e64e02..485b8405 100644
--- a/ltablib.c
+++ b/ltablib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltablib.c,v 1.85 2015/11/12 18:07:25 roberto Exp roberto $ 2** $Id: ltablib.c,v 1.86 2015/11/20 12:30:20 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*/
@@ -167,11 +167,10 @@ static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) {
167 167
168static int tconcat (lua_State *L) { 168static int tconcat (lua_State *L) {
169 luaL_Buffer b; 169 luaL_Buffer b;
170 size_t lsep;
171 lua_Integer i;
172 lua_Integer last = aux_getn(L, 1, TAB_R); 170 lua_Integer last = aux_getn(L, 1, TAB_R);
171 size_t lsep;
173 const char *sep = luaL_optlstring(L, 2, "", &lsep); 172 const char *sep = luaL_optlstring(L, 2, "", &lsep);
174 i = luaL_optinteger(L, 3, 1); 173 lua_Integer i = luaL_optinteger(L, 3, 1);
175 last = luaL_opt(L, luaL_checkinteger, 4, last); 174 last = luaL_opt(L, luaL_checkinteger, 4, last);
176 luaL_buffinit(L, &b); 175 luaL_buffinit(L, &b);
177 for (; i < last; i++) { 176 for (; i < last; i++) {
@@ -205,10 +204,9 @@ static int pack (lua_State *L) {
205 204
206 205
207static int unpack (lua_State *L) { 206static int unpack (lua_State *L) {
208 lua_Integer i, e;
209 lua_Unsigned n; 207 lua_Unsigned n;
210 i = luaL_optinteger(L, 2, 1); 208 lua_Integer i = luaL_optinteger(L, 2, 1);
211 e = luaL_opt(L, luaL_checkinteger, 3, luaL_len(L, 1)); 209 lua_Integer e = luaL_opt(L, luaL_checkinteger, 3, luaL_len(L, 1));
212 if (i > e) return 0; /* empty range */ 210 if (i > e) return 0; /* empty range */
213 n = (lua_Unsigned)e - i; /* number of elements minus 1 (avoid overflows) */ 211 n = (lua_Unsigned)e - i; /* number of elements minus 1 (avoid overflows) */
214 if (n >= (unsigned int)INT_MAX || !lua_checkstack(L, (int)(++n))) 212 if (n >= (unsigned int)INT_MAX || !lua_checkstack(L, (int)(++n)))