From 3ccbae84d2be8e2978a65bcea15b3fffba7664f5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 29 Jul 2014 13:01:00 -0300 Subject: added some casts between integral types (to avoid warnings) --- lstrlib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lstrlib.c') diff --git a/lstrlib.c b/lstrlib.c index bbf6fbb1..5289e8b7 100644 --- a/lstrlib.c +++ b/lstrlib.c @@ -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 || -- cgit v1.2.3-55-g6feb