svn commit: r204358 - head/usr.bin/pr

Ed Schouten ed at FreeBSD.org
Fri Feb 26 13:47:51 UTC 2010


Author: ed
Date: Fri Feb 26 13:47:51 2010
New Revision: 204358
URL: http://svn.freebsd.org/changeset/base/204358

Log:
  Use time(NULL) instead of gettimeofday(), because we only need tv_sec.

Modified:
  head/usr.bin/pr/pr.c

Modified: head/usr.bin/pr/pr.c
==============================================================================
--- head/usr.bin/pr/pr.c	Fri Feb 26 12:40:01 2010	(r204357)
+++ head/usr.bin/pr/pr.c	Fri Feb 26 13:47:51 2010	(r204358)
@@ -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 cha
 			*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 cha
 			++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 cha
 				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) {


More information about the svn-src-all mailing list