diff options
author | cheloha <cheloha@cvs.openbsd.org> | 2017-12-23 20:53:08 +0000 |
---|---|---|
committer | cheloha <cheloha@cvs.openbsd.org> | 2017-12-23 20:53:08 +0000 |
commit | 24742988183dcde580f2ff0832bb5c25e648798e (patch) | |
tree | 10a678e373aa9c564c873763b1510bf6b9381da0 /usr.bin/pr | |
parent | 9dba6024ec66fc3aad30ed0feae3e5776ed99355 (diff) |
As we only use the .tv_sec field, simplify gettimeofday(2) -> time(3).
ok tb@ jca@
Diffstat (limited to 'usr.bin/pr')
-rw-r--r-- | usr.bin/pr/pr.c | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/usr.bin/pr/pr.c b/usr.bin/pr/pr.c index 08941e13d16..0342df907aa 100644 --- a/usr.bin/pr/pr.c +++ b/usr.bin/pr/pr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pr.c,v 1.40 2017/11/02 09:52:04 jca Exp $ */ +/* $OpenBSD: pr.c,v 1.41 2017/12/23 20:53:07 cheloha Exp $ */ /*- * Copyright (c) 1991 Keith Muller. @@ -34,7 +34,6 @@ */ #include <sys/types.h> -#include <sys/time.h> #include <sys/stat.h> #include <ctype.h> @@ -45,6 +44,7 @@ #include <stdarg.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <unistd.h> #include "pr.h" @@ -1442,7 +1442,6 @@ FILE * nxtfile(int argc, char *argv[], char **fname, char *buf, int dt) { FILE *inf = NULL; - struct timeval tv; struct tm *timeptr = NULL; struct stat statbuf; time_t curtime; @@ -1463,14 +1462,7 @@ nxtfile(int argc, char *argv[], char **fname, char *buf, int dt) *fname = FNAME; if (nohead) return(inf); - if (gettimeofday(&tv, NULL) < 0) { - ++errcnt; - ferrout("pr: cannot get time of day, %s\n", - strerror(errno)); - eoptind = argc - 1; - return(NULL); - } - curtime = tv.tv_sec; + curtime = time(NULL);; timeptr = localtime(&curtime); } for (; eoptind < argc; ++eoptind) { @@ -1487,13 +1479,7 @@ nxtfile(int argc, char *argv[], char **fname, char *buf, int dt) ++eoptind; if (nohead || (dt && twice)) return(inf); - if (gettimeofday(&tv, NULL) < 0) { - ++errcnt; - ferrout("pr: cannot get time of day, %s\n", - strerror(errno)); - return(NULL); - } - curtime = tv.tv_sec; + curtime = time(NULL); timeptr = localtime(&curtime); } else { /* @@ -1518,13 +1504,7 @@ nxtfile(int argc, char *argv[], char **fname, char *buf, int dt) return(inf); if (dt) { - if (gettimeofday(&tv, NULL) < 0) { - ++errcnt; - ferrout("pr: cannot get time of day, %s\n", - strerror(errno)); - return(NULL); - } - curtime = tv.tv_sec; + curtime = time(NULL); timeptr = localtime(&curtime); } else { if (fstat(fileno(inf), &statbuf) < 0) { |