diff options
author | Simon J. Gerraty <sjg@FreeBSD.org> | 2012-11-04 02:52:03 +0000 |
---|---|---|
committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2012-11-04 02:52:03 +0000 |
commit | 23090366f729c56cab62de74c7a51792357e98a9 (patch) | |
tree | c511c885796e28ec571b5267e8f11f3b103d35e9 /bin/cat | |
parent | 7750ad47a9a7dbc83f87158464170c8640723293 (diff) | |
parent | 22ff74b2f44234d31540b1f7fd6c91489c37cad3 (diff) | |
download | src-test2-23090366f729c56cab62de74c7a51792357e98a9.tar.gz src-test2-23090366f729c56cab62de74c7a51792357e98a9.zip |
Notes
Diffstat (limited to 'bin/cat')
-rw-r--r-- | bin/cat/cat.1 | 2 | ||||
-rw-r--r-- | bin/cat/cat.c | 37 |
2 files changed, 21 insertions, 18 deletions
diff --git a/bin/cat/cat.1 b/bin/cat/cat.1 index 1f0f6b60a31c..4fdff3ae6df4 100644 --- a/bin/cat/cat.1 +++ b/bin/cat/cat.1 @@ -127,7 +127,7 @@ to the file truncating .Pa file3 if it already exists. -See the manual page for your shell (i.e., +See the manual page for your shell (e.g., .Xr sh 1 ) for more information on redirection. .Pp diff --git a/bin/cat/cat.c b/bin/cat/cat.c index 437c01379faf..69c56c0af224 100644 --- a/bin/cat/cat.c +++ b/bin/cat/cat.c @@ -58,11 +58,11 @@ __FBSDID("$FreeBSD$"); #include <err.h> #include <fcntl.h> #include <locale.h> +#include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <stddef.h> static int bflag, eflag, nflag, sflag, tflag, vflag; static int rval; @@ -77,16 +77,20 @@ static void raw_cat(int); static int udom_open(const char *path, int flags); #endif -/* Memory strategy threshold, in pages: if physmem is larger then this, use a - * large buffer */ -#define PHYSPAGES_THRESHOLD (32*1024) +/* + * Memory strategy threshold, in pages: if physmem is larger than this, + * use a large buffer. + */ +#define PHYSPAGES_THRESHOLD (32 * 1024) -/* Maximum buffer size in bytes - do not allow it to grow larger than this */ -#define BUFSIZE_MAX (2*1024*1024) +/* Maximum buffer size in bytes - do not allow it to grow larger than this. */ +#define BUFSIZE_MAX (2 * 1024 * 1024) -/* Small (default) buffer size in bytes. It's inefficient for this to be - * smaller than MAXPHYS */ -#define BUFSIZE_SMALL (MAXPHYS) +/* + * Small (default) buffer size in bytes. It's inefficient for this to be + * smaller than MAXPHYS. + */ +#define BUFSIZE_SMALL (MAXPHYS) int main(int argc, char *argv[]) @@ -144,13 +148,12 @@ usage(void) static void scanfiles(char *argv[], int cooked) { - int i = 0; + int fd, i; char *path; FILE *fp; + i = 0; while ((path = argv[i]) != NULL || i == 0) { - int fd; - if (path == NULL || strcmp(path, "-") == 0) { filename = "stdin"; fd = STDIN_FILENO; @@ -257,16 +260,16 @@ raw_cat(int rfd) wfd = fileno(stdout); if (buf == NULL) { if (fstat(wfd, &sbuf)) - err(1, "%s", filename); + err(1, "stdout"); if (S_ISREG(sbuf.st_mode)) { /* If there's plenty of RAM, use a large copy buffer */ if (sysconf(_SC_PHYS_PAGES) > PHYSPAGES_THRESHOLD) - bsize = MIN(BUFSIZE_MAX, MAXPHYS*8); + bsize = MIN(BUFSIZE_MAX, MAXPHYS * 8); else bsize = BUFSIZE_SMALL; } else - bsize = MAX(sbuf.st_blksize, - (blksize_t)sysconf(_SC_PAGESIZE)); + bsize = MAX(sbuf.st_blksize, + (blksize_t)sysconf(_SC_PAGESIZE)); if ((buf = malloc(bsize)) == NULL) err(1, "malloc() failure of IO buffer"); } @@ -327,7 +330,7 @@ udom_open(const char *path, int flags) break; } } - return(fd); + return (fd); } #endif |