summaryrefslogtreecommitdiff
path: root/usr/src/lib/libbc/libc/stdio/sys5
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libbc/libc/stdio/sys5')
-rw-r--r--usr/src/lib/libbc/libc/stdio/sys5/filbuf.c20
-rw-r--r--usr/src/lib/libbc/libc/stdio/sys5/flsbuf.c94
-rw-r--r--usr/src/lib/libbc/libc/stdio/sys5/fopen.c20
-rw-r--r--usr/src/lib/libbc/libc/stdio/sys5/fprintf.c20
-rw-r--r--usr/src/lib/libbc/libc/stdio/sys5/printf.c19
-rw-r--r--usr/src/lib/libbc/libc/stdio/sys5/sprintf.c18
-rw-r--r--usr/src/lib/libbc/libc/stdio/sys5/vfprintf.c21
-rw-r--r--usr/src/lib/libbc/libc/stdio/sys5/vprintf.c15
-rw-r--r--usr/src/lib/libbc/libc/stdio/sys5/vsprintf.c12
9 files changed, 107 insertions, 132 deletions
diff --git a/usr/src/lib/libbc/libc/stdio/sys5/filbuf.c b/usr/src/lib/libbc/libc/stdio/sys5/filbuf.c
index aa247dab34..7d197f149c 100644
--- a/usr/src/lib/libbc/libc/stdio/sys5/filbuf.c
+++ b/usr/src/lib/libbc/libc/stdio/sys5/filbuf.c
@@ -27,28 +27,25 @@
/* Copyright (c) 1984 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 2.1 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include <stdio.h>
+#include <unistd.h>
-extern _findbuf();
-extern int read();
-extern int fflush();
+extern void _findbuf();
+
+static void lbfflush(FILE *);
int
-__filbuf(iop)
-register FILE *iop;
+__filbuf(FILE *iop)
{
return (_filbuf(iop));
}
int
-_filbuf(iop)
-register FILE *iop;
+_filbuf(FILE *iop)
{
- static void lbfflush();
-
if ( !(iop->_flag & _IOREAD) )
if (iop->_flag & _IORW)
iop->_flag |= _IOREAD;
@@ -84,8 +81,7 @@ register FILE *iop;
}
static void
-lbfflush(iop)
-FILE *iop;
+lbfflush(FILE *iop)
{
if (iop->_flag & _IOLBF)
(void) fflush(iop);
diff --git a/usr/src/lib/libbc/libc/stdio/sys5/flsbuf.c b/usr/src/lib/libbc/libc/stdio/sys5/flsbuf.c
index 635b1ff2ba..4dcc1f3f18 100644
--- a/usr/src/lib/libbc/libc/stdio/sys5/flsbuf.c
+++ b/usr/src/lib/libbc/libc/stdio/sys5/flsbuf.c
@@ -25,51 +25,48 @@
*/
#pragma ident "%Z%%M% %I% %E% SMI"
- /* from ../4.2/flsbuf.c */
/*LINTLIBRARY*/
#include <stdio.h>
-#include <sys/errno.h>
+#include <errno.h>
#include "../common/stdiom.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <malloc.h>
-extern void free();
-extern int errno, write(), close(), isatty();
-extern char *malloc();
extern unsigned char (*_smbuf)[_SBFSIZ];
-void _getsmbuf();
+void _findbuf(FILE *);
+void _bufsync(FILE *);
+
+extern int fclose();
/*
* Flush buffers on exit
*/
-
void
-_cleanup()
+_cleanup(void)
{
- extern int fclose();
_fwalk(fclose);
}
+
/*
- fclose() will flush (output) buffers for a buffered open
- FILE and then issue a system close on the _fileno. The
- _base field will be reset to NULL for any but stdin and
- stdout, the _ptr field will be set the same as the _base
- field. The _flags and the _cnt field will be zeroed.
- If buffers had been obtained via malloc(), the space will
- be free()'d. In case the FILE was not open, or fflush()
- or close() failed, an EOF will be returned, otherwise the
- return value is 0.
+ * fclose() will flush (output) buffers for a buffered open
+ * FILE and then issue a system close on the _fileno. The
+ * _base field will be reset to NULL for any but stdin and
+ * stdout, the _ptr field will be set the same as the _base
+ * field. The _flags and the _cnt field will be zeroed.
+ * If buffers had been obtained via malloc(), the space will
+ * be free()'d. In case the FILE was not open, or fflush()
+ * or close() failed, an EOF will be returned, otherwise the
+ * return value is 0.
*/
-
int
-fclose(iop)
-register FILE *iop;
+fclose(FILE *iop)
{
- register int rtn=EOF;
+ int rtn=EOF;
if(iop == NULL)
return(rtn);
@@ -91,15 +88,14 @@ register FILE *iop;
}
/*
- The fflush() routine must take care because of the
- possibility for recursion. The calling program might
- do IO in an interupt catching routine that is likely
- to interupt the write() call within fflush()
+ * The fflush() routine must take care because of the
+ * possibility for recursion. The calling program might
+ * do IO in an interupt catching routine that is likely
+ * to interupt the write() call within fflush()
*/
int
-fflush(iop)
-register FILE *iop;
+fflush(FILE *iop)
{
if (!(iop->_flag & _IOWRT)) {
if ((iop->_base != NULL) && iop->_cnt) {
@@ -114,7 +110,8 @@ register FILE *iop;
return(ferror(iop) ? EOF : 0);
}
-/* The routine _flsbuf may or may not actually flush the output buffer. If
+/*
+ * The routine _flsbuf may or may not actually flush the output buffer. If
* the file is line-buffered, the fact that iop->_cnt has run below zero
* is meaningless: it is always kept below zero so that invocations of putc
* will consistently give control to _flsbuf, even if the buffer is far from
@@ -127,9 +124,7 @@ register FILE *iop;
*/
int
-_flsbuf(c, iop)
-unsigned char c;
-register FILE *iop;
+_flsbuf(unsigned char c, FILE *iop)
{
unsigned char c1;
@@ -165,7 +160,8 @@ register FILE *iop;
return( ferror(iop) ? EOF : c);
}
-/* The function _xflsbuf writes out the current contents of the output
+/*
+ * The function _xflsbuf writes out the current contents of the output
* buffer delimited by iop->_base and iop->_ptr.
* iop->_cnt is reset appropriately, but its value on entry to _xflsbuf
* is ignored.
@@ -184,11 +180,10 @@ register FILE *iop;
*/
int
-_xflsbuf(iop)
-register FILE *iop;
+_xflsbuf(FILE *iop)
{
- register unsigned char *base;
- register int n;
+ unsigned char *base;
+ int n;
n = iop->_ptr - (base = iop->_base);
iop->_ptr = base;
@@ -201,15 +196,15 @@ register FILE *iop;
return(0);
}
-/* The function _wrtchk checks to see whether it is legitimate to write
+/*
+ * The function _wrtchk checks to see whether it is legitimate to write
* to the specified device. If it is, _wrtchk sets flags in iop->_flag for
* writing, assures presence of a buffer, and returns 0. If writing is not
* legitimate, EOF is returned.
*/
int
-_wrtchk(iop)
-register FILE *iop;
+_wrtchk(FILE *iop)
{
if ( (iop->_flag & (_IOWRT | _IOEOF)) != _IOWRT ) {
if (!(iop->_flag & (_IOWRT | _IORW)))
@@ -233,12 +228,12 @@ register FILE *iop;
* the _IOMYBUF flag is set in iop->_flag.
*/
-_findbuf(iop)
-register FILE *iop;
+void
+_findbuf(FILE *iop)
{
- register int fno = fileno(iop); /* file number */
+ int fno = fileno(iop); /* file number */
struct stat statb;
- register int size;
+ int size;
/* allocate a small block for unbuffered, large for buffered */
if (iop->_flag & _IONBF) {
@@ -272,7 +267,8 @@ register FILE *iop;
iop->_ptr = iop->_base;
}
-/* The function _bufsync is called because interrupts and other signals
+/*
+ * The function _bufsync is called because interrupts and other signals
* which occur in between the decrementing of iop->_cnt and the incrementing
* of iop->_ptr, or in other contexts as well, may upset the synchronization
* of iop->_cnt and iop->ptr. If this happens, calling _bufsync should
@@ -282,11 +278,11 @@ register FILE *iop;
* _bufsync to do the wrong thing, but usually with benign effects.
*/
-_bufsync(iop)
-register FILE *iop;
+void
+_bufsync(FILE *iop)
{
- register int spaceleft;
- register unsigned char *bufend = iop->_base + iop->_bufsiz;
+ int spaceleft;
+ unsigned char *bufend = iop->_base + iop->_bufsiz;
if ((spaceleft = bufend - iop->_ptr) < 0)
iop->_ptr = bufend;
diff --git a/usr/src/lib/libbc/libc/stdio/sys5/fopen.c b/usr/src/lib/libbc/libc/stdio/sys5/fopen.c
index d7cb1ee876..e156dfc876 100644
--- a/usr/src/lib/libbc/libc/stdio/sys5/fopen.c
+++ b/usr/src/lib/libbc/libc/stdio/sys5/fopen.c
@@ -22,37 +22,33 @@
/* Copyright (c) 1984 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.8 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
+
#include <stdio.h>
#include <fcntl.h>
-extern int open(), fclose();
-extern FILE *_findiop(), *_endopen();
+extern FILE *_findiop();
+static FILE *_endopen();
FILE *
-fopen(file, mode)
-char *file, *mode;
+fopen(char *file, char *mode)
{
return (_endopen(file, mode, _findiop()));
}
FILE *
-freopen(file, mode, iop)
-char *file, *mode;
-register FILE *iop;
+freopen(char *file, char *mode, FILE *iop)
{
(void) fclose(iop); /* doesn't matter if this fails */
return (_endopen(file, mode, iop));
}
static FILE *
-_endopen(file, mode, iop)
-char *file, *mode;
-register FILE *iop;
+_endopen(char *file, char *mode, FILE *iop)
{
- register int plus, oflag, fd;
+ int plus, oflag, fd;
if (iop == NULL || file == NULL || file[0] == '\0')
return (NULL);
diff --git a/usr/src/lib/libbc/libc/stdio/sys5/fprintf.c b/usr/src/lib/libbc/libc/stdio/sys5/fprintf.c
index 8daed9d391..a04eb6080f 100644
--- a/usr/src/lib/libbc/libc/stdio/sys5/fprintf.c
+++ b/usr/src/lib/libbc/libc/stdio/sys5/fprintf.c
@@ -20,33 +20,28 @@
* CDDL HEADER END
*/
/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.5 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include <stdio.h>
-#include <varargs.h>
+#include <stdarg.h>
extern int _doprnt();
-/*VARARGS2*/
int
-fprintf(iop, format, va_alist)
-FILE *iop;
-char *format;
-va_dcl
+fprintf(FILE *iop, char *format, ...)
{
unsigned char localbuf[BUFSIZ];
- register int count;
+ int count;
va_list ap;
- va_start(ap);
if (!(iop->_flag & _IOWRT)) {
/* if no write flag */
if (iop->_flag & _IORW) {
@@ -54,9 +49,10 @@ va_dcl
iop->_flag |= _IOWRT;
} else {
/* else error */
- return EOF;
+ return (EOF);
}
}
+ va_start(ap, format);
if (iop->_flag & _IONBF) {
iop->_flag &= ~_IONBF;
iop->_ptr = iop->_base = localbuf;
@@ -70,5 +66,5 @@ va_dcl
} else
count = _doprnt(format, ap, iop);
va_end(ap);
- return(ferror(iop)? EOF: count);
+ return (ferror(iop)? EOF: count);
}
diff --git a/usr/src/lib/libbc/libc/stdio/sys5/printf.c b/usr/src/lib/libbc/libc/stdio/sys5/printf.c
index 0a320e4d86..87319f3283 100644
--- a/usr/src/lib/libbc/libc/stdio/sys5/printf.c
+++ b/usr/src/lib/libbc/libc/stdio/sys5/printf.c
@@ -20,31 +20,27 @@
* CDDL HEADER END
*/
/*
- * Copyright 1986 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.5 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include <stdio.h>
-#include <varargs.h>
+#include <stdarg.h>
extern int _doprnt();
-/*VARARGS1*/
int
-printf(format, va_alist)
-char *format;
-va_dcl
+printf(char *format, ...)
{
- register int count;
+ int count;
va_list ap;
- va_start(ap);
if (!(stdout->_flag & _IOWRT)) {
/* if no write flag */
if (stdout->_flag & _IORW) {
@@ -52,10 +48,11 @@ va_dcl
stdout->_flag |= _IOWRT;
} else {
/* else error */
- return EOF;
+ return (EOF);
}
}
+ va_start(ap, format);
count = _doprnt(format, ap, stdout);
va_end(ap);
- return(ferror(stdout)? EOF: count);
+ return (ferror(stdout)? EOF: count);
}
diff --git a/usr/src/lib/libbc/libc/stdio/sys5/sprintf.c b/usr/src/lib/libbc/libc/stdio/sys5/sprintf.c
index a86dbc8be5..51814e7595 100644
--- a/usr/src/lib/libbc/libc/stdio/sys5/sprintf.c
+++ b/usr/src/lib/libbc/libc/stdio/sys5/sprintf.c
@@ -19,32 +19,34 @@
*
* CDDL HEADER END
*/
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
/* Copyright (c) 1984 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.5 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include <stdio.h>
-#include <varargs.h>
+#include <stdarg.h>
#include <values.h>
extern int _doprnt();
-/*VARARGS2*/
int
-sprintf(string, format, va_alist)
-char *string, *format;
-va_dcl
+sprintf(char *string, char *format, ...)
{
- register int count;
+ int count;
FILE siop;
va_list ap;
siop._cnt = MAXINT;
siop._base = siop._ptr = (unsigned char *)string;
siop._flag = _IOWRT+_IOSTRG;
- va_start(ap);
+ va_start(ap, format);
count = _doprnt(format, ap, &siop);
va_end(ap);
*siop._ptr = '\0'; /* plant terminating null character */
diff --git a/usr/src/lib/libbc/libc/stdio/sys5/vfprintf.c b/usr/src/lib/libbc/libc/stdio/sys5/vfprintf.c
index 502add53e5..fa4bb97a12 100644
--- a/usr/src/lib/libbc/libc/stdio/sys5/vfprintf.c
+++ b/usr/src/lib/libbc/libc/stdio/sys5/vfprintf.c
@@ -20,30 +20,26 @@
* CDDL HEADER END
*/
/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.1 */
+#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include <stdio.h>
-#include <varargs.h>
+#include <stdarg.h>
extern int _doprnt();
-/*VARARGS2*/
int
-vfprintf(iop, format, ap)
-FILE *iop;
-char *format;
-va_list ap;
+vfprintf(FILE *iop, char *format, va_list ap)
{
unsigned char localbuf[BUFSIZ];
- register int count;
+ int count;
if (!(iop->_flag & _IOWRT)) {
/* if no write flag */
@@ -52,7 +48,7 @@ va_list ap;
iop->_flag |= _IOWRT;
} else {
/* else error */
- return EOF;
+ return (EOF);
}
}
if (iop->_flag & _IONBF) {
@@ -65,7 +61,8 @@ va_list ap;
iop->_base = NULL;
iop->_bufsiz = 0;
iop->_cnt = 0;
- } else
+ } else {
count = _doprnt(format, ap, iop);
- return(ferror(iop)? EOF: count);
+ }
+ return (ferror(iop)? EOF: count);
}
diff --git a/usr/src/lib/libbc/libc/stdio/sys5/vprintf.c b/usr/src/lib/libbc/libc/stdio/sys5/vprintf.c
index 442c95cb5f..9973cf3cdd 100644
--- a/usr/src/lib/libbc/libc/stdio/sys5/vprintf.c
+++ b/usr/src/lib/libbc/libc/stdio/sys5/vprintf.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -36,17 +36,14 @@
/*LINTLIBRARY*/
#include <stdio.h>
-#include <varargs.h>
+#include <stdarg.h>
extern int _doprnt();
-/*VARARGS1*/
int
-vprintf(format, ap)
-char *format;
-va_list ap;
+vprintf(char *format, va_list ap)
{
- register int count;
+ int count;
if (!(stdout->_flag & _IOWRT)) {
/* if no write flag */
@@ -55,9 +52,9 @@ va_list ap;
stdout->_flag |= _IOWRT;
} else {
/* else error */
- return EOF;
+ return (EOF);
}
}
count = _doprnt(format, ap, stdout);
- return(ferror(stdout)? EOF: count);
+ return (ferror(stdout)? EOF: count);
}
diff --git a/usr/src/lib/libbc/libc/stdio/sys5/vsprintf.c b/usr/src/lib/libbc/libc/stdio/sys5/vsprintf.c
index c86412d4fb..09dca81392 100644
--- a/usr/src/lib/libbc/libc/stdio/sys5/vsprintf.c
+++ b/usr/src/lib/libbc/libc/stdio/sys5/vsprintf.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -36,18 +36,16 @@
/*LINTLIBRARY*/
#include <stdio.h>
-#include <varargs.h>
+#include <stdarg.h>
#include <values.h>
extern int _doprnt();
/*VARARGS2*/
int
-vsprintf(string, format, ap)
-char *string, *format;
-va_list ap;
+vsprintf(char *string, char *format, va_list ap)
{
- register int count;
+ int count;
FILE siop;
siop._cnt = MAXINT;
@@ -55,5 +53,5 @@ va_list ap;
siop._flag = _IOWRT+_IOSTRG;
count = _doprnt(format, ap, &siop);
*siop._ptr = '\0'; /* plant terminating null character */
- return(count);
+ return (count);
}