diff options
Diffstat (limited to 'stdio')
| -rw-r--r-- | stdio/fclose.c | 10 | ||||
| -rw-r--r-- | stdio/feof.c | 14 | ||||
| -rw-r--r-- | stdio/ferror.c | 14 | ||||
| -rw-r--r-- | stdio/fflush.c | 16 | ||||
| -rw-r--r-- | stdio/fgetc.c | 12 | ||||
| -rw-r--r-- | stdio/fgetpos.c | 19 | ||||
| -rw-r--r-- | stdio/fgets.c | 18 | ||||
| -rw-r--r-- | stdio/fileno.c | 12 | ||||
| -rw-r--r-- | stdio/fmemopen.c | 15 | ||||
| -rw-r--r-- | stdio/fopen.c | 19 | ||||
| -rw-r--r-- | stdio/fputc.c | 13 | ||||
| -rw-r--r-- | stdio/fread.c | 26 | ||||
| -rw-r--r-- | stdio/freopen.c | 15 | ||||
| -rw-r--r-- | stdio/fseek.c | 17 | ||||
| -rw-r--r-- | stdio/fsetpos.c | 11 | ||||
| -rw-r--r-- | stdio/ftell.c | 8 | ||||
| -rw-r--r-- | stdio/fwrite.c | 21 | ||||
| -rw-r--r-- | stdio/getdelim.c | 16 | ||||
| -rw-r--r-- | stdio/gets.c | 14 | ||||
| -rw-r--r-- | stdio/glue.c | 15 | ||||
| -rw-r--r-- | stdio/internals.c | 108 | ||||
| -rw-r--r-- | stdio/memstream.c | 32 | ||||
| -rw-r--r-- | stdio/setvbuf.c | 22 | ||||
| -rw-r--r-- | stdio/ungetc.c | 11 | ||||
| -rw-r--r-- | stdio/vsscanf.c | 15 |
25 files changed, 263 insertions, 230 deletions
diff --git a/stdio/fclose.c b/stdio/fclose.c index bcf4cd4163..413d8f3d7b 100644 --- a/stdio/fclose.c +++ b/stdio/fclose.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1995 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> @@ -26,7 +25,8 @@ Cambridge, MA 02139, USA. */ /* Close a stream. */ int -DEFUN(fclose, (stream), register FILE *stream) +fclose (stream) + register FILE *stream; { int status; @@ -42,10 +42,10 @@ DEFUN(fclose, (stream), register FILE *stream) if (!__validfp(stream)) { - errno = EINVAL; + __set_errno (EINVAL); return EOF; } - + if (stream->__mode.__write && /* Flush the buffer. */ __flshfp (stream, EOF) == EOF) diff --git a/stdio/feof.c b/stdio/feof.c index c18300f6b5..b98220799f 100644 --- a/stdio/feof.c +++ b/stdio/feof.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <errno.h> #include <stdio.h> @@ -25,13 +24,14 @@ Cambridge, MA 02139, USA. */ /* Return non-zero if STREAM has its EOF indicator set. */ int -DEFUN(feof, (stream), FILE *stream) +feof (stream) + FILE *stream; { - if (!__validfp(stream)) + if (!__validfp (stream)) { - errno = EINVAL; - return(-1); + __set_errno (EINVAL); + return -1; } - return(stream->__eof); + return stream->__eof; } diff --git a/stdio/ferror.c b/stdio/ferror.c index ed8f74401a..857b250201 100644 --- a/stdio/ferror.c +++ b/stdio/ferror.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <errno.h> #include <stdio.h> @@ -25,13 +24,14 @@ Cambridge, MA 02139, USA. */ /* Return non-zero if STREAM has its error indicator set. */ int -DEFUN(ferror, (stream), FILE *stream) +ferror (stream) + FILE *stream; { - if (!__validfp(stream)) + if (!__validfp (stream)) { - errno = EINVAL; - return(-1); + __set_errno (EINVAL); + return -1; } - return(stream->__error); + return stream->__error; } diff --git a/stdio/fflush.c b/stdio/fflush.c index a6d52ba3e7..41e66fa540 100644 --- a/stdio/fflush.c +++ b/stdio/fflush.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -24,22 +23,23 @@ Cambridge, MA 02139, USA. */ /* Flush STREAM's buffer. If STREAM is NULL, flush the buffers of all streams that are writing. */ int -DEFUN(fflush, (stream), register FILE *stream) +fflush (stream) + register FILE *stream; { if (stream == NULL) { int lossage = 0; for (stream = __stdio_head; stream != NULL; stream = stream->__next) - if (__validfp(stream) && stream->__mode.__write) - lossage |= fflush(stream) == EOF; + if (__validfp (stream) && stream->__mode.__write) + lossage |= fflush (stream) == EOF; return lossage ? EOF : 0; } - if (!__validfp(stream) || !stream->__mode.__write) + if (!__validfp (stream) || !stream->__mode.__write) { - errno = EINVAL; + __set_errno (EINVAL); return EOF; } - return __flshfp(stream, EOF); + return __flshfp (stream, EOF); } diff --git a/stdio/fgetc.c b/stdio/fgetc.c index 7f01090294..9bfff3477a 100644 --- a/stdio/fgetc.c +++ b/stdio/fgetc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,20 +16,20 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <errno.h> #include <stdio.h> /* Read a character from STREAM. */ int -DEFUN(fgetc, (stream), FILE *stream) +fgetc (stream) + FILE *stream; { - if (!__validfp(stream) || !stream->__mode.__read) + if (!__validfp (stream) || !stream->__mode.__read) { - errno = EINVAL; + __set_errno (EINVAL); return EOF; } - return __getc(stream); + return __getc (stream); } diff --git a/stdio/fgetpos.c b/stdio/fgetpos.c index cb6a1588ba..a615081c99 100644 --- a/stdio/fgetpos.c +++ b/stdio/fgetpos.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <errno.h> #include <stdio.h> @@ -25,16 +24,18 @@ Cambridge, MA 02139, USA. */ /* Put the current position of STREAM in *POS. */ int -DEFUN(fgetpos, (stream, pos), FILE *stream AND fpos_t *pos) +fgetpos (stream, pos) + FILE *stream; + fpos_t *pos; { - if (!__validfp(stream) || pos == NULL) + if (!__validfp (stream) || pos == NULL) { - errno = EINVAL; - return(-1); + __set_errno (EINVAL); + return -1; } - *pos = ftell(stream); + *pos = ftell (stream); if (*pos < 0L) - return(-1); - return(0); + return -1; + return 0; } diff --git a/stdio/fgets.c b/stdio/fgets.c index e9e53c88dd..01d4d9d095 100644 --- a/stdio/fgets.c +++ b/stdio/fgets.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <errno.h> #include <stdio.h> #include <string.h> @@ -28,13 +27,16 @@ Cambridge, MA 02139, USA. */ to S, the function returns NULL without appending the null character. If there is a file error, always return NULL. */ char * -DEFUN(fgets, (s, n, stream), char *s AND int n AND register FILE *stream) +fgets (s, n, stream) + char *s; + int n; + register FILE *stream; { register char *p = s; - if (!__validfp(stream) || s == NULL || n <= 0) + if (!__validfp (stream) || s == NULL || n <= 0) { - errno = EINVAL; + __set_errno (EINVAL); return NULL; } @@ -45,7 +47,7 @@ DEFUN(fgets, (s, n, stream), char *s AND int n AND register FILE *stream) { /* Unbuffered stream. Not much optimization to do. */ register int c = 0; - while (--n > 0 && (c = getc (stream)) != EOF) + while (--n > 0 && (c = getc (stream)) != EOF) if ((*p++ = c) == '\n') break; if (c == EOF && (p == s || ferror (stream))) @@ -79,7 +81,7 @@ DEFUN(fgets, (s, n, stream), char *s AND int n AND register FILE *stream) size_t i; char *found; - i = stream->__get_limit - stream->__bufp; + i = stream->__get_limit - stream->__bufp; if (i == 0) { /* Refill the buffer. */ @@ -93,7 +95,7 @@ DEFUN(fgets, (s, n, stream), char *s AND int n AND register FILE *stream) *p = '\0'; return s; } - i = stream->__get_limit - stream->__bufp; + i = stream->__get_limit - stream->__bufp; } if (i > n) diff --git a/stdio/fileno.c b/stdio/fileno.c index da55300c8b..dc3dfdf6e2 100644 --- a/stdio/fileno.c +++ b/stdio/fileno.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1993, 1994, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,19 +16,19 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <errno.h> #include <stdio.h> /* Return the system file descriptor associated with STREAM. */ int -DEFUN(fileno, (stream), FILE *stream) +fileno (stream) + FILE *stream; { extern void __stdio_check_funcs __P ((FILE *)); if (! __validfp (stream)) { - errno = EINVAL; + __set_errno (EINVAL); return -1; } @@ -37,9 +37,9 @@ DEFUN(fileno, (stream), FILE *stream) if (stream->__io_funcs.__fileno == NULL) { #ifdef EOPNOTSUPP - errno = EOPNOTSUPP; + __set_errno (EOPNOTSUPP); #else - errno = ENOSYS; + __set_errno (ENOSYS); #endif return -1; } diff --git a/stdio/fmemopen.c b/stdio/fmemopen.c index 42a137a2c8..a161110703 100644 --- a/stdio/fmemopen.c +++ b/stdio/fmemopen.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <errno.h> #include <stddef.h> #include <stdio.h> @@ -25,7 +24,7 @@ Cambridge, MA 02139, USA. */ /* Defined in fopen.c. */ -extern int EXFUN(__getmode, (CONST char *mode, __io_mode *mptr)); +extern int __getmode __P ((const char *mode, __io_mode *mptr)); /* Open a new stream that will read and/or write from the buffer in S, which is of LEN bytes. If the mode indicates appending, the @@ -40,8 +39,10 @@ extern int EXFUN(__getmode, (CONST char *mode, __io_mode *mptr)); to read, attempted writes always return an output error and attempted reads always return end-of-file. */ FILE * -DEFUN(fmemopen, (s, len, mode), - PTR s AND size_t len AND CONST char *mode) +fmemopen (s, len, mode) + void *s; + size_t len; + const char *mode; { __io_mode m; register FILE *stream; @@ -77,7 +78,7 @@ DEFUN(fmemopen, (s, len, mode), { int save = errno; (void) fclose (stream); - errno = save; + __set_errno (save); return NULL; } } @@ -102,7 +103,7 @@ DEFUN(fmemopen, (s, len, mode), stream->__bufp = p; } else if (stream->__mode.__truncate) - memset ((PTR) stream->__buffer, 0, len); + memset ((void *) stream->__buffer, 0, len); return stream; } diff --git a/stdio/fopen.c b/stdio/fopen.c index fba6ac436a..fea227482f 100644 --- a/stdio/fopen.c +++ b/stdio/fopen.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <ctype.h> #include <errno.h> #include <stdio.h> @@ -24,18 +23,20 @@ Cambridge, MA 02139, USA. */ #include <string.h> -#define badmode() return ((errno = EINVAL), 0) +#define badmode() return ((__set_errno (EINVAL)), 0) /* Dissect the given mode string into an __io_mode. */ int -DEFUN(__getmode, (mode, mptr), CONST char *mode AND __io_mode *mptr) +__getmode (mode, mptr) + const char *mode; + __io_mode *mptr; { register unsigned char i; if (mode == NULL) badmode (); - memset ((PTR) mptr, 0, sizeof (*mptr)); + memset ((void *) mptr, 0, sizeof (*mptr)); switch (*mode) { @@ -78,14 +79,16 @@ DEFUN(__getmode, (mode, mptr), CONST char *mode AND __io_mode *mptr) /* Open a new stream on the given file. */ FILE * -DEFUN(fopen, (filename, mode), CONST char *filename AND CONST char *mode) +fopen (filename, mode) + const char *filename; + const char *mode; { FILE *stream; __io_mode m; if (filename == NULL) { - errno = EINVAL; + __set_errno (EINVAL); return NULL; } @@ -100,7 +103,7 @@ DEFUN(fopen, (filename, mode), CONST char *filename AND CONST char *mode) { int save = errno; (void) fclose (stream); - errno = save; + __set_errno (save); return NULL; } diff --git a/stdio/fputc.c b/stdio/fputc.c index 36b9501195..2cbba2a449 100644 --- a/stdio/fputc.c +++ b/stdio/fputc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,20 +16,21 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <errno.h> #include <stdio.h> /* Write the character C to STREAM. */ int -DEFUN(fputc, (c, stream), int c AND FILE *stream) +fputc (c, stream) + int c; + FILE *stream; { - if (!__validfp(stream) || !stream->__mode.__write) + if (!__validfp (stream) || !stream->__mode.__write) { - errno = EINVAL; + __set_errno (EINVAL); return EOF; } - return __putc(c, stream); + return __putc (c, stream); } diff --git a/stdio/fread.c b/stdio/fread.c index d2766f6616..63d41d2bd0 100644 --- a/stdio/fread.c +++ b/stdio/fread.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <errno.h> #include <stdio.h> #include <string.h> @@ -26,19 +25,22 @@ Cambridge, MA 02139, USA. */ /* Read NMEMB chunks of SIZE bytes each from STREAM into P. */ size_t -DEFUN(fread, (p, size, nmemb, stream), - PTR p AND size_t size AND size_t nmemb AND register FILE *stream) +fread (p, size, nmemb, stream) + void *p; + size_t size; + size_t nmemb; + register FILE *stream; { register char *ptr = (char *) p; register size_t to_read = size * nmemb; size_t bytes = to_read; - if (!__validfp(stream) || !stream->__mode.__read) + if (!__validfp (stream) || !stream->__mode.__read) { - errno = EINVAL; + __set_errno (EINVAL); return 0; } - if (feof(stream) || ferror(stream)) + if (feof (stream) || ferror (stream)) return 0; if (p == NULL || to_read == 0) return 0; @@ -48,7 +50,7 @@ DEFUN(fread, (p, size, nmemb, stream), /* This stream has never been seen before, or it has a character pushed back. Call __fillbf to deal with those cases. Life will be simpler after this call. */ - int c = __fillbf(stream); + int c = __fillbf (stream); if (c == EOF) return 0; *ptr++ = c; @@ -65,7 +67,7 @@ DEFUN(fread, (p, size, nmemb, stream), |
