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 /liolib.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 'liolib.c')
-rw-r--r-- | liolib.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 1.26 1998/11/20 15:41:43 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 1.27 1998/12/27 20:21:28 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 | */ |
@@ -105,8 +105,11 @@ static FILE *getfileparam (char *name, int *arg) { | |||
105 | static char *getmode (char mode) { | 105 | static char *getmode (char mode) { |
106 | static char m[3]; | 106 | static char m[3]; |
107 | m[0] = mode; | 107 | m[0] = mode; |
108 | m[1] = (*luaL_opt_string(FIRSTARG+1, "text") == 'b') ? 'b' : '\0'; | 108 | if (*luaL_opt_string(FIRSTARG+1, "text") == 'b') { |
109 | m[2] = '\0'; | 109 | m[1] = 'b'; |
110 | m[2] = '\0'; | ||
111 | } | ||
112 | else m[1] = '\0'; | ||
110 | return m; | 113 | return m; |
111 | } | 114 | } |
112 | 115 | ||
@@ -308,7 +311,7 @@ static void io_read (void) { | |||
308 | l = luaL_getsize(); | 311 | l = luaL_getsize(); |
309 | if (!success && l==0) return; /* read fails */ | 312 | if (!success && l==0) return; /* read fails */ |
310 | lua_pushlstring(luaL_buffer(), l); | 313 | lua_pushlstring(luaL_buffer(), l); |
311 | } while ((p = luaL_opt_string(arg++, NULL))); | 314 | } while ((p = luaL_opt_string(arg++, NULL)) != NULL); |
312 | } | 315 | } |
313 | 316 | ||
314 | 317 | ||
@@ -319,7 +322,7 @@ static void io_write (void) { | |||
319 | char *s; | 322 | char *s; |
320 | long l; | 323 | long l; |
321 | while ((s = luaL_opt_lstr(arg++, NULL, &l)) != NULL) | 324 | while ((s = luaL_opt_lstr(arg++, NULL, &l)) != NULL) |
322 | status = status && (fwrite(s, 1, l, f) == l); | 325 | status = status && ((long)fwrite(s, 1, l, f) == l); |
323 | pushresult(status); | 326 | pushresult(status); |
324 | } | 327 | } |
325 | 328 | ||
@@ -329,7 +332,7 @@ static void io_seek (void) { | |||
329 | static char *modenames[] = {"set", "cur", "end", NULL}; | 332 | static char *modenames[] = {"set", "cur", "end", NULL}; |
330 | FILE *f = getfile(FIRSTARG-1+1); | 333 | FILE *f = getfile(FIRSTARG-1+1); |
331 | int op = luaL_findstring(luaL_opt_string(FIRSTARG-1+2, "cur"), modenames); | 334 | int op = luaL_findstring(luaL_opt_string(FIRSTARG-1+2, "cur"), modenames); |
332 | long offset = luaL_opt_number(FIRSTARG-1+3, 0); | 335 | long offset = luaL_opt_long(FIRSTARG-1+3, 0); |
333 | luaL_arg_check(f, FIRSTARG-1+1, "invalid file handler"); | 336 | luaL_arg_check(f, FIRSTARG-1+1, "invalid file handler"); |
334 | luaL_arg_check(op != -1, FIRSTARG-1+2, "invalid mode"); | 337 | luaL_arg_check(op != -1, FIRSTARG-1+2, "invalid mode"); |
335 | op = fseek(f, offset, mode[op]); | 338 | op = fseek(f, offset, mode[op]); |