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 bcf4cd4..413d8f3 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 c18300f..b982207 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 ed8f744..857b250 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 a6d52ba..41e66fa 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 7f01090..9bfff34 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 cb6a158..a615081 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 e9e53c8..01d4d9d 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 da55300..dc3dfdf 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 42a137a..a161110 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 fba6ac4..fea2274 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 36b95011..2cbba2a 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 d2766f6..63d41d2 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), copy = to_read; to_read -= copy; if (copy > 20) - memcpy((PTR) ptr, (PTR) stream->__bufp, copy); + memcpy((void *) ptr, (void *) stream->__bufp, copy); else { register size_t i; @@ -90,8 +92,8 @@ DEFUN(fread, (p, size, nmemb, stream), while (to_read > 0) { register int count; - count = (*stream->__io_funcs.__read)(stream->__cookie, - ptr, to_read); + count = (*stream->__io_funcs.__read) (stream->__cookie, + ptr, to_read); if (count > 0) { to_read -= count; @@ -118,7 +120,7 @@ DEFUN(fread, (p, size, nmemb, stream), } else { - int c = __fillbf(stream); + int c = __fillbf (stream); if (c == EOF) return (bytes - to_read) / size; *ptr++ = (char) c; diff --git a/stdio/freopen.c b/stdio/freopen.c index bedddb1..a21d725 100644 --- a/stdio/freopen.c +++ b/stdio/freopen.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1994, 1995 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994, 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> @@ -30,16 +29,18 @@ extern int __stdio_reopen __P ((const char *filename, __io_mode mode, /* Replace STREAM, opening it on FILENAME. */ FILE * -DEFUN(freopen, (filename, mode, stream), - CONST char *filename AND CONST char *mode AND register FILE *stream) +freopen (filename, mode, stream) + const char *filename; + const char *mode; + register FILE *stream; { __io_mode m; - PTR cookie; + void *cookie; if (!__getmode (mode, &m)) { (void) fclose (stream); - errno = EINVAL; + __set_errno (EINVAL); return NULL; } @@ -56,7 +57,7 @@ DEFUN(freopen, (filename, mode, stream), { int save = errno; (void) fclose (stream); - errno = save; + __set_errno (save); return NULL; } diff --git a/stdio/fseek.c b/stdio/fseek.c index 2127c97..9dce18f 100644 --- a/stdio/fseek.c +++ b/stdio/fseek.c @@ -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> @@ -26,14 +25,16 @@ Cambridge, MA 02139, USA. */ is SEEK_SET, the end of the file is it is SEEK_END, or the current position if it is SEEK_CUR. */ int -DEFUN(fseek, (stream, offset, whence), - register FILE *stream AND long int offset AND int whence) +fseek (stream, offset, whence) + register FILE *stream; + long int offset; + int whence; { long int o; if (!__validfp (stream)) { - errno = EINVAL; + __set_errno (EINVAL); return EOF; } @@ -63,7 +64,7 @@ DEFUN(fseek, (stream, offset, whence), switch (whence) { default: - errno = EINVAL; + __set_errno (EINVAL); return EOF; case SEEK_END: @@ -72,7 +73,7 @@ DEFUN(fseek, (stream, offset, whence), for, and then look where that is. */ if (stream->__io_funcs.__seek == NULL) { - errno = ESPIPE; + __set_errno (ESPIPE); return EOF; } else @@ -144,7 +145,7 @@ DEFUN(fseek, (stream, offset, whence), if (o < 0) { /* Negative file position is meaningless. */ - errno = EINVAL; + __set_errno (EINVAL); return -1; } @@ -167,7 +168,7 @@ DEFUN(fseek, (stream, offset, whence), But it makes more sense for fseek to to fail with ESPIPE than for the next reading or writing operation to fail that way. */ - errno = ESPIPE; + __set_errno (ESPIPE); return EOF; } diff --git a/stdio/fsetpos.c b/stdio/fsetpos.c index 7c8fcb7..6aea674 100644 --- a/stdio/fsetpos.c +++ b/stdio/fsetpos.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,15 @@ Cambridge, MA 02139, USA. */ /* Set the file position of STREAM to *POS. */ int -DEFUN(fsetpos, (stream, pos), FILE *stream AND CONST fpos_t *pos) +fsetpos (stream, pos) + FILE *stream; + const fpos_t *pos; { if (pos == NULL) { - errno = EINVAL; + __set_errno (EINVAL); return EOF; } - return fseek(stream, *pos, SEEK_SET); + return fseek (stream, *pos, SEEK_SET); } diff --git a/stdio/ftell.c b/stdio/ftell.c index d27eaf7..d715f20 100644 --- a/stdio/ftell.c +++ b/stdio/ftell.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 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,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> /* Return the offset in bytes from the beginning of the file of the file position of STREAM. */ long int -DEFUN(ftell, (stream), FILE *stream) +ftell (stream) + FILE *stream; { long int pos; if (!__validfp (stream)) { - errno = EINVAL; + __set_errno (EINVAL); return -1L; } diff --git a/stdio/fwrite.c b/stdio/fwrite.c index 790c663..7cf3898 100644 --- a/stdio/fwrite.c +++ b/stdio/fwrite.c @@ -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> @@ -24,11 +23,13 @@ Cambridge, MA 02139, USA. */ /* Write NMEMB chunks of SIZE bytes each from PTR onto STREAM. */ size_t -DEFUN(fwrite, (ptr, size, nmemb, stream), - CONST PTR ptr AND size_t size AND - size_t nmemb AND register FILE *stream) +fwrite (ptr, size, nmemb, stream) + const void *ptr; + size_t size; + size_t nmemb; + register FILE *stream; { - register CONST unsigned char *p = (CONST unsigned char *) ptr; + register const unsigned char *p = (const unsigned char *) ptr; register size_t to_write = size * nmemb; register size_t written = 0; int newlinep; @@ -37,7 +38,7 @@ DEFUN(fwrite, (ptr, size, nmemb, stream), if (!__validfp (stream) || !stream->__mode.__write) { - errno = EINVAL; + __set_errno (EINVAL); return 0; } @@ -71,7 +72,7 @@ DEFUN(fwrite, (ptr, size, nmemb, stream), goto done; } - errno = save; + __set_errno (save); } if (stream->__buffer == NULL && default_func && @@ -82,7 +83,7 @@ DEFUN(fwrite, (ptr, size, nmemb, stream), { int count = (stream->__io_funcs.__write == NULL ? to_write : (*stream->__io_funcs.__write) (stream->__cookie, - (CONST char *) p, + (const char *) p, to_write)); if (count > 0) { @@ -105,7 +106,7 @@ DEFUN(fwrite, (ptr, size, nmemb, stream), buffer_space = stream->__bufsize - (stream->__bufp - stream->__buffer); newlinep = (stream->__linebuf && - memchr ((CONST PTR) p, '\n', to_write) != NULL); + memchr ((const void *) p, '\n', to_write) != NULL); if (newlinep && stream->__bufp == stream->__buffer && stream->__offset == stream->__target) @@ -148,7 +149,7 @@ DEFUN(fwrite, (ptr, size, nmemb, stream), *stream->__bufp++ = *p++; else { - memcpy ((PTR) stream->__bufp, (PTR) p, n); + memcpy ((void *) stream->__bufp, (void *) p, n); stream->__bufp += n; p += n; } diff --git a/stdio/getdelim.c b/stdio/getdelim.c index 2cdb95c..761c798 100644 --- a/stdio/getdelim.c +++ b/stdio/getdelim.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 <stddef.h> #include <stdio.h> #include <stdlib.h> @@ -31,15 +30,18 @@ Cambridge, MA 02139, USA. */ null terminator), or -1 on error or EOF. */ ssize_t -DEFUN(__getdelim, (lineptr, n, terminator, stream), - char **lineptr AND size_t *n AND int terminator AND FILE *stream) +__getdelim (lineptr, n, terminator, stream) + char **lineptr; + size_t *n; + int terminator; + FILE *stream; { char *line, *p; size_t size, copy; if (!__validfp (stream) || lineptr == NULL || n == NULL) { - errno = EINVAL; + __set_errno (EINVAL); return -1; } @@ -116,7 +118,7 @@ DEFUN(__getdelim, (lineptr, n, terminator, stream), size_t i; char *found; - i = stream->__get_limit - stream->__bufp; + i = stream->__get_limit - stream->__bufp; if (i == 0) { /* Refill the buffer. */ @@ -127,7 +129,7 @@ DEFUN(__getdelim, (lineptr, n, terminator, stream), if (c == terminator) goto win; --copy; - i = stream->__get_limit - stream->__bufp; + i = stream->__get_limit - stream->__bufp; } if (i > copy) diff --git a/stdio/gets.c b/stdio/gets.c index 37426cf..7f84c92 100644 --- a/stdio/gets.c +++ b/stdio/gets.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1994, 1995 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994, 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 <stdio.h> #include <errno.h> #include <string.h> @@ -27,22 +26,23 @@ link_warning (gets, /* Read a newline-terminated string from stdin into S, removing the trailing newline. Return S or NULL. */ char * -DEFUN(gets, (s), char *s) +gets (s) + char *s; { register char *p = s; register int c; FILE *stream = stdin; - if (!__validfp(stream) || p == NULL) + if (!__validfp (stream) || p == NULL) { - errno = EINVAL; + __set_errno (EINVAL); return NULL; } - if (feof(stream) || ferror(stream)) + if (feof (stream) || ferror (stream)) return NULL; - while ((c = getchar()) != EOF) + while ((c = getchar ()) != EOF) if (c == '\n') break; else diff --git a/stdio/glue.c b/stdio/glue.c index 6ef52a7..592700f 100644 --- a/stdio/glue.c +++ b/stdio/glue.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 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 @@ -27,7 +27,6 @@ Cambridge, MA 02139, USA. */ libraries) compiled with Unix header files to work with the GNU C library. */ -#include <ansidecl.h> #include <stdio.h> #include <errno.h> @@ -74,7 +73,8 @@ unix_FILE _iob[] = In a Unix stdio FILE `_cnt' is the first element. In a GNU stdio or glued FILE, the first element is the magic number. */ int -DEFUN(_filbuf, (file), unix_FILE *file) +_filbuf (file) + unix_FILE *file; { switch (++file->glue.magic) /* Compensate for Unix getc's decrement. */ { @@ -88,15 +88,16 @@ DEFUN(_filbuf, (file), unix_FILE *file) default: /* Bogus stream. */ - errno = EINVAL; + __set_errno (EINVAL); return EOF; } } /* Called by the Unix stdio `putc' macro. Much like getc, above. */ int -DEFUN(_flsbuf, (c, file), - int c AND unix_FILE *file) +_flsbuf (c, file) + int c; + unix_FILE *file; { /* Compensate for putc's decrement. */ switch (++file->glue.magic) @@ -108,7 +109,7 @@ DEFUN(_flsbuf, (c, file), return putc (c, (FILE *) file); default: - errno = EINVAL; + __set_errno (EINVAL); return EOF; } } diff --git a/stdio/internals.c b/stdio/internals.c index a1d1fa4..8c2acc4 100644 --- a/stdio/internals.c +++ b/stdio/internals.c @@ -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> @@ -25,7 +24,8 @@ Cambridge, MA 02139, USA. */ /* Make sure that FP has its functions set. */ void -DEFUN(__stdio_check_funcs, (fp), register FILE *fp) +__stdio_check_funcs (fp) + register FILE *fp; { if (!fp->__seen) { @@ -34,7 +34,7 @@ DEFUN(__stdio_check_funcs, (fp), register FILE *fp) If no buffer is set (and the stream is not made explicitly unbuffered), we allocate a buffer below, using the bufsize set by this function. */ - extern void EXFUN(__stdio_init_stream, (FILE *)); + extern void __stdio_init_stream __P ((FILE *)); fp->__room_funcs = __default_room_functions; fp->__io_funcs = __default_io_functions; __stdio_init_stream (fp); @@ -51,7 +51,8 @@ DEFUN(__stdio_check_funcs, (fp), register FILE *fp) /* Figure out what kind of buffering (none, line, or full) and what buffer size to give FP. */ static void -DEFUN(init_stream, (fp), register FILE *fp) +init_stream (fp) + register FILE *fp; { __stdio_check_funcs (fp); @@ -69,13 +70,13 @@ DEFUN(init_stream, (fp), register FILE *fp) save = errno; while (fp->__bufsize >= MIN_BUFSIZE) { - fp->__buffer = (char *) malloc(fp->__bufsize); + fp->__buffer = (char *) malloc (fp->__bufsize); if (fp->__buffer == NULL) fp->__bufsize /= 2; else break; } - errno = save; + __set_errno (save); if (fp->__buffer == NULL) { @@ -96,7 +97,8 @@ DEFUN(init_stream, (fp), register FILE *fp) /* Determine the current file position of STREAM if it is unknown. */ int -DEFUN(__stdio_check_offset, (stream), FILE *stream) +__stdio_check_offset (stream) + FILE *stream; { init_stream (stream); @@ -106,15 +108,15 @@ DEFUN(__stdio_check_offset, (stream), FILE *stream) if (stream->__io_funcs.__seek == NULL) { /* Unknowable. */ - errno = ESPIPE; + __set_errno (ESPIPE); return EOF; } else { /* Unknown. Find it out. */ fpos_t pos = (fpos_t) 0; - if ((*stream->__io_funcs.__seek)(stream->__cookie, - &pos, SEEK_CUR) < 0) + if ((*stream->__io_funcs.__seek) (stream->__cookie, + &pos, SEEK_CUR) < 0) { if (errno == ESPIPE) /* Object is incapable of seeking. */ @@ -139,13 +141,14 @@ DEFUN(__stdio_check_offset, (stream), FILE *stream) seeking as necessary and updating its `offset' field. Sets ferror(FP) (and possibly errno) for errors. */ static void -DEFUN(seek_to_target, (fp), FILE *fp) +seek_to_target (fp) + FILE *fp; { int save = errno; if (__stdio_check_offset (fp) == EOF) { if (errno == ESPIPE) - errno = save; + __set_errno (save); else fp->__error = 1; } @@ -156,13 +159,13 @@ DEFUN(seek_to_target, (fp), FILE *fp) if (fp->__io_funcs.__seek == NULL) { /* We can't seek! */ - errno = ESPIPE; + __set_errno (ESPIPE); fp->__error = 1; } else { fpos_t pos = fp->__target; - if ((*fp->__io_funcs.__seek)(fp->__cookie, &pos, SEEK_SET) < 0) + if ((*fp->__io_funcs.__seek) (fp->__cookie, &pos, SEEK_SET) < 0) /* Seek failed! */ fp->__error = 1; else @@ -175,10 +178,10 @@ DEFUN(seek_to_target, (fp), FILE *fp) #ifdef EGRATUITOUS /* It happens in the Hurd when the io server doesn't obey the protocol for io_seek. */ - errno = EGRATUITOUS; + __set_errno (EGRATUITOUS); #else /* I don't think this can happen in Unix. */ - errno = ESPIPE; /* ??? */ + __set_errno (ESPIPE); /* ??? */ #endif fp->__error = 1; } @@ -194,8 +197,9 @@ DEFUN(seek_to_target, (fp), FILE *fp) flushed to avoid a system call for a single character. This is the default `output room' function. */ static void -DEFUN(flushbuf, (fp, c), - register FILE *fp AND int c) +flushbuf (fp, c) + register FILE *fp; + int c; { int flush_only = c == EOF; size_t buffer_written; @@ -223,21 +227,21 @@ DEFUN(flushbuf, (fp, c), !fp->__mode.__append) { int save = errno; - CONST int aligned = (fp->__buffer == NULL || - __stdio_check_offset(fp) == EOF || + const int aligned = (fp->__buffer == NULL || + __stdio_check_offset (fp) == EOF || fp->__target % fp->__bufsize == 0); - errno = save; + __set_errno (save); if (!aligned) { /* Move to a block (buffer size) boundary and read in a block. Then the output will be written as a whole block, too. */ - CONST size_t o = fp->__target % fp->__bufsize; + const size_t o = fp->__target % fp->__bufsize; fp->__target -= o; - if ((*fp->__room_funcs.__input)(fp) == EOF && ferror(fp)) + if ((*fp->__room_funcs.__input) (fp) == EOF && ferror (fp)) return; else - __clearerr(fp); + __clearerr (fp); if (fp->__get_limit - fp->__buffer < o) /* Oops. We didn't read enough (probably because we got EOF). @@ -322,8 +326,8 @@ DEFUN(flushbuf, (fp, c), if (!ferror(fp)) { /* Write out the buffered data. */ - wrote = (*fp->__io_funcs.__write)(fp->__cookie, fp->__buffer, - to_write); + wrote = (*fp->__io_funcs.__write) (fp->__cookie, fp->__buffer, + to_write); if (wrote > 0) { if (fp->__mode.__append) @@ -347,7 +351,7 @@ DEFUN(flushbuf, (fp, c), fp->__bufp = fp->__buffer; /* If we're not just flushing, write the last character, C. */ - if (!flush_only && !ferror(fp)) + if (!flush_only && !ferror (fp)) { if (fp->__buffer == NULL || (fp->__linebuf && (unsigned char) c == '\n')) { @@ -382,7 +386,7 @@ DEFUN(flushbuf, (fp, c), fp->__get_limit = fp->__buffer; } - if (feof(fp) || ferror(fp)) + if (feof (fp) || ferror (fp)) fp->__bufp = fp->__put_limit; } @@ -390,7 +394,8 @@ DEFUN(flushbuf, (fp, c), /* Fill the buffer for FP and return the first character read (or EOF). This is the default `input_room' function. */ static int -DEFUN(fillbuf, (fp), register FILE *fp) +fillbuf (fp) + register FILE *fp; { /* How far into the buffer we read we want to start bufp. */ size_t buffer_offset = 0; @@ -435,13 +440,13 @@ DEFUN(fillbuf, (fp), register FILE *fp) } seek_to_target (fp); } - errno = save; + __set_errno (save); } - while (!ferror(fp) && !feof(fp) && nread <= buffer_offset) + while (!ferror (fp) && !feof (fp) && nread <= buffer_offset) { /* Try to fill the buffer. */ - int count = (*fp->__io_funcs.__read)(fp->__cookie, buffer, to_read); + int count = (*fp->__io_funcs.__read) (fp->__cookie, buffer, to_read); if (count == 0) fp->__eof = 1; else if (count < 0) @@ -460,7 +465,7 @@ DEFUN(fillbuf, (fp), register FILE *fp) if (fp->__buffer == NULL) /* There is no buffer, so return the character we read without all the buffer pointer diddling. */ - return (feof(fp) || ferror(fp)) ? EOF : c; + return (feof (fp) || ferror (fp)) ? EOF : c; /* Reset the buffer pointer to the beginning of the buffer (plus whatever offset we may have set above). */ @@ -468,7 +473,7 @@ DEFUN(fillbuf, (fp), register FILE *fp) end:; - if (feof(fp) || ferror(fp)) + if (feof (fp) || ferror (fp)) { /* Set both end pointers to the beginning of the buffer so the next i/o call will force a call to __fillbf/__flshfp. */ @@ -494,12 +499,12 @@ extern __io_write_fn __stdio_write; extern __io_seek_fn __stdio_seek; extern __io_close_fn __stdio_close; extern __io_fileno_fn __stdio_fileno; -CONST __io_functions __default_io_functions = +const __io_functions __default_io_functions = { __stdio_read, __stdio_write, __stdio_seek, __stdio_close, __stdio_fileno }; -CONST __room_functions __default_room_functions = +const __room_functions __default_room_functions = { fillbuf, flushbuf }; @@ -508,18 +513,19 @@ CONST __room_functions __default_room_functions = /* Flush the buffer for FP and also write C if FLUSH_ONLY is nonzero. This is the function used by putc and fflush. */ int -DEFUN(__flshfp, (fp, c), - register FILE *fp AND int c) +__flshfp (fp, c) + register FILE *fp; + int c; { int flush_only = c == EOF; - if (!__validfp(fp) || !fp->__mode.__write) + if (!__validfp (fp) || !fp->__mode.__write) { - errno = EINVAL; + __set_errno (EINVAL); return EOF; } - if (ferror(fp)) + if (ferror (fp)) return EOF; if (fp->__pushed_back) @@ -530,7 +536,7 @@ DEFUN(__flshfp, (fp, c), } /* Make sure the stream is initialized (has functions and buffering). */ - init_stream(fp); + init_stream (fp); /* Do this early, so a `putc' on such a stream will never return success. */ if (fp->__room_funcs.__output == NULL) @@ -589,14 +595,15 @@ DEFUN(__flshfp, (fp, c), /* Fill the buffer for FP and return the first character read. This is the function used by getc. */ int -DEFUN(__fillbf, (fp), register FILE *fp) +__fillbf (fp) + register FILE *fp; { register int c; fpos_t new_target; - if (!__validfp(fp) || !fp->__mode.__read) + if (!__validfp (fp) || !fp->__mode.__read) { - errno = EINVAL; + __set_errno (EINVAL); return EOF; } @@ -609,7 +616,7 @@ DEFUN(__fillbf, (fp), register FILE *fp) } /* Make sure the stream is initialized (has functions and buffering). */ - init_stream(fp); + init_stream (fp); /* If we're trying to read the first character of a new line of input from an unbuffered or line buffered stream, @@ -648,11 +655,11 @@ DEFUN(__fillbf, (fp), register FILE *fp) fp->__target = new_target; - if (ferror(fp)) + if (ferror (fp)) c = EOF; else if (fp->__room_funcs.__input != NULL) { - c = (*fp->__room_funcs.__input)(fp); + c = (*fp->__room_funcs.__input) (fp); if (fp->__buffer == NULL) /* This is an unbuffered stream, so the target sync above won't do anything the next time around. Instead, note that @@ -673,13 +680,14 @@ DEFUN(__fillbf, (fp), register FILE *fp) /* Nuke a stream, but don't kill its link in the chain. */ void -DEFUN(__invalidate, (stream), register FILE *stream) +__invalidate (stream) + register FILE *stream; { /* Save its link. */ register FILE *next = stream->__next; /* Pulverize the fucker. */ - memset((PTR) stream, 0, sizeof(FILE)); + memset((void *) stream, 0, sizeof(FILE)); /* Restore the deceased's link. */ stream->__next = next; diff --git a/stdio/memstream.c b/stdio/memstream.c index 1a8b350..ab285f4 100644 --- a/stdio/memstream.c +++ b/stdio/memstream.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1994, 1995 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 94, 95, 96 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 <stdio.h> #include <stdlib.h> #include <string.h> @@ -30,8 +29,9 @@ struct memstream_info /* Enlarge STREAM's buffer. */ static void -DEFUN(enlarge_buffer, (stream, c), - register FILE *stream AND int c) +enlarge_buffer (stream, c) + register FILE *stream; + int c; { struct memstream_info *info = (struct memstream_info *) stream->__cookie; size_t need; @@ -64,7 +64,7 @@ DEFUN(enlarge_buffer, (stream, c), newsize = need; else newsize = stream->__bufsize * 2; - newbuf = (char *) realloc ((PTR) stream->__buffer, newsize); + newbuf = (char *) realloc ((void *) stream->__buffer, newsize); if (newbuf == NULL) { stream->__error = 1; @@ -82,7 +82,7 @@ DEFUN(enlarge_buffer, (stream, c), if (need > 0) { /* We are extending the buffer after an fseek; zero-fill new space. */ - bzero (stream->__bufp, need); + memset (stream->__bufp, '\0', need); stream->__bufp += need; } @@ -96,8 +96,10 @@ DEFUN(enlarge_buffer, (stream, c), There is no external state to munge. */ static int -DEFUN(seek, (cookie, pos, whence), - PTR cookie AND fpos_t *pos AND int whence) +seek (cookie, pos, whence) + void *cookie; + fpos_t *pos; + int whence; { switch (whence) { @@ -118,7 +120,8 @@ DEFUN(seek, (cookie, pos, whence), } static int -DEFUN(free_info, (cookie), PTR cookie) +free_info (cookie) + void *cookie; { #if 0 struct memstream_info *info = (struct memstream_info *) cookie; @@ -138,15 +141,16 @@ DEFUN(free_info, (cookie), PTR cookie) necessary. *BUFLOC and *SIZELOC are updated with the buffer's location and the number of characters written on fflush or fclose. */ FILE * -DEFUN(open_memstream, (bufloc, sizeloc), - char **bufloc AND size_t *sizeloc) +open_memstream (bufloc, sizeloc) + char **bufloc; + size_t *sizeloc; { FILE *stream; struct memstream_info *info; if (bufloc == NULL || sizeloc == NULL) { - errno = EINVAL; + __set_errno (EINVAL); return NULL; } @@ -159,14 +163,14 @@ DEFUN(open_memstream, (bufloc, sizeloc), { int save = errno; (void) fclose (stream); - errno = save; + __set_errno (save); return NULL; } stream->__room_funcs.__output = enlarge_buffer; stream->__io_funcs.__seek = seek; stream->__io_funcs.__close = free_info; - stream->__cookie = (PTR) info; + stream->__cookie = (void *) info; stream->__userbuf = 1; info->buffer = bufloc; diff --git a/stdio/setvbuf.c b/stdio/setvbuf.c index 6bfe829..ba79959 100644 --- a/stdio/setvbuf.c +++ b/stdio/setvbuf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1993, 1995 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1993, 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> @@ -27,12 +26,15 @@ Cambridge, MA 02139, USA. */ If MODE indicates full or line buffering, use BUF, a buffer of SIZE bytes; if BUF is NULL, malloc a buffer. */ int -DEFUN(setvbuf, (stream, buf, mode, size), - FILE *stream AND char *buf AND int mode AND size_t size) +setvbuf (stream, buf, mode, size) + FILE *stream; + char *buf; + int mode; + size_t size; { - if (!__validfp(stream)) + if (!__validfp (stream)) { - errno = EINVAL; + __set_errno (EINVAL); return EOF; } @@ -40,7 +42,7 @@ DEFUN(setvbuf, (stream, buf, mode, size), but we allow it to replace an old buffer, flushing it first. */ if (stream->__buffer != NULL) { - (void) fflush(stream); + (void) fflush (stream); /* Free the old buffer if it was malloc'd. */ if (!stream->__userbuf) free(stream->__buffer); @@ -53,7 +55,7 @@ DEFUN(setvbuf, (stream, buf, mode, size), switch (mode) { default: - errno = EINVAL; + __set_errno (EINVAL); return EOF; case _IONBF: /* Unbuffered. */ stream->__buffer = NULL; @@ -65,13 +67,13 @@ DEFUN(setvbuf, (stream, buf, mode, size), case _IOFBF: /* Fully buffered. */ if (size == 0) { - errno = EINVAL; + __set_errno (EINVAL); return EOF; } stream->__bufsize = size; if (buf != NULL) stream->__userbuf = 1; - else if ((buf = (char *) malloc(size)) == NULL) + else if ((buf = (char *) malloc (size)) == NULL) return EOF; stream->__buffer = buf; break; diff --git a/stdio/ungetc.c b/stdio/ungetc.c index 7b22a20..834f5be 100644 --- a/stdio/ungetc.c +++ b/stdio/ungetc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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,18 +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> /* Push the character C back onto the input stream of STREAM. */ int -DEFUN(ungetc, (c, stream), register int c AND register FILE *stream) +ungetc (c, stream) + register int c; + register FILE *stream; { - if (!__validfp(stream) || !stream->__mode.__read) + if (!__validfp (stream) || !stream->__mode.__read) { - errno = EINVAL; + __set_errno (EINVAL); return EOF; } diff --git a/stdio/vsscanf.c b/stdio/vsscanf.c index 6f027d5..5e53829 100644 --- a/stdio/vsscanf.c +++ b/stdio/vsscanf.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 <stdarg.h> #include <stdio.h> @@ -28,18 +27,20 @@ Cambridge, MA 02139, USA. */ /* Read formatted input from S according to the format string FORMAT, using the argument list in ARG. */ int -DEFUN(__vsscanf, (s, format, arg), - CONST char *s AND CONST char *format AND va_list arg) +__vsscanf (s, format, arg) + const char *s; + const char *format; + va_list arg; { FILE f; if (s == NULL) { - errno = EINVAL; + __set_errno (EINVAL); return -1; } - memset((PTR) &f, 0, sizeof(f)); + memset ((void *) &f, 0, sizeof (f)); f.__magic = _IOMAGIC; f.__mode.__read = 1; f.__bufp = f.__buffer = (char *) s; @@ -51,7 +52,7 @@ DEFUN(__vsscanf, (s, format, arg), f.__room_funcs.__input = NULL; f.__seen = 1; - return __vfscanf(&f, format, arg); + return __vfscanf (&f, format, arg); } |