summaryrefslogtreecommitdiff
path: root/usr.bin
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
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')
-rw-r--r--usr.bin/cvs/cvs.h8
-rw-r--r--usr.bin/cvs/date.y13
-rw-r--r--usr.bin/cvs/entries.c5
-rw-r--r--usr.bin/cvs/resp.c8
-rw-r--r--usr.bin/cvs/util.c76
5 files changed, 18 insertions, 92 deletions
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index 12b6c140969..adc18318197 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.55 2005/05/18 20:24:19 joris Exp $ */
+/* $OpenBSD: cvs.h,v 1.56 2005/05/19 04:17:24 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -393,12 +393,10 @@ char* cvs_logmsg_open (const char *);
char* cvs_logmsg_get (const char *, struct cvs_flist *, struct cvs_flist *, struct cvs_flist *);
int cvs_logmsg_send (struct cvsroot *, const char *);
-/* from util.c */
-#define CVS_DATE_CTIME 0
-#define CVS_DATE_RFC822 1
+
+time_t cvs_date_parse (const char *);
int cvs_readrepo (const char *, char *, size_t);
-time_t cvs_datesec (const char *, int, int);
int cvs_modetostr (mode_t, char *, size_t);
int cvs_strtomode (const char *, mode_t *);
int cvs_splitpath (const char *, char *, size_t, char **);
diff --git a/usr.bin/cvs/date.y b/usr.bin/cvs/date.y
index 71494006852..849888b32ba 100644
--- a/usr.bin/cvs/date.y
+++ b/usr.bin/cvs/date.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: date.y,v 1.6 2005/04/18 21:55:13 joris Exp $ */
+/* $OpenBSD: date.y,v 1.7 2005/05/19 04:17:24 jfb Exp $ */
/*
** Originally written by Steven M. Bellovin <smb@research.att.com> while
@@ -25,6 +25,7 @@
#include <time.h>
#include "log.h"
+#include "cvs.h"
#define YEAR_EPOCH 1970
#define YEAR_TMORIGIN 1900
@@ -57,7 +58,7 @@ typedef enum _MERIDIAN {
* yacc had the %union construct.) Maybe someday; right now we only use
* the %union very rarely.
*/
-static char *yyInput;
+static const char *yyInput;
static DSTMODE yyDSTmode;
static time_t yyDayOrdinal;
static time_t yyDayNumber;
@@ -82,8 +83,6 @@ static int yyerror (const char *, ...);
static int yylex (void);
static int yyparse (void);
-time_t get_date(char *, struct timeb *);
-
%}
%union {
@@ -809,12 +808,14 @@ difftm(struct tm *a, struct tm *b)
}
time_t
-get_date(char *p, struct timeb *now)
+cvs_date_parse(const char *p)
{
struct tm *tm, gmt;
- struct timeb ftz;
+ struct timeb ftz, *now;
time_t Start, tod, nowtime;
+ now = NULL;
+
yyInput = p;
if (now == NULL) {
struct tm *gmt_ptr;
diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c
index cf8350682d5..8deb047ecae 100644
--- a/usr.bin/cvs/entries.c
+++ b/usr.bin/cvs/entries.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: entries.c,v 1.27 2005/04/22 15:16:15 joris Exp $ */
+/* $OpenBSD: entries.c,v 1.28 2005/05/19 04:17:24 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -380,8 +380,7 @@ cvs_ent_parse(const char *entry)
if (strcmp(fields[3], CVS_DATE_DUMMY) == 0)
entp->ce_mtime = CVS_DATE_DMSEC;
else
- entp->ce_mtime = cvs_datesec(fields[3],
- CVS_DATE_CTIME, 0);
+ entp->ce_mtime = cvs_date_parse(fields[3]);
entp->ce_opts = fields[4];
entp->ce_tag = fields[5];
diff --git a/usr.bin/cvs/resp.c b/usr.bin/cvs/resp.c
index 7888593be39..d50ca15d3ec 100644
--- a/usr.bin/cvs/resp.c
+++ b/usr.bin/cvs/resp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resp.c,v 1.33 2005/05/12 17:32:16 joris Exp $ */
+/* $OpenBSD: resp.c,v 1.34 2005/05/19 04:17:24 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -566,7 +566,7 @@ cvs_resp_copyfile(struct cvsroot *root, int type, char *line)
static int
cvs_resp_modtime(struct cvsroot *root, int type, char *line)
{
- cvs_modtime = cvs_datesec(line, CVS_DATE_RFC822, 1);
+ cvs_modtime = cvs_date_parse(line);
return (0);
}
@@ -615,7 +615,6 @@ cvs_resp_updated(struct cvsroot *root, int type, char *line)
if (cvs_modtime != CVS_DATE_DMSEC) {
ep->ce_mtime = cvs_modtime;
- cvs_modtime = CVS_DATE_DMSEC; /* invalidate */
} else
ep->ce_mtime = time(&(ep->ce_mtime));
@@ -653,6 +652,9 @@ cvs_resp_updated(struct cvsroot *root, int type, char *line)
cvs_log(LP_ERRNO, "failed to set file timestamps");
}
+ /* invalidate last received timestamp */
+ cvs_modtime = CVS_DATE_DMSEC;
+
/* now see if there is a checksum */
if (cvs_fcksum != NULL) {
if (cvs_cksum(path, cksum_buf, sizeof(cksum_buf)) < 0)
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