From a67c6273255c0357bf1e14ea35005b47c9a94e6c Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 6 Jul 2000 00:20:50 +0000 Subject: Lots and lots of cleanups. -Erik --- libc/stdio/stdio.c | 56 +++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'libc/stdio/stdio.c') diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c index 98d0ba3b4..9043e6199 100644 --- a/libc/stdio/stdio.c +++ b/libc/stdio/stdio.c @@ -6,15 +6,19 @@ /* This is an implementation of the C standard IO package. */ +#include #include - +#include #include #include #include #include +#include #undef STUB_FWRITE +void __io_init_vars(void); + extern FILE *__IO_list; /* For fflush at exit */ #define FIXED_BUFFERS 2 @@ -80,10 +84,7 @@ FILE stderr[1] = /* Call the stdio initiliser; it's main job it to call atexit */ -#define STATIC - -STATIC int -__stdio_close_all() +void __stdio_close_all(void) { FILE *fp; fflush(stdout); @@ -103,8 +104,7 @@ static int first_time = 0; struct fixed_buffer _fixed_buffers[2]; -STATIC void -__io_init_vars() +void __io_init_vars(void) { if( first_time ) return; first_time = 1; @@ -206,7 +206,9 @@ FILE *fp; if (fp->mode & __MODE_WRITING) fflush(fp); +#if __MODE_IOTRAN try_again: +#endif /* Can't read or there's been an EOF or error then return EOF */ if ((fp->mode & (__MODE_READ | __MODE_EOF | __MODE_ERR)) != __MODE_READ) return EOF; @@ -319,7 +321,7 @@ FILE *fp; char * fgets(s, count, f) char *s; -size_t count; +int count; FILE *f; { char *ret; @@ -368,7 +370,7 @@ char *str; #ifdef L_fputs int fputs(str, fp) -char *str; +const char *str; FILE *fp; { register int n = 0; @@ -385,7 +387,7 @@ FILE *fp; #ifdef L_puts int puts(str) -char *str; +const char *str; { register int n; @@ -405,12 +407,12 @@ char *str; * This ignores __MODE__IOTRAN; probably exactly what you want. (It _is_ what * fgetc wants) */ -int +size_t fread(buf, size, nelm, fp) -char *buf; -int size; -int nelm; -FILE *fp; +void *buf; +size_t size; +size_t nelm; +FILE *fp; { int len, v; unsigned bytes, got = 0; @@ -467,12 +469,12 @@ FILE *fp; * * Again this ignores __MODE__IOTRAN. */ -int +size_t fwrite(buf, size, nelm, fp) -char *buf; -int size; -int nelm; -FILE *fp; +const void *buf; +size_t size; +size_t nelm; +FILE *fp; { register int v; int len; @@ -606,7 +608,6 @@ int ref; long ftell(fp) FILE * fp; { - long rv; if (fflush(fp) == EOF) return EOF; return lseek(fp->fd, 0L, SEEK_CUR); @@ -620,10 +621,10 @@ FILE * fp; */ FILE * __fopen(fname, fd, fp, mode) -char *fname; +const char *fname; int fd; FILE *fp; -char *mode; +const char *mode; { int open_mode = 0; #if __MODE_IOTRAN @@ -875,8 +876,8 @@ size_t size; if( mode == _IOFBF || mode == _IOLBF ) { - if( size <= 0 ) size = BUFSIZ; - if( buf == 0 ) + if( size <= 0 ) { size = BUFSIZ; } + if( buf == 0 ) { if (size == BUFSIZ) { int i; for(i=0;ibufstart = buf; @@ -896,6 +899,7 @@ size_t size; fp->mode |= mode; } fp->bufpos = fp->bufread = fp->bufwrite = fp->bufstart; + return 0; } #endif -- cgit v1.2.3