summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjh <jh@FreeBSD.org>2012-07-20 08:31:36 +0000
committerjh <jh@FreeBSD.org>2012-07-20 08:31:36 +0000
commit0fdc094d92caaeafda40a566b16a806e177d57ba (patch)
tree8213e367cb8cb5a7f533f61c74d0e46353d86af4 /bin
parent555bfe85d8596073738d1a44fadf874b8ba61511 (diff)
downloadFreeBSD-src-0fdc094d92caaeafda40a566b16a806e177d57ba.zip
FreeBSD-src-0fdc094d92caaeafda40a566b16a806e177d57ba.tar.gz
style(9).
Diffstat (limited to 'bin')
-rw-r--r--bin/cat/cat.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/bin/cat/cat.c b/bin/cat/cat.c
index 437c013..8b75a82 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;
@@ -261,12 +264,12 @@ raw_cat(int rfd)
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
OpenPOWER on IntegriCloud