added some casts between integral types (to avoid warnings)

This commit is contained in:
Roberto Ierusalimschy 2014-07-29 13:01:00 -03:00
parent 255d59ed5e
commit 3ccbae84d2
4 changed files with 15 additions and 15 deletions

View File

@ -1,5 +1,5 @@
/*
** $Id: liolib.c,v 2.126 2014/06/02 03:00:51 roberto Exp roberto $
** $Id: liolib.c,v 2.127 2014/06/30 19:48:08 roberto Exp roberto $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@ -654,7 +654,7 @@ static int f_setvbuf (lua_State *L) {
FILE *f = tofile(L);
int op = luaL_checkoption(L, 2, NULL, modenames);
lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE);
int res = setvbuf(f, NULL, mode[op], sz);
int res = setvbuf(f, NULL, mode[op], (size_t)sz);
return luaL_fileresult(L, res == 0, NULL);
}

View File

@ -1,5 +1,5 @@
/*
** $Id: loadlib.c,v 1.114 2014/07/16 13:56:14 roberto Exp roberto $
** $Id: loadlib.c,v 1.115 2014/07/28 17:47:53 roberto Exp roberto $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@ -293,7 +293,7 @@ static void addtoclib (lua_State *L, const char *path, void *plib) {
** handles in list CLIBS
*/
static int gctm (lua_State *L) {
int n = luaL_len(L, 1);
lua_Integer n = luaL_len(L, 1);
for (; n >= 1; n--) { /* for each handle, in reverse order */
lua_rawgeti(L, 1, n); /* get handle CLIBS[n] */
lsys_unloadlib(lua_touserdata(L, -1));

View File

@ -1,5 +1,5 @@
/*
** $Id: lstrlib.c,v 1.197 2014/04/16 18:48:31 roberto Exp roberto $
** $Id: lstrlib.c,v 1.198 2014/04/27 14:42:26 roberto Exp roberto $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
@ -59,7 +59,7 @@ static int str_sub (lua_State *L) {
if (start < 1) start = 1;
if (end > (lua_Integer)l) end = l;
if (start <= end)
lua_pushlstring(L, s + start - 1, end - start + 1);
lua_pushlstring(L, s + start - 1, (size_t)(end - start + 1));
else lua_pushliteral(L, "");
return 1;
}
@ -119,7 +119,7 @@ static int str_rep (lua_State *L) {
else if (l + lsep < l || l + lsep > MAXSIZE / n) /* may overflow? */
return luaL_error(L, "resulting string too large");
else {
size_t totallen = n * l + (n - 1) * lsep;
size_t totallen = (size_t)n * l + (size_t)(n - 1) * lsep;
luaL_Buffer b;
char *p = luaL_buffinitsize(L, &b, totallen);
while (n-- > 1) { /* first n-1 copies (followed by separator) */
@ -594,7 +594,7 @@ static int str_find_aux (lua_State *L, int find) {
/* explicit request or no special characters? */
if (find && (lua_toboolean(L, 4) || nospecials(p, lp))) {
/* do a plain search */
const char *s2 = lmemfind(s + init - 1, ls - init + 1, p, lp);
const char *s2 = lmemfind(s + init - 1, ls - (size_t)init + 1, p, lp);
if (s2) {
lua_pushinteger(L, s2 - s + 1);
lua_pushinteger(L, s2 - s + lp);
@ -744,9 +744,9 @@ static int str_gsub (lua_State *L) {
const char *src = luaL_checklstring(L, 1, &srcl);
const char *p = luaL_checklstring(L, 2, &lp);
int tr = lua_type(L, 3);
size_t max_s = luaL_optinteger(L, 4, srcl+1);
lua_Integer max_s = luaL_optinteger(L, 4, srcl + 1);
int anchor = (*p == '^');
size_t n = 0;
lua_Integer n = 0;
MatchState ms;
luaL_Buffer b;
luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||

View File

@ -1,5 +1,5 @@
/*
** $Id: ltablib.c,v 1.71 2014/07/16 12:44:52 roberto Exp roberto $
** $Id: ltablib.c,v 1.72 2014/07/25 18:46:00 roberto Exp roberto $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/
@ -227,13 +227,13 @@ static int unpack (lua_State *L) {
e = luaL_opt(L, luaL_checkinteger, 3, luaL_len(L, 1));
if (i > e) return 0; /* empty range */
n = (lua_Unsigned)e - i; /* number of elements minus 1 (avoid overflows) */
if (n >= (unsigned int)INT_MAX || !lua_checkstack(L, ++n))
if (n >= (unsigned int)INT_MAX || !lua_checkstack(L, (int)(++n)))
return luaL_error(L, "too many results to unpack");
do { /* must have at least one element */
(*ta.geti)(L, 1, i); /* push arg[i..e] */
} while (i++ < e);
return n;
return (int)n;
}
/* }====================================================== */
@ -334,11 +334,11 @@ static void auxsort (lua_State *L, TabA *ta, int l, int u) {
static int sort (lua_State *L) {
TabA ta;
int n = aux_getn(L, 1, &ta);
int n = (int)aux_getn(L, 1, &ta);
luaL_checkstack(L, 50, ""); /* assume array is smaller than 2^50 */
if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */
luaL_checktype(L, 2, LUA_TFUNCTION);
lua_settop(L, 2); /* make sure there is two arguments */
lua_settop(L, 2); /* make sure there are two arguments */
auxsort(L, &ta, 1, n);
return 0;
}