Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-4]: src/bin/cat pullup 1.19->1.20 (Juergen Hannken-Illjes)
details: https://anonhg.NetBSD.org/src/rev/018308808419
branches: netbsd-1-4
changeset: 468495:018308808419
user: perry <perry%NetBSD.org@localhost>
date: Mon Apr 26 21:34:16 1999 +0000
description:
pullup 1.19->1.20 (Juergen Hannken-Illjes)
diffstat:
bin/cat/cat.c | 26 ++++++++++++--------------
1 files changed, 12 insertions(+), 14 deletions(-)
diffs (54 lines):
diff -r eff248c8e4b5 -r 018308808419 bin/cat/cat.c
--- a/bin/cat/cat.c Mon Apr 26 20:55:12 1999 +0000
+++ b/bin/cat/cat.c Mon Apr 26 21:34:16 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.19 1999/03/11 12:04:18 fair Exp $ */
+/* $NetBSD: cat.c,v 1.19.2.1 1999/04/26 21:34:16 perry Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@
#if 0
static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
#else
-__RCSID("$NetBSD: cat.c,v 1.19 1999/03/11 12:04:18 fair Exp $");
+__RCSID("$NetBSD: cat.c,v 1.19.2.1 1999/04/26 21:34:16 perry Exp $");
#endif
#endif /* not lint */
@@ -254,25 +254,23 @@
raw_cat(rfd)
int rfd;
{
- int wfd = 0;
+ int wfd;
static char *buf;
+ static char fb_buf[BUFSIZ];
struct stat sbuf;
static size_t bsize;
ssize_t nr, nw, off;
wfd = fileno(stdout);
- if (fstat(wfd, &sbuf))
- err(1, "%s", filename);
- if (bsize < sbuf.st_blksize) {
- bsize = MIN(sbuf.st_blksize, SSIZE_MAX);
- if (bsize != sbuf.st_blksize) {
- bsize = 16384;
+ if (buf == NULL) {
+ if (fstat(wfd, &sbuf) == 0) {
+ bsize = MIN(sbuf.st_blksize, SSIZE_MAX);
+ bsize = MAX(bsize, BUFSIZ);
+ buf = malloc(bsize);
}
- if(buf != NULL)
- free(buf);
- if ((buf = malloc(bsize)) == NULL) {
- bsize = 0;
- err(1, "malloc failed: cannot allocate buffer");
+ if (buf == NULL) {
+ buf = fb_buf;
+ bsize = BUFSIZ;
}
}
while ((nr = read(rfd, buf, bsize)) > 0)
Home |
Main Index |
Thread Index |
Old Index