diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2006-03-07 01:40:53 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2006-03-07 01:40:53 +0000 |
commit | 1fefa4418ce05b837c9e670fb162a259d0c6fede (patch) | |
tree | d2001ffbff5388b23aa11218185902f40ec0708c | |
parent | e8a814a53fa228312a4794cbe232b763a0d4813c (diff) |
-z support for RCS;
-rw-r--r-- | usr.bin/cvs/rcs.c | 64 | ||||
-rw-r--r-- | usr.bin/cvs/rcs.h | 4 | ||||
-rw-r--r-- | usr.bin/rcs/ci.c | 7 | ||||
-rw-r--r-- | usr.bin/rcs/co.c | 7 | ||||
-rw-r--r-- | usr.bin/rcs/rcsdiff.c | 7 | ||||
-rw-r--r-- | usr.bin/rcs/rcsmerge.c | 7 | ||||
-rw-r--r-- | usr.bin/rcs/rlog.c | 6 |
7 files changed, 85 insertions, 17 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index 0ee9049eadd..55be3b38b88 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.133 2006/03/05 16:22:31 niallo Exp $ */ +/* $OpenBSD: rcs.c,v 1.134 2006/03/07 01:40:52 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -232,7 +232,7 @@ static const char *rcs_errstrs[] = { int rcs_errno = RCS_ERR_NOERR; - +char *timezone_flag = NULL; static int rcs_write(RCSFILE *); static int rcs_parse_init(RCSFILE *); @@ -2531,16 +2531,65 @@ static char * rcs_expand_keywords(char *rcsfile, struct rcs_delta *rdp, char *data, size_t len, int mode) { + int tzone; int kwtype, sizdiff; u_int i, j, found, start_offset, c_offset; - char *c, *kwstr, *start, *end, *tbuf; + char *c, *kwstr, *start, *end, *tbuf, *m, *h; char expbuf[256], buf[256]; + struct tm *tb, ltb; + time_t now; + char *fmt; kwtype = 0; kwstr = NULL; i = 0; /* + * -z support for RCS + */ + tb = &rdp->rd_date; + if (timezone_flag != NULL) { + if (!strcmp(timezone_flag, "LT")) { + now = mktime(&rdp->rd_date); + tb = localtime(&now); + tb->tm_hour += ((int)tb->tm_gmtoff / 3600); + } else { + h = timezone_flag; + if ((m = strrchr(timezone_flag, ':')) != NULL) + *(m++) = '\0'; + + ltb = rdp->rd_date; + tb = <b; + + tzone = atoi(h); + + if (tzone >= 24 && tzone <= -24) + fatal("not a known time zone: %d", tzone); + + tb->tm_hour += tzone; + if (tb->tm_hour >= 24 && tb->tm_hour <= -24) + tb->tm_hour = 0; + + tb->tm_gmtoff += (tzone * 3600); + + if (m != NULL) { + tzone = atoi(m); + if (tzone >= 60) + fatal("not a known time zone: %d", tzone); + + if ((tb->tm_min + tzone) >= 60) { + tb->tm_hour++; + tb->tm_min -= tzone; + } else { + tb->tm_min += tzone; + } + + tb->tm_gmtoff += (tzone * 60); + } + } + } + + /* * Keyword formats: * $Keyword$ * $Keyword: value$ @@ -2636,9 +2685,12 @@ rcs_expand_keywords(char *rcsfile, struct rcs_delta *rdp, char *data, } if (kwtype & RCS_KW_DATE) { - strftime(buf, sizeof(buf), - "%Y/%m/%d %H:%M:%S ", - &rdp->rd_date); + if (timezone_flag != NULL) + fmt = "%Y/%m/%d %H:%M:%S%z "; + else + fmt = "%Y/%m/%d %H:%M:%S "; + + 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 33595e78d90..4d0b0942997 100644 --- a/usr.bin/cvs/rcs.h +++ b/usr.bin/cvs/rcs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.h,v 1.47 2006/03/05 14:18:56 niallo Exp $ */ +/* $OpenBSD: rcs.h,v 1.48 2006/03/07 01:40:52 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -271,4 +271,6 @@ char *rcsnum_tostr(const RCSNUM *, char *, size_t); int rcsnum_cpy(const RCSNUM *, RCSNUM *, u_int); int rcsnum_cmp(const RCSNUM *, const RCSNUM *, u_int); +extern char *timezone_flag; + #endif /* RCS_H */ diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c index 76b0e6f756f..23054c213b9 100644 --- a/usr.bin/rcs/ci.c +++ b/usr.bin/rcs/ci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ci.c,v 1.109 2006/03/06 15:04:17 niallo Exp $ */ +/* $OpenBSD: ci.c,v 1.110 2006/03/07 01:40:52 joris Exp $ */ /* * Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org> * All rights reserved. @@ -29,7 +29,7 @@ #include "rcsprog.h" #include "diff.h" -#define CI_OPTSTRING "d::f::i::j::k::l::m:M::N:n:qr::s:Tt:u::Vw:x:" +#define CI_OPTSTRING "d::f::i::j::k::l::m:M::N:n:qr::s:Tt:u::Vw:x:z:" #define DATE_NOW -1 #define DATE_MTIME -2 @@ -200,6 +200,9 @@ checkin_main(int argc, char **argv) case 'x': rcs_suffixes = rcs_optarg; break; + case 'z': + timezone_flag = rcs_optarg; + break; default: (usage)(); exit(1); diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c index 67c0f642258..f57208b1376 100644 --- a/usr.bin/rcs/co.c +++ b/usr.bin/rcs/co.c @@ -1,4 +1,4 @@ -/* $OpenBSD: co.c,v 1.58 2006/03/06 14:03:33 xsa Exp $ */ +/* $OpenBSD: co.c,v 1.59 2006/03/07 01:40:52 joris Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -28,7 +28,7 @@ #include "rcsprog.h" -#define CO_OPTSTRING "d:f::k:l::M::p::q::r::s:Tu::Vw::x:" +#define CO_OPTSTRING "d:f::k:l::M::p::q::r::s:Tu::Vw::x:z:" static void checkout_err_nobranch(RCSFILE *, const char *, const char *, const char *, int); @@ -123,6 +123,9 @@ checkout_main(int argc, char **argv) case 'x': rcs_suffixes = rcs_optarg; break; + case 'z': + timezone_flag = rcs_optarg; + break; default: (usage)(); exit(1); diff --git a/usr.bin/rcs/rcsdiff.c b/usr.bin/rcs/rcsdiff.c index 511592078cd..b4c157315b2 100644 --- a/usr.bin/rcs/rcsdiff.c +++ b/usr.bin/rcs/rcsdiff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsdiff.c,v 1.35 2006/03/06 15:00:21 jmc Exp $ */ +/* $OpenBSD: rcsdiff.c,v 1.36 2006/03/07 01:40:52 joris Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -48,7 +48,7 @@ rcsdiff_main(int argc, char **argv) strlcpy(diffargs, "diff", sizeof(diffargs)); - while ((ch = rcs_getopt(argc, argv, "ck:nqr:TuVx:")) != -1) { + while ((ch = rcs_getopt(argc, argv, "ck:nqr:TuVx:z:")) != -1) { switch (ch) { case 'c': strlcat(diffargs, " -c", sizeof(diffargs)); @@ -94,6 +94,9 @@ rcsdiff_main(int argc, char **argv) case 'x': rcs_suffixes = rcs_optarg; break; + case 'z': + timezone_flag = rcs_optarg; + break; default: (usage)(); exit (1); diff --git a/usr.bin/rcs/rcsmerge.c b/usr.bin/rcs/rcsmerge.c index 331856a3d62..6b6524ed053 100644 --- a/usr.bin/rcs/rcsmerge.c +++ b/usr.bin/rcs/rcsmerge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsmerge.c,v 1.16 2006/03/06 14:44:51 jmc Exp $ */ +/* $OpenBSD: rcsmerge.c,v 1.17 2006/03/07 01:40:52 joris Exp $ */ /* * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> * All rights reserved. @@ -42,7 +42,7 @@ rcsmerge_main(int argc, char **argv) baserev = rev2 = RCS_HEAD_REV; - while ((ch = rcs_getopt(argc, argv, "AEek:p::q::r:TVx:")) != -1) { + while ((ch = rcs_getopt(argc, argv, "AEek:p::q::r:TVx:z:")) != -1) { switch (ch) { case 'A': case 'E': case 'e': break; @@ -82,6 +82,9 @@ rcsmerge_main(int argc, char **argv) case 'x': rcs_suffixes = rcs_optarg; break; + case 'z': + timezone_flag = rcs_optarg; + break; default: break; } diff --git a/usr.bin/rcs/rlog.c b/usr.bin/rcs/rlog.c index b6ff3d94b68..48186d8824a 100644 --- a/usr.bin/rcs/rlog.c +++ b/usr.bin/rcs/rlog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rlog.c,v 1.25 2006/03/06 15:03:37 jmc Exp $ */ +/* $OpenBSD: rlog.c,v 1.26 2006/03/07 01:40:52 joris Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> @@ -61,7 +61,7 @@ rlog_main(int argc, char **argv) char fpath[MAXPATHLEN]; hflag = Rflag = 0; - while ((ch = rcs_getopt(argc, argv, "hLl::NqRs:TtVw::x:")) != -1) { + while ((ch = rcs_getopt(argc, argv, "hLl::NqRs:TtVw::x:z:")) != -1) { switch (ch) { case 'h': hflag = 1; @@ -103,6 +103,8 @@ rlog_main(int argc, char **argv) case 'x': rcs_suffixes = rcs_optarg; break; + case 'z': + timezone_flag = rcs_optarg; default: (usage()); exit(1); |