summaryrefslogtreecommitdiffstats
path: root/bin/sh/output.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2002-02-02 06:50:57 +0000
committerimp <imp@FreeBSD.org>2002-02-02 06:50:57 +0000
commit5ef5088ac4e038d0a147a08377ef087fd6edf527 (patch)
tree01a827446e9ba4f34cf1e754fcac691f6c9eb1cf /bin/sh/output.c
parent50014e35418ca00d25ea852fc4f94acf80be4df3 (diff)
downloadFreeBSD-src-5ef5088ac4e038d0a147a08377ef087fd6edf527.zip
FreeBSD-src-5ef5088ac4e038d0a147a08377ef087fd6edf527.tar.gz
o __P has been reoved
o Old-style K&R declarations have been converted to new C89 style o register has been removed o prototype for main() has been removed (gcc3 makes it an error) o int main(int argc, char *argv[]) is the preferred main definition. o Attempt to not break style(9) conformance for declarations more than they already are. o Change int foo() { ... to int foo(void) { ...
Diffstat (limited to 'bin/sh/output.c')
-rw-r--r--bin/sh/output.c171
1 files changed, 26 insertions, 145 deletions
diff --git a/bin/sh/output.c b/bin/sh/output.c
index 2989c9a..56a437c 100644
--- a/bin/sh/output.c
+++ b/bin/sh/output.c
@@ -58,11 +58,7 @@ static const char rcsid[] =
#include <stdio.h> /* defines BUFSIZ */
#include <string.h>
-#ifdef __STDC__
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
@@ -105,46 +101,23 @@ RESET {
#endif
-#ifdef notdef /* no longer used */
-/*
- * Set up an output file to write to memory rather than a file.
- */
-
-void
-open_mem(block, length, file)
- char *block;
- int length;
- struct output *file;
- {
- file->nextc = block;
- file->nleft = --length;
- file->fd = BLOCK_OUT;
- file->flags = 0;
-}
-#endif
-
-
void
-out1str(p)
- const char *p;
- {
+out1str(const char *p)
+{
outstr(p, out1);
}
void
-out2str(p)
- const char *p;
- {
+out2str(const char *p)
+{
outstr(p, out2);
}
void
-outstr(p, file)
- const char *p;
- struct output *file;
- {
+outstr(const char *p, struct output *file)
+{
while (*p)
outc(*p++, file);
if (file == out2)
@@ -156,9 +129,8 @@ char out_junk[16];
void
-emptyoutbuf(dest)
- struct output *dest;
- {
+emptyoutbuf(struct output *dest)
+{
int offset;
if (dest->fd == BLOCK_OUT) {
@@ -187,16 +159,16 @@ emptyoutbuf(dest)
void
-flushall() {
+flushall(void)
+{
flushout(&output);
flushout(&errout);
}
void
-flushout(dest)
- struct output *dest;
- {
+flushout(struct output *dest)
+{
if (dest->buf == NULL || dest->nextc == dest->buf || dest->fd < 0)
return;
@@ -208,7 +180,8 @@ flushout(dest)
void
-freestdout() {
+freestdout(void)
+{
INTOFF;
if (output.buf) {
ckfree(output.buf);
@@ -219,9 +192,9 @@ freestdout() {
}
-#ifdef __STDC__
void
-outfmt(struct output *file, const char *fmt, ...) {
+outfmt(struct output *file, const char *fmt, ...)
+{
va_list ap;
va_start(ap, fmt);
@@ -231,7 +204,8 @@ outfmt(struct output *file, const char *fmt, ...) {
void
-out1fmt(const char *fmt, ...) {
+out1fmt(const char *fmt, ...)
+{
va_list ap;
va_start(ap, fmt);
@@ -240,7 +214,8 @@ out1fmt(const char *fmt, ...) {
}
void
-dprintf(const char *fmt, ...) {
+dprintf(const char *fmt, ...)
+{
va_list ap;
va_start(ap, fmt);
@@ -250,7 +225,8 @@ dprintf(const char *fmt, ...) {
}
void
-fmtstr(char *outbuf, int length, const char *fmt, ...) {
+fmtstr(char *outbuf, int length, const char *fmt, ...)
+{
va_list ap;
struct output strout;
@@ -265,77 +241,6 @@ fmtstr(char *outbuf, int length, const char *fmt, ...) {
outbuf[length - 1] = '\0';
}
-#else /* not __STDC__ */
-
-void
-outfmt(va_alist)
- va_dcl
- {
- va_list ap;
- struct output *file;
- const char *fmt;
-
- va_start(ap);
- file = va_arg(ap, struct output *);
- fmt = va_arg(ap, char *);
- doformat(file, fmt, ap);
- va_end(ap);
-}
-
-
-void
-out1fmt(va_alist)
- va_dcl
- {
- va_list ap;
- const char *fmt;
-
- va_start(ap);
- fmt = va_arg(ap, char *);
- doformat(out1, fmt, ap);
- va_end(ap);
-}
-
-void
-dprintf(va_alist)
- va_dcl
- {
- va_list ap;
- const char *fmt;
-
- va_start(ap);
- fmt = va_arg(ap, char *);
- doformat(out2, fmt, ap);
- va_end(ap);
- flushout(out2);
-}
-
-void
-fmtstr(va_alist)
- va_dcl
- {
- va_list ap;
- struct output strout;
- char *outbuf;
- int length;
- const char *fmt;
-
- va_start(ap);
- outbuf = va_arg(ap, char *);
- length = va_arg(ap, int);
- fmt = va_arg(ap, char *);
- strout.nextc = outbuf;
- strout.nleft = length;
- strout.fd = BLOCK_OUT;
- strout.flags = 0;
- doformat(&strout, fmt, ap);
- outc('\0', &strout);
- if (strout.flags & OUTPUT_ERR)
- outbuf[length - 1] = '\0';
-}
-#endif /* __STDC__ */
-
-
/*
* Formatted output. This routine handles a subset of the printf formats:
* - Formats supported: d, u, o, X, s, and c.
@@ -355,11 +260,8 @@ static const char digit[] = "0123456789ABCDEF";
void
-doformat(dest, f, ap)
- struct output *dest;
- const char *f; /* format string */
- va_list ap;
- {
+doformat(struct output *dest, const char *f, va_list ap)
+{
char c;
char temp[TEMPSIZE];
int flushleft;
@@ -529,11 +431,8 @@ number: /* process a number */
*/
int
-xwrite(fd, buf, nbytes)
- int fd;
- char *buf;
- int nbytes;
- {
+xwrite(int fd, char *buf, int nbytes)
+{
int ntry;
int i;
int n;
@@ -555,21 +454,3 @@ xwrite(fd, buf, nbytes)
}
}
}
-
-
-/*
- * Version of ioctl that retries after a signal is caught.
- * XXX unused function
- */
-
-int
-xioctl(fd, request, arg)
- int fd;
- unsigned long request;
- char * arg;
-{
- int i;
-
- while ((i = ioctl(fd, request, arg)) == -1 && errno == EINTR);
- return i;
-}
OpenPOWER on IntegriCloud