summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/util.c
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-05-19 04:17:25 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-05-19 04:17:25 +0000
commit73777a9b14f042c516abc7fbd8789f38d6f1c225 (patch)
treeb7c46c515fd4aef73d658532f08aa0807c278209 /usr.bin/cvs/util.c
parent55ce8dc1ce848c42d7f8eab4ceab058a3286ec2d (diff)
use the date parsing code from date.y and fix timestamps on newly
created files so they match the values found in the corresponding entries, otherwise all files appear as modified ok joris
Diffstat (limited to 'usr.bin/cvs/util.c')
-rw-r--r--usr.bin/cvs/util.c76
1 files changed, 1 insertions, 75 deletions
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index 4e6d9f6b821..0b5cf36a247 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.24 2005/05/18 20:24:19 joris Exp $ */
+/* $OpenBSD: util.c,v 1.25 2005/05/19 04:17:24 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -128,80 +128,6 @@ cvs_readrepo(const char *dir, char *dst, size_t len)
/*
- * cvs_datesec()
- *
- * Take a date string and transform it into the number of seconds since the
- * Epoch. The <type> argument specifies whether the timestamp is in ctime(3)
- * format or RFC 822 format (as CVS uses in its protocol). If the <adj>
- * parameter is not 0, the returned time will be adjusted according to the
- * machine's local timezone.
- */
-time_t
-cvs_datesec(const char *date, int type, int adj)
-{
- int i;
- long off;
- char sign, mon[8], gmt[8], hr[4], min[4], *ep;
- struct tm cvs_tm;
-
- memset(&cvs_tm, 0, sizeof(cvs_tm));
- cvs_tm.tm_isdst = -1;
-
- if (type == CVS_DATE_RFC822) {
- if (sscanf(date, "%d %3s %d %2d:%2d:%2d %5s", &cvs_tm.tm_mday,
- mon, &cvs_tm.tm_year, &cvs_tm.tm_hour, &cvs_tm.tm_min,
- &cvs_tm.tm_sec, gmt) < 7)
- return (-1);
- cvs_tm.tm_year -= 1900;
-
- if (*gmt == '-') {
- sscanf(gmt, "%c%2s%2s", &sign, hr, min);
- cvs_tm.tm_gmtoff = strtol(hr, &ep, 10);
- if ((cvs_tm.tm_gmtoff == LONG_MIN) ||
- (cvs_tm.tm_gmtoff == LONG_MAX) ||
- (*ep != '\0')) {
- cvs_log(LP_ERR,
- "parse error in GMT hours specification `%s'", hr);
- cvs_tm.tm_gmtoff = 0;
- } else {
- /* get seconds */
- cvs_tm.tm_gmtoff *= 3600;
-
- /* add the minutes */
- off = strtol(min, &ep, 10);
- if ((cvs_tm.tm_gmtoff == LONG_MIN) ||
- (cvs_tm.tm_gmtoff == LONG_MAX) ||
- (*ep != '\0')) {
- cvs_log(LP_ERR,
- "parse error in GMT minutes "
- "specification `%s'", min);
- } else
- cvs_tm.tm_gmtoff += off * 60;
- }
- }
- if (sign == '-')
- cvs_tm.tm_gmtoff = -cvs_tm.tm_gmtoff;
- } else if (type == CVS_DATE_CTIME) {
- /* gmt is used for the weekday */
- sscanf(date, "%3s %3s %d %2d:%2d:%2d %d", gmt, mon,
- &cvs_tm.tm_mday, &cvs_tm.tm_hour, &cvs_tm.tm_min,
- &cvs_tm.tm_sec, &cvs_tm.tm_year);
- cvs_tm.tm_year -= 1900;
- cvs_tm.tm_gmtoff = 0;
- }
-
- for (i = 0; i < (int)(sizeof(cvs_months)/sizeof(cvs_months[0])); i++) {
- if (strcmp(cvs_months[i], mon) == 0) {
- cvs_tm.tm_mon = i;
- break;
- }
- }
-
- return mktime(&cvs_tm);
-}
-
-
-/*
* cvs_strtomode()
*
* Read the contents of the string <str> and generate a permission mode from