diff options
Diffstat (limited to 'ltablib.c')
-rw-r--r-- | ltablib.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -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 | ||
168 | static int tconcat (lua_State *L) { | 168 | static 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 | ||
207 | static int unpack (lua_State *L) { | 206 | static 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))) |