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.
This commit is contained in:
Jeff Johnston 2004-04-23 20:01:55 +00:00
parent 7ed02aabd1
commit 05b315770a
79 changed files with 1502 additions and 1157 deletions

View File

@ -1,3 +1,40 @@
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.
2004-04-21 J"orn Rennecke <joern.rennecke@superh.com>
* libc/stdio/vfscanf.c (NNZDIGITS): New define.

View File

@ -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;

View File

@ -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);
}

View File

@ -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
<<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);
}

View File

@ -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
<<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);
}

View File

@ -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
<<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);
}

View File

@ -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
<<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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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
<<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;
}

View File

@ -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
<<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);
}

View File

@ -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;
}

View File

@ -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
<<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;
}

View File

@ -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 ();
}

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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
<<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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -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
<<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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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. */

View File

@ -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. */

View File

@ -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. */

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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);
}

View File

@ -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
<<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);
}

View File

@ -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

View File

@ -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;
}

View File

@ -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. */

View File

@ -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. */

View File

@ -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

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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 */

View File

@ -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
<<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);
}

View File

@ -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
<<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);
}

View File

@ -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 */

View File

@ -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)
{

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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));
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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. */