aboutsummaryrefslogtreecommitdiff
path: root/lstrlib.c
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 /lstrlib.c
parent255d59ed5e2743b97626eff57444f44defc39270 (diff)
downloadlua-3ccbae84d2be8e2978a65bcea15b3fffba7664f5.tar.gz
lua-3ccbae84d2be8e2978a65bcea15b3fffba7664f5.tar.bz2
lua-3ccbae84d2be8e2978a65bcea15b3fffba7664f5.zip
added some casts between integral types (to avoid warnings)
Diffstat (limited to 'lstrlib.c')
-rw-r--r--lstrlib.c12
1 files changed, 6 insertions, 6 deletions
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 ||