summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoris <joris@openbsd.org>2006-04-13 19:16:15 +0000
committerjoris <joris@openbsd.org>2006-04-13 19:16:15 +0000
commit25939815f53a15f6843a3a10a474a216a41dea0d (patch)
tree84380a68cf1a142150fd9fbc66fe1c6ef277fe07
parentfix the obviously broken cvs_buf_set(), so we don't end up (diff)
downloadwireguard-openbsd-25939815f53a15f6843a3a10a474a216a41dea0d.tar.xz
wireguard-openbsd-25939815f53a15f6843a3a10a474a216a41dea0d.zip
fix -z option for openrcs, this was broken by xsa
when he yanked the code out of rcs.c and placed it in rcstime.c. struct tm ltb, *tb; tb = &ltb; return (tb); isn't really the most perfect idiom to return a value to the caller, now is it? as a bonus -z for rlog now works too. okay niallo@
-rw-r--r--usr.bin/cvs/rcs.c10
-rw-r--r--usr.bin/cvs/rcs.h4
-rw-r--r--usr.bin/cvs/rcstime.c45
-rw-r--r--usr.bin/rcs/rlog.c28
4 files changed, 51 insertions, 36 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index f9a8f402459..ed6398691a5 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.164 2006/04/12 22:54:23 ray Exp $ */
+/* $OpenBSD: rcs.c,v 1.165 2006/04/13 19:16:15 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -2536,7 +2536,7 @@ rcs_expand_keywords(char *rcsfile, struct rcs_delta *rdp, char *data,
u_int j, found;
char *c, *kwstr, *start, *end, *tbuf;
char expbuf[256], buf[256];
- struct tm *tb;
+ struct tm tb;
char *fmt;
kwtype = 0;
@@ -2546,9 +2546,9 @@ rcs_expand_keywords(char *rcsfile, struct rcs_delta *rdp, char *data,
/*
* -z support for RCS
*/
- tb = &rdp->rd_date;
+ tb = rdp->rd_date;
if (timezone_flag != NULL)
- tb = rcs_set_tz(timezone_flag, rdp);
+ rcs_set_tz(timezone_flag, rdp, &tb);
/*
* Keyword formats:
@@ -2651,7 +2651,7 @@ rcs_expand_keywords(char *rcsfile, struct rcs_delta *rdp, char *data,
else
fmt = "%Y/%m/%d %H:%M:%S ";
- strftime(buf, sizeof(buf), fmt, tb);
+ strftime(buf, sizeof(buf), fmt, &tb);
strlcat(expbuf, buf, sizeof(expbuf));
}
diff --git a/usr.bin/cvs/rcs.h b/usr.bin/cvs/rcs.h
index 1e17701cd0a..f544c73092b 100644
--- a/usr.bin/cvs/rcs.h
+++ b/usr.bin/cvs/rcs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.h,v 1.58 2006/04/10 08:08:00 xsa Exp $ */
+/* $OpenBSD: rcs.h,v 1.59 2006/04/13 19:16:15 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -270,7 +270,7 @@ void rcsnum_cpy(const RCSNUM *, RCSNUM *, u_int);
int rcsnum_cmp(const RCSNUM *, const RCSNUM *, u_int);
/* rcstime.c */
-struct tm *rcs_set_tz(char *, struct rcs_delta *);
+void rcs_set_tz(char *, struct rcs_delta *, struct tm *);
extern char *timezone_flag;
diff --git a/usr.bin/cvs/rcstime.c b/usr.bin/cvs/rcstime.c
index 672ad53bfb2..73c90298f80 100644
--- a/usr.bin/cvs/rcstime.c
+++ b/usr.bin/cvs/rcstime.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcstime.c,v 1.2 2006/03/09 16:53:56 joris Exp $ */
+/* $OpenBSD: rcstime.c,v 1.3 2006/04/13 19:16:15 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -29,46 +29,53 @@
#include "log.h"
#include "rcs.h"
-
-struct tm *
-rcs_set_tz(char *tz, struct rcs_delta *rdp)
+void
+rcs_set_tz(char *tz, struct rcs_delta *rdp, struct tm *tb)
{
int tzone;
+ int neg, pos;
char *h, *m;
- struct tm *tb, ltb;
+ struct tm *ltb;
time_t now;
- tb = &rdp->rd_date;
-
if (!strcmp(tz, "LT")) {
now = mktime(&rdp->rd_date);
- tb = localtime(&now);
- tb->tm_hour += ((int)tb->tm_gmtoff/3600);
+ ltb = localtime(&now);
+ ltb->tm_hour += ((int)ltb->tm_gmtoff/3600);
+ memcpy(tb, ltb, sizeof(struct tm));
} else {
+ neg = pos = 0;
switch (*tz) {
case '-':
- case '+':
+ neg = 1;
+ break;
+ case '+':
+ pos = 1;
break;
default:
fatal("%s: not a known time zone", tz);
}
- h = tz;
+ h = (tz + 1);
if ((m = strrchr(tz, ':')) != NULL)
*(m++) = '\0';
- ltb = rdp->rd_date;
- tb = &ltb;
+ memcpy(tb, &rdp->rd_date, sizeof(struct tm));
tzone = atoi(h);
if ((tzone >= 24) && (tzone <= -24))
fatal("%s: not a known time zone", tz);
- tb->tm_hour += tzone;
- if ((tb->tm_hour >= 24) && (tb->tm_hour <= -24))
- tb->tm_hour = 0;
+ if (pos) {
+ tb->tm_hour += tzone;
+ tb->tm_gmtoff += (tzone * 3600);
+ } else {
+ tb->tm_hour -= tzone;
+ tb->tm_gmtoff -= (tzone * 3600);
+ }
- tb->tm_gmtoff += (tzone*3600);
+ if ((tb->tm_hour >= 24) || (tb->tm_hour <= -24))
+ tb->tm_hour = 0;
if (m != NULL) {
tzone = atoi(m);
@@ -77,13 +84,11 @@ rcs_set_tz(char *tz, struct rcs_delta *rdp)
if ((tb->tm_min + tzone) >= 60) {
tb->tm_hour++;
- tb->tm_min -= tzone;
+ tb->tm_min -= (60 - tzone);
} else
tb->tm_min += tzone;
tb->tm_gmtoff += (tzone*60);
}
}
-
- return (tb);
}
diff --git a/usr.bin/rcs/rlog.c b/usr.bin/rcs/rlog.c
index 6971d2a3397..bebb3bd1e0b 100644
--- a/usr.bin/rcs/rlog.c
+++ b/usr.bin/rcs/rlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rlog.c,v 1.39 2006/04/10 15:32:26 niallo Exp $ */
+/* $OpenBSD: rlog.c,v 1.40 2006/04/13 19:16:15 joris Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -235,7 +235,8 @@ static void
rlog_rev_print(struct rcs_delta *rdp)
{
int i, found;
- char *author, numb[64];
+ struct tm t;
+ char *author, numb[64], *fmt, timeb[64];
struct cvs_argvector *largv, *sargv, *wargv;
i = found = 0;
@@ -266,6 +267,7 @@ rlog_rev_print(struct rcs_delta *rdp)
cvs_argv_destroy(largv);
}
}
+
/* -sstates */
if (slist != NULL) {
sargv = cvs_strsplit(slist, ",");
@@ -278,6 +280,7 @@ rlog_rev_print(struct rcs_delta *rdp)
}
cvs_argv_destroy(sargv);
}
+
/* -w[logins] */
if (wflag == 1) {
if (wlist != NULL) {
@@ -315,13 +318,20 @@ rlog_rev_print(struct rcs_delta *rdp)
printf("revision %s", numb);
if (rdp->rd_locker != NULL)
printf("\tlocked by: %s;", rdp->rd_locker);
- printf("\ndate: %d/%02d/%02d %02d:%02d:%02d;"
- " author: %s; state: %s;\n",
- rdp->rd_date.tm_year + 1900,
- rdp->rd_date.tm_mon + 1,
- rdp->rd_date.tm_mday, rdp->rd_date.tm_hour,
- rdp->rd_date.tm_min, rdp->rd_date.tm_sec,
- rdp->rd_author, rdp->rd_state);
+
+ if (timezone_flag != NULL) {
+ rcs_set_tz(timezone_flag, rdp, &t);
+ fmt = "%Y/%m/%d %H:%M:%S%z";
+ } else {
+ t = rdp->rd_date;
+ fmt = "%Y/%m/%d %H:%M:%S";
+ }
+
+ strftime(timeb, sizeof(timeb), fmt, &t);
+
+ printf("\ndate: %s; author: %s; state: %s;\n", timeb, rdp->rd_author,
+ rdp->rd_state);
+
printf("%s", rdp->rd_log);
}