diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-12-28 11:44:54 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-12-28 11:44:54 -0200 |
commit | 766e67ef3b2af42f800b281e0fa0f57c7e3d2e3f (patch) | |
tree | 96fbaa15baec33d4f14b27df79778e766ef46f57 /lstrlib.c | |
parent | 4c94d8cc2cbeac74ae3618b1322c3f3d3ec166ea (diff) | |
download | lua-766e67ef3b2af42f800b281e0fa0f57c7e3d2e3f.tar.gz lua-766e67ef3b2af42f800b281e0fa0f57c7e3d2e3f.tar.bz2 lua-766e67ef3b2af42f800b281e0fa0f57c7e3d2e3f.zip |
to avoid warnings about "typecast" (Visual C++)
Diffstat (limited to 'lstrlib.c')
-rw-r--r-- | lstrlib.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.20 1998/11/10 19:38:12 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.21 1998/12/01 18:41:25 roberto Exp roberto $ |
3 | ** Standard library for strings and pattern-matching | 3 | ** Standard library for strings and pattern-matching |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -46,8 +46,8 @@ static long posrelat (long pos, long len) { | |||
46 | static void str_sub (void) { | 46 | static void str_sub (void) { |
47 | long l; | 47 | long l; |
48 | char *s = luaL_check_lstr(1, &l); | 48 | char *s = luaL_check_lstr(1, &l); |
49 | long start = posrelat(luaL_check_number(2), l); | 49 | long start = posrelat(luaL_check_long(2), l); |
50 | long end = posrelat(luaL_opt_number(3, -1), l); | 50 | long end = posrelat(luaL_opt_long(3, -1), l); |
51 | if (start < 1) start = 1; | 51 | if (start < 1) start = 1; |
52 | if (end > l) end = l; | 52 | if (end > l) end = l; |
53 | if (start <= end) | 53 | if (start <= end) |
@@ -82,7 +82,7 @@ static void str_rep (void) | |||
82 | { | 82 | { |
83 | long l; | 83 | long l; |
84 | char *s = luaL_check_lstr(1, &l); | 84 | char *s = luaL_check_lstr(1, &l); |
85 | int n = (int)luaL_check_number(2); | 85 | int n = luaL_check_int(2); |
86 | luaL_resetbuffer(); | 86 | luaL_resetbuffer(); |
87 | while (n-- > 0) | 87 | while (n-- > 0) |
88 | addnchar(s, l); | 88 | addnchar(s, l); |
@@ -94,7 +94,7 @@ static void str_byte (void) | |||
94 | { | 94 | { |
95 | long l; | 95 | long l; |
96 | char *s = luaL_check_lstr(1, &l); | 96 | char *s = luaL_check_lstr(1, &l); |
97 | long pos = posrelat(luaL_opt_number(2, 1), l); | 97 | long pos = posrelat(luaL_opt_long(2, 1), l); |
98 | luaL_arg_check(0<pos && pos<=l, 2, "out of range"); | 98 | luaL_arg_check(0<pos && pos<=l, 2, "out of range"); |
99 | lua_pushnumber((unsigned char)s[pos-1]); | 99 | lua_pushnumber((unsigned char)s[pos-1]); |
100 | } | 100 | } |
@@ -105,7 +105,7 @@ static void str_char (void) { | |||
105 | while (lua_getparam(++i) != LUA_NOOBJECT) { | 105 | while (lua_getparam(++i) != LUA_NOOBJECT) { |
106 | double c = luaL_check_number(i); | 106 | double c = luaL_check_number(i); |
107 | luaL_arg_check((unsigned char)c == c, i, "invalid value"); | 107 | luaL_arg_check((unsigned char)c == c, i, "invalid value"); |
108 | luaL_addchar((int)c); | 108 | luaL_addchar((unsigned char)c); |
109 | } | 109 | } |
110 | closeandpush(); | 110 | closeandpush(); |
111 | } | 111 | } |
@@ -338,7 +338,7 @@ static void str_find (void) | |||
338 | long l; | 338 | long l; |
339 | char *s = luaL_check_lstr(1, &l); | 339 | char *s = luaL_check_lstr(1, &l); |
340 | char *p = luaL_check_string(2); | 340 | char *p = luaL_check_string(2); |
341 | long init = posrelat(luaL_opt_number(3, 1), l) - 1; | 341 | long init = posrelat(luaL_opt_long(3, 1), l) - 1; |
342 | struct Capture cap; | 342 | struct Capture cap; |
343 | luaL_arg_check(0 <= init && init <= l, 3, "out of range"); | 343 | luaL_arg_check(0 <= init && init <= l, 3, "out of range"); |
344 | if (lua_getparam(4) != LUA_NOOBJECT || | 344 | if (lua_getparam(4) != LUA_NOOBJECT || |
@@ -418,7 +418,7 @@ static void str_gsub (void) | |||
418 | char *src = luaL_check_lstr(1, &srcl); | 418 | char *src = luaL_check_lstr(1, &srcl); |
419 | char *p = luaL_check_string(2); | 419 | char *p = luaL_check_string(2); |
420 | lua_Object newp = lua_getparam(3); | 420 | lua_Object newp = lua_getparam(3); |
421 | int max_s = (int)luaL_opt_number(4, srcl+1); | 421 | int max_s = luaL_opt_int(4, srcl+1); |
422 | int anchor = (*p == '^') ? (p++, 1) : 0; | 422 | int anchor = (*p == '^') ? (p++, 1) : 0; |
423 | int n = 0; | 423 | int n = 0; |
424 | struct Capture cap; | 424 | struct Capture cap; |
@@ -507,7 +507,7 @@ static void str_format (void) | |||
507 | break; | 507 | break; |
508 | } | 508 | } |
509 | case 'c': case 'd': case 'i': | 509 | case 'c': case 'd': case 'i': |
510 | sprintf(buff, form, (int)luaL_check_number(arg)); | 510 | sprintf(buff, form, luaL_check_int(arg)); |
511 | break; | 511 | break; |
512 | case 'o': case 'u': case 'x': case 'X': | 512 | case 'o': case 'u': case 'x': case 'X': |
513 | sprintf(buff, form, (unsigned int)luaL_check_number(arg)); | 513 | sprintf(buff, form, (unsigned int)luaL_check_number(arg)); |