aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-29 13:01:00 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-29 13:01:00 -0300
commit3ccbae84d2be8e2978a65bcea15b3fffba7664f5 (patch)
tree5d375f2e0c64840e2849620043aafe9bd17e46d9
parent255d59ed5e2743b97626eff57444f44defc39270 (diff)
downloadlua-3ccbae84d2be8e2978a65bcea15b3fffba7664f5.tar.gz
lua-3ccbae84d2be8e2978a65bcea15b3fffba7664f5.tar.bz2
lua-3ccbae84d2be8e2978a65bcea15b3fffba7664f5.zip
added some casts between integral types (to avoid warnings)
-rw-r--r--liolib.c4
-rw-r--r--loadlib.c4
-rw-r--r--lstrlib.c12
-rw-r--r--ltablib.c10
4 files changed, 15 insertions, 15 deletions
diff --git a/liolib.c b/liolib.c
index b7f4c55a..42dcb7ef 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 2.126 2014/06/02 03:00:51 roberto Exp roberto $ 2** $Id: liolib.c,v 2.127 2014/06/30 19:48:08 roberto Exp roberto $
3** Standard I/O (and system) library 3** Standard I/O (and system) library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -654,7 +654,7 @@ static int f_setvbuf (lua_State *L) {
654 FILE *f = tofile(L); 654 FILE *f = tofile(L);
655 int op = luaL_checkoption(L, 2, NULL, modenames); 655 int op = luaL_checkoption(L, 2, NULL, modenames);
656 lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); 656 lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE);
657 int res = setvbuf(f, NULL, mode[op], sz); 657 int res = setvbuf(f, NULL, mode[op], (size_t)sz);
658 return luaL_fileresult(L, res == 0, NULL); 658 return luaL_fileresult(L, res == 0, NULL);
659} 659}
660 660
diff --git a/loadlib.c b/loadlib.c
index c85ef405..bf5ca9da 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: loadlib.c,v 1.114 2014/07/16 13:56:14 roberto Exp roberto $ 2** $Id: loadlib.c,v 1.115 2014/07/28 17:47:53 roberto Exp roberto $
3** Dynamic library loader for Lua 3** Dynamic library loader for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5** 5**
@@ -293,7 +293,7 @@ static void addtoclib (lua_State *L, const char *path, void *plib) {
293** handles in list CLIBS 293** handles in list CLIBS
294*/ 294*/
295static int gctm (lua_State *L) { 295static int gctm (lua_State *L) {
296 int n = luaL_len(L, 1); 296 lua_Integer n = luaL_len(L, 1);
297 for (; n >= 1; n--) { /* for each handle, in reverse order */ 297 for (; n >= 1; n--) { /* for each handle, in reverse order */
298 lua_rawgeti(L, 1, n); /* get handle CLIBS[n] */ 298 lua_rawgeti(L, 1, n); /* get handle CLIBS[n] */
299 lsys_unloadlib(lua_touserdata(L, -1)); 299 lsys_unloadlib(lua_touserdata(L, -1));
diff --git a/lstrlib.c b/lstrlib.c
index bbf6fbb1..5289e8b7 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.197 2014/04/16 18:48:31 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.198 2014/04/27 14:42:26 roberto Exp roberto $
3** Standard library for string operations and pattern-matching 3** Standard library for string operations and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -59,7 +59,7 @@ static int str_sub (lua_State *L) {
59 if (start < 1) start = 1; 59 if (start < 1) start = 1;
60 if (end > (lua_Integer)l) end = l; 60 if (end > (lua_Integer)l) end = l;
61 if (start <= end) 61 if (start <= end)
62 lua_pushlstring(L, s + start - 1, end - start + 1); 62 lua_pushlstring(L, s + start - 1, (size_t)(end - start + 1));
63 else lua_pushliteral(L, ""); 63 else lua_pushliteral(L, "");
64 return 1; 64 return 1;
65} 65}
@@ -119,7 +119,7 @@ static int str_rep (lua_State *L) {
119 else if (l + lsep < l || l + lsep > MAXSIZE / n) /* may overflow? */ 119 else if (l + lsep < l || l + lsep > MAXSIZE / n) /* may overflow? */
120 return luaL_error(L, "resulting string too large"); 120 return luaL_error(L, "resulting string too large");
121 else { 121 else {
122 size_t totallen = n * l + (n - 1) * lsep; 122 size_t totallen = (size_t)n * l + (size_t)(n - 1) * lsep;
123 luaL_Buffer b; 123 luaL_Buffer b;
124 char *p = luaL_buffinitsize(L, &b, totallen); 124 char *p = luaL_buffinitsize(L, &b, totallen);
125 while (n-- > 1) { /* first n-1 copies (followed by separator) */ 125 while (n-- > 1) { /* first n-1 copies (followed by separator) */
@@ -594,7 +594,7 @@ static int str_find_aux (lua_State *L, int find) {
594 /* explicit request or no special characters? */ 594 /* explicit request or no special characters? */
595 if (find && (lua_toboolean(L, 4) || nospecials(p, lp))) { 595 if (find && (lua_toboolean(L, 4) || nospecials(p, lp))) {
596 /* do a plain search */ 596 /* do a plain search */
597 const char *s2 = lmemfind(s + init - 1, ls - init + 1, p, lp); 597 const char *s2 = lmemfind(s + init - 1, ls - (size_t)init + 1, p, lp);
598 if (s2) { 598 if (s2) {
599 lua_pushinteger(L, s2 - s + 1); 599 lua_pushinteger(L, s2 - s + 1);
600 lua_pushinteger(L, s2 - s + lp); 600 lua_pushinteger(L, s2 - s + lp);
@@ -744,9 +744,9 @@ static int str_gsub (lua_State *L) {
744 const char *src = luaL_checklstring(L, 1, &srcl); 744 const char *src = luaL_checklstring(L, 1, &srcl);
745 const char *p = luaL_checklstring(L, 2, &lp); 745 const char *p = luaL_checklstring(L, 2, &lp);
746 int tr = lua_type(L, 3); 746 int tr = lua_type(L, 3);
747 size_t max_s = luaL_optinteger(L, 4, srcl+1); 747 lua_Integer max_s = luaL_optinteger(L, 4, srcl + 1);
748 int anchor = (*p == '^'); 748 int anchor = (*p == '^');
749 size_t n = 0; 749 lua_Integer n = 0;
750 MatchState ms; 750 MatchState ms;
751 luaL_Buffer b; 751 luaL_Buffer b;
752 luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || 752 luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
diff --git a/ltablib.c b/ltablib.c
index 5d27cb2f..cc72cc4b 100644
--- a/ltablib.c
+++ b/ltablib.c
@@ -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
335static int sort (lua_State *L) { 335static 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}