diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2004-04-23 20:01:55 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2004-04-23 20:01:55 +0000 |
commit | 05b315770a3925648b1a3b52781a75232809198d (patch) | |
tree | 6e791ccfcc9aea4e70f350dce432bdda02a40785 /newlib/libc | |
parent | 7ed02aabd1ffe4c684bd893c0393f389a8f24643 (diff) | |
download | newlib-05b315770a3925648b1a3b52781a75232809198d.zip newlib-05b315770a3925648b1a3b52781a75232809198d.tar.gz newlib-05b315770a3925648b1a3b52781a75232809198d.tar.bz2 |
2004-04-23 Artem B. Bityuckiy <abitytsky@softminecorp.com>
* libc/stdio/asprintf.c libc/stdio/clearerr.c,
libc/stdio/fclose.c libc/stdio/fcloseall.c libc/stdio/fdopen.c,
libc/stdio/feof.c libc/stdio/ferror.c libc/stdio/fflush.c,
libc/stdio/fgetc.c libc/stdio/fgetpos.c libc/stdio/fgets.c,
libc/stdio/fileno.c libc/stdio/findfp.c libc/stdio/fiprintf.c,
libc/stdio/flags.c libc/stdio/fopen.c libc/stdio/fprintf.c,
libc/stdio/fputc.c libc/stdio/fputs.c libc/stdio/fread.c,
libc/stdio/freopen.c libc/stdio/fscanf.c libc/stdio/fseek.c,
libc/stdio/fseeko.c libc/stdio/fsetpos.c libc/stdio/ftell.c,
libc/stdio/ftello.c libc/stdio/fvwrite.c libc/stdio/fwalk.c,
libc/stdio/fwrite.c libc/stdio/getc.c libc/stdio/getc_u.c,
libc/stdio/getchar.c libc/stdio/getchar_u.c,
libc/stdio/getdelim.c libc/stdio/getline.c libc/stdio/gets.c,
libc/stdio/getw.c libc/stdio/iprintf.c libc/stdio/local.h,
libc/stdio/makebuf.c libc/stdio/mktemp.c libc/stdio/perror.c,
libc/stdio/printf.c libc/stdio/putc.c libc/stdio/putc_u.c,
libc/stdio/putchar.c libc/stdio/putchar_u.c libc/stdio/puts.c,
libc/stdio/putw.c libc/stdio/refill.c libc/stdio/remove.c,
libc/stdio/rename.c libc/stdio/rewind.c libc/stdio/rget.c,
libc/stdio/scanf.c libc/stdio/setbuf.c libc/stdio/setbuffer.c,
libc/stdio/setlinebuf.c libc/stdio/setvbuf.c,
libc/stdio/siprintf.c libc/stdio/snprintf.c,
libc/stdio/sprintf.c libc/stdio/sscanf.c libc/stdio/stdio.c,
libc/stdio/tmpfile.c libc/stdio/tmpnam.c libc/stdio/ungetc.c,
libc/stdio/vasprintf.c libc/stdio/vfieeefp.h,
libc/stdio/vfprintf.c libc/stdio/vfscanf.c,
libc/stdio/vprintf.c libc/stdio/vscanf.c,
libc/stdio/vsnprintf.c libc/stdio/vsprintf.c,
libc/stdio/vsscanf.c libc/stdio/wbuf.c,
libc/stdio/wsetup.c: Perform minor formatting changes. Move
copyright notices to top of file, ensure that <_ansi.h> is
included, be consistent with open parentheses, use _DEFUN macro,
include "local.h" where needed, and remove various compiler
warnings.
Diffstat (limited to 'newlib/libc')
78 files changed, 1398 insertions, 1090 deletions
diff --git a/newlib/libc/stdio/asprintf.c b/newlib/libc/stdio/asprintf.c index 1d7dd4b..928e849 100644 --- a/newlib/libc/stdio/asprintf.c +++ b/newlib/libc/stdio/asprintf.c @@ -14,9 +14,10 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ - /* This code was copied from sprintf.c */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #ifdef _HAVE_STDC #include <stdarg.h> @@ -24,18 +25,20 @@ #include <varargs.h> #endif #include <limits.h> -#include <_ansi.h> #include "local.h" int #ifdef _HAVE_STDC -_DEFUN (_asprintf_r, (ptr, strp, fmt), struct _reent *ptr _AND char **strp _AND _CONST char *fmt _DOTS) +_DEFUN(_asprintf_r, (ptr, strp, fmt), + struct _reent *ptr _AND + char **strp _AND + _CONST char *fmt _DOTS) #else -_asprintf_r (ptr, strp, fmt, va_alist) - struct _reent *ptr; - char **strp; - _CONST char *fmt; - va_dcl +_asprintf_r(ptr, strp, fmt, va_alist) + struct _reent *ptr; + char **strp; + _CONST char *fmt; + va_dcl #endif { int ret; @@ -63,12 +66,14 @@ _asprintf_r (ptr, strp, fmt, va_alist) int #ifdef _HAVE_STDC -_DEFUN (asprintf, (strp, fmt), char **strp _AND _CONST char *fmt _DOTS) +_DEFUN(asprintf, (strp, fmt), + char **strp _AND + _CONST char *fmt _DOTS) #else -asprintf (strp, fmt, va_alist) - char **strp; - _CONST char *fmt; - va_dcl +asprintf(strp, fmt, va_alist) + char **strp; + _CONST char *fmt; + va_dcl #endif { int ret; diff --git a/newlib/libc/stdio/clearerr.c b/newlib/libc/stdio/clearerr.c index 6a1b0af..e242ff5 100644 --- a/newlib/libc/stdio/clearerr.c +++ b/newlib/libc/stdio/clearerr.c @@ -52,14 +52,15 @@ ANSI C requires <<clearerr>>. No supporting OS subroutines are required. */ +#include <_ansi.h> #include <stdio.h> #undef clearerr _VOID -_DEFUN (clearerr, (fp), - FILE * fp) +_DEFUN(clearerr, (fp), + FILE * fp) { - _flockfile(fp); + _flockfile (fp); __sclearerr (fp); - _funlockfile(fp); + _funlockfile (fp); } diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c index 0f92e07..2f2ae47 100644 --- a/newlib/libc/stdio/fclose.c +++ b/newlib/libc/stdio/fclose.c @@ -1,4 +1,21 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION <<fclose>>---close a file @@ -10,7 +27,7 @@ INDEX ANSI_SYNOPSIS #include <stdio.h> int fclose(FILE *<[fp]>); - int _fclose_r(void *<[reent]>, FILE *<[fp]>); + int _fclose_r(struct _reent *<[reent]>, FILE *<[fp]>); TRAD_SYNOPSIS #include <stdio.h> @@ -18,7 +35,7 @@ TRAD_SYNOPSIS FILE *<[fp]>; int fclose(<[fp]>) - void *<[reent]> + struct _reent *<[reent]> FILE *<[fp]>; DESCRIPTION @@ -40,37 +57,17 @@ Required OS subroutines: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - +#include <_ansi.h> #include <reent.h> #include <stdio.h> #include <stdlib.h> -#include "local.h" #include <sys/lock.h> - -/* - * Close a file. - */ +#include "local.h" int -_DEFUN (_fclose_r, (rptr, fp), - struct _reent *rptr _AND - register FILE * fp) +_DEFUN(_fclose_r, (rptr, fp), + struct _reent *rptr _AND + register FILE * fp) { int r; @@ -79,13 +76,13 @@ _DEFUN (_fclose_r, (rptr, fp), __sfp_lock_acquire (); - _flockfile(fp); + _flockfile (fp); CHECK_INIT (fp); if (fp->_flags == 0) /* not open! */ { - _funlockfile(fp); + _funlockfile (fp); __sfp_lock_release (); return (0); } @@ -99,7 +96,7 @@ _DEFUN (_fclose_r, (rptr, fp), if (HASLB (fp)) FREELB (fp); fp->_flags = 0; /* release this FILE for reuse */ - _funlockfile(fp); + _funlockfile (fp); #ifndef __SINGLE_THREAD__ __lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock); #endif @@ -112,8 +109,8 @@ _DEFUN (_fclose_r, (rptr, fp), #ifndef _REENT_ONLY int -_DEFUN (fclose, (fp), - register FILE * fp) +_DEFUN(fclose, (fp), + register FILE * fp) { return _fclose_r(_REENT, fp); } diff --git a/newlib/libc/stdio/fcloseall.c b/newlib/libc/stdio/fcloseall.c index 58e61e4..090f3f2 100644 --- a/newlib/libc/stdio/fcloseall.c +++ b/newlib/libc/stdio/fcloseall.c @@ -1,4 +1,21 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION <<fcloseall>>---close all files @@ -37,34 +54,18 @@ PORTABILITY Required OS subroutines: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ - /* This file based upon fwalk.c. */ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include "local.h" int -_fcloseall_r (ptr) - struct _reent *ptr; +_DEFUN(_fcloseall_r, (ptr), + struct _reent *ptr) { return _fwalk_reent (ptr, _fclose_r); } @@ -72,7 +73,7 @@ _fcloseall_r (ptr) #ifndef _REENT_ONLY int -fcloseall (void) +_DEFUN_VOID(fcloseall) { return _fcloseall_r (_GLOBAL_REENT); } diff --git a/newlib/libc/stdio/fdopen.c b/newlib/libc/stdio/fdopen.c index 8c1555d..f4fc551 100644 --- a/newlib/libc/stdio/fdopen.c +++ b/newlib/libc/stdio/fdopen.c @@ -1,4 +1,21 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION <<fdopen>>---turn open file into a stream @@ -10,9 +27,9 @@ INDEX ANSI_SYNOPSIS #include <stdio.h> FILE *fdopen(int <[fd]>, const char *<[mode]>); - FILE *_fdopen_r(void *<[reent]>, - int <[fd]>, const char *<[mode]>); - + FILE *_fdopen_r(struct _reent *<[reent]>, + int <[fd]>, const char *<[mode]>); + TRAD_SYNOPSIS #include <stdio.h> FILE *fdopen(<[fd]>, <[mode]>) @@ -20,7 +37,7 @@ TRAD_SYNOPSIS char *<[mode]>; FILE *_fdopen_r(<[reent]>, <[fd]>, <[mode]>) - char *<[reent]>; + struct _reent *<[reent]>; int <[fd]>; char *<[mode]>); @@ -37,21 +54,20 @@ PORTABILITY <<fdopen>> is ANSI. */ +#include <_ansi.h> +#include <reent.h> #include <sys/types.h> #include <sys/fcntl.h> - #include <stdio.h> #include <errno.h> #include "local.h" #include <_syslist.h> -extern int __sflags (); - FILE * -_DEFUN (_fdopen_r, (ptr, fd, mode), - struct _reent *ptr _AND - int fd _AND - _CONST char *mode) +_DEFUN(_fdopen_r, (ptr, fd, mode), + struct _reent *ptr _AND + int fd _AND + _CONST char *mode) { register FILE *fp; int flags, oflags; @@ -77,7 +93,7 @@ _DEFUN (_fdopen_r, (ptr, fd, mode), if ((fp = __sfp (ptr)) == 0) return 0; - _flockfile(fp); + _flockfile (fp); fp->_flags = flags; /* @@ -107,23 +123,23 @@ _DEFUN (_fdopen_r, (ptr, fd, mode), #ifdef __SCLE /* Explicit given mode results in explicit setting mode on fd */ if (oflags & O_BINARY) - setmode(fp->_file, O_BINARY); + setmode (fp->_file, O_BINARY); else if (oflags & O_TEXT) - setmode(fp->_file, O_TEXT); - if (__stextmode(fp->_file)) + setmode (fp->_file, O_TEXT); + if (__stextmode (fp->_file)) fp->_flags |= __SCLE; #endif - _funlockfile(fp); + _funlockfile (fp); return fp; } #ifndef _REENT_ONLY FILE * -_DEFUN (fdopen, (fd, mode), - int fd _AND - _CONST char *mode) +_DEFUN(fdopen, (fd, mode), + int fd _AND + _CONST char *mode) { return _fdopen_r (_REENT, fd, mode); } diff --git a/newlib/libc/stdio/feof.c b/newlib/libc/stdio/feof.c index b7981bd..5372f2f 100644 --- a/newlib/libc/stdio/feof.c +++ b/newlib/libc/stdio/feof.c @@ -1,4 +1,21 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION <<feof>>---test for end of file @@ -33,12 +50,12 @@ No supporting OS subroutines are required. #undef feof int -_DEFUN (feof, (fp), - FILE * fp) +_DEFUN(feof, (fp), + FILE * fp) { int result; - _flockfile(fp); + _flockfile (fp); result = __sfeof (fp); - _funlockfile(fp); + _funlockfile (fp); return result; } diff --git a/newlib/libc/stdio/ferror.c b/newlib/libc/stdio/ferror.c index ef17fd8..6f665d4 100644 --- a/newlib/libc/stdio/ferror.c +++ b/newlib/libc/stdio/ferror.c @@ -53,6 +53,7 @@ No supporting OS subroutines are required. static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> #include <stdio.h> /* A subroutine version of the macro ferror. */ @@ -60,12 +61,12 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #undef ferror int -_DEFUN (ferror, (fp), - FILE * fp) +_DEFUN(ferror, (fp), + FILE * fp) { int result; - _flockfile(fp); + _flockfile (fp); result = __sferror (fp); - _funlockfile(fp); + _funlockfile (fp); return result; } diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c index 30ac996..0b157d0 100644 --- a/newlib/libc/stdio/fflush.c +++ b/newlib/libc/stdio/fflush.c @@ -51,14 +51,15 @@ ANSI C requires <<fflush>>. No supporting OS subroutines are required. */ +#include <_ansi.h> #include <stdio.h> #include "local.h" /* Flush a single file, or (if fp is NULL) all files. */ int -_DEFUN (fflush, (fp), - register FILE * fp) +_DEFUN(fflush, (fp), + register FILE * fp) { register unsigned char *p; register int n, t; @@ -66,14 +67,14 @@ _DEFUN (fflush, (fp), if (fp == NULL) return _fwalk (_GLOBAL_REENT, fflush); - _flockfile(fp); + _flockfile (fp); CHECK_INIT (fp); t = fp->_flags; if ((t & __SWR) == 0 || (p = fp->_bf._base) == NULL) { - _funlockfile(fp); + _funlockfile (fp); return 0; } n = fp->_p - p; /* write this much */ @@ -92,12 +93,12 @@ _DEFUN (fflush, (fp), if (t <= 0) { fp->_flags |= __SERR; - _funlockfile(fp); + _funlockfile (fp); return EOF; } p += t; n -= t; } - _funlockfile(fp); + _funlockfile (fp); return 0; } diff --git a/newlib/libc/stdio/fgetc.c b/newlib/libc/stdio/fgetc.c index 1160b67..5d5ad9a 100644 --- a/newlib/libc/stdio/fgetc.c +++ b/newlib/libc/stdio/fgetc.c @@ -1,4 +1,21 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION <<fgetc>>---get a character from a file or stream @@ -36,15 +53,16 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ +#include <_ansi.h> #include <stdio.h> int -_DEFUN (fgetc, (fp), - FILE * fp) +_DEFUN(fgetc, (fp), + FILE * fp) { int result; - _flockfile(fp); + _flockfile (fp); result = __sgetc (fp); - _funlockfile(fp); + _funlockfile (fp); return result; } diff --git a/newlib/libc/stdio/fgetpos.c b/newlib/libc/stdio/fgetpos.c index 26c69bf..a89d88f 100644 --- a/newlib/libc/stdio/fgetpos.c +++ b/newlib/libc/stdio/fgetpos.c @@ -1,4 +1,21 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION <<fgetpos>>---record position in a stream or file @@ -54,32 +71,34 @@ conforming C implementations may return a different result from No supporting OS subroutines are required. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> int -_DEFUN (_fgetpos_r, (ptr, fp, pos), - struct _reent * ptr _AND - FILE * fp _AND - _fpos_t * pos) +_DEFUN(_fgetpos_r, (ptr, fp, pos), + struct _reent * ptr _AND + FILE * fp _AND + _fpos_t * pos) { - _flockfile(fp); + _flockfile (fp); *pos = _ftell_r (ptr, fp); if (*pos != -1) { - _funlockfile(fp); + _funlockfile (fp); return 0; } - _funlockfile(fp); + _funlockfile (fp); return 1; } #ifndef _REENT_ONLY int -_DEFUN (fgetpos, (fp, pos), - FILE * fp _AND - _fpos_t * pos) +_DEFUN(fgetpos, (fp, pos), + FILE * fp _AND + _fpos_t * pos) { return _fgetpos_r (_REENT, fp, pos); } diff --git a/newlib/libc/stdio/fgets.c b/newlib/libc/stdio/fgets.c index 46e1900..8c5147a 100644 --- a/newlib/libc/stdio/fgets.c +++ b/newlib/libc/stdio/fgets.c @@ -16,9 +16,9 @@ */ /* - FUNCTION - <<fgets>>---get character string from a file or stream +<<fgets>>---get character string from a file or stream + INDEX fgets @@ -54,10 +54,10 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ +#include <_ansi.h> #include <stdio.h> #include <string.h> - -extern int __srefill (); +#include "local.h" /* * Read at most n-1 characters from the given file. @@ -66,10 +66,10 @@ extern int __srefill (); */ char * -_DEFUN (fgets, (buf, n, fp), - char *buf _AND - int n _AND - FILE * fp) +_DEFUN(fgets, (buf, n, fp), + char *buf _AND + int n _AND + FILE * fp) { size_t len; char *s; @@ -80,13 +80,13 @@ _DEFUN (fgets, (buf, n, fp), s = buf; - _flockfile(fp); + _flockfile (fp); #ifdef __SCLE if (fp->_flags & __SCLE) { int c; /* Sorry, have to do it the slow way */ - while (--n > 0 && (c = __sgetc(fp)) != EOF) + while (--n > 0 && (c = __sgetc (fp)) != EOF) { *s++ = c; if (c == '\n') @@ -94,11 +94,11 @@ _DEFUN (fgets, (buf, n, fp), } if (c == EOF && s == buf) { - _funlockfile(fp); + _funlockfile (fp); return NULL; } *s = 0; - _funlockfile(fp); + _funlockfile (fp); return buf; } #endif @@ -116,7 +116,7 @@ _DEFUN (fgets, (buf, n, fp), /* EOF: stop with partial or no line */ if (s == buf) { - _funlockfile(fp); + _funlockfile (fp); return 0; } break; @@ -139,18 +139,18 @@ _DEFUN (fgets, (buf, n, fp), len = ++t - p; fp->_r -= len; fp->_p = t; - (void) memcpy ((_PTR) s, (_PTR) p, len); + _CAST_VOID memcpy ((_PTR) s, (_PTR) p, len); s[len] = 0; - _funlockfile(fp); + _funlockfile (fp); return (buf); } fp->_r -= len; fp->_p += len; - (void) memcpy ((_PTR) s, (_PTR) p, len); + _CAST_VOID memcpy ((_PTR) s, (_PTR) p, len); s += len; } while ((n -= len) != 0); *s = 0; - _funlockfile(fp); + _funlockfile (fp); return buf; } diff --git a/newlib/libc/stdio/fileno.c b/newlib/libc/stdio/fileno.c index c9ecbb4..57d0912 100644 --- a/newlib/libc/stdio/fileno.c +++ b/newlib/libc/stdio/fileno.c @@ -1,4 +1,21 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION <<fileno>>---return file descriptor associated with stream @@ -28,17 +45,18 @@ POSIX requires <<fileno>>. Supporting OS subroutines required: none. */ +#include <_ansi.h> #include <stdio.h> #include "local.h" int -_DEFUN (fileno, (f), - FILE * f) +_DEFUN(fileno, (f), + FILE * f) { int result; - _flockfile(f); + _flockfile (f); CHECK_INIT (f); result = __sfileno (f); - _funlockfile(f); + _funlockfile (f); return result; } diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index f8b67f7..9a9cb03 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -1,5 +1,3 @@ -/* No user fns here. Pesch 15apr92. */ - /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -16,7 +14,10 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* No user fns here. Pesch 15apr92. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> @@ -25,12 +26,12 @@ #include <sys/lock.h> #include "local.h" -static void -std (ptr, flags, file, data) - FILE *ptr; - int flags; - int file; - struct _reent *data; +static _VOID +_DEFUN(std, (ptr, flags, file, data), + FILE *ptr _AND + int flags _AND + int file _AND + struct _reent *data) { ptr->_p = 0; ptr->_r = 0; @@ -54,15 +55,15 @@ std (ptr, flags, file, data) #endif #ifdef __SCLE - if (__stextmode(ptr->_file)) + if (__stextmode (ptr->_file)) ptr->_flags |= __SCLE; #endif } struct _glue * -__sfmoreglue (d, n) - struct _reent *d; - register int n; +_DEFUN(__sfmoreglue, (d, n), + struct _reent *d _AND + register int n) { struct _glue *g; FILE *p; @@ -83,8 +84,8 @@ __sfmoreglue (d, n) */ FILE * -__sfp (d) - struct _reent *d; +_DEFUN(__sfp, (d), + struct _reent *d) { FILE *fp; int n; @@ -138,17 +139,17 @@ found: * The name `_cleanup' is, alas, fairly well known outside stdio. */ -void -_cleanup_r (ptr) - struct _reent *ptr; +_VOID +_DEFUN(_cleanup_r, (ptr), + struct _reent *ptr) { - /* (void) _fwalk(fclose); */ - (void) _fwalk (ptr, fflush); /* `cheating' */ + /* _CAST_VOID _fwalk(fclose); */ + _CAST_VOID _fwalk (ptr, fflush); /* `cheating' */ } #ifndef _REENT_ONLY -void -_cleanup () +_VOID +_DEFUN_VOID(_cleanup) { _cleanup_r (_GLOBAL_REENT); } @@ -158,9 +159,9 @@ _cleanup () * __sinit() is called whenever stdio's internal variables must be set up. */ -void -__sinit (s) - struct _reent *s; +_VOID +_DEFUN(__sinit, (s), + struct _reent *s) { /* make sure we clean up on exit */ s->__cleanup = _cleanup_r; /* conservative */ @@ -197,50 +198,50 @@ __sinit (s) __LOCK_INIT_RECURSIVE(static, __sfp_lock); -void -__sfp_lock_acquire () +_VOID +_DEFUN_VOID(__sfp_lock_acquire) { - __lock_acquire(__sfp_lock); + __lock_acquire_recursive (__sfp_lock); } -void -__sfp_lock_release () +_VOID +_DEFUN_VOID(__sfp_lock_release) { - __lock_release(__sfp_lock); + __lock_release_recursive (__sfp_lock); } /* Walkable file locking routine. */ static int -__fp_lock (ptr) - FILE * ptr; +_DEFUN(__fp_lock, (ptr), + FILE * ptr) { - _flockfile(ptr); + _flockfile (ptr); return 0; } /* Walkable file unlocking routine. */ static int -__fp_unlock (ptr) - FILE * ptr; +_DEFUN(__fp_unlock, (ptr), + FILE * ptr) { - _funlockfile(ptr); + _funlockfile (ptr); return 0; } -void -__fp_lock_all () +_VOID +_DEFUN_VOID(__fp_lock_all) { __sfp_lock_acquire (); - (void) _fwalk (_REENT, __fp_lock); + _CAST_VOID _fwalk (_REENT, __fp_lock); } -void -__fp_unlock_all () +_VOID +_DEFUN_VOID(__fp_unlock_all) { - (void) _fwalk (_REENT, __fp_unlock); + _CAST_VOID _fwalk (_REENT, __fp_unlock); __sfp_lock_release (); } diff --git a/newlib/libc/stdio/fiprintf.c b/newlib/libc/stdio/fiprintf.c index 77199c2..4bf6094 100644 --- a/newlib/libc/stdio/fiprintf.c +++ b/newlib/libc/stdio/fiprintf.c @@ -1,6 +1,24 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION - <<fiprintf>>---format output to file (integer only) +<<fiprintf>>---format output to file (integer only) + INDEX fiprintf @@ -38,7 +56,6 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include <_ansi.h> #include <stdio.h> - #ifdef _HAVE_STDC #include <stdarg.h> #else @@ -47,13 +64,13 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #ifdef _HAVE_STDC int -fiprintf (FILE * fp, const char *fmt,...) +fiprintf(FILE * fp, _CONST char *fmt,...) #else int -fiprintf (fp, fmt, va_alist) - FILE *fp; - char *fmt; - va_dcl +fiprintf(fp, fmt, va_alist) + FILE *fp; + char *fmt; + va_dcl #endif { int ret; diff --git a/newlib/libc/stdio/flags.c b/newlib/libc/stdio/flags.c index e448cca..d7bf52b 100644 --- a/newlib/libc/stdio/flags.c +++ b/newlib/libc/stdio/flags.c @@ -1,5 +1,3 @@ -/* No user fns here. Pesch 15apr92 */ - /* * Copyright (c) 1990 Regents of the University of California. * All rights reserved. @@ -16,11 +14,12 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* No user fns here. Pesch 15apr92 */ +#include <_ansi.h> #include <stdio.h> #include <time.h> #include <fcntl.h> - #include <errno.h> #include <sys/types.h> @@ -31,10 +30,10 @@ */ int -__sflags (ptr, mode, optr) - struct _reent *ptr; - register char *mode; - int *optr; +_DEFUN(__sflags, (ptr, mode, optr), + struct _reent *ptr _AND + register char *mode _AND + int *optr) { register int ret, m, o; diff --git a/newlib/libc/stdio/fopen.c b/newlib/libc/stdio/fopen.c index 4e55129..816e172 100644 --- a/newlib/libc/stdio/fopen.c +++ b/newlib/libc/stdio/fopen.c @@ -28,7 +28,7 @@ ANSI_SYNOPSIS #include <stdio.h> FILE *fopen(const char *<[file]>, const char *<[mode]>); - FILE *_fopen_r(void *<[reent]>, + FILE *_fopen_r(struct _reent *<[reent]>, const char *<[file]>, const char *<[mode]>); TRAD_SYNOPSIS @@ -38,7 +38,7 @@ TRAD_SYNOPSIS char *<[mode]>; FILE *_fopen_r(<[reent]>, <[file]>, <[mode]>) - void *<[reent]>; + struct _reent *<[reent]>; char *<[file]>; char *<[mode]>; @@ -113,19 +113,21 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #include <errno.h> -#include "local.h" +#include <sys/lock.h> #ifdef __CYGWIN__ #include <fcntl.h> #endif -#include <sys/lock.h> +#include "local.h" FILE * -_DEFUN (_fopen_r, (ptr, file, mode), - struct _reent *ptr _AND - _CONST char *file _AND - _CONST char *mode) +_DEFUN(_fopen_r, (ptr, file, mode), + struct _reent *ptr _AND + _CONST char *file _AND + _CONST char *mode) { register FILE *fp; register int f; @@ -147,7 +149,7 @@ _DEFUN (_fopen_r, (ptr, file, mode), return NULL; } - _flockfile(fp); + _flockfile (fp); fp->_file = f; fp->_flags = flags; @@ -165,16 +167,16 @@ _DEFUN (_fopen_r, (ptr, file, mode), fp->_flags |= __SCLE; #endif - _funlockfile(fp); + _funlockfile (fp); return fp; } #ifndef _REENT_ONLY FILE * -_DEFUN (fopen, (file, mode), - _CONST char *file _AND - _CONST char *mode) +_DEFUN(fopen, (file, mode), + _CONST char *file _AND + _CONST char *mode) { return _fopen_r (_REENT, file, mode); } diff --git a/newlib/libc/stdio/fprintf.c b/newlib/libc/stdio/fprintf.c index 8f97a8b..56a0886 100644 --- a/newlib/libc/stdio/fprintf.c +++ b/newlib/libc/stdio/fprintf.c @@ -17,7 +17,6 @@ #include <_ansi.h> #include <stdio.h> - #ifdef _HAVE_STDC #include <stdarg.h> #else @@ -26,13 +25,13 @@ #ifdef _HAVE_STDC int -fprintf (FILE * fp, const char *fmt,...) +fprintf(FILE * fp, _CONST char *fmt,...) #else int -fprintf (fp, fmt, va_alist) - FILE *fp; - char *fmt; - va_dcl +fprintf(fp, fmt, va_alist) + FILE *fp; + char *fmt; + va_dcl #endif { int ret; diff --git a/newlib/libc/stdio/fputc.c b/newlib/libc/stdio/fputc.c index b945095..026ccfb 100644 --- a/newlib/libc/stdio/fputc.c +++ b/newlib/libc/stdio/fputc.c @@ -1,4 +1,21 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION <<fputc>>---write a character on a stream or file @@ -40,16 +57,17 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ +#include <_ansi.h> #include <stdio.h> int -_DEFUN (fputc, (ch, file), - int ch _AND - FILE * file) +_DEFUN(fputc, (ch, file), + int ch _AND + FILE * file) { int result; - _flockfile(file); + _flockfile (file); result = putc (ch, file); - _funlockfile(file); + _funlockfile (file); return result; } diff --git a/newlib/libc/stdio/fputs.c b/newlib/libc/stdio/fputs.c index 78758ce..8d605c0 100644 --- a/newlib/libc/stdio/fputs.c +++ b/newlib/libc/stdio/fputs.c @@ -47,6 +47,7 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ +#include <_ansi.h> #include <stdio.h> #include <string.h> #include "fvwrite.h" @@ -56,9 +57,9 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, */ int -_DEFUN (fputs, (s, fp), - char _CONST * s _AND - FILE * fp) +_DEFUN(fputs, (s, fp), + char _CONST * s _AND + FILE * fp) { int result; struct __suio uio; @@ -68,8 +69,8 @@ _DEFUN (fputs, (s, fp), iov.iov_len = uio.uio_resid = strlen (s); uio.uio_iov = &iov; uio.uio_iovcnt = 1; - _flockfile(fp); + _flockfile (fp); result = __sfvwrite (fp, &uio); - _funlockfile(fp); + _funlockfile (fp); return result; } diff --git a/newlib/libc/stdio/fread.c b/newlib/libc/stdio/fread.c index faca537..d8ceb86 100644 --- a/newlib/libc/stdio/fread.c +++ b/newlib/libc/stdio/fread.c @@ -55,17 +55,18 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ +#include <_ansi.h> #include <stdio.h> #include <string.h> #include "local.h" #ifdef __SCLE static size_t -_DEFUN (crlf, (fp, buf, count, eof), - FILE * fp _AND - char * buf _AND - size_t count _AND - int eof) +_DEFUN(crlf, (fp, buf, count, eof), + FILE * fp _AND + char * buf _AND + size_t count _AND + int eof) { int newcount = 0, r; char *s, *d, *e; @@ -84,11 +85,11 @@ _DEFUN (crlf, (fp, buf, count, eof), { if (*s == '\r') { - int c = __sgetc_raw(fp); + int c = __sgetc_raw (fp); if (c == '\n') *s = '\n'; else - ungetc(c, fp); + ungetc (c, fp); } *d++ = *s++; } @@ -96,7 +97,7 @@ _DEFUN (crlf, (fp, buf, count, eof), while (d < e) { - r = getc(fp); + r = getc (fp); if (r == EOF) return count - (e-d); *d++ = r; @@ -109,11 +110,11 @@ _DEFUN (crlf, (fp, buf, count, eof), #endif size_t -_DEFUN (fread, (buf, size, count, fp), - _PTR buf _AND - size_t size _AND - size_t count _AND - FILE * fp) +_DEFUN(fread, (buf, size, count, fp), + _PTR buf _AND + size_t size _AND + size_t count _AND + FILE * fp) { register size_t resid; register char *p; @@ -123,7 +124,7 @@ _DEFUN (fread, (buf, size, count, fp), if ((resid = count * size) == 0) return 0; - _flockfile(fp); + _flockfile (fp); if (fp->_r < 0) fp->_r = 0; total = resid; @@ -131,7 +132,7 @@ _DEFUN (fread, (buf, size, count, fp), while (resid > (r = fp->_r)) { - (void) memcpy ((void *) p, (void *) fp->_p, (size_t) r); + _CAST_VOID memcpy ((_PTR) p, (_PTR) fp->_p, (size_t) r); fp->_p += r; /* fp->_r = 0 ... done in __srefill */ p += r; @@ -142,24 +143,24 @@ _DEFUN (fread, (buf, size, count, fp), #ifdef __SCLE if (fp->_flags & __SCLE) { - _funlockfile(fp); - return crlf(fp, buf, total-resid, 1) / size; + _funlockfile (fp); + return crlf (fp, buf, total-resid, 1) / size; } #endif - _funlockfile(fp); + _funlockfile (fp); return (total - resid) / size; } } - (void) memcpy ((void *) p, (void *) fp->_p, resid); + _CAST_VOID memcpy ((_PTR) p, (_PTR) fp->_p, resid); fp->_r -= resid; fp->_p += resid; #ifdef __SCLE if (fp->_flags & __SCLE) { - _funlockfile(fp); + _funlockfile (fp); return crlf(fp, buf, total, 0) / size; } #endif - _funlockfile(fp); + _funlockfile (fp); return count; } diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c index b0372b5..8312852 100644 --- a/newlib/libc/stdio/freopen.c +++ b/newlib/libc/stdio/freopen.c @@ -66,37 +66,39 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<open>>, <<read>>, <<sbrk>>, <<write>>. */ +#include <_ansi.h> +#include <reent.h> #include <time.h> #include <stdio.h> #include <fcntl.h> #include <stdlib.h> -#include "local.h" #include <sys/lock.h> +#include "local.h" /* * Re-direct an existing, open (probably) file to some other file. */ FILE * -_DEFUN (_freopen_r, (ptr, file, mode, fp), - struct _reent *ptr _AND - _CONST char *file _AND - _CONST char *mode _AND - register FILE *fp) +_DEFUN(_freopen_r, (ptr, file, mode, fp), + struct _reent *ptr _AND + _CONST char *file _AND + _CONST char *mode _AND + register FILE *fp) { register int f; int flags, oflags, e; __sfp_lock_acquire (); - _flockfile(fp); + _flockfile (fp); CHECK_INIT (fp); if ((flags = __sflags (ptr, mode, &oflags)) == 0) { - _funlockfile(fp); - (void) _fclose_r (ptr, fp); + _funlockfile (fp); + _CAST_VOID _fclose_r (ptr, fp); __sfp_lock_release (); return NULL; } @@ -114,10 +116,10 @@ _DEFUN (_freopen_r, (ptr, file, mode, fp), else { if (fp->_flags & __SWR) - (void) fflush (fp); + _CAST_VOID fflush (fp); /* if close is NULL, closing is a no-op, hence pointless */ if (fp->_close != NULL) - (void) (*fp->_close) (fp->_cookie); + _CAST_VOID (*fp->_close) (fp->_cookie); } /* @@ -153,7 +155,7 @@ _DEFUN (_freopen_r, (ptr, file, mode, fp), { /* did not get it after all */ fp->_flags = 0; /* set it free */ ptr->_errno = e; /* restore in case _close clobbered */ - _funlockfile(fp); + _funlockfile (fp); #ifndef __SINGLE_THREAD__ __lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock); #endif @@ -170,11 +172,11 @@ _DEFUN (_freopen_r, (ptr, file, mode, fp), fp->_close = __sclose; #ifdef __SCLE - if (__stextmode(fp->_file)) + if (__stextmode (fp->_file)) fp->_flags |= __SCLE; #endif - _funlockfile(fp); + _funlockfile (fp); __sfp_lock_release (); return fp; } @@ -182,10 +184,10 @@ _DEFUN (_freopen_r, (ptr, file, mode, fp), #ifndef _REENT_ONLY FILE * -_DEFUN (freopen, (file, mode, fp), - _CONST char *file _AND - _CONST char *mode _AND - register FILE *fp) +_DEFUN(freopen, (file, mode, fp), + _CONST char *file _AND + _CONST char *mode _AND + register FILE *fp) { return _freopen_r (_REENT, file, mode, fp); } diff --git a/newlib/libc/stdio/fscanf.c b/newlib/libc/stdio/fscanf.c index 92fc4ea..c00a469 100644 --- a/newlib/libc/stdio/fscanf.c +++ b/newlib/libc/stdio/fscanf.c @@ -16,26 +16,25 @@ */ #include <_ansi.h> +#include <reent.h> #include <stdio.h> - #ifdef _HAVE_STDC #include <stdarg.h> #else #include <varargs.h> #endif - #include "local.h" #ifndef _REENT_ONLY int #ifdef _HAVE_STDC -fscanf (FILE *fp, const char *fmt, ...) +fscanf(FILE *fp, _CONST char *fmt, ...) #else -fscanf (FILE *fp, fmt, va_alist) - FILE *fp; - char *fmt; - va_dcl +fscanf(FILE *fp, fmt, va_alist) + FILE *fp; + char *fmt; + va_dcl #endif { int ret; @@ -55,13 +54,13 @@ fscanf (FILE *fp, fmt, va_alist) int #ifdef _HAVE_STDC -_fscanf_r (struct _reent *ptr, FILE *fp, const char *fmt, ...) +_fscanf_r(struct _reent *ptr, FILE *fp, _CONST char *fmt, ...) #else -_fscanf_r (ptr, FILE *fp, fmt, va_alist) - struct _reent *ptr; - FILE *fp; - char *fmt; - va_dcl +_fscanf_r(ptr, FILE *fp, fmt, va_alist) + struct _reent *ptr; + FILE *fp; + char *fmt; + va_dcl #endif { int ret; diff --git a/newlib/libc/stdio/fseek.c b/newlib/libc/stdio/fseek.c index 4747e21..b3df7f0 100644 --- a/newlib/libc/stdio/fseek.c +++ b/newlib/libc/stdio/fseek.c @@ -98,6 +98,8 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #include <time.h> #include <fcntl.h> @@ -114,19 +116,20 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, */ int -_DEFUN (_fseek_r, (ptr, fp, offset, whence), - struct _reent *ptr _AND - register FILE *fp _AND - long offset _AND - int whence) +_DEFUN(_fseek_r, (ptr, fp, offset, whence), + struct _reent *ptr _AND + register FILE *fp _AND + long offset _AND + int whence) { - _fpos_t _EXFUN ((*seekfn), (void *, _fpos_t, int)); - _fpos_t target, curoff; + _fpos_t _EXFUN((*seekfn), (_PTR, _fpos_t, int)); + _fpos_t target; + _fpos_t curoff = 0; size_t n; struct stat st; int havepos; - _flockfile(fp); + _flockfile (fp); /* Make sure stdio is set up. */ @@ -146,7 +149,7 @@ _DEFUN (_fseek_r, (ptr, fp, offset, whence), if ((seekfn = fp->_seek) == NULL) { ptr->_errno = ESPIPE; /* ??? */ - _funlockfile(fp); + _funlockfile (fp); return EOF; } @@ -163,7 +166,7 @@ _DEFUN (_fseek_r, (ptr, fp, offset, whence), * we have to first find the current stream offset a la * ftell (see ftell for details). */ - fflush(fp); /* may adjust seek offset on append stream */ + fflush (fp); /* may adjust seek offset on append stream */ if (fp->_flags & __SOFF) curoff = fp->_offset; else @@ -171,7 +174,7 @@ _DEFUN (_fseek_r, (ptr, fp, offset, whence), curoff = (*seekfn) (fp->_cookie, (_fpos_t) 0, SEEK_CUR); if (curoff == -1L) { - _funlockfile(fp); + _funlockfile (fp); return EOF; } } @@ -196,7 +199,7 @@ _DEFUN (_fseek_r, (ptr, fp, offset, whence), default: ptr->_errno = EINVAL; - _funlockfile(fp); + _funlockfile (fp); return (EOF); } @@ -306,7 +309,7 @@ _DEFUN (_fseek_r, (ptr, fp, offset, whence), if (HASUB (fp)) FREEUB (fp); fp->_flags &= ~__SEOF; - _funlockfile(fp); + _funlockfile (fp); return 0; } @@ -335,7 +338,7 @@ _DEFUN (_fseek_r, (ptr, fp, offset, whence), fp->_p += n; fp->_r -= n; } - _funlockfile(fp); + _funlockfile (fp); return 0; /* @@ -346,7 +349,7 @@ _DEFUN (_fseek_r, (ptr, fp, offset, whence), dumb: if (fflush (fp) || (*seekfn) (fp->_cookie, offset, whence) == POS_ERR) { - _funlockfile(fp); + _funlockfile (fp); return EOF; } /* success: clear EOF indicator and discard ungetc() data */ @@ -356,17 +359,17 @@ dumb: fp->_r = 0; /* fp->_w = 0; *//* unnecessary (I think...) */ fp->_flags &= ~__SEOF; - _funlockfile(fp); + _funlockfile (fp); return 0; } #ifndef _REENT_ONLY int -_DEFUN (fseek, (fp, offset, whence), - register FILE *fp _AND - long offset _AND - int whence) +_DEFUN(fseek, (fp, offset, whence), + register FILE *fp _AND + long offset _AND + int whence) { return _fseek_r (_REENT, fp, offset, whence); } diff --git a/newlib/libc/stdio/fseeko.c b/newlib/libc/stdio/fseeko.c index 62a9d43..0d655d0 100644 --- a/newlib/libc/stdio/fseeko.c +++ b/newlib/libc/stdio/fseeko.c @@ -15,14 +15,16 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> int -_DEFUN (_fseeko_r, (ptr, fp, offset, whence), - struct _reent *ptr _AND - register FILE *fp _AND - _off_t offset _AND - int whence) +_DEFUN(_fseeko_r, (ptr, fp, offset, whence), + struct _reent *ptr _AND + register FILE *fp _AND + _off_t offset _AND + int whence) { return _fseek_r (ptr, fp, (long)offset, whence); } @@ -30,10 +32,10 @@ _DEFUN (_fseeko_r, (ptr, fp, offset, whence), #ifndef _REENT_ONLY int -fseeko (fp, offset, whence) - register FILE *fp; - _off_t offset; - int whence; +_DEFUN(fseeko, (fp, offset, whence), + register FILE *fp _AND + _off_t offset _AND + int whence) { /* for now we simply cast since off_t should be long */ return _fseek_r (_REENT, fp, (long)offset, whence); diff --git a/newlib/libc/stdio/fsetpos.c b/newlib/libc/stdio/fsetpos.c index 75f719b..e2dd39b 100644 --- a/newlib/libc/stdio/fsetpos.c +++ b/newlib/libc/stdio/fsetpos.c @@ -1,4 +1,21 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION <<fsetpos>>---restore position of a stream or file @@ -48,13 +65,15 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> int -_DEFUN (_fsetpos_r, (ptr, iop, pos), - struct _reent * ptr _AND - FILE * iop _AND - _CONST _fpos_t * pos) +_DEFUN(_fsetpos_r, (ptr, iop, pos), + struct _reent * ptr _AND + FILE * iop _AND + _CONST _fpos_t * pos) { int x = _fseek_r (ptr, iop, *pos, SEEK_SET); @@ -66,9 +85,9 @@ _DEFUN (_fsetpos_r, (ptr, iop, pos), #ifndef _REENT_ONLY int -_DEFUN (fsetpos, (iop, pos), - FILE * iop _AND - _CONST _fpos_t * pos) +_DEFUN(fsetpos, (iop, pos), + FILE * iop _AND + _CONST _fpos_t * pos) { return _fsetpos_r (_REENT, iop, pos); } diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c index 1df8563..9525741 100644 --- a/newlib/libc/stdio/ftell.c +++ b/newlib/libc/stdio/ftell.c @@ -92,19 +92,20 @@ static char sccsid[] = "%W% (Berkeley) %G%"; * ftell: return current offset. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #include <errno.h> - #include "local.h" long -_DEFUN (_ftell_r, (ptr, fp), - struct _reent *ptr _AND - register FILE * fp) +_DEFUN(_ftell_r, (ptr, fp), + struct _reent *ptr _AND + register FILE * fp) { _fpos_t pos; - _flockfile(fp); + _flockfile (fp); /* Ensure stdio is set up. */ @@ -113,7 +114,7 @@ _DEFUN (_ftell_r, (ptr, fp), if (fp->_seek == NULL) { ptr->_errno = ESPIPE; - _funlockfile(fp); + _funlockfile (fp); return -1L; } @@ -127,7 +128,7 @@ _DEFUN (_ftell_r, (ptr, fp), pos = (*fp->_seek) (fp->_cookie, (_fpos_t) 0, SEEK_CUR); if (pos == -1L) { - _funlockfile(fp); + _funlockfile (fp); return pos; } } @@ -152,15 +153,15 @@ _DEFUN (_ftell_r, (ptr, fp), pos += fp->_p - fp->_bf._base; } - _funlockfile(fp); + _funlockfile (fp); return pos; } #ifndef _REENT_ONLY long -_DEFUN (ftell, (fp), - register FILE * fp) +_DEFUN(ftell, (fp), + register FILE * fp) { return _ftell_r (_REENT, fp); } diff --git a/newlib/libc/stdio/ftello.c b/newlib/libc/stdio/ftello.c index 918883c..216d884 100644 --- a/newlib/libc/stdio/ftello.c +++ b/newlib/libc/stdio/ftello.c @@ -15,12 +15,14 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> _off_t -_DEFUN (_ftello_r, (ptr, fp), - struct _reent * ptr _AND - register FILE * fp) +_DEFUN(_ftello_r, (ptr, fp), + struct _reent * ptr _AND + register FILE * fp) { /* for now we simply cast since off_t should be long */ return (_off_t)_ftell_r (ptr, fp); @@ -29,8 +31,8 @@ _DEFUN (_ftello_r, (ptr, fp), #ifndef _REENT_ONLY _off_t -_DEFUN (ftello, (fp), - register FILE * fp) +_DEFUN(ftello, (fp), + register FILE * fp) { return (_off_t)_ftell_r (_REENT, fp); } diff --git a/newlib/libc/stdio/fvwrite.c b/newlib/libc/stdio/fvwrite.c index aaf3a19..3143b01 100644 --- a/newlib/libc/stdio/fvwrite.c +++ b/newlib/libc/stdio/fvwrite.c @@ -1,5 +1,3 @@ -/* No user fns here. Pesch 15apr92. */ - /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -16,7 +14,9 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* No user fns here. Pesch 15apr92. */ +#include <_ansi.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -24,7 +24,7 @@ #include "fvwrite.h" #define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define COPY(n) (void) memmove((void *) fp->_p, (void *) p, (size_t) (n)) +#define COPY(n) _CAST_VOID memmove ((_PTR) fp->_p, (_PTR) p, (size_t) (n)) #define GETIOV(extra_work) \ while (len == 0) \ @@ -43,12 +43,12 @@ */ int -__sfvwrite (fp, uio) - register FILE *fp; - register struct __suio *uio; +_DEFUN(__sfvwrite, (fp, uio), + register FILE *fp _AND + register struct __suio *uio) { register size_t len; - register _CONST char *p; + register _CONST char *p = NULL; register struct __siov *iov; register int w, s; char *nl; @@ -72,7 +72,7 @@ __sfvwrite (fp, uio) GETIOV (;); while (len > 0) { - if (putc(*p, fp) == EOF) + if (putc (*p, fp) == EOF) return EOF; p++; len--; @@ -181,12 +181,13 @@ __sfvwrite (fp, uio) * that the amount to write is MIN(len,nldist). */ nlknown = 0; + nldist = 0; do { GETIOV (nlknown = 0); if (!nlknown) { - nl = memchr ((void *) p, '\n', len); + nl = memchr ((_PTR) p, '\n', len); nldist = nl ? nl + 1 - p : len + 1; nlknown = 1; } diff --git a/newlib/libc/stdio/fwalk.c b/newlib/libc/stdio/fwalk.c index 02a8970..87cebdb 100644 --- a/newlib/libc/stdio/fwalk.c +++ b/newlib/libc/stdio/fwalk.c @@ -1,5 +1,3 @@ -/* No user fns here. Pesch 15apr92. */ - /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -16,20 +14,23 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* No user fns here. Pesch 15apr92. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include "local.h" static int -__fwalk (ptr, function) - struct _reent *ptr; - register int (*function) (); +_DEFUN(__fwalk, (ptr, function), + struct _reent *ptr _AND + register int (*function) ()) { register FILE *fp; register int n, ret = 0; @@ -51,9 +52,9 @@ __fwalk (ptr, function) /* Special version of __fwalk where the function pointer is a reentrant I/O function (e.g. _fclose_r). */ static int -__fwalk_reent (ptr, reent_function) - struct _reent *ptr; - register int (*reent_function) (); +_DEFUN(__fwalk_reent, (ptr, reent_function), + struct _reent *ptr _AND + register int (*reent_function) ()) { register FILE *fp; register int n, ret = 0; @@ -73,9 +74,9 @@ __fwalk_reent (ptr, reent_function) } int -_fwalk (ptr, function) - struct _reent *ptr; - register int (*function) (); +_DEFUN(_fwalk, (ptr, function), + struct _reent *ptr _AND + register int (*function)()) { register int ret = 0; @@ -96,9 +97,9 @@ _fwalk (ptr, function) /* Special version of _fwalk which handles a function pointer to a reentrant I/O function (e.g. _fclose_r). */ int -_fwalk_reent (ptr, reent_function) - struct _reent *ptr; - register int (*reent_function) (); +_DEFUN(_fwalk_reent, (ptr, reent_function), + struct _reent *ptr _AND + register int (*reent_function) ()) { register int ret = 0; diff --git a/newlib/libc/stdio/fwrite.c b/newlib/libc/stdio/fwrite.c index 1c91632..18514ec 100644 --- a/newlib/libc/stdio/fwrite.c +++ b/newlib/libc/stdio/fwrite.c @@ -61,6 +61,7 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> #include <stdio.h> #include <string.h> #if 0 @@ -77,11 +78,11 @@ static char sccsid[] = "%W% (Berkeley) %G%"; */ size_t -_DEFUN (fwrite, (buf, size, count, fp), - _CONST _PTR buf _AND - size_t size _AND - size_t count _AND - FILE * fp) +_DEFUN(fwrite, (buf, size, count, fp), + _CONST _PTR buf _AND + size_t size _AND + size_t count _AND + FILE * fp) { size_t n; struct __suio uio; @@ -98,12 +99,12 @@ _DEFUN (fwrite, (buf, size, count, fp), * generally slow and since this occurs whenever size==0. */ - _flockfile(fp); + _flockfile (fp); if (__sfvwrite (fp, &uio) == 0) { - _funlockfile(fp); + _funlockfile (fp); return count; } - _funlockfile(fp); + _funlockfile (fp); return (n - uio.uio_resid) / size; } diff --git a/newlib/libc/stdio/getc.c b/newlib/libc/stdio/getc.c index f7a2cac..0aa5ce3 100644 --- a/newlib/libc/stdio/getc.c +++ b/newlib/libc/stdio/getc.c @@ -62,6 +62,7 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> #include <stdio.h> /* @@ -71,13 +72,13 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #undef getc int -getc (fp) - register FILE *fp; +_DEFUN(getc, (fp), + register FILE *fp) { int result; - _flockfile(fp); + _flockfile (fp); /* CHECK_INIT is called (eventually) by __srefill. */ result = __sgetc (fp); - _funlockfile(fp); + _funlockfile (fp); return result; } diff --git a/newlib/libc/stdio/getc_u.c b/newlib/libc/stdio/getc_u.c index 877c7f8..9c05fa6 100644 --- a/newlib/libc/stdio/getc_u.c +++ b/newlib/libc/stdio/getc_u.c @@ -50,6 +50,7 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> #include <stdio.h> /* @@ -59,8 +60,8 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #undef getc_unlocked int -getc_unlocked (fp) - register FILE *fp; +_DEFUN(getc_unlocked, (fp), + register FILE *fp) { /* CHECK_INIT is called (eventually) by __srefill. */ diff --git a/newlib/libc/stdio/getchar.c b/newlib/libc/stdio/getchar.c index 3459326..8bb46ef 100644 --- a/newlib/libc/stdio/getchar.c +++ b/newlib/libc/stdio/getchar.c @@ -28,7 +28,7 @@ ANSI_SYNOPSIS #include <stdio.h> int getchar(void); - int _getchar_r(void *<[reent]>); + int _getchar_r(struct _reent *<[reent]>); TRAD_SYNOPSIS #include <stdio.h> @@ -71,25 +71,25 @@ static char sccsid[] = "%W% (Berkeley) %G%"; * A subroutine version of the macro getchar. */ -#include <stdio.h> +#include <_ansi.h> #include <reent.h> - +#include <stdio.h> #include "local.h" #undef getchar int -_getchar_r (f) - struct _reent *f; +_DEFUN(_getchar_r, (f), + struct _reent *f) { - _REENT_SMALL_CHECK_INIT(_stdin_r (f)); + _REENT_SMALL_CHECK_INIT (_stdin_r (f)); return getc (_stdin_r (f)); } #ifndef _REENT_ONLY int -getchar () +_DEFUN_VOID(getchar) { /* CHECK_INIT is called (eventually) by __srefill. */ diff --git a/newlib/libc/stdio/getchar_u.c b/newlib/libc/stdio/getchar_u.c index f36f888..be566ea 100644 --- a/newlib/libc/stdio/getchar_u.c +++ b/newlib/libc/stdio/getchar_u.c @@ -54,14 +54,15 @@ static char sccsid[] = "%W% (Berkeley) %G%"; * A subroutine version of the macro getchar_unlocked. */ -#include <stdio.h> +#include <_ansi.h> #include <reent.h> +#include <stdio.h> #undef getchar_unlocked int -_getchar_unlocked_r (f) - struct _reent *f; +_DEFUN(_getchar_unlocked_r, (f), + struct _reent *f) { return getc_unlocked (_stdin_r (f)); } @@ -69,7 +70,7 @@ _getchar_unlocked_r (f) #ifndef _REENT_ONLY int -getchar_unlocked () +_DEFUN_VOID(getchar_unlocked) { /* CHECK_INIT is called (eventually) by __srefill. */ diff --git a/newlib/libc/stdio/getdelim.c b/newlib/libc/stdio/getdelim.c index 64f60ee..6c3e298 100644 --- a/newlib/libc/stdio/getdelim.c +++ b/newlib/libc/stdio/getdelim.c @@ -1,3 +1,4 @@ +/* Copyright 2002, Red Hat Inc. - all rights reserved */ /* FUNCTION <<getdelim>>---read a line up to a specified line delimeter @@ -37,8 +38,7 @@ PORTABILITY No supporting OS subroutines are directly required. */ -/* Copyright 2002, Red Hat Inc. - all rights reserved */ - +#include <_ansi.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> @@ -48,11 +48,11 @@ No supporting OS subroutines are directly required. #define DEFAULT_LINE_SIZE 128 ssize_t -__getdelim (bufptr, n, delim, fp) - char **bufptr; - size_t *n; - int delim; - FILE *fp; +_DEFUN(__getdelim, (bufptr, n, delim, fp), + char **bufptr _AND + size_t *n _AND + int delim _AND + FILE *fp) { char *buf; char *ptr; @@ -79,9 +79,9 @@ __getdelim (bufptr, n, delim, fp) *n = DEFAULT_LINE_SIZE; } - _flockfile(fp); + _flockfile (fp); - CHECK_INIT(fp); + CHECK_INIT (fp); numbytes = *n; ptr = buf; diff --git a/newlib/libc/stdio/getline.c b/newlib/libc/stdio/getline.c index 741a7dc..c758ae9 100644 --- a/newlib/libc/stdio/getline.c +++ b/newlib/libc/stdio/getline.c @@ -1,3 +1,4 @@ +/* Copyright 2002, Red Hat Inc. - all rights reserved */ /* FUNCTION <<getline>>---read a line from a file @@ -37,17 +38,16 @@ PORTABILITY No supporting OS subroutines are directly required. */ -/* Copyright 2002, Red Hat Inc. - all rights reserved */ - +#include <_ansi.h> #include <stdio.h> -extern ssize_t __getdelim (char **, size_t *, int, FILE *); +extern ssize_t _EXFUN(__getdelim, (char **, size_t *, int, FILE *)); ssize_t -__getline (lptr, n, fp) - char **lptr; - size_t *n; - FILE *fp; +_DEFUN(__getline, (lptr, n, fp), + char **lptr _AND + size_t *n _AND + FILE *fp) { return __getdelim (lptr, n, '\n', fp); } diff --git a/newlib/libc/stdio/gets.c b/newlib/libc/stdio/gets.c index 796100e..b90271f 100644 --- a/newlib/libc/stdio/gets.c +++ b/newlib/libc/stdio/gets.c @@ -15,11 +15,10 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ - /* - FUNCTION - <<gets>>---get character string (obsolete, use <<fgets>> instead) +<<gets>>---get character string (obsolete, use <<fgets>> instead) + INDEX gets INDEX @@ -30,7 +29,7 @@ ANSI_SYNOPSIS char *gets(char *<[buf]>); - char *_gets_r(void *<[reent]>, char *<[buf]>); + char *_gets_r(struct _reent *<[reent]>, char *<[buf]>); TRAD_SYNOPSIS #include <stdio.h> @@ -39,7 +38,7 @@ TRAD_SYNOPSIS char *<[buf]>; char *_gets_r(<[reent]>, <[buf]>) - char *<[reent]>; + struct _reent *<[reent]>; char *<[buf]>; DESCRIPTION @@ -68,12 +67,14 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> char * -_gets_r (ptr, buf) - struct _reent *ptr; - char *buf; +_DEFUN(_gets_r, (ptr, buf), + struct _reent *ptr _AND + char *buf) { register int c; register char *s = buf; @@ -93,8 +94,8 @@ _gets_r (ptr, buf) #ifndef _REENT_ONLY char * -gets (buf) - char *buf; +_DEFUN(gets, (buf), + char *buf) { return _gets_r (_REENT, buf); } diff --git a/newlib/libc/stdio/getw.c b/newlib/libc/stdio/getw.c index b6fd873..b5065bd 100644 --- a/newlib/libc/stdio/getw.c +++ b/newlib/libc/stdio/getw.c @@ -54,14 +54,15 @@ Supporting OS subroutines required: <<fread>>. */ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> #include <stdio.h> int -getw (fp) - register FILE *fp; +_DEFUN(getw, (fp), + register FILE *fp) { int result; - if (fread((char*)&result, sizeof(result), 1, fp) != 1) + if (fread ((char*)&result, sizeof (result), 1, fp) != 1) return EOF; return result; } diff --git a/newlib/libc/stdio/iprintf.c b/newlib/libc/stdio/iprintf.c index dc91b12..9bbe733 100644 --- a/newlib/libc/stdio/iprintf.c +++ b/newlib/libc/stdio/iprintf.c @@ -1,6 +1,24 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION - <<iprintf>>---write formatted output (integer only) +<<iprintf>>---write formatted output (integer only) + INDEX iprintf @@ -36,32 +54,31 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, */ #include <_ansi.h> +#include <reent.h> #include <stdio.h> - -#include "local.h" - #ifdef _HAVE_STDC #include <stdarg.h> #else #include <varargs.h> #endif +#include "local.h" #ifndef _REENT_ONLY #ifdef _HAVE_STDC int -iprintf (const char *fmt,...) +iprintf(_CONST char *fmt,...) #else int -iprintf (fmt, va_alist) - char *fmt; - va_dcl +iprintf(fmt, va_alist) + char *fmt; + va_dcl #endif { int ret; va_list ap; - _REENT_SMALL_CHECK_INIT(_stdout_r (_REENT)); + _REENT_SMALL_CHECK_INIT (_stdout_r (_REENT)); #ifdef _HAVE_STDC va_start (ap, fmt); #else @@ -76,19 +93,19 @@ iprintf (fmt, va_alist) #ifdef _HAVE_STDC int -_iprintf_r (struct _reent *ptr, const char *fmt, ...) +_iprintf_r(struct _reent *ptr, _CONST char *fmt, ...) #else int -_iprintf_r (data, fmt, va_alist) - char *data; - char *fmt; - va_dcl +_iprintf_r(data, fmt, va_alist) + char *data; + char *fmt; + va_dcl #endif { int ret; va_list ap; - _REENT_SMALL_CHECK_INIT(_stdout_r (ptr)); + _REENT_SMALL_CHECK_INIT (_stdout_r (ptr)); #ifdef _HAVE_STDC va_start (ap, fmt); #else diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h index d97a03e..809bbc2 100644 --- a/newlib/libc/stdio/local.h +++ b/newlib/libc/stdio/local.h @@ -23,6 +23,7 @@ */ #include <_ansi.h> +#include <reent.h> #include <stdarg.h> #include <reent.h> #include <unistd.h> @@ -31,15 +32,16 @@ extern int _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list extern FILE *_EXFUN(__sfp,(struct _reent *)); extern int _EXFUN(__sflags,(struct _reent *,_CONST char*, int*)); extern int _EXFUN(__srefill,(FILE *)); -extern _READ_WRITE_RETURN_TYPE _EXFUN(__sread,(void *, char *, int)); -extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite,(void *, char const *, int)); -extern _fpos_t _EXFUN(__sseek,(void *, _fpos_t, int)); -extern int _EXFUN(__sclose,(void *)); +extern _READ_WRITE_RETURN_TYPE _EXFUN(__sread,(_PTR, char *, int)); +extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite,(_PTR, char _CONST *, int)); +extern _fpos_t _EXFUN(__sseek,(_PTR, _fpos_t, int)); +extern int _EXFUN(__sclose,(_PTR)); extern int _EXFUN(__stextmode,(int)); -extern void _EXFUN(__sinit,(struct _reent *)); -extern void _EXFUN(_cleanup_r,(struct _reent *)); -extern void _EXFUN(__smakebuf,(FILE *)); +extern _VOID _EXFUN(__sinit,(struct _reent *)); +extern _VOID _EXFUN(_cleanup_r,(struct _reent *)); +extern _VOID _EXFUN(__smakebuf,(FILE *)); extern int _EXFUN(_fwalk,(struct _reent *, int (*)(FILE *))); +extern int _EXFUN(_fwalk_reent,(struct _reent *, int (*)(FILE *))); struct _glue * _EXFUN(__sfmoreglue,(struct _reent *,int n)); extern int _EXFUN(__srefill,(FILE *fp)); @@ -92,6 +94,6 @@ char *_EXFUN(_llicvt,(char *, long long, char)); #define __sfp_lock_acquire() #define __sfp_lock_release() #else -void _EXFUN(__sfp_lock_acquire,(void)); -void _EXFUN(__sfp_lock_release,(void)); +_VOID _EXFUN(__sfp_lock_acquire,(_VOID)); +_VOID _EXFUN(__sfp_lock_release,(_VOID)); #endif diff --git a/newlib/libc/stdio/makebuf.c b/newlib/libc/stdio/makebuf.c index 48b6645..c4d03ec 100644 --- a/newlib/libc/stdio/makebuf.c +++ b/newlib/libc/stdio/makebuf.c @@ -1,5 +1,3 @@ -/* No user fns here. Pesch 15apr92. */ - /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -16,13 +14,14 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* No user fns here. Pesch 15apr92. */ +#include <_ansi.h> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/unistd.h> - #include "local.h" /* @@ -33,9 +32,9 @@ * optimization) right after the _fstat() that finds the buffer size. */ -void -__smakebuf (fp) - register FILE *fp; +_VOID +_DEFUN(__smakebuf, (fp), + register FILE *fp) { register size_t size, couldbetty; register _PTR p; diff --git a/newlib/libc/stdio/mktemp.c b/newlib/libc/stdio/mktemp.c index f5757f3..59e7a5c 100644 --- a/newlib/libc/stdio/mktemp.c +++ b/newlib/libc/stdio/mktemp.c @@ -1,8 +1,3 @@ -/* This is file MKTEMP.C */ -/* This file may have been modified by DJ Delorie (Jan 1991). If so, -** these modifications are Copyright (C) 1991 DJ Delorie. -*/ - /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. @@ -21,6 +16,10 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* This is file MKTEMP.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Copyright (C) 1991 DJ Delorie. +*/ /* FUNCTION @@ -40,8 +39,8 @@ ANSI_SYNOPSIS char *mktemp(char *<[path]>); int mkstemp(char *<[path]>); - char *_mktemp_r(void *<[reent]>, char *<[path]>); - int *_mkstemp_r(void *<[reent]>, char *<[path]>); + char *_mktemp_r(struct _reent *<[reent]>, char *<[path]>); + int *_mkstemp_r(struct _reent *<[reent]>, char *<[path]>); TRAD_SYNOPSIS #include <stdio.h> @@ -52,11 +51,11 @@ TRAD_SYNOPSIS char *<[path]>; char *_mktemp_r(<[reent]>, <[path]>) - char *<[reent]>; + struct _reent *<[reent]>; char *<[path]>; int _mkstemp_r(<[reent]>, <[path]>) - char *<[reent]>; + struct _reent *<[reent]>; char *<[path]>; DESCRIPTION @@ -93,19 +92,20 @@ V Interface Definition requires <<mktemp>> as of Issue 2. Supporting OS subroutines required: <<getpid>>, <<open>>, <<stat>>. */ +#include <_ansi.h> +#include <reent.h> #include <sys/types.h> #include <fcntl.h> #include <sys/stat.h> #include <errno.h> #include <stdio.h> #include <ctype.h> -#include <reent.h> static int -_DEFUN (_gettemp, (ptr, path, doopen), - struct _reent *ptr _AND - char *path _AND - register int *doopen) +_DEFUN(_gettemp, (ptr, path, doopen), + struct _reent *ptr _AND + char *path _AND + register int *doopen) { register char *start, *trv; struct stat sbuf; @@ -190,9 +190,9 @@ _DEFUN (_gettemp, (ptr, path, doopen), } int -_DEFUN (_mkstemp_r, (ptr, path), - struct _reent *ptr _AND - char *path) +_DEFUN(_mkstemp_r, (ptr, path), + struct _reent *ptr _AND + char *path) { int fd; @@ -200,9 +200,9 @@ _DEFUN (_mkstemp_r, (ptr, path), } char * -_DEFUN (_mktemp_r, (ptr, path), - struct _reent *ptr _AND - char *path) +_DEFUN(_mktemp_r, (ptr, path), + struct _reent *ptr _AND + char *path) { return (_gettemp (ptr, path, (int *) NULL) ? path : (char *) NULL); } @@ -210,8 +210,8 @@ _DEFUN (_mktemp_r, (ptr, path), #ifndef _REENT_ONLY int -_DEFUN (mkstemp, (path), - char *path) +_DEFUN(mkstemp, (path), + char *path) { int fd; @@ -219,8 +219,8 @@ _DEFUN (mkstemp, (path), } char * -_DEFUN (mktemp, (path), - char *path) +_DEFUN(mktemp, (path), + char *path) { return (_gettemp (_REENT, path, (int *) NULL) ? path : (char *) NULL); } diff --git a/newlib/libc/stdio/perror.c b/newlib/libc/stdio/perror.c index 19354c1..6ee6987 100644 --- a/newlib/libc/stdio/perror.c +++ b/newlib/libc/stdio/perror.c @@ -1,4 +1,21 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION <<perror>>---print an error message on standard error @@ -11,7 +28,7 @@ ANSI_SYNOPSIS #include <stdio.h> void perror(char *<[prefix]>); - void _perror_r(void *<[reent]>, char *<[prefix]>); + void _perror_r(struct _reent *<[reent]>, char *<[prefix]>); TRAD_SYNOPSIS #include <stdio.h> @@ -19,7 +36,7 @@ TRAD_SYNOPSIS char *<[prefix]>; void _perror_r(<[reent]>, <[prefix]>) - char *<[reent]>; + struct _reent *<[reent]>; char *<[prefix]>; DESCRIPTION @@ -33,7 +50,6 @@ of the strings described for <<strerror>>. The alternate function <<_perror_r>> is a reentrant version. The extra argument <[reent]> is a pointer to a reentrancy structure. - RETURNS <<perror>> returns no result. @@ -45,20 +61,20 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ -#include <stddef.h> +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #include <string.h> - #include "local.h" -void -_DEFUN (_perror_r, (ptr, s), - struct _reent *ptr _AND - _CONST char *s) +_VOID +_DEFUN(_perror_r, (ptr, s), + struct _reent *ptr _AND + _CONST char *s) { char *error; - _REENT_SMALL_CHECK_INIT(_stderr_r (ptr)); + _REENT_SMALL_CHECK_INIT (_stderr_r (ptr)); if (s != NULL && *s != '\0') { fputs (s, _stderr_r (ptr)); @@ -73,9 +89,9 @@ _DEFUN (_perror_r, (ptr, s), #ifndef _REENT_ONLY -void -_DEFUN (perror, (s), - _CONST char *s) +_VOID +_DEFUN(perror, (s), + _CONST char *s) { _perror_r (_REENT, s); } diff --git a/newlib/libc/stdio/printf.c b/newlib/libc/stdio/printf.c index da4cb8e..2512afe 100644 --- a/newlib/libc/stdio/printf.c +++ b/newlib/libc/stdio/printf.c @@ -1,30 +1,45 @@ +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ #include <_ansi.h> +#include <reent.h> #include <stdio.h> - -#include "local.h" - #ifdef _HAVE_STDC #include <stdarg.h> #else #include <varargs.h> #endif +#include "local.h" #ifdef _HAVE_STDC int -_printf_r (struct _reent *ptr, const char *fmt, ...) +_printf_r(struct _reent *ptr, _CONST char *fmt, ...) #else int -_printf_r (ptr, fmt, va_alist) - struct _reent *ptr; - char *fmt; - va_dcl +_printf_r(ptr, fmt, va_alist) + struct _reent *ptr; + char *fmt; + va_dcl #endif { int ret; va_list ap; - _REENT_SMALL_CHECK_INIT(_stdout_r (ptr)); + _REENT_SMALL_CHECK_INIT (_stdout_r (ptr)); #ifdef _HAVE_STDC va_start (ap, fmt); #else @@ -39,18 +54,18 @@ _printf_r (ptr, fmt, va_alist) #ifdef _HAVE_STDC int -printf (const char *fmt, ...) +printf(_CONST char *fmt, ...) #else int -printf (fmt, va_alist) - char *fmt; - va_dcl +printf(fmt, va_alist) + char *fmt; + va_dcl #endif { int ret; va_list ap; - _REENT_SMALL_CHECK_INIT(_stdout_r (_REENT)); + _REENT_SMALL_CHECK_INIT (_stdout_r (_REENT)); #ifdef _HAVE_STDC va_start (ap, fmt); #else diff --git a/newlib/libc/stdio/putc.c b/newlib/libc/stdio/putc.c index 7e53868..509aaf4 100644 --- a/newlib/libc/stdio/putc.c +++ b/newlib/libc/stdio/putc.c @@ -65,6 +65,7 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> #include <stdio.h> /* @@ -74,14 +75,14 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #undef putc int -putc (c, fp) - int c; - register FILE *fp; +_DEFUN(putc, (c, fp), + int c _AND + register FILE *fp) { int result; - _flockfile(fp); + _flockfile (fp); /* CHECK_INIT is (eventually) called by __swbuf. */ result = __sputc (c, fp); - _funlockfile(fp); + _funlockfile (fp); return result; } diff --git a/newlib/libc/stdio/putc_u.c b/newlib/libc/stdio/putc_u.c index a3c0e08..aee11f4 100644 --- a/newlib/libc/stdio/putc_u.c +++ b/newlib/libc/stdio/putc_u.c @@ -44,12 +44,14 @@ POSIX 1003.1 requires <<putc_unlocked>>. <<putc_unlocked>> may be implemented as a macro, so arguments should not have side-effects. Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, -<<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ +<<lseek>>, <<read>>, <<sbrk>>, <<write>>. +*/ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> #include <stdio.h> /* @@ -59,9 +61,9 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #undef putc_unlocked int -putc_unlocked (c, fp) - int c; - register FILE *fp; +_DEFUN(putc_unlocked, (c, fp), + int c _AND + register FILE *fp) { /* CHECK_INIT is (eventually) called by __swbuf. */ diff --git a/newlib/libc/stdio/putchar.c b/newlib/libc/stdio/putchar.c index ff207f3..903de07 100644 --- a/newlib/libc/stdio/putchar.c +++ b/newlib/libc/stdio/putchar.c @@ -28,7 +28,7 @@ ANSI_SYNOPSIS #include <stdio.h> int putchar(int <[ch]>); - int _putchar_r(void *<[reent]>, int <[ch]>); + int _putchar_r(struct _reent *<[reent]>, int <[ch]>); TRAD_SYNOPSIS #include <stdio.h> @@ -36,7 +36,7 @@ TRAD_SYNOPSIS int <[ch]>; int _putchar_r(<[reent]>, <[ch]>) - char *<[reent]>; + struct _reent *<[reent]>; int <[ch]>; DESCRIPTION @@ -68,26 +68,27 @@ static char sccsid[] = "%W% (Berkeley) %G%"; * A subroutine version of the macro putchar. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> - #include "local.h" #undef putchar int -_putchar_r (ptr, c) - struct _reent *ptr; - int c; +_DEFUN(_putchar_r, (ptr, c), + struct _reent *ptr _AND + int c) { - _REENT_SMALL_CHECK_INIT(_stdout_r (ptr)); + _REENT_SMALL_CHECK_INIT (_stdout_r (ptr)); return putc (c, _stdout_r (ptr)); } #ifndef _REENT_ONLY int -putchar (c) - int c; +_DEFUN(putchar, (c), + int c) { /* CHECK_INIT is (eventually) called by __swbuf. */ diff --git a/newlib/libc/stdio/putchar_u.c b/newlib/libc/stdio/putchar_u.c index 3542fe4..423ad77 100644 --- a/newlib/libc/stdio/putchar_u.c +++ b/newlib/libc/stdio/putchar_u.c @@ -54,14 +54,16 @@ static char sccsid[] = "%W% (Berkeley) %G%"; * A subroutine version of the macro putchar_unlocked. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #undef putchar_unlocked int -_putchar_unlocked_r (ptr, c) - struct _reent *ptr; - int c; +_DEFUN(_putchar_unlocked_r, (ptr, c), + struct _reent *ptr _AND + int c) { return putc_unlocked (c, _stdout_r (ptr)); } @@ -69,12 +71,12 @@ _putchar_unlocked_r (ptr, c) #ifndef _REENT_ONLY int -putchar_unlocked (c) - int c; +_DEFUN(putchar_unlocked, (c), + int c) { /* CHECK_INIT is (eventually) called by __swbuf. */ - _putchar_unlocked_r (_REENT, c); + return _putchar_unlocked_r (_REENT, c); } #endif diff --git a/newlib/libc/stdio/puts.c b/newlib/libc/stdio/puts.c index e270199..68251ce 100644 --- a/newlib/libc/stdio/puts.c +++ b/newlib/libc/stdio/puts.c @@ -28,7 +28,7 @@ ANSI_SYNOPSIS #include <stdio.h> int puts(const char *<[s]>); - int _puts_r(void *<[reent]>, const char *<[s]>); + int _puts_r(struct _reent *<[reent]>, const char *<[s]>); TRAD_SYNOPSIS #include <stdio.h> @@ -36,7 +36,7 @@ TRAD_SYNOPSIS char *<[s]>; int _puts_r(<[reent]>, <[s]>) - char *<[reent]>; + struct _reent *<[reent]>; char *<[s]>; DESCRIPTION @@ -55,15 +55,17 @@ ANSI C requires <<puts>>, but does not specify that the result on success must be <<0>>; any non-negative value is permitted. Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, -<<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ +<<lseek>>, <<read>>, <<sbrk>>, <<write>>. +*/ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #include <string.h> - #include "fvwrite.h" #include "local.h" @@ -72,9 +74,9 @@ static char sccsid[] = "%W% (Berkeley) %G%"; */ int -_DEFUN (_puts_r, (ptr, s), - struct _reent *ptr _AND - _CONST char * s) +_DEFUN(_puts_r, (ptr, s), + struct _reent *ptr _AND + _CONST char * s) { size_t c = strlen (s); struct __suio uio; @@ -88,15 +90,15 @@ _DEFUN (_puts_r, (ptr, s), uio.uio_iov = &iov[0]; uio.uio_iovcnt = 2; - _REENT_SMALL_CHECK_INIT(_stdout_r (ptr)); + _REENT_SMALL_CHECK_INIT (_stdout_r (ptr)); return (__sfvwrite (_stdout_r (ptr), &uio) ? EOF : '\n'); } #ifndef _REENT_ONLY int -_DEFUN (puts, (s), - char _CONST * s) +_DEFUN(puts, (s), + char _CONST * s) { return _puts_r (_REENT, s); } diff --git a/newlib/libc/stdio/putw.c b/newlib/libc/stdio/putw.c index 19f4abc..78406ee 100644 --- a/newlib/libc/stdio/putw.c +++ b/newlib/libc/stdio/putw.c @@ -44,7 +44,8 @@ PORTABILITY <<fwrite>> should be used instead. In fact, this implementation of <<putw>> is based upon <<fwrite>>. -Supporting OS subroutines required: <<fwrite>>. */ +Supporting OS subroutines required: <<fwrite>>. +*/ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "%W% (Berkeley) %G%"; @@ -53,11 +54,11 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #include <stdio.h> int -putw (w, fp) - int w; - register FILE *fp; +_DEFUN(putw, (w, fp), + int w _AND + register FILE *fp) { - if (fwrite((const char*)&w, sizeof(w), 1, fp) != 1) + if (fwrite ((_CONST char*)&w, sizeof (w), 1, fp) != 1) return EOF; return 0; } diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c index 66ce4ca..74573e8 100644 --- a/newlib/libc/stdio/refill.c +++ b/newlib/libc/stdio/refill.c @@ -1,5 +1,3 @@ -/* No user fns here. Pesch 15apr92. */ - /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -16,14 +14,16 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* No user fns here. Pesch 15apr92. */ +#include <_ansi.h> #include <stdio.h> -#include "local.h" #include <stdlib.h> +#include "local.h" static int -lflush (fp) - FILE *fp; +_DEFUN(lflush, (fp), + FILE *fp) { if ((fp->_flags & (__SLBF | __SWR)) == (__SLBF | __SWR)) return fflush (fp); @@ -36,8 +36,8 @@ lflush (fp) */ int -_DEFUN (__srefill, (fp), - register FILE * fp) +_DEFUN(__srefill, (fp), + register FILE * fp) { /* make sure stdio is set up */ @@ -94,7 +94,7 @@ _DEFUN (__srefill, (fp), */ if (fp->_flags & (__SLBF | __SNBF)) - (void) _fwalk (_GLOBAL_REENT, lflush); + _CAST_VOID _fwalk (_GLOBAL_REENT, lflush); fp->_p = fp->_bf._base; fp->_r = (*fp->_read) (fp->_cookie, (char *) fp->_p, fp->_bf._size); fp->_flags &= ~__SMOD; /* buffer contents are again pristine */ diff --git a/newlib/libc/stdio/remove.c b/newlib/libc/stdio/remove.c index b24ce71..e026ce5 100644 --- a/newlib/libc/stdio/remove.c +++ b/newlib/libc/stdio/remove.c @@ -1,4 +1,21 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION <<remove>>---delete a file's name @@ -9,7 +26,7 @@ ANSI_SYNOPSIS #include <stdio.h> int remove(char *<[filename]>); - int _remove_r(void *<[reent]>, char *<[filename]>); + int _remove_r(struct _reent *<[reent]>, char *<[filename]>); TRAD_SYNOPSIS #include <stdio.h> @@ -17,7 +34,7 @@ TRAD_SYNOPSIS char *<[filename]>; int _remove_r(<[reent]>, <[filename]>) - char *<[reent]>; + struct _reent *<[reent]>; char *<[filename]>; DESCRIPTION @@ -44,13 +61,14 @@ open file may vary among implementations. Supporting OS subroutine required: <<unlink>>. */ -#include <stdio.h> +#include <_ansi.h> #include <reent.h> +#include <stdio.h> int -_remove_r (ptr, filename) - struct _reent *ptr; - _CONST char *filename; +_DEFUN(_remove_r, (ptr, filename), + struct _reent *ptr _AND + _CONST char *filename) { if (_unlink_r (ptr, filename) == -1) return -1; @@ -61,8 +79,8 @@ _remove_r (ptr, filename) #ifndef _REENT_ONLY int -remove (filename) - _CONST char *filename; +_DEFUN(remove, (filename), + _CONST char *filename) { return _remove_r (_REENT, filename); } diff --git a/newlib/libc/stdio/rename.c b/newlib/libc/stdio/rename.c index 19a6afd..4fa8e39 100644 --- a/newlib/libc/stdio/rename.c +++ b/newlib/libc/stdio/rename.c @@ -1,4 +1,21 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION <<rename>>---rename a file @@ -11,7 +28,7 @@ ANSI_SYNOPSIS #include <stdio.h> int rename(const char *<[old]>, const char *<[new]>); - int _rename_r(void *<[reent]>, + int _rename_r(struct _reent *<[reent]>, const char *<[old]>, const char *<[new]>); TRAD_SYNOPSIS @@ -21,7 +38,7 @@ TRAD_SYNOPSIS char *<[new]>; int _rename_r(<[reent]>, <[old]>, <[new]>) - char *<[reent]>; + struct _reent *<[reent]>; char *<[old]>; char *<[new]>; @@ -48,15 +65,16 @@ as <<*<[new]>>> may vary from one implementation to another. Supporting OS subroutines required: <<link>>, <<unlink>>, or <<rename>>. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #include <sys/unistd.h> -#include <reent.h> int -_rename_r (ptr, old, new) - struct _reent *ptr; - _CONST char *old; - _CONST char *new; +_DEFUN(_rename_r, (ptr, old, new), + struct _reent *ptr _AND + _CONST char *old _AND + _CONST char *new) { #ifdef HAVE_RENAME return _rename (old,new); @@ -76,9 +94,9 @@ _rename_r (ptr, old, new) #ifndef _REENT_ONLY int -rename (old, new) - _CONST char *old; - _CONST char *new; +_DEFUN(rename, (old, new), + _CONST char *old _AND + _CONST char *new) { return _rename_r (_REENT, old, new); } diff --git a/newlib/libc/stdio/rewind.c b/newlib/libc/stdio/rewind.c index 2b9f319..58f4cc3 100644 --- a/newlib/libc/stdio/rewind.c +++ b/newlib/libc/stdio/rewind.c @@ -56,24 +56,26 @@ No supporting OS subroutines are required. static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> -void -_DEFUN (_rewind_r, (ptr, fp), - struct _reent * ptr _AND - register FILE * fp) +_VOID +_DEFUN(_rewind_r, (ptr, fp), + struct _reent * ptr _AND + register FILE * fp) { - (void) _fseek_r (ptr, fp, 0L, SEEK_SET); - clearerr(fp); + _CAST_VOID _fseek_r (ptr, fp, 0L, SEEK_SET); + clearerr (fp); } #ifndef _REENT_ONLY -void -_DEFUN (rewind, (fp), - register FILE * fp) +_VOID +_DEFUN(rewind, (fp), + register FILE * fp) { - (void) _fseek_r (_REENT, fp, 0L, SEEK_SET); + _CAST_VOID _fseek_r (_REENT, fp, 0L, SEEK_SET); } #endif /* !_REENT_ONLY */ diff --git a/newlib/libc/stdio/rget.c b/newlib/libc/stdio/rget.c index ea29c2b..ee4e49e 100644 --- a/newlib/libc/stdio/rget.c +++ b/newlib/libc/stdio/rget.c @@ -1,5 +1,3 @@ -/* No user fns here. Pesch 15apr92. */ - /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -16,11 +14,13 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* No user fns here. Pesch 15apr92. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> #include <stdio.h> #include "local.h" @@ -31,8 +31,8 @@ static char sccsid[] = "%W% (Berkeley) %G%"; */ int -__srget (fp) - register FILE *fp; +_DEFUN(__srget, (fp), + register FILE *fp) { if (__srefill (fp) == 0) { diff --git a/newlib/libc/stdio/scanf.c b/newlib/libc/stdio/scanf.c index de8e038..733a638 100644 --- a/newlib/libc/stdio/scanf.c +++ b/newlib/libc/stdio/scanf.c @@ -16,30 +16,30 @@ */ #include <_ansi.h> +#include <reent.h> #include <stdio.h> -#include "local.h" - #ifdef _HAVE_STDC #include <stdarg.h> #else #include <varargs.h> #endif +#include "local.h" #ifndef _REENT_ONLY int #ifdef _HAVE_STDC -scanf (const char *fmt, ...) +scanf(_CONST char *fmt, ...) #else -scanf (fmt, va_alist) - char *fmt; - va_dcl +scanf(fmt, va_alist) + char *fmt; + va_dcl #endif { int ret; va_list ap; - _REENT_SMALL_CHECK_INIT(_stdin_r (_REENT)); + _REENT_SMALL_CHECK_INIT (_stdin_r (_REENT)); #ifdef _HAVE_STDC va_start (ap, fmt); #else @@ -54,18 +54,18 @@ scanf (fmt, va_alist) int #ifdef _HAVE_STDC -_scanf_r (struct _reent *ptr, const char *fmt, ...) +_scanf_r(struct _reent *ptr, _CONST char *fmt, ...) #else -_scanf_r (ptr, fmt, va_alist) - struct _reent *ptr; - char *fmt; - va_dcl +_scanf_r(ptr, fmt, va_alist) + struct _reent *ptr; + char *fmt; + va_dcl #endif { int ret; va_list ap; - _REENT_SMALL_CHECK_INIT(_stdin_r (ptr)); + _REENT_SMALL_CHECK_INIT (_stdin_r (ptr)); #ifdef _HAVE_STDC va_start (ap, fmt); #else @@ -76,4 +76,3 @@ _scanf_r (ptr, fmt, va_alist) return (ret); } - diff --git a/newlib/libc/stdio/setbuf.c b/newlib/libc/stdio/setbuf.c index 15d09e0..1a8bc6d 100644 --- a/newlib/libc/stdio/setbuf.c +++ b/newlib/libc/stdio/setbuf.c @@ -70,10 +70,10 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include <stdio.h> #include "local.h" -void -_DEFUN (setbuf, (fp, buf), - FILE * fp _AND - char *buf) +_VOID +_DEFUN(setbuf, (fp, buf), + FILE * fp _AND + char *buf) { - (void) setvbuf (fp, buf, buf ? _IOFBF : _IONBF, BUFSIZ); + _CAST_VOID setvbuf (fp, buf, buf ? _IOFBF : _IONBF, BUFSIZ); } diff --git a/newlib/libc/stdio/setbuffer.c b/newlib/libc/stdio/setbuffer.c index c74c7fc..4b2e2f6 100644 --- a/newlib/libc/stdio/setbuffer.c +++ b/newlib/libc/stdio/setbuffer.c @@ -14,7 +14,6 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ - /* Modified copy of setbuf.c to support the setbuffer function defined as part of BSD. @@ -69,7 +68,6 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, FUNCTION - <<setlinebuf>>---specify line buffering for a file or stream INDEX @@ -108,11 +106,11 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include <stdio.h> #include "local.h" -void -_DEFUN (setbuffer, (fp, buf, size), - FILE * fp _AND - char *buf _AND - int size) +_VOID +_DEFUN(setbuffer, (fp, buf, size), + FILE * fp _AND + char *buf _AND + int size) { - (void) setvbuf (fp, buf, buf ? _IOFBF : _IONBF, (size_t) size); + _CAST_VOID setvbuf (fp, buf, buf ? _IOFBF : _IONBF, (size_t) size); } diff --git a/newlib/libc/stdio/setlinebuf.c b/newlib/libc/stdio/setlinebuf.c index f279713..0df6a57 100644 --- a/newlib/libc/stdio/setlinebuf.c +++ b/newlib/libc/stdio/setlinebuf.c @@ -14,7 +14,6 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ - /* Modified copy of setbuf.c to support setlinebuf function defined as part of BSD. @@ -23,7 +22,6 @@ Modifications by Gareth Pearce, 2001. /* FUNCTION - <<setlinebuf>>---specify line buffering for a file or stream INDEX @@ -63,8 +61,8 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include "local.h" int -_DEFUN (setlinebuf, (fp), - FILE * fp) +_DEFUN(setlinebuf, (fp), + FILE * fp) { return (setvbuf (fp, (char *) NULL, _IOLBF, (size_t) 0)); } diff --git a/newlib/libc/stdio/setvbuf.c b/newlib/libc/stdio/setvbuf.c index 74a4cea..eddfde8 100644 --- a/newlib/libc/stdio/setvbuf.c +++ b/newlib/libc/stdio/setvbuf.c @@ -96,15 +96,15 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, */ int -_DEFUN (setvbuf, (fp, buf, mode, size), - register FILE * fp _AND - char *buf _AND - register int mode _AND - register size_t size) +_DEFUN(setvbuf, (fp, buf, mode, size), + register FILE * fp _AND + char *buf _AND + register int mode _AND + register size_t size) { int ret = 0; - _flockfile(fp); + _flockfile (fp); CHECK_INIT (fp); @@ -115,7 +115,7 @@ _DEFUN (setvbuf, (fp, buf, mode, size), if ((mode != _IOFBF && mode != _IOLBF && mode != _IONBF) || (int)(_POINTER_INT) size < 0) { - _funlockfile(fp); + _funlockfile (fp); return (EOF); } @@ -126,11 +126,11 @@ _DEFUN (setvbuf, (fp, buf, mode, size), * non buffer flags, and clear malloc flag. */ - (void) fflush (fp); + _CAST_VOID fflush (fp); fp->_r = 0; fp->_lbfsize = 0; if (fp->_flags & __SMBF) - _free_r (_REENT, (void *) fp->_bf._base); + _free_r (_REENT, (_PTR) fp->_bf._base); fp->_flags &= ~(__SLBF | __SNBF | __SMBF); if (mode == _IONBF) @@ -158,7 +158,7 @@ nbf: fp->_w = 0; fp->_bf._base = fp->_p = fp->_nbuf; fp->_bf._size = 1; - _funlockfile(fp); + _funlockfile (fp); return (ret); } fp->_flags |= __SMBF; @@ -193,6 +193,6 @@ nbf: if (fp->_flags & __SWR) fp->_w = fp->_flags & (__SLBF | __SNBF) ? 0 : size; - _funlockfile(fp); + _funlockfile (fp); return 0; } diff --git a/newlib/libc/stdio/siprintf.c b/newlib/libc/stdio/siprintf.c index aeced2e..1462339 100644 --- a/newlib/libc/stdio/siprintf.c +++ b/newlib/libc/stdio/siprintf.c @@ -1,6 +1,24 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* FUNCTION - <<siprintf>>---write formatted output (integer only) +<<siprintf>>---write formatted output (integer only) + INDEX siprintf @@ -29,6 +47,8 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #ifdef _HAVE_STDC #include <stdarg.h> @@ -36,18 +56,18 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include <varargs.h> #endif #include <limits.h> -#include <_ansi.h> -#include <reent.h> #include "local.h" int #ifdef _HAVE_STDC -_DEFUN (siprintf, (str, fmt), char *str _AND _CONST char *fmt _DOTS) +_DEFUN(siprintf, (str, fmt), + char *str _AND + _CONST char *fmt _DOTS) #else -siprintf (str, fmt, va_alist) - char *str; - _CONST char *fmt; - va_dcl +siprintf(str, fmt, va_alist) + char *str; + _CONST char *fmt; + va_dcl #endif { int ret; diff --git a/newlib/libc/stdio/snprintf.c b/newlib/libc/stdio/snprintf.c index fe54ea0..fc818d2 100644 --- a/newlib/libc/stdio/snprintf.c +++ b/newlib/libc/stdio/snprintf.c @@ -1,7 +1,3 @@ -/* doc in sprintf.c */ - -/* This code created by modifying sprintf.c so copyright inherited. */ - /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -18,7 +14,11 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* doc in sprintf.c */ +/* This code created by modifying sprintf.c so copyright inherited. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #ifdef _HAVE_STDC #include <stdarg.h> @@ -26,19 +26,22 @@ #include <varargs.h> #endif #include <limits.h> -#include <_ansi.h> #include "local.h" int #ifdef _HAVE_STDC -_DEFUN (_snprintf_r, (ptr, str, size, fmt), struct _reent *ptr _AND char *str _AND size_t size _AND _CONST char *fmt _DOTS) +_DEFUN(_snprintf_r, (ptr, str, size, fmt), + struct _reent *ptr _AND + char *str _AND + size_t size _AND + _CONST char *fmt _DOTS) #else -_snprintf_r (ptr, str, size, fmt, va_alist) - struct _reent *ptr; - char *str; - size_t size; - _CONST char *fmt; - va_dcl +_snprintf_r(ptr, str, size, fmt, va_alist) + struct _reent *ptr; + char *str; + size_t size; + _CONST char *fmt; + va_dcl #endif { int ret; @@ -64,13 +67,16 @@ _snprintf_r (ptr, str, size, fmt, va_alist) int #ifdef _HAVE_STDC -_DEFUN (snprintf, (str, size, fmt), char *str _AND size_t size _AND _CONST char *fmt _DOTS) +_DEFUN(snprintf, (str, size, fmt), + char *str _AND + size_t size _AND + _CONST char *fmt _DOTS) #else -snprintf (str, size, fmt, va_alist) - char *str; - size_t size; - _CONST char *fmt; - va_dcl +snprintf(str, size, fmt, va_alist) + char *str; + size_t size; + _CONST char *fmt; + va_dcl #endif { int ret; diff --git a/newlib/libc/stdio/sprintf.c b/newlib/libc/stdio/sprintf.c index 01be921..8ee5307 100644 --- a/newlib/libc/stdio/sprintf.c +++ b/newlib/libc/stdio/sprintf.c @@ -16,9 +16,9 @@ */ /* - FUNCTION <<printf>>, <<fprintf>>, <<asprintf>>, <<sprintf>>, <<snprintf>>---format output + INDEX fprintf INDEX @@ -305,6 +305,8 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #ifdef _HAVE_STDC #include <stdarg.h> @@ -312,18 +314,20 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include <varargs.h> #endif #include <limits.h> -#include <_ansi.h> #include "local.h" int #ifdef _HAVE_STDC -_DEFUN (_sprintf_r, (ptr, str, fmt), struct _reent *ptr _AND char *str _AND _CONST char *fmt _DOTS) +_DEFUN(_sprintf_r, (ptr, str, fmt), + struct _reent *ptr _AND + char *str _AND + _CONST char *fmt _DOTS) #else -_sprintf_r (ptr, str, fmt, va_alist) - struct _reent *ptr; - char *str; - _CONST char *fmt; - va_dcl +_sprintf_r(ptr, str, fmt, va_alist) + struct _reent *ptr; + char *str; + _CONST char *fmt; + va_dcl #endif { int ret; @@ -349,12 +353,14 @@ _sprintf_r (ptr, str, fmt, va_alist) int #ifdef _HAVE_STDC -_DEFUN (sprintf, (str, fmt), char *str _AND _CONST char *fmt _DOTS) +_DEFUN(sprintf, (str, fmt), + char *str _AND + _CONST char *fmt _DOTS) #else -sprintf (str, fmt, va_alist) - char *str; - _CONST char *fmt; - va_dcl +sprintf(str, fmt, va_alist) + char *str; + _CONST char *fmt; + va_dcl #endif { int ret; diff --git a/newlib/libc/stdio/sscanf.c b/newlib/libc/stdio/sscanf.c index ca80c0e..1aca405 100644 --- a/newlib/libc/stdio/sscanf.c +++ b/newlib/libc/stdio/sscanf.c @@ -16,9 +16,8 @@ */ /* - FUNCTION - <<scanf>>, <<fscanf>>, <<sscanf>>---scan and format input +<<scanf>>, <<fscanf>>, <<sscanf>>---scan and format input INDEX scanf @@ -375,12 +374,11 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, /* | ARGSUSED */ /*SUPPRESS 590*/ -static -_READ_WRITE_RETURN_TYPE -eofread (cookie, buf, len) - _PTR cookie; - char *buf; - int len; +static _READ_WRITE_RETURN_TYPE +_DEFUN(eofread, (cookie, buf, len), + _PTR cookie _AND + char *buf _AND + int len) { return 0; } @@ -389,13 +387,15 @@ eofread (cookie, buf, len) #ifdef _HAVE_STDC int -_DEFUN (sscanf, (str, fmt), _CONST char *str _AND _CONST char *fmt _DOTS) +_DEFUN(sscanf, (str, fmt), + _CONST char *str _AND + _CONST char *fmt _DOTS) #else int -sscanf (str, fmt, va_alist) - _CONST char *str; - _CONST char *fmt; - va_dcl +sscanf(str, fmt, va_alist) + _CONST char *str; + _CONST char *fmt; + va_dcl #endif { int ret; @@ -422,14 +422,17 @@ sscanf (str, fmt, va_alist) #ifdef _HAVE_STDC int -_DEFUN (_sscanf_r, (ptr, str, fmt), struct _reent *ptr _AND _CONST char *str _AND _CONST char *fmt _DOTS) +_DEFUN(_sscanf_r, (ptr, str, fmt), + struct _reent *ptr _AND + _CONST char *str _AND + _CONST char *fmt _DOTS) #else int -_sscanf_r (ptr, str, fmt, va_alist) - struct _reent *ptr; - _CONST char *str; - _CONST char *fmt; - va_dcl +_sscanf_r(ptr, str, fmt, va_alist) + struct _reent *ptr; + _CONST char *str; + _CONST char *fmt; + va_dcl #endif { int ret; diff --git a/newlib/libc/stdio/stdio.c b/newlib/libc/stdio/stdio.c index bf304bc..8bc7360 100644 --- a/newlib/libc/stdio/stdio.c +++ b/newlib/libc/stdio/stdio.c @@ -1,5 +1,3 @@ -/* No user fns here. Pesch 15apr92. */ - /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -16,7 +14,10 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* No user fns here. Pesch 15apr92. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #include <sys/types.h> #include <fcntl.h> @@ -29,10 +30,10 @@ */ _READ_WRITE_RETURN_TYPE -__sread (cookie, buf, n) - _PTR cookie; - char *buf; - int n; +_DEFUN(__sread, (cookie, buf, n), + _PTR cookie _AND + char *buf _AND + int n) { register FILE *fp = (FILE *) cookie; register int ret; @@ -40,14 +41,14 @@ __sread (cookie, buf, n) #ifdef __SCLE int oldmode = 0; if (fp->_flags & __SCLE) - oldmode = setmode(fp->_file, O_BINARY); + oldmode = setmode (fp->_file, O_BINARY); #endif ret = _read_r (_REENT, fp->_file, buf, n); #ifdef __SCLE if (oldmode) - setmode(fp->_file, oldmode); + setmode (fp->_file, oldmode); #endif /* If the read succeeded, update the current offset. */ @@ -60,10 +61,10 @@ __sread (cookie, buf, n) } _READ_WRITE_RETURN_TYPE -__swrite (cookie, buf, n) - _PTR cookie; - char _CONST *buf; - int n; +_DEFUN(__swrite, (cookie, buf, n), + _PTR cookie _AND + char _CONST *buf _AND + int n) { register FILE *fp = (FILE *) cookie; int w; @@ -72,29 +73,29 @@ __swrite (cookie, buf, n) #endif if (fp->_flags & __SAPP) - (void) _lseek_r (_REENT, fp->_file, (_off_t) 0, SEEK_END); + _CAST_VOID _lseek_r (_REENT, fp->_file, (_off_t) 0, SEEK_END); fp->_flags &= ~__SOFF; /* in case O_APPEND mode is set */ #ifdef __SCLE if (fp->_flags & __SCLE) - oldmode = setmode(fp->_file, O_BINARY); + oldmode = setmode (fp->_file, O_BINARY); #endif w = _write_r (_REENT, fp->_file, buf, n); #ifdef __SCLE if (oldmode) - setmode(fp->_file, oldmode); + setmode (fp->_file, oldmode); #endif return w; } _fpos_t -__sseek (cookie, offset, whence) - _PTR cookie; - _fpos_t offset; - int whence; +_DEFUN(__sseek, (cookie, offset, whence), + _PTR cookie _AND + _fpos_t offset _AND + int whence) { register FILE *fp = (FILE *) cookie; register _off_t ret; @@ -111,8 +112,8 @@ __sseek (cookie, offset, whence) } int -__sclose (cookie) - _PTR cookie; +_DEFUN(__sclose, (cookie), + _PTR cookie) { FILE *fp = (FILE *) cookie; @@ -121,7 +122,8 @@ __sclose (cookie) #ifdef __SCLE int -__stextmode (int fd) +_DEFUN(__stextmode, (fd), + int fd) { #ifdef __CYGWIN__ return _cygwin_istext_for_stdio (fd); diff --git a/newlib/libc/stdio/tmpfile.c b/newlib/libc/stdio/tmpfile.c index c38e61d..a6c2c91 100644 --- a/newlib/libc/stdio/tmpfile.c +++ b/newlib/libc/stdio/tmpfile.c @@ -11,14 +11,14 @@ ANSI_SYNOPSIS #include <stdio.h> FILE *tmpfile(void); - FILE *_tmpfile_r(void *<[reent]>); + FILE *_tmpfile_r(struct _reent *<[reent]>); TRAD_SYNOPSIS #include <stdio.h> FILE *tmpfile(); FILE *_tmpfile_r(<[reent]>) - char *<[reent]>; + struct _reent *<[reent]>; DESCRIPTION Create a temporary file (a file which will be deleted automatically), @@ -45,12 +45,14 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<getpid>>, <<tmpfile>> also requires the global pointer <<environ>>. */ +#include <_ansi.h> +#include <reent.h> #include <stdio.h> #include <errno.h> FILE * -_DEFUN (_tmpfile_r, (ptr), - struct _reent *ptr) +_DEFUN(_tmpfile_r, (ptr), + struct _reent *ptr) { FILE *fp; int e; @@ -69,7 +71,7 @@ _DEFUN (_tmpfile_r, (ptr), #ifndef _REENT_ONLY FILE * -_DEFUN_VOID (tmpfile) +_DEFUN_VOID(tmpfile) { return _tmpfile_r (_REENT); } diff --git a/newlib/libc/stdio/tmpnam.c b/newlib/libc/stdio/tmpnam.c index ec346c8..ee722e6 100644 --- a/newlib/libc/stdio/tmpnam.c +++ b/newlib/libc/stdio/tmpnam.c @@ -2,7 +2,6 @@ * tmpname.c * Original Author: G. Haley */ - /* FUNCTION <<tmpnam>>, <<tempnam>>---name for a temporary file @@ -20,8 +19,8 @@ ANSI_SYNOPSIS #include <stdio.h> char *tmpnam(char *<[s]>); char *tempnam(char *<[dir]>, char *<[pfx]>); - char *_tmpnam_r(void *<[reent]>, char *<[s]>); - char *_tempnam_r(void *<[reent]>, char *<[dir]>, char *<[pfx]>); + char *_tmpnam_r(struct _reent *<[reent]>, char *<[s]>); + char *_tempnam_r(struct _reent *<[reent]>, char *<[dir]>, char *<[pfx]>); TRAD_SYNOPSIS #include <stdio.h> @@ -33,11 +32,11 @@ TRAD_SYNOPSIS char *<[pfx]>; char *_tmpnam_r(<[reent]>, <[s]>) - char *<[reent]>; + struct _reent *<[reent]>; char *<[s]>; char *_tempnam_r(<[reent]>, <[dir]>, <[pfx]>) - char *<[reent]>; + struct *<[reent]>; char *<[dir]>; char *<[pfx]>; @@ -93,6 +92,7 @@ The global pointer <<environ>> is also required. */ #include <_ansi.h> +#include <reent.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -104,13 +104,13 @@ The global pointer <<environ>> is also required. another one. Return nonzero if successful, otherwise zero. */ static int -worker (ptr, result, part1, part2, part3, part4) - struct _reent *ptr; - char *result; - _CONST char *part1; - _CONST char *part2; - int part3; - int *part4; +_DEFUN(worker, (ptr, result, part1, part2, part3, part4), + struct _reent *ptr _AND + char *result _AND + _CONST char *part1 _AND + _CONST char *part2 _AND + int part3 _AND + int *part4) { /* Generate the filename and make sure that there isn't one called it already. */ @@ -136,9 +136,9 @@ worker (ptr, result, part1, part2, part3, part4) } char * -_DEFUN (_tmpnam_r, (p, s), - struct _reent *p _AND - char *s) +_DEFUN(_tmpnam_r, (p, s), + struct _reent *p _AND + char *s) { char *result; int pid; @@ -165,10 +165,10 @@ _DEFUN (_tmpnam_r, (p, s), } char * -_DEFUN (_tempnam_r, (p, dir, pfx), - struct _reent *p _AND - _CONST char *dir _AND - _CONST char *pfx) +_DEFUN(_tempnam_r, (p, dir, pfx), + struct _reent *p _AND + _CONST char *dir _AND + _CONST char *pfx) { char *filename; int length; @@ -192,16 +192,16 @@ _DEFUN (_tempnam_r, (p, dir, pfx), #ifndef _REENT_ONLY char * -_DEFUN (tempnam, (dir, pfx), - _CONST char *dir _AND - _CONST char *pfx) +_DEFUN(tempnam, (dir, pfx), + _CONST char *dir _AND + _CONST char *pfx) { return _tempnam_r (_REENT, dir, pfx); } char * -_DEFUN (tmpnam, (s), - char *s) +_DEFUN(tmpnam, (s), + char *s) { return _tmpnam_r (_REENT, s); } diff --git a/newlib/libc/stdio/ungetc.c b/newlib/libc/stdio/ungetc.c index 5ca9825..4380cc2 100644 --- a/newlib/libc/stdio/ungetc.c +++ b/newlib/libc/stdio/ungetc.c @@ -19,6 +19,7 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -33,8 +34,8 @@ static char sccsid[] = "%W% (Berkeley) %G%"; /*static*/ int -__submore (fp) - register FILE *fp; +_DEFUN(__submore, (fp), + register FILE *fp) { register int i; register unsigned char *p; @@ -58,7 +59,7 @@ __submore (fp) p = (unsigned char *) _realloc_r (_REENT, (_PTR) (fp->_ub._base), i << 1); if (p == NULL) return EOF; - (void) memcpy ((void *) (p + i), (void *) p, (size_t) i); + _CAST_VOID memcpy ((_PTR) (p + i), (_PTR) p, (size_t) i); fp->_p = p + i; fp->_ub._base = p; fp->_ub._size = i << 1; @@ -66,14 +67,14 @@ __submore (fp) } int -ungetc (c, fp) - int c; - register FILE *fp; +_DEFUN(ungetc, (c, fp), + int c _AND + register FILE *fp) { if (c == EOF) return (EOF); - _flockfile(fp); + _flockfile (fp); /* Ensure stdio has been initialized. ??? Might be able to remove this as some other stdio routine should @@ -92,14 +93,14 @@ ungetc (c, fp) */ if ((fp->_flags & __SRW) == 0) { - _funlockfile(fp); + _funlockfile (fp); return EOF; } if (fp->_flags & __SWR) { if (fflush (fp)) { - _funlockfile(fp); + _funlockfile (fp); return EOF; } fp->_flags &= ~__SWR; @@ -119,12 +120,12 @@ ungetc (c, fp) { if (fp->_r >= fp->_ub._size && __submore (fp)) { - _funlockfile(fp); + _funlockfile (fp); return EOF; } *--fp->_p = c; fp->_r++; - _funlockfile(fp); + _funlockfile (fp); return c; } @@ -138,7 +139,7 @@ ungetc (c, fp) { fp->_p--; fp->_r++; - _funlockfile(fp); + _funlockfile (fp); return c; } @@ -154,6 +155,6 @@ ungetc (c, fp) fp->_ubuf[sizeof (fp->_ubuf) - 1] = c; fp->_p = &fp->_ubuf[sizeof (fp->_ubuf) - 1]; fp->_r = 1; - _funlockfile(fp); + _funlockfile (fp); return c; } diff --git a/newlib/libc/stdio/vasprintf.c b/newlib/libc/stdio/vasprintf.c index 539e231..43197d5 100644 --- a/newlib/libc/stdio/vasprintf.c +++ b/newlib/libc/stdio/vasprintf.c @@ -1,5 +1,3 @@ -/* doc in vfprintf.c */ - /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -16,15 +14,14 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ - /* This code was based on vsprintf.c */ +/* doc in vfprintf.c */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #include <_ansi.h> -#include <reent.h> #include <stdio.h> #include <limits.h> #ifdef _HAVE_STDC @@ -36,10 +33,10 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #ifndef _REENT_ONLY int -_DEFUN (vasprintf, (strp, fmt, ap), - char **strp _AND - _CONST char *fmt _AND - va_list ap) +_DEFUN(vasprintf, (strp, fmt, ap), + char **strp _AND + _CONST char *fmt _AND + va_list ap) { int ret; FILE f; @@ -57,11 +54,11 @@ _DEFUN (vasprintf, (strp, fmt, ap), #endif /* !_REENT_ONLY */ int -_DEFUN (_vasprintf_r, (ptr, strp, fmt, ap), - struct _reent *ptr _AND - char **strp _AND - _CONST char *fmt _AND - va_list ap) +_DEFUN(_vasprintf_r, (ptr, strp, fmt, ap), + struct _reent *ptr _AND + char **strp _AND + _CONST char *fmt _AND + va_list ap) { int ret; FILE f; diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 96fa4ba..b61c78d 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -1,4 +1,40 @@ /* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* FUNCTION <<vprintf>>, <<vfprintf>>, <<vsprintf>>---format argument list @@ -20,15 +56,15 @@ ANSI_SYNOPSIS int vasprintf(char **<[strp]>, const char *<[fmt]>, va_list <[list]>); int vsnprintf(char *<[str]>, size_t <[size]>, const char *<[fmt]>, va_list <[list]>); - int _vprintf_r(void *<[reent]>, const char *<[fmt]>, + int _vprintf_r(struct _reent *<[reent]>, const char *<[fmt]>, va_list <[list]>); - int _vfprintf_r(void *<[reent]>, FILE *<[fp]>, const char *<[fmt]>, + int _vfprintf_r(struct _reent *<[reent]>, FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); - int _vasprintf_r(void *<[reent]>, char **<[str]>, const char *<[fmt]>, + int _vasprintf_r(struct _reent *<[reent]>, char **<[str]>, const char *<[fmt]>, va_list <[list]>); - int _vsprintf_r(void *<[reent]>, char *<[str]>, const char *<[fmt]>, + int _vsprintf_r(struct _reent *<[reent]>, char *<[str]>, const char *<[fmt]>, va_list <[list]>); - int _vsnprintf_r(void *<[reent]>, char *<[str]>, size_t <[size]>, const char *<[fmt]>, + int _vsnprintf_r(struct _reent *<[reent]>, char *<[str]>, size_t <[size]>, const char *<[fmt]>, va_list <[list]>); TRAD_SYNOPSIS @@ -60,30 +96,30 @@ TRAD_SYNOPSIS va_list <[list]>; int _vprintf_r(<[reent]>, <[fmt]>, <[list]>) - char *<[reent]>; + struct _reent *<[reent]>; char *<[fmt]>; va_list <[list]>; int _vfprintf_r(<[reent]>, <[fp]>, <[fmt]>, <[list]>) - char *<[reent]>; + struct _reent *<[reent]>; FILE *<[fp]>; char *<[fmt]>; va_list <[list]>; int _vasprintf_r(<[reent]>, <[strp]>, <[fmt]>, <[list]>) - char *<[reent]>; + struct _reent *<[reent]>; char **<[strp]>; char *<[fmt]>; va_list <[list]>; int _vsprintf_r(<[reent]>, <[str]>, <[fmt]>, <[list]>) - char *<[reent]>; + struct _reent *<[reent]>; char *<[str]>; char *<[fmt]>; va_list <[list]>; int _vsnprintf_r(<[reent]>, <[str]>, <[size]>, <[fmt]>, <[list]>) - char *<[reent]>; + struct _reent *<[reent]>; char *<[str]>; size_t <[size]>; char *<[fmt]>; @@ -111,42 +147,6 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. */ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)vfprintf.c 5.50 (Berkeley) 12/16/92";*/ static char *rcsid = "$Id$"; @@ -180,21 +180,19 @@ static char *rcsid = "$Id$"; #endif #include <_ansi.h> +#include <reent.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> -#include <reent.h> #include <wchar.h> #include <string.h> #include <sys/lock.h> - #ifdef _HAVE_STDC #include <stdarg.h> #else #include <varargs.h> #endif - #include "local.h" #include "fvwrite.h" #include "vfieeefp.h" @@ -212,9 +210,9 @@ static char *rcsid = "$Id$"; * then reset it so that it can be reused. */ static int -__sprint(fp, uio) - FILE *fp; - register struct __suio *uio; +_DEFUN(__sprint, (fp, uio), + FILE *fp _AND + register struct __suio *uio) { register int err; @@ -234,10 +232,10 @@ __sprint(fp, uio) * worries about ungetc buffers and so forth. */ static int -__sbprintf(fp, fmt, ap) - register FILE *fp; - const char *fmt; - va_list ap; +_DEFUN(__sbprintf, (fp, fmt, ap), + register FILE *fp _AND + _CONST char *fmt _AND + va_list ap) { int ret; FILE fake; @@ -251,14 +249,14 @@ __sbprintf(fp, fmt, ap) /* set up the buffer */ fake._bf._base = fake._p = buf; - fake._bf._size = fake._w = sizeof(buf); + fake._bf._size = fake._w = sizeof (buf); fake._lbfsize = 0; /* not actually used, but Just In Case */ #ifndef __SINGLE_THREAD__ __lock_init_recursive (*(_LOCK_RECURSIVE_T *)&fake._lock); #endif /* do the work, then copy any error status */ - ret = VFPRINTF(&fake, fmt, ap); + ret = VFPRINTF (&fake, fmt, ap); if (ret >= 0 && fflush(&fake)) ret = EOF; if (fake._flags & __SERR) @@ -285,13 +283,15 @@ __sbprintf(fp, fmt, ap) #define DEFPREC 6 #ifdef _NO_LONGDBL -static char *cvt _PARAMS((struct _reent *, double, int, int, char *, int *, int, int *)); +static char * +_EXFUN(cvt, (struct _reent *, double, int, int, char *, int *, int, int *)); #else -static char *cvt _PARAMS((struct _reent *, _LONG_DOUBLE, int, int, char *, int *, int, int *)); -extern int _ldcheck _PARAMS((_LONG_DOUBLE *)); +static char * +_EXFUN(cvt, (struct _reent *, _LONG_DOUBLE, int, int, char *, int *, int, int *)); +extern int _EXFUN(_ldcheck,(_LONG_DOUBLE *)); #endif -static int exponent _PARAMS((char *, int, int)); +static int _EXFUN(exponent, (char *, int, int)); #else /* no FLOATING_POINT */ @@ -308,7 +308,7 @@ static int exponent _PARAMS((char *, int, int)); #endif typedef quad_t * quad_ptr_t; -typedef void * void_ptr_t; +typedef _PTR void_ptr_t; typedef char * char_ptr_t; typedef long * long_ptr_t; typedef int * int_ptr_t; @@ -337,16 +337,17 @@ union arg_val wint_t val_wint_t; }; -static union arg_val *get_arg (struct _reent *data, int n, char *fmt, - va_list *ap, int *numargs, union arg_val *args, - int *arg_type, char **last_fmt); +static union arg_val * +_EXFUN(get_arg, (struct _reent *data, int n, char *fmt, + va_list *ap, int *numargs, union arg_val *args, + int *arg_type, char **last_fmt)); #endif /* !_NO_POS_ARGS */ /* * Macros for converting digits to letters and vice versa */ #define to_digit(c) ((c) - '0') -#define is_digit(c) ((unsigned)to_digit(c) <= 9) +#define is_digit(c) ((unsigned)to_digit (c) <= 9) #define to_char(n) ((n) + '0') /* @@ -368,28 +369,28 @@ static union arg_val *get_arg (struct _reent *data, int n, char *fmt, #define ZEROPAD 0x080 /* zero (as opposed to blank) pad */ #define FPT 0x100 /* Floating point number */ -int _EXFUN (_VFPRINTF_R, (struct _reent *, FILE *, _CONST char *, va_list)); +int _EXFUN(_VFPRINTF_R, (struct _reent *, FILE *, _CONST char *, va_list)); int -_DEFUN (VFPRINTF, (fp, fmt0, ap), - FILE * fp _AND - _CONST char *fmt0 _AND - va_list ap) +_DEFUN(VFPRINTF, (fp, fmt0, ap), + FILE * fp _AND + _CONST char *fmt0 _AND + va_list ap) { int result; - _flockfile(fp); + _flockfile (fp); CHECK_INIT (fp); result = _VFPRINTF_R (_REENT, fp, fmt0, ap); - _funlockfile(fp); + _funlockfile (fp); return result; } int -_DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), - struct _reent *data _AND - FILE * fp _AND - _CONST char *fmt0 _AND - va_list ap) +_DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), + struct _reent *data _AND + FILE * fp _AND + _CONST char *fmt0 _AND + va_list ap) { register char *fmt; /* format string */ register int ch; /* character from fmt */ @@ -476,10 +477,10 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), #define PAD(howmany, with) { \ if ((n = (howmany)) > 0) { \ while (n > PADSIZE) { \ - PRINT(with, PADSIZE); \ + PRINT (with, PADSIZE); \ n -= PADSIZE; \ } \ - PRINT(with, n); \ + PRINT (with, n); \ } \ } #define FLUSH() { \ @@ -499,11 +500,11 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), : arg_index++ < numargs \ ? args[n].val_##type \ : numargs < MAX_POS_ARGS \ - ? args[numargs++].val_##type = va_arg(ap, type) \ - : va_arg(ap, type) \ + ? args[numargs++].val_##type = va_arg (ap, type) \ + : va_arg (ap, type) \ ) #else -#define GET_ARG(n, ap, type) (va_arg(ap, type)) +#define GET_ARG(n, ap, type) (va_arg (ap, type)) #endif /* @@ -512,34 +513,34 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), */ #ifndef _NO_LONGLONG #define SARG() \ - (flags&QUADINT ? GET_ARG(N, ap, quad_t) : \ - flags&LONGINT ? GET_ARG(N, ap, long) : \ - flags&SHORTINT ? (long)(short)GET_ARG(N, ap, int) : \ - (long)GET_ARG(N, ap, int)) + (flags&QUADINT ? GET_ARG (N, ap, quad_t) : \ + flags&LONGINT ? GET_ARG (N, ap, long) : \ + flags&SHORTINT ? (long)(short)GET_ARG (N, ap, int) : \ + (long)GET_ARG (N, ap, int)) #define UARG() \ - (flags&QUADINT ? GET_ARG(N, ap, u_quad_t) : \ - flags&LONGINT ? GET_ARG(N, ap, u_long) : \ - flags&SHORTINT ? (u_long)(u_short)GET_ARG(N, ap, int) : \ - (u_long)GET_ARG(N, ap, u_int)) + (flags&QUADINT ? GET_ARG (N, ap, u_quad_t) : \ + flags&LONGINT ? GET_ARG (N, ap, u_long) : \ + flags&SHORTINT ? (u_long)(u_short)GET_ARG (N, ap, int) : \ + (u_long)GET_ARG (N, ap, u_int)) #else #define SARG() \ - (flags&LONGINT ? GET_ARG(N, ap, long) : \ - flags&SHORTINT ? (long)(short)GET_ARG(N, ap, int) : \ - (long)GET_ARG(N, ap, int)) + (flags&LONGINT ? GET_ARG (N, ap, long) : \ + flags&SHORTINT ? (long)(short)GET_ARG (N, ap, int) : \ + (long)GET_ARG (N, ap, int)) #define UARG() \ - (flags&LONGINT ? GET_ARG(N, ap, u_long) : \ - flags&SHORTINT ? (u_long)(u_short)GET_ARG(N, ap, int) : \ - (u_long)GET_ARG(N, ap, u_int)) + (flags&LONGINT ? GET_ARG (N, ap, u_long) : \ + flags&SHORTINT ? (u_long)(u_short)GET_ARG (N, ap, int) : \ + (u_long)GET_ARG (N, ap, u_int)) #endif /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */ - if (cantwrite(fp)) + if (cantwrite (fp)) return (EOF); /* optimise fprintf(stderr) (and other unbuffered Unix files) */ if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && fp->_file >= 0) - return (__sbprintf(fp, fmt0, ap)); + return (__sbprintf (fp, fmt0, ap)); fmt = (char *)fmt0; uio.uio_iov = iovp = iov; @@ -560,7 +561,7 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), for (;;) { cp = fmt; #ifdef MB_CAPABLE - while ((n = _mbtowc_r(data, &wc, fmt, MB_CUR_MAX, &state)) > 0) { + while ((n = _mbtowc_r (data, &wc, fmt, MB_CUR_MAX, &state)) > 0) { if (wc == '%') break; fmt += n; @@ -570,7 +571,7 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), fmt += 1; #endif if ((m = fmt - cp) != 0) { - PRINT(cp, m); + PRINT (cp, m); ret += m; } #ifdef MB_CAPABLE @@ -613,15 +614,15 @@ reswitch: switch (ch) { /* we must check for positional arg used for dynamic width */ old_is_pos_arg = is_pos_arg; is_pos_arg = 0; - if (is_digit(*fmt)) { + if (is_digit (*fmt)) { char *old_fmt = fmt; n = 0; ch = *fmt++; do { - n = 10 * n + to_digit(ch); + n = 10 * n + to_digit (ch); ch = *fmt++; - } while (is_digit(ch)); + } while (is_digit (ch)); if (ch == '$') { if (n <= MAX_POS_ARGS) { @@ -644,7 +645,7 @@ reswitch: switch (ch) { * -- ANSI X3J11 * They don't exclude field widths read from args. */ - width = GET_ARG(n, ap, int); + width = GET_ARG (n, ap, int); #ifndef _NO_POS_ARGS is_pos_arg = old_is_pos_arg; #endif @@ -665,15 +666,15 @@ reswitch: switch (ch) { /* we must check for positional arg used for dynamic width */ old_is_pos_arg = is_pos_arg; is_pos_arg = 0; - if (is_digit(*fmt)) { + if (is_digit (*fmt)) { char *old_fmt = fmt; n = 0; ch = *fmt++; do { - n = 10 * n + to_digit(ch); + n = 10 * n + to_digit (ch); ch = *fmt++; - } while (is_digit(ch)); + } while (is_digit (ch)); if (ch == '$') { if (n <= MAX_POS_ARGS) { @@ -689,7 +690,7 @@ reswitch: switch (ch) { } } #endif /* !_NO_POS_ARGS */ - prec = GET_ARG(n, ap, int); + prec = GET_ARG (n, ap, int); #ifndef _NO_POS_ARGS is_pos_arg = old_is_pos_arg; #endif @@ -698,8 +699,8 @@ reswitch: switch (ch) { goto rflag; } n = 0; - while (is_digit(ch)) { - n = 10 * n + to_digit(ch); + while (is_digit (ch)) { + n = 10 * n + to_digit (ch); ch = *fmt++; } prec = n < 0 ? -1 : n; @@ -716,9 +717,9 @@ reswitch: switch (ch) { case '5': case '6': case '7': case '8': case '9': n = 0; do { - n = 10 * n + to_digit(ch); + n = 10 * n + to_digit (ch); ch = *fmt++; - } while (is_digit(ch)); + } while (is_digit (ch)); #ifndef _NO_POS_ARGS if (ch == '$') { if (n <= MAX_POS_ARGS) { @@ -757,14 +758,14 @@ reswitch: switch (ch) { if (ch == 'C' || (flags & LONGINT)) { mbstate_t ps; - memset((void *)&ps, '\0', sizeof(mbstate_t)); - if ((size = (int)_wcrtomb_r(data, cp, - (wchar_t)GET_ARG(N, ap, wint_t), + memset ((_PTR)&ps, '\0', sizeof (mbstate_t)); + if ((size = (int)_wcrtomb_r (data, cp, + (wchar_t)GET_ARG (N, ap, wint_t), &ps)) == -1) goto error; } else { - *cp = GET_ARG(N, ap, int); + *cp = GET_ARG (N, ap, int); size = 1; } sign = '\0'; @@ -774,7 +775,7 @@ reswitch: switch (ch) { /*FALLTHROUGH*/ case 'd': case 'i': - _uquad = SARG(); + _uquad = SARG (); #ifndef _NO_LONGLONG if ((quad_t)_uquad < 0) #else @@ -801,20 +802,20 @@ reswitch: switch (ch) { #ifdef _NO_LONGDBL if (flags & LONGDBL) { - _fpvalue = (double) GET_ARG(N, ap, _LONG_DOUBLE); + _fpvalue = (double) GET_ARG (N, ap, _LONG_DOUBLE); } else { - _fpvalue = GET_ARG(N, ap, double); + _fpvalue = GET_ARG (N, ap, double); } /* do this before tricky precision changes */ - if (isinf(_fpvalue)) { + if (isinf (_fpvalue)) { if (_fpvalue < 0) sign = '-'; cp = "Inf"; size = 3; break; } - if (isnan(_fpvalue)) { + if (isnan (_fpvalue)) { cp = "NaN"; size = 3; break; @@ -823,9 +824,9 @@ reswitch: switch (ch) { #else /* !_NO_LONGDBL */ if (flags & LONGDBL) { - _fpvalue = GET_ARG(N, ap, _LONG_DOUBLE); + _fpvalue = GET_ARG (N, ap, _LONG_DOUBLE); } else { - _fpvalue = (_LONG_DOUBLE)GET_ARG(N, ap, double); + _fpvalue = (_LONG_DOUBLE)GET_ARG (N, ap, double); } /* do this before tricky precision changes */ @@ -846,7 +847,7 @@ reswitch: switch (ch) { flags |= FPT; - cp = cvt(data, _fpvalue, prec, flags, &softsign, + cp = cvt (data, _fpvalue, prec, flags, &softsign, &expt, ch, &ndig); if (ch == 'g' || ch == 'G') { @@ -857,7 +858,7 @@ reswitch: switch (ch) { } if (ch <= 'e') { /* 'e' or 'E' fmt */ --expt; - expsize = exponent(expstr, expt, ch); + expsize = exponent (expstr, expt, ch); size = expsize + ndig; if (ndig > 1 || flags & ALT) ++size; @@ -885,21 +886,21 @@ reswitch: switch (ch) { case 'n': #ifndef _NO_LONGLONG if (flags & QUADINT) - *GET_ARG(N, ap, quad_ptr_t) = ret; + *GET_ARG (N, ap, quad_ptr_t) = ret; else #endif if (flags & LONGINT) - *GET_ARG(N, ap, long_ptr_t) = ret; + *GET_ARG (N, ap, long_ptr_t) = ret; else if (flags & SHORTINT) - *GET_ARG(N, ap, short_ptr_t) = ret; + *GET_ARG (N, ap, short_ptr_t) = ret; else - *GET_ARG(N, ap, int_ptr_t) = ret; + *GET_ARG (N, ap, int_ptr_t) = ret; continue; /* no output */ case 'O': flags |= LONGINT; /*FALLTHROUGH*/ case 'o': - _uquad = UARG(); + _uquad = UARG (); base = OCT; goto nosign; case 'p': @@ -911,7 +912,7 @@ reswitch: switch (ch) { * -- ANSI X3J11 */ /* NOSTRICT */ - _uquad = (u_long)(unsigned _POINTER_INT)GET_ARG(N, ap, void_ptr_t); + _uquad = (u_long)(unsigned _POINTER_INT)GET_ARG (N, ap, void_ptr_t); base = HEX; xdigs = "0123456789abcdef"; flags |= HEXPREFIX; @@ -920,7 +921,7 @@ reswitch: switch (ch) { case 's': case 'S': sign = '\0'; - if ((cp = GET_ARG(N, ap, char_ptr_t)) == NULL) { + if ((cp = GET_ARG (N, ap, char_ptr_t)) == NULL) { cp = "(null)"; size = 6; } @@ -930,7 +931,7 @@ reswitch: switch (ch) { wcp = (_CONST wchar_t *)cp; size = m = 0; - memset((void *)&ps, '\0', sizeof(mbstate_t)); + memset ((_PTR)&ps, '\0', sizeof (mbstate_t)); /* Count number of bytes needed for multibyte string that will be produced from widechar @@ -939,7 +940,7 @@ reswitch: switch (ch) { while (1) { if (wcp[m] == L'\0') break; - if ((n = (int)_wcrtomb_r(data, + if ((n = (int)_wcrtomb_r (data, buf, wcp[m], &ps)) == -1) goto error; if (n + size > prec) @@ -951,7 +952,7 @@ reswitch: switch (ch) { } } else { - if ((size = (int)_wcsrtombs_r(data, + if ((size = (int)_wcsrtombs_r (data, NULL, &wcp, 0, &ps)) == -1) goto error; wcp = (_CONST wchar_t *)cp; @@ -961,12 +962,12 @@ reswitch: switch (ch) { break; if ((malloc_buf = - (char *)_malloc_r(data, size + 1)) == NULL) + (char *)_malloc_r (data, size + 1)) == NULL) goto error; /* Convert widechar string to multibyte string. */ - memset((void *)&ps, '\0', sizeof(mbstate_t)); - if (_wcsrtombs_r(data, malloc_buf, + memset ((_PTR)&ps, '\0', sizeof (mbstate_t)); + if (_wcsrtombs_r (data, malloc_buf, &wcp, size, &ps) != size) goto error; cp = malloc_buf; @@ -976,9 +977,9 @@ reswitch: switch (ch) { /* * can't use strlen; can only look for the * NUL in the first `prec' characters, and - * strlen() will go further. + * strlen () will go further. */ - char *p = memchr(cp, 0, prec); + char *p = memchr (cp, 0, prec); if (p != NULL) { size = p - cp; @@ -987,14 +988,14 @@ reswitch: switch (ch) { } else size = prec; } else - size = strlen(cp); + size = strlen (cp); break; case 'U': flags |= LONGINT; /*FALLTHROUGH*/ case 'u': - _uquad = UARG(); + _uquad = UARG (); base = DEC; goto nosign; case 'X': @@ -1002,7 +1003,7 @@ reswitch: switch (ch) { goto hex; case 'x': xdigs = "0123456789abcdef"; -hex: _uquad = UARG(); +hex: _uquad = UARG (); base = HEX; /* leading 0x/X only if non-zero */ if (flags & ALT && _uquad != 0) @@ -1033,7 +1034,7 @@ number: if ((dprec = prec) >= 0) switch (base) { case OCT: do { - *--cp = to_char(_uquad & 7); + *--cp = to_char (_uquad & 7); _uquad >>= 3; } while (_uquad); /* handle octal leading 0 */ @@ -1044,10 +1045,10 @@ number: if ((dprec = prec) >= 0) case DEC: /* many numbers are 1 digit */ while (_uquad >= 10) { - *--cp = to_char(_uquad % 10); + *--cp = to_char (_uquad % 10); _uquad /= 10; } - *--cp = to_char(_uquad); + *--cp = to_char (_uquad); break; case HEX: @@ -1059,7 +1060,7 @@ number: if ((dprec = prec) >= 0) default: cp = "bug in vfprintf: bad base"; - size = strlen(cp); + size = strlen (cp); goto skipsize; } } @@ -1111,93 +1112,93 @@ number: if ((dprec = prec) >= 0) /* right-adjusting blank padding */ if ((flags & (LADJUST|ZEROPAD)) == 0) - PAD(width - realsz, blanks); + PAD (width - realsz, blanks); /* prefix */ if (sign) { - PRINT(&sign, 1); + PRINT (&sign, 1); } else if (flags & HEXPREFIX) { ox[0] = '0'; ox[1] = ch; - PRINT(ox, 2); + PRINT (ox, 2); } /* right-adjusting zero padding */ if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) - PAD(width - realsz, zeroes); + PAD (width - realsz, zeroes); /* leading zeroes from decimal precision */ - PAD(dprec - size, zeroes); + PAD (dprec - size, zeroes); /* the string or number proper */ #ifdef FLOATING_POINT if ((flags & FPT) == 0) { - PRINT(cp, size); + PRINT (cp, size); } else { /* glue together f_p fragments */ if (ch >= 'f') { /* 'f' or 'g' */ if (_fpvalue == 0) { /* kludge for __dtoa irregularity */ - PRINT("0", 1); + PRINT ("0", 1); if (expt < ndig || (flags & ALT) != 0) { - PRINT(decimal_point, 1); - PAD(ndig - 1, zeroes); + PRINT (decimal_point, 1); + PAD (ndig - 1, zeroes); } } else if (expt <= 0) { - PRINT("0", 1); + PRINT ("0", 1); if(expt || ndig) { - PRINT(decimal_point, 1); - PAD(-expt, zeroes); - PRINT(cp, ndig); + PRINT (decimal_point, 1); + PAD (-expt, zeroes); + PRINT (cp, ndig); } } else if (expt >= ndig) { - PRINT(cp, ndig); - PAD(expt - ndig, zeroes); + PRINT (cp, ndig); + PAD (expt - ndig, zeroes); if (flags & ALT) - PRINT(".", 1); + PRINT (".", 1); } else { - PRINT(cp, expt); + PRINT (cp, expt); cp += expt; - PRINT(".", 1); - PRINT(cp, ndig-expt); + PRINT (".", 1); + PRINT (cp, ndig-expt); } } else { /* 'e' or 'E' */ if (ndig > 1 || flags & ALT) { ox[0] = *cp++; ox[1] = '.'; - PRINT(ox, 2); + PRINT (ox, 2); if (_fpvalue) { - PRINT(cp, ndig-1); + PRINT (cp, ndig-1); } else /* 0.[0..] */ /* __dtoa irregularity */ - PAD(ndig - 1, zeroes); + PAD (ndig - 1, zeroes); } else /* XeYYY */ - PRINT(cp, 1); - PRINT(expstr, expsize); + PRINT (cp, 1); + PRINT (expstr, expsize); } } #else - PRINT(cp, size); + PRINT (cp, size); #endif /* left-adjusting padding (always blank) */ if (flags & LADJUST) - PAD(width - realsz, blanks); + PAD (width - realsz, blanks); /* finally, adjust ret */ ret += width > realsz ? width : realsz; - FLUSH(); /* copy out the I/O vectors */ + FLUSH (); /* copy out the I/O vectors */ if (malloc_buf != NULL) { - free(malloc_buf); + free (malloc_buf); malloc_buf = NULL; } } done: - FLUSH(); + FLUSH (); error: if (malloc_buf != NULL) - free(malloc_buf); - return (__sferror(fp) ? EOF : ret); + free (malloc_buf); + return (__sferror (fp) ? EOF : ret); /* NOTREACHED */ } @@ -1213,16 +1214,29 @@ extern char *_ldtoa_r _PARAMS((struct _reent *, _LONG_DOUBLE, int, #define word0(x) ldword0(x) #endif -static char * -cvt(data, value, ndigits, flags, sign, decpt, ch, length) - struct _reent *data; #ifdef _NO_LONGDBL - double value; +static char * +_DEFUN(cvt, (data, value, ndigits, flags, sign, decpt, ch, length), + struct _reent *data _AND + double value _AND + int ndigits _AND + int flags _AND + char *sign _AND + int *decpt _AND + int ch _AND + int *length) #else - _LONG_DOUBLE value; +static char * +_DEFUN(cvt, (data, value, ndigits, flags, sign, decpt, ch, length), + struct _reent *data _AND + _LONG_DOUBLE value _AND + int ndigits _AND + int flags _AND + char *sign _AND + int *decpt _AND + int ch _AND + int *length) #endif - int ndigits, flags, *decpt, ch, *length; - char *sign; { int mode, dsgn; char *digits, *bp, *rve; @@ -1248,13 +1262,13 @@ cvt(data, value, ndigits, flags, sign, decpt, ch, length) #ifdef _NO_LONGDBL tmp.d = value; - if (word0(tmp) & Sign_bit) { /* this will check for < 0 and -0.0 */ + if (word0 (tmp) & Sign_bit) { /* this will check for < 0 and -0.0 */ value = -value; *sign = '-'; } else *sign = '\000'; - digits = _dtoa_r(data, value, mode, ndigits, decpt, &dsgn, &rve); + digits = _dtoa_r (data, value, mode, ndigits, decpt, &dsgn, &rve); #else /* !_NO_LONGDBL */ ldptr = (struct ldieee *)&value; if (ldptr->sign) { /* this will check for < 0 and -0.0 */ @@ -1263,7 +1277,7 @@ cvt(data, value, ndigits, flags, sign, decpt, ch, length) } else *sign = '\000'; - digits = _ldtoa_r(data, value, mode, ndigits, decpt, &dsgn, &rve); + digits = _ldtoa_r (data, value, mode, ndigits, decpt, &dsgn, &rve); #endif /* !_NO_LONGDBL */ if ((ch != 'g' && ch != 'G') || flags & ALT) { /* Print trailing zeros */ @@ -1283,9 +1297,10 @@ cvt(data, value, ndigits, flags, sign, decpt, ch, length) } static int -exponent(p0, exp, fmtch) - char *p0; - int exp, fmtch; +_DEFUN(exponent, (p0, exp, fmtch), + char *p0 _AND + int exp _AND + int fmtch) { register char *p, *t; char expbuf[40]; @@ -1301,14 +1316,14 @@ exponent(p0, exp, fmtch) t = expbuf + 40; if (exp > 9) { do { - *--t = to_char(exp % 10); + *--t = to_char (exp % 10); } while ((exp /= 10) > 9); - *--t = to_char(exp); + *--t = to_char (exp); for (; t < expbuf + 40; *p++ = *t++); } else { *p++ = '0'; - *p++ = to_char(exp); + *p++ = to_char (exp); } return (p - p0); } @@ -1389,7 +1404,7 @@ typedef enum { PWPOS, /* get positional parameter value for variable width or precision */ } ACTION; -const static CH_CLASS chclass[256] = { +_CONST static CH_CLASS chclass[256] = { /* 00-07 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, /* 08-0f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, /* 10-17 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, @@ -1424,7 +1439,7 @@ const static CH_CLASS chclass[256] = { /* f8-ff */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, }; -const static STATE state_table[MAX_STATE][MAX_CH_CLASS] = { +_CONST static STATE state_table[MAX_STATE][MAX_CH_CLASS] = { /* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */ /* START */ { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE }, /* SFLAG */ { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE }, @@ -1439,7 +1454,7 @@ const static STATE state_table[MAX_STATE][MAX_CH_CLASS] = { /* VPDIG */ { DONE, DONE, PREC, DONE, DONE, DONE, DONE, DONE, DONE }, }; -const static ACTION action_table[MAX_STATE][MAX_CH_CLASS] = { +_CONST static ACTION action_table[MAX_STATE][MAX_CH_CLASS] = { /* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */ /* START */ { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, /* SFLAG */ { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, @@ -1456,9 +1471,15 @@ const static ACTION action_table[MAX_STATE][MAX_CH_CLASS] = { /* function to get positional parameter N where n = N - 1 */ static union arg_val * -get_arg (struct _reent *data, int n, char *fmt, va_list *ap, - int *numargs_p, union arg_val *args, - int *arg_type, char **last_fmt) +_DEFUN(get_arg, (data, n, fmt, ap, numargs_p, args, arg_type, last_fmt), + struct _reent *data _AND + int n _AND + char *fmt _AND + va_list *ap _AND + int *numargs_p _AND + union arg_val *args _AND + int *arg_type _AND + char **last_fmt) { int ch; int number, flags; @@ -1489,7 +1510,7 @@ get_arg (struct _reent *data, int n, char *fmt, va_list *ap, while (*fmt && n >= numargs) { #ifdef MB_CAPABLE - while ((nbytes = _mbtowc_r(data, &wc, fmt, MB_CUR_MAX, &wc_state)) > 0) + while ((nbytes = _mbtowc_r (data, &wc, fmt, MB_CUR_MAX, &wc_state)) > 0) { fmt += nbytes; if (wc == '%') @@ -1610,27 +1631,27 @@ get_arg (struct _reent *data, int n, char *fmt, va_list *ap, switch (spec_type) { case LONG_INT: - args[numargs++].val_long = va_arg(*ap, long); + args[numargs++].val_long = va_arg (*ap, long); break; case QUAD_INT: - args[numargs++].val_quad_t = va_arg(*ap, quad_t); + args[numargs++].val_quad_t = va_arg (*ap, quad_t); break; case WIDE_CHAR: - args[numargs++].val_wint_t = va_arg(*ap, wint_t); + args[numargs++].val_wint_t = va_arg (*ap, wint_t); break; case CHAR: case SHORT_INT: case INT: - args[numargs++].val_int = va_arg(*ap, int); + args[numargs++].val_int = va_arg (*ap, int); break; case CHAR_PTR: - args[numargs++].val_char_ptr_t = va_arg(*ap, char *); + args[numargs++].val_char_ptr_t = va_arg (*ap, char *); break; case DOUBLE: - args[numargs++].val_double = va_arg(*ap, double); + args[numargs++].val_double = va_arg (*ap, double); break; case LONG_DOUBLE: - args[numargs++].val__LONG_DOUBLE = va_arg(*ap, _LONG_DOUBLE); + args[numargs++].val__LONG_DOUBLE = va_arg (*ap, _LONG_DOUBLE); break; } } @@ -1638,13 +1659,13 @@ get_arg (struct _reent *data, int n, char *fmt, va_list *ap, break; case GETPOS: /* we have positional specifier */ if (arg_type[0] == -1) - memset (arg_type, 0, sizeof(int) * MAX_POS_ARGS); + memset (arg_type, 0, sizeof (int) * MAX_POS_ARGS); pos = number - 1; max_pos_arg = (max_pos_arg > pos ? max_pos_arg : pos); break; case PWPOS: /* we have positional specifier for width or precision */ if (arg_type[0] == -1) - memset (arg_type, 0, sizeof(int) * MAX_POS_ARGS); + memset (arg_type, 0, sizeof (int) * MAX_POS_ARGS); number -= 1; arg_type[number] = INT; max_pos_arg = (max_pos_arg > number ? max_pos_arg : number); @@ -1653,18 +1674,18 @@ get_arg (struct _reent *data, int n, char *fmt, va_list *ap, --fmt; /* fallthrough */ case GETPW: /* we have a variable precision or width to acquire */ - args[numargs++].val_int = va_arg(*ap, int); + args[numargs++].val_int = va_arg (*ap, int); break; case NUMBER: /* we have a number to process */ number = (ch - '0'); - while ((ch = *fmt) != '\0' && is_digit(ch)) + while ((ch = *fmt) != '\0' && is_digit (ch)) { number = number * 10 + (ch - '0'); ++fmt; } break; case SKIPNUM: /* we have a number to skip */ - while ((ch = *fmt) != '\0' && is_digit(ch)) + while ((ch = *fmt) != '\0' && is_digit (ch)) ++fmt; break; case NOOP: @@ -1686,28 +1707,28 @@ get_arg (struct _reent *data, int n, char *fmt, va_list *ap, switch (arg_type[numargs]) { case LONG_INT: - args[numargs++].val_long = va_arg(*ap, long); + args[numargs++].val_long = va_arg (*ap, long); break; case QUAD_INT: - args[numargs++].val_quad_t = va_arg(*ap, quad_t); + args[numargs++].val_quad_t = va_arg (*ap, quad_t); break; case CHAR_PTR: - args[numargs++].val_char_ptr_t = va_arg(*ap, char *); + args[numargs++].val_char_ptr_t = va_arg (*ap, char *); break; case DOUBLE: - args[numargs++].val_double = va_arg(*ap, double); + args[numargs++].val_double = va_arg (*ap, double); break; case LONG_DOUBLE: - args[numargs++].val__LONG_DOUBLE = va_arg(*ap, _LONG_DOUBLE); + args[numargs++].val__LONG_DOUBLE = va_arg (*ap, _LONG_DOUBLE); break; case WIDE_CHAR: - args[numargs++].val_wint_t = va_arg(*ap, wint_t); + args[numargs++].val_wint_t = va_arg (*ap, wint_t); break; case INT: case SHORT_INT: case CHAR: default: - args[numargs++].val_int = va_arg(*ap, int); + args[numargs++].val_int = va_arg (*ap, int); break; } } diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c index 6e7f87c..7e4f335 100644 --- a/newlib/libc/stdio/vfscanf.c +++ b/newlib/libc/stdio/vfscanf.c @@ -1,3 +1,20 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + /* FUNCTION <<vscanf>>, <<vfscanf>>, <<vsscanf>>---format argument list @@ -16,11 +33,11 @@ ANSI_SYNOPSIS int vfscanf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); int vsscanf(const char *<[str]>, const char *<[fmt]>, va_list <[list]>); - int _vscanf_r(void *<[reent]>, const char *<[fmt]>, + int _vscanf_r(struct _reent *<[reent]>, const char *<[fmt]>, va_list <[list]>); - int _vfscanf_r(void *<[reent]>, FILE *<[fp]>, const char *<[fmt]>, + int _vfscanf_r(struct _reent *<[reent]>, FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); - int _vsscanf_r(void *<[reent]>, const char *<[str]>, const char *<[fmt]>, + int _vsscanf_r(struct _reent *<[reent]>, const char *<[str]>, const char *<[fmt]>, va_list <[list]>); TRAD_SYNOPSIS @@ -41,18 +58,18 @@ TRAD_SYNOPSIS va_list <[list]>; int _vscanf_r( <[reent]>, <[fmt]>, <[ist]>) - char *<[reent]>; + struct _reent *<[reent]>; char *<[fmt]>; va_list <[list]>; int _vfscanf_r( <[reent]>, <[fp]>, <[fmt]>, <[list]>) - char *<[reent]>; + struct _reent *<[reent]>; FILE *<[fp]>; char *<[fmt]>; va_list <[list]>; int _vsscanf_r( <[reent]>, <[str]>, <[fmt]>, <[list]>) - char *<[reent]>; + struct _reent *<[reent]>; char *<[str]>; char *<[fmt]>; va_list <[list]>; @@ -85,24 +102,8 @@ These are GNU extensions. Supporting OS subroutines required: */ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - #include <_ansi.h> +#include <reent.h> #include <ctype.h> #include <wctype.h> #include <stdio.h> @@ -212,20 +213,20 @@ typedef unsigned long long u_long_long; #ifndef _REENT_ONLY int -_DEFUN (vfscanf, (fp, fmt, ap), - register FILE *fp _AND - _CONST char *fmt _AND - va_list ap) +_DEFUN(vfscanf, (fp, fmt, ap), + register FILE *fp _AND + _CONST char *fmt _AND + va_list ap) { CHECK_INIT(fp); return __svfscanf_r (_REENT, fp, fmt, ap); } int -__svfscanf (fp, fmt0, ap) - register FILE *fp; - char _CONST *fmt0; - va_list ap; +_DEFUN(__svfscanf, (fp, fmt0, ap), + register FILE *fp _AND + char _CONST *fmt0 _AND + va_list ap) { return __svfscanf_r (_REENT, fp, fmt0, ap); } @@ -233,22 +234,22 @@ __svfscanf (fp, fmt0, ap) #endif /* !_REENT_ONLY */ int -_DEFUN (_vfscanf_r, (data, fp, fmt, ap), - struct _reent *data _AND - register FILE *fp _AND - _CONST char *fmt _AND - va_list ap) +_DEFUN(_vfscanf_r, (data, fp, fmt, ap), + struct _reent *data _AND + register FILE *fp _AND + _CONST char *fmt _AND + va_list ap) { return __svfscanf_r (data, fp, fmt, ap); } int -__svfscanf_r (rptr, fp, fmt0, ap) - struct _reent *rptr; - register FILE *fp; - char _CONST *fmt0; - va_list ap; +_DEFUN(__svfscanf_r, (rptr, fp, fmt0, ap), + struct _reent *rptr _AND + register FILE *fp _AND + char _CONST *fmt0 _AND + va_list ap) { register u_char *fmt = (u_char *) fmt0; register int c; /* character from format, or conversion */ @@ -555,7 +556,7 @@ __svfscanf_r (rptr, fp, fmt0, ap) if (flags & LONG) { if ((flags & SUPPRESS) == 0) - wcp = va_arg(ap, wchar_t *); + wcp = va_arg (ap, wchar_t *); else wcp = NULL; n = 0; @@ -566,8 +567,8 @@ __svfscanf_r (rptr, fp, fmt0, ap) buf[n++] = *fp->_p; fp->_r -= 1; fp->_p += 1; - memset((void *)&state, '\0', sizeof(mbstate_t)); - if ((mbslen = _mbrtowc_r(rptr, wcp, buf, n, &state)) + memset ((_PTR)&state, '\0', sizeof (mbstate_t)); + if ((mbslen = _mbrtowc_r (rptr, wcp, buf, n, &state)) == (size_t)-1) goto input_failure; /* Invalid sequence */ if (mbslen == 0 && !(flags & SUPPRESS)) @@ -684,19 +685,19 @@ __svfscanf_r (rptr, fp, fmt0, ap) { /* Process %S and %ls placeholders */ if ((flags & SUPPRESS) == 0) - wcp = va_arg(ap, wchar_t *); + wcp = va_arg (ap, wchar_t *); else wcp = &wc; n = 0; - while (!isspace(*fp->_p) && width != 0) + while (!isspace (*fp->_p) && width != 0) { if (n == MB_CUR_MAX) goto input_failure; buf[n++] = *fp->_p; fp->_r -= 1; fp->_p += 1; - memset((void *)&state, '\0', sizeof(mbstate_t)); - if ((mbslen = _mbrtowc_r(rptr, wcp, buf, n, &state)) + memset ((_PTR)&state, '\0', sizeof (mbstate_t)); + if ((mbslen = _mbrtowc_r (rptr, wcp, buf, n, &state)) == (size_t)-1) goto input_failure; if (mbslen == 0) @@ -706,7 +707,7 @@ __svfscanf_r (rptr, fp, fmt0, ap) if (iswspace(*wcp)) { while (n != 0) - ungetc(buf[--n], fp); + ungetc (buf[--n], fp); break; } nread += n; @@ -1171,9 +1172,9 @@ all_done: /*static*/ u_char * -__sccl (tab, fmt) - register char *tab; - register u_char *fmt; +_DEFUN(__sccl, (tab, fmt), + register char *tab _AND + register u_char *fmt) { register int c, n, v; diff --git a/newlib/libc/stdio/vprintf.c b/newlib/libc/stdio/vprintf.c index 916d518..8a1faae 100644 --- a/newlib/libc/stdio/vprintf.c +++ b/newlib/libc/stdio/vprintf.c @@ -1,5 +1,3 @@ -/* doc in vfprintf.c */ - /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -16,37 +14,37 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* doc in vfprintf.c */ #include <_ansi.h> +#include <reent.h> #include <stdio.h> - #ifdef _HAVE_STDC #include <stdarg.h> #else #include <varargs.h> #endif - #include "local.h" #ifndef _REENT_ONLY int -_DEFUN (vprintf, (fmt, ap), - _CONST char *fmt _AND - va_list ap) +_DEFUN(vprintf, (fmt, ap), + _CONST char *fmt _AND + va_list ap) { - _REENT_SMALL_CHECK_INIT(_stdout_r (_REENT)); + _REENT_SMALL_CHECK_INIT (_stdout_r (_REENT)); return _vfprintf_r (_REENT, _stdout_r (_REENT), fmt, ap); } #endif /* !_REENT_ONLY */ int -_DEFUN (_vprintf_r, (ptr, fmt, ap), - struct _reent *ptr _AND - _CONST char *fmt _AND - va_list ap) +_DEFUN(_vprintf_r, (ptr, fmt, ap), + struct _reent *ptr _AND + _CONST char *fmt _AND + va_list ap) { - _REENT_SMALL_CHECK_INIT(_stdout_r (ptr)); + _REENT_SMALL_CHECK_INIT (_stdout_r (ptr)); return _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap); } diff --git a/newlib/libc/stdio/vscanf.c b/newlib/libc/stdio/vscanf.c index e494aaf..a62b0a8 100644 --- a/newlib/libc/stdio/vscanf.c +++ b/newlib/libc/stdio/vscanf.c @@ -18,39 +18,35 @@ */ #include <_ansi.h> +#include <reent.h> #include <stdio.h> -#include "local.h" - #ifdef _HAVE_STDC #include <stdarg.h> #else #include <varargs.h> #endif - -/* - * vscanf - */ +#include "local.h" #ifndef _REENT_ONLY int -_DEFUN (vscanf, (fmt, ap), - _CONST char *fmt _AND - va_list ap) +_DEFUN(vscanf, (fmt, ap), + _CONST char *fmt _AND + va_list ap) { - _REENT_SMALL_CHECK_INIT(_stdin_r (_REENT)); + _REENT_SMALL_CHECK_INIT (_stdin_r (_REENT)); return __svfscanf_r (_REENT, _stdin_r (_REENT), fmt, ap); } #endif /* !_REENT_ONLY */ int -_DEFUN (_vscanf_r, (ptr, fmt, ap), - struct _reent *ptr _AND - _CONST char *fmt _AND - va_list ap) +_DEFUN(_vscanf_r, (ptr, fmt, ap), + struct _reent *ptr _AND + _CONST char *fmt _AND + va_list ap) { - _REENT_SMALL_CHECK_INIT(_stdin_r (ptr)); + _REENT_SMALL_CHECK_INIT (_stdin_r (ptr)); return __svfscanf_r (ptr, _stdin_r (ptr), fmt, ap); } diff --git a/newlib/libc/stdio/vsnprintf.c b/newlib/libc/stdio/vsnprintf.c index 0393ead..fb80f41 100644 --- a/newlib/libc/stdio/vsnprintf.c +++ b/newlib/libc/stdio/vsnprintf.c @@ -1,7 +1,3 @@ -/* doc in vfprintf.c */ - -/* This code created by modifying vsprintf.c so copyright inherited. */ - /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -18,6 +14,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* doc in vfprintf.c */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "%W% (Berkeley) %G%"; @@ -36,11 +33,11 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #ifndef _REENT_ONLY int -_DEFUN (vsnprintf, (str, size, fmt, ap), - char *str _AND - size_t size _AND - _CONST char *fmt _AND - va_list ap) +_DEFUN(vsnprintf, (str, size, fmt, ap), + char *str _AND + size_t size _AND + _CONST char *fmt _AND + va_list ap) { int ret; FILE f; @@ -57,12 +54,12 @@ _DEFUN (vsnprintf, (str, size, fmt, ap), #endif /* !_REENT_ONLY */ int -_DEFUN (_vsnprintf_r, (ptr, str, size, fmt, ap), - struct _reent *ptr _AND - char *str _AND - size_t size _AND - _CONST char *fmt _AND - va_list ap) +_DEFUN(_vsnprintf_r, (ptr, str, size, fmt, ap), + struct _reent *ptr _AND + char *str _AND + size_t size _AND + _CONST char *fmt _AND + va_list ap) { int ret; FILE f; diff --git a/newlib/libc/stdio/vsprintf.c b/newlib/libc/stdio/vsprintf.c index 5efd43a..daf4605 100644 --- a/newlib/libc/stdio/vsprintf.c +++ b/newlib/libc/stdio/vsprintf.c @@ -1,5 +1,3 @@ -/* doc in vfprintf.c */ - /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -16,6 +14,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* doc in vfprintf.c */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "%W% (Berkeley) %G%"; @@ -34,10 +33,10 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #ifndef _REENT_ONLY int -_DEFUN (vsprintf, (str, fmt, ap), - char *str _AND - _CONST char *fmt _AND - va_list ap) +_DEFUN(vsprintf, (str, fmt, ap), + char *str _AND + _CONST char *fmt _AND + va_list ap) { int ret; FILE f; @@ -54,11 +53,11 @@ _DEFUN (vsprintf, (str, fmt, ap), #endif /* !_REENT_ONLY */ int -_DEFUN (_vsprintf_r, (ptr, str, fmt, ap), - struct _reent *ptr _AND - char *str _AND - _CONST char *fmt _AND - va_list ap) +_DEFUN(_vsprintf_r, (ptr, str, fmt, ap), + struct _reent *ptr _AND + char *str _AND + _CONST char *fmt _AND + va_list ap) { int ret; FILE f; diff --git a/newlib/libc/stdio/vsscanf.c b/newlib/libc/stdio/vsscanf.c index 16f8104..c623711 100644 --- a/newlib/libc/stdio/vsscanf.c +++ b/newlib/libc/stdio/vsscanf.c @@ -28,12 +28,11 @@ #endif #include "local.h" -static -_READ_WRITE_RETURN_TYPE -eofread1 (cookie, buf, len) - _PTR cookie; - char *buf; - int len; +static _READ_WRITE_RETURN_TYPE +_DEFUN(eofread1, (cookie, buf, len), + _PTR cookie _AND + char *buf _AND + int len) { return 0; } @@ -45,10 +44,10 @@ eofread1 (cookie, buf, len) #ifndef _REENT_ONLY int -_DEFUN (vsscanf, (str, fmt, ap), - _CONST char *str _AND - _CONST char *fmt _AND - va_list ap) +_DEFUN(vsscanf, (str, fmt, ap), + _CONST char *str _AND + _CONST char *fmt _AND + va_list ap) { return _vsscanf_r (_REENT, str, fmt, ap); } @@ -56,11 +55,11 @@ _DEFUN (vsscanf, (str, fmt, ap), #endif /* !_REENT_ONLY */ int -_DEFUN (_vsscanf_r, (ptr, str, fmt, ap), - struct _reent *ptr _AND - _CONST char *str _AND - _CONST char *fmt _AND - va_list ap) +_DEFUN(_vsscanf_r, (ptr, str, fmt, ap), + struct _reent *ptr _AND + _CONST char *str _AND + _CONST char *fmt _AND + va_list ap) { FILE f; diff --git a/newlib/libc/stdio/wbuf.c b/newlib/libc/stdio/wbuf.c index 1106829..29dd03e 100644 --- a/newlib/libc/stdio/wbuf.c +++ b/newlib/libc/stdio/wbuf.c @@ -1,5 +1,3 @@ -/* No user fns here. Pesch 15apr92. */ - /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -16,11 +14,13 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +/* No user fns here. Pesch 15apr92. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ +#include <_ansi.h> #include <stdio.h> #include "local.h" #include "fvwrite.h" @@ -32,9 +32,9 @@ static char sccsid[] = "%W% (Berkeley) %G%"; */ int -__swbuf (c, fp) - register int c; - register FILE *fp; +_DEFUN(__swbuf, (c, fp), + register int c _AND + register FILE *fp) { register int n; diff --git a/newlib/libc/stdio/wsetup.c b/newlib/libc/stdio/wsetup.c index 23b032e..c1641db 100644 --- a/newlib/libc/stdio/wsetup.c +++ b/newlib/libc/stdio/wsetup.c @@ -17,6 +17,7 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +#include <_ansi.h> #include <stdio.h> #include <stdlib.h> #include "local.h" @@ -28,8 +29,8 @@ */ int -_DEFUN (__swsetup, (fp), - register FILE * fp) +_DEFUN(__swsetup, (fp), + register FILE * fp) { /* Make sure stdio is set up. */ |