summaryrefslogtreecommitdiffstats
path: root/usr.bin/pr/pr.c
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-02-26 13:47:51 +0000
committered <ed@FreeBSD.org>2010-02-26 13:47:51 +0000
commit95f188bc4a86944aa82e9fa3c5fa535612662e09 (patch)
tree46c571b104e725d87f51e9727f3c7b8dd86c6d3b /usr.bin/pr/pr.c
parent0c57ffc7c18dc3a29c71e8edc8fe9f366ab73c03 (diff)
downloadFreeBSD-src-95f188bc4a86944aa82e9fa3c5fa535612662e09.zip
FreeBSD-src-95f188bc4a86944aa82e9fa3c5fa535612662e09.tar.gz
Use time(NULL) instead of gettimeofday(), because we only need tv_sec.
Diffstat (limited to 'usr.bin/pr/pr.c')
-rw-r--r--usr.bin/pr/pr.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/usr.bin/pr/pr.c b/usr.bin/pr/pr.c
index fed27f2..ae7ae07 100644
--- a/usr.bin/pr/pr.c
+++ b/usr.bin/pr/pr.c
@@ -1265,9 +1265,7 @@ FILE *
nxtfile(int argc, char **argv, const char **fname, char *buf, int dt)
{
FILE *inf = NULL;
- struct timeval tv;
time_t tv_sec;
- struct timezone tz;
struct tm *timeptr = NULL;
struct stat statbuf;
static int twice = -1;
@@ -1287,14 +1285,13 @@ nxtfile(int argc, char **argv, const char **fname, char *buf, int dt)
*fname = fnamedefault;
if (nohead)
return(inf);
- if (gettimeofday(&tv, &tz) < 0) {
+ if ((tv_sec = time(NULL)) == -1) {
++errcnt;
(void)fprintf(err, "pr: cannot get time of day, %s\n",
strerror(errno));
eoptind = argc - 1;
return(NULL);
}
- tv_sec = tv.tv_sec;
timeptr = localtime(&tv_sec);
}
for (; eoptind < argc; ++eoptind) {
@@ -1311,14 +1308,13 @@ nxtfile(int argc, char **argv, const char **fname, char *buf, int dt)
++eoptind;
if (nohead || (dt && twice))
return(inf);
- if (gettimeofday(&tv, &tz) < 0) {
+ if ((tv_sec = time(NULL)) == -1) {
++errcnt;
(void)fprintf(err,
"pr: cannot get time of day, %s\n",
strerror(errno));
return(NULL);
}
- tv_sec = tv.tv_sec;
timeptr = localtime(&tv_sec);
} else {
/*
@@ -1343,14 +1339,13 @@ nxtfile(int argc, char **argv, const char **fname, char *buf, int dt)
return(inf);
if (dt) {
- if (gettimeofday(&tv, &tz) < 0) {
+ if ((tv_sec = time(NULL)) == -1) {
++errcnt;
(void)fprintf(err,
"pr: cannot get time of day, %s\n",
strerror(errno));
return(NULL);
}
- tv_sec = tv.tv_sec;
timeptr = localtime(&tv_sec);
} else {
if (fstat(fileno(inf), &statbuf) < 0) {
OpenPOWER on IntegriCloud