Date: Sun, 7 Feb 2010 01:16:06 +0000 (UTC) From: Tim Kientzle <kientzle@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r203587 - head/usr.bin/tar Message-ID: <201002070116.o171G696094551@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kientzle Date: Sun Feb 7 01:16:05 2010 New Revision: 203587 URL: http://svn.freebsd.org/changeset/base/203587 Log: Minor code rework. Modified: head/usr.bin/tar/getdate.c Modified: head/usr.bin/tar/getdate.c ============================================================================== --- head/usr.bin/tar/getdate.c Sun Feb 7 01:07:58 2010 (r203586) +++ head/usr.bin/tar/getdate.c Sun Feb 7 01:16:05 2010 (r203587) @@ -219,7 +219,8 @@ datephrase(struct gdstate *gds) gds->Year = gds->tokenp[0].value; gds->Month = gds->tokenp[2].value; gds->Day = gds->tokenp[4].value; - } else if ((gds->tokenp[4].value >= 13) || (gds->tokenp[2].value >= 13)) { + } else if ((gds->tokenp[4].value >= 13) + || (gds->tokenp[2].value >= 13)) { /* Last number is big: 01/07/98 */ /* Middle number is big: 01/29/04 */ gds->Month = gds->tokenp[0].value; @@ -681,20 +682,6 @@ static struct LEXICON { }; /* - * Convert hour/minute/second to count of seconds. - */ -static time_t -ToSeconds(time_t Hours, time_t Minutes, time_t Seconds) -{ - if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) - return -1; - if (Hours < 0 || Hours > 23) - return -1; - return Hours * HOUR + Minutes * MINUTE + Seconds; -} - - -/* * Year is either: * = A number from 0 to 99, which means a year from 1970 to 2069, or * = The actual year (>=100). @@ -707,7 +694,6 @@ Convert(time_t Month, time_t Day, time_t static int DaysInMonth[12] = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - time_t tod; time_t Julian; int i; @@ -722,7 +708,10 @@ Convert(time_t Month, time_t Day, time_t if (Year < EPOCH || Year > 2038 || Month < 1 || Month > 12 /* Lint fluff: "conversion from long may lose accuracy" */ - || Day < 1 || Day > DaysInMonth[(int)--Month]) + || Day < 1 || Day > DaysInMonth[(int)--Month] + || Hours < 0 || Hours > 23 + || Minutes < 0 || Minutes > 59 + || Seconds < 0 || Seconds > 59) return -1; Julian = Day - 1; @@ -732,9 +721,7 @@ Convert(time_t Month, time_t Day, time_t Julian += 365 + (i % 4 == 0); Julian *= DAY; Julian += Timezone; - if ((tod = ToSeconds(Hours, Minutes, Seconds)) < 0) - return -1; - Julian += tod; + Julian += Hours * HOUR + Minutes * MINUTE + Seconds; if (DSTmode == DSTon || (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst)) Julian -= HOUR; @@ -838,7 +825,7 @@ nexttoken(char **in, time_t *value) } src++; } - buff[i++] = '\0'; + buff[i] = '\0'; /* * Find the first match. If the word can be
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002070116.o171G696094551>