aboutsummaryrefslogtreecommitdiff
path: root/iolib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-05-22 18:59:07 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-05-22 18:59:07 -0300
commit29f0021837b9e4f5624806e03ef493ec488ea114 (patch)
tree3c9223037eb979a34d6c656e883f1586f3f32eec /iolib.c
parent7acddb871d6b008abdc4bc306ee683086282bac4 (diff)
downloadlua-29f0021837b9e4f5624806e03ef493ec488ea114.tar.gz
lua-29f0021837b9e4f5624806e03ef493ec488ea114.tar.bz2
lua-29f0021837b9e4f5624806e03ef493ec488ea114.zip
variables which contain string lengths must be long (if they also may
be negative) or size_t.
Diffstat (limited to 'iolib.c')
-rw-r--r--iolib.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/iolib.c b/iolib.c
index 861665ee..9fec943c 100644
--- a/iolib.c
+++ b/iolib.c
@@ -3,7 +3,7 @@
3** Input/output library to LUA 3** Input/output library to LUA
4*/ 4*/
5 5
6char *rcs_iolib="$Id: iolib.c,v 1.43 1996/04/30 21:13:55 roberto Exp roberto $"; 6char *rcs_iolib="$Id: iolib.c,v 1.44 1996/05/03 20:10:59 roberto Exp roberto $";
7 7
8#include <stdio.h> 8#include <stdio.h>
9#include <ctype.h> 9#include <ctype.h>
@@ -141,7 +141,7 @@ static void io_appendto (void)
141} 141}
142 142
143 143
144static char getformat (char *f, int *just, int *m, int *n) 144static char getformat (char *f, int *just, long *m, int *n)
145{ 145{
146 int t; 146 int t;
147 switch (*f++) 147 switch (*f++)
@@ -211,7 +211,7 @@ static void read_until_blank (void)
211 if (c != EOF) ungetc(c,in); 211 if (c != EOF) ungetc(c,in);
212} 212}
213 213
214static void read_m (int m) 214static void read_m (size_t m)
215{ 215{
216 int c; 216 int c;
217 while (m-- && (c = fgetc(in)) != EOF) 217 while (m-- && (c = fgetc(in)) != EOF)
@@ -260,7 +260,8 @@ static void io_read (void)
260 read_free(); 260 read_free();
261 else /* formatted */ 261 else /* formatted */
262 { 262 {
263 int m, dummy1, dummy2; 263 long m;
264 int dummy1, dummy2;
264 switch (getformat(lua_check_string(1, "read"), &dummy1, &m, &dummy2)) 265 switch (getformat(lua_check_string(1, "read"), &dummy1, &m, &dummy2))
265 { 266 {
266 case 's': 267 case 's':
@@ -348,7 +349,7 @@ static void io_readuntil (void)
348** string -> nao se aplica 349** string -> nao se aplica
349*/ 350*/
350 351
351static int write_fill (int n, int c) 352static int write_fill (size_t n, int c)
352{ 353{
353 while (n--) 354 while (n--)
354 if (fputc(c, out) == EOF) 355 if (fputc(c, out) == EOF)
@@ -356,11 +357,11 @@ static int write_fill (int n, int c)
356 return 1; 357 return 1;
357} 358}
358 359
359static int write_string (char *s, int just, int m) 360static int write_string (char *s, int just, long m)
360{ 361{
361 int status; 362 int status;
362 int l = strlen(s); 363 size_t l = strlen(s);
363 int pre; /* number of blanks before string */ 364 size_t pre; /* number of blanks before string */
364 if (m < 0) m = l; 365 if (m < 0) m = l;
365 else if (l > m) 366 else if (l > m)
366 { 367 {
@@ -374,14 +375,14 @@ static int write_string (char *s, int just, int m)
374 return status; 375 return status;
375} 376}
376 377
377static int write_quoted (int just, int m) 378static int write_quoted (int just, long m)
378{ 379{
379 luaI_addchar(0); 380 luaI_addchar(0);
380 luaI_addquoted(lua_check_string(1, "write")); 381 luaI_addquoted(lua_check_string(1, "write"));
381 return write_string(luaI_addchar(0), just, m); 382 return write_string(luaI_addchar(0), just, m);
382} 383}
383 384
384static int write_float (int just, int m, int n) 385static int write_float (int just, long m, int n)
385{ 386{
386 char buffer[100]; 387 char buffer[100];
387 lua_Object p = lua_getparam(1); 388 lua_Object p = lua_getparam(1);
@@ -396,7 +397,7 @@ static int write_float (int just, int m, int n)
396} 397}
397 398
398 399
399static int write_int (int just, int m, int n) 400static int write_int (int just, long m, int n)
400{ 401{
401 char buffer[100]; 402 char buffer[100];
402 lua_Object p = lua_getparam(1); 403 lua_Object p = lua_getparam(1);
@@ -425,7 +426,8 @@ static void io_write (void)
425 } 426 }
426 else /* formated */ 427 else /* formated */
427 { 428 {
428 int just, m, n; 429 long m;
430 int just, n;
429 switch (getformat(lua_check_string(2, "write"), &just, &m, &n)) 431 switch (getformat(lua_check_string(2, "write"), &just, &m, &n))
430 { 432 {
431 case 's': 433 case 's':
@@ -490,7 +492,7 @@ static void io_errorno (void)
490 492
491 493
492/* 494/*
493** To get a environment variable 495** To get an environment variable
494*/ 496*/
495static void io_getenv (void) 497static void io_getenv (void)
496{ 498{