style(9).

This commit is contained in:
Jaakko Heinonen 2012-07-20 08:31:36 +00:00
parent 2ff991dc64
commit 67bf019b10
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=238652

View File

@ -58,11 +58,11 @@ __FBSDID("$FreeBSD$");
#include <err.h> #include <err.h>
#include <fcntl.h> #include <fcntl.h>
#include <locale.h> #include <locale.h>
#include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <stddef.h>
static int bflag, eflag, nflag, sflag, tflag, vflag; static int bflag, eflag, nflag, sflag, tflag, vflag;
static int rval; static int rval;
@ -77,16 +77,20 @@ static void raw_cat(int);
static int udom_open(const char *path, int flags); static int udom_open(const char *path, int flags);
#endif #endif
/* Memory strategy threshold, in pages: if physmem is larger then this, use a /*
* large buffer */ * Memory strategy threshold, in pages: if physmem is larger than this,
#define PHYSPAGES_THRESHOLD (32*1024) * use a large buffer.
*/
#define PHYSPAGES_THRESHOLD (32 * 1024)
/* Maximum buffer size in bytes - do not allow it to grow larger than this */ /* Maximum buffer size in bytes - do not allow it to grow larger than this. */
#define BUFSIZE_MAX (2*1024*1024) #define BUFSIZE_MAX (2 * 1024 * 1024)
/* Small (default) buffer size in bytes. It's inefficient for this to be /*
* smaller than MAXPHYS */ * Small (default) buffer size in bytes. It's inefficient for this to be
#define BUFSIZE_SMALL (MAXPHYS) * smaller than MAXPHYS.
*/
#define BUFSIZE_SMALL (MAXPHYS)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
@ -144,13 +148,12 @@ usage(void)
static void static void
scanfiles(char *argv[], int cooked) scanfiles(char *argv[], int cooked)
{ {
int i = 0; int fd, i;
char *path; char *path;
FILE *fp; FILE *fp;
i = 0;
while ((path = argv[i]) != NULL || i == 0) { while ((path = argv[i]) != NULL || i == 0) {
int fd;
if (path == NULL || strcmp(path, "-") == 0) { if (path == NULL || strcmp(path, "-") == 0) {
filename = "stdin"; filename = "stdin";
fd = STDIN_FILENO; fd = STDIN_FILENO;
@ -261,12 +264,12 @@ raw_cat(int rfd)
if (S_ISREG(sbuf.st_mode)) { if (S_ISREG(sbuf.st_mode)) {
/* If there's plenty of RAM, use a large copy buffer */ /* If there's plenty of RAM, use a large copy buffer */
if (sysconf(_SC_PHYS_PAGES) > PHYSPAGES_THRESHOLD) if (sysconf(_SC_PHYS_PAGES) > PHYSPAGES_THRESHOLD)
bsize = MIN(BUFSIZE_MAX, MAXPHYS*8); bsize = MIN(BUFSIZE_MAX, MAXPHYS * 8);
else else
bsize = BUFSIZE_SMALL; bsize = BUFSIZE_SMALL;
} else } else
bsize = MAX(sbuf.st_blksize, bsize = MAX(sbuf.st_blksize,
(blksize_t)sysconf(_SC_PAGESIZE)); (blksize_t)sysconf(_SC_PAGESIZE));
if ((buf = malloc(bsize)) == NULL) if ((buf = malloc(bsize)) == NULL)
err(1, "malloc() failure of IO buffer"); err(1, "malloc() failure of IO buffer");
} }
@ -327,7 +330,7 @@ udom_open(const char *path, int flags)
break; break;
} }
} }
return(fd); return (fd);
} }
#endif #endif