diff options
Diffstat (limited to 'ltablib.c')
-rw-r--r-- | ltablib.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltablib.c,v 1.71 2014/07/16 12:44:52 roberto Exp roberto $ | 2 | ** $Id: ltablib.c,v 1.72 2014/07/25 18:46:00 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 | */ |
@@ -227,13 +227,13 @@ static int unpack (lua_State *L) { | |||
227 | e = luaL_opt(L, luaL_checkinteger, 3, luaL_len(L, 1)); | 227 | e = luaL_opt(L, luaL_checkinteger, 3, luaL_len(L, 1)); |
228 | if (i > e) return 0; /* empty range */ | 228 | if (i > e) return 0; /* empty range */ |
229 | n = (lua_Unsigned)e - i; /* number of elements minus 1 (avoid overflows) */ | 229 | n = (lua_Unsigned)e - i; /* number of elements minus 1 (avoid overflows) */ |
230 | if (n >= (unsigned int)INT_MAX || !lua_checkstack(L, ++n)) | 230 | if (n >= (unsigned int)INT_MAX || !lua_checkstack(L, (int)(++n))) |
231 | return luaL_error(L, "too many results to unpack"); | 231 | return luaL_error(L, "too many results to unpack"); |
232 | do { /* must have at least one element */ | 232 | do { /* must have at least one element */ |
233 | (*ta.geti)(L, 1, i); /* push arg[i..e] */ | 233 | (*ta.geti)(L, 1, i); /* push arg[i..e] */ |
234 | } while (i++ < e); | 234 | } while (i++ < e); |
235 | 235 | ||
236 | return n; | 236 | return (int)n; |
237 | } | 237 | } |
238 | 238 | ||
239 | /* }====================================================== */ | 239 | /* }====================================================== */ |
@@ -334,11 +334,11 @@ static void auxsort (lua_State *L, TabA *ta, int l, int u) { | |||
334 | 334 | ||
335 | static int sort (lua_State *L) { | 335 | static int sort (lua_State *L) { |
336 | TabA ta; | 336 | TabA ta; |
337 | int n = aux_getn(L, 1, &ta); | 337 | int n = (int)aux_getn(L, 1, &ta); |
338 | luaL_checkstack(L, 50, ""); /* assume array is smaller than 2^50 */ | 338 | luaL_checkstack(L, 50, ""); /* assume array is smaller than 2^50 */ |
339 | if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ | 339 | if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ |
340 | luaL_checktype(L, 2, LUA_TFUNCTION); | 340 | luaL_checktype(L, 2, LUA_TFUNCTION); |
341 | lua_settop(L, 2); /* make sure there is two arguments */ | 341 | lua_settop(L, 2); /* make sure there are two arguments */ |
342 | auxsort(L, &ta, 1, n); | 342 | auxsort(L, &ta, 1, n); |
343 | return 0; | 343 | return 0; |
344 | } | 344 | } |