Deleted Added
full compact
cat.c (50471) cat.c (59239)
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kevin Fall.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 31 unchanged lines hidden (view full) ---

40 The Regents of the University of California. All rights reserved.\n";
41#endif /* not lint */
42
43#ifndef lint
44#if 0
45static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
46#endif
47static const char rcsid[] =
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kevin Fall.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 31 unchanged lines hidden (view full) ---

40 The Regents of the University of California. All rights reserved.\n";
41#endif /* not lint */
42
43#ifndef lint
44#if 0
45static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
46#endif
47static const char rcsid[] =
48 "$FreeBSD: head/bin/cat/cat.c 50471 1999-08-27 23:15:48Z peter $";
48 "$FreeBSD: head/bin/cat/cat.c 59239 2000-04-14 21:01:35Z asmodai $";
49#endif /* not lint */
50
51#include <sys/param.h>
52#include <sys/stat.h>
53
54#include <ctype.h>
55#include <err.h>
56#include <fcntl.h>

--- 34 unchanged lines hidden (view full) ---

91 break;
92 case 's':
93 sflag = 1;
94 break;
95 case 't':
96 tflag = vflag = 1; /* -t implies -v */
97 break;
98 case 'u':
49#endif /* not lint */
50
51#include <sys/param.h>
52#include <sys/stat.h>
53
54#include <ctype.h>
55#include <err.h>
56#include <fcntl.h>

--- 34 unchanged lines hidden (view full) ---

91 break;
92 case 's':
93 sflag = 1;
94 break;
95 case 't':
96 tflag = vflag = 1; /* -t implies -v */
97 break;
98 case 'u':
99 setbuf(stdout, (char *)NULL);
99 setbuf(stdout, NULL);
100 break;
101 case 'v':
102 vflag = 1;
103 break;
104 default:
105 (void)fprintf(stderr,
106 "usage: cat [-benstuv] [-] [file ...]\n");
107 exit(1);

--- 136 unchanged lines hidden (view full) ---

244 struct stat sbuf;
245
246 wfd = fileno(stdout);
247 if (buf == NULL) {
248 if (fstat(wfd, &sbuf))
249 err(1, "%s", filename);
250 bsize = MAX(sbuf.st_blksize, 1024);
251 if ((buf = malloc(bsize)) == NULL)
100 break;
101 case 'v':
102 vflag = 1;
103 break;
104 default:
105 (void)fprintf(stderr,
106 "usage: cat [-benstuv] [-] [file ...]\n");
107 exit(1);

--- 136 unchanged lines hidden (view full) ---

244 struct stat sbuf;
245
246 wfd = fileno(stdout);
247 if (buf == NULL) {
248 if (fstat(wfd, &sbuf))
249 err(1, "%s", filename);
250 bsize = MAX(sbuf.st_blksize, 1024);
251 if ((buf = malloc(bsize)) == NULL)
252 err(1, NULL);
252 err(1, "buffer");
253 }
254 while ((nr = read(rfd, buf, bsize)) > 0)
255 for (off = 0; nr; nr -= nw, off += nw)
256 if ((nw = write(wfd, buf + off, (size_t)nr)) < 0)
257 err(1, "stdout");
258 if (nr < 0) {
259 warn("%s", filename);
260 rval = 1;
261 }
262}
253 }
254 while ((nr = read(rfd, buf, bsize)) > 0)
255 for (off = 0; nr; nr -= nw, off += nw)
256 if ((nw = write(wfd, buf + off, (size_t)nr)) < 0)
257 err(1, "stdout");
258 if (nr < 0) {
259 warn("%s", filename);
260 rval = 1;
261 }
262}