summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/cvs/diff.c35
-rw-r--r--usr.bin/cvs/diff.h4
-rw-r--r--usr.bin/rcs/rcsdiff.c21
-rw-r--r--usr.bin/rcs/rcsprog.c16
-rw-r--r--usr.bin/rcs/rlog.c15
5 files changed, 77 insertions, 14 deletions
diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c
index 50cecc3241b..bf5aad4dd01 100644
--- a/usr.bin/cvs/diff.c
+++ b/usr.bin/cvs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.89 2006/04/14 02:45:35 deraadt Exp $ */
+/* $OpenBSD: diff.c,v 1.90 2006/04/14 23:29:01 joris Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -208,6 +208,8 @@ static int aflag, bflag, dflag, iflag, pflag, tflag, Tflag, wflag;
static int context = 3;
int diff_format = D_NORMAL;
char *diff_file = NULL;
+RCSNUM *diff_rev1 = NULL;
+RCSNUM *diff_rev2 = NULL;
char diffargs[128];
static struct stat stb1, stb2;
static char *ifdefname, *ignore_pats;
@@ -1249,8 +1251,10 @@ ignoreline(char *line)
static void
change(FILE *f1, FILE *f2, int a, int b, int c, int d)
{
- static size_t max_context = 64;
int i;
+ static size_t max_context = 64;
+ char buf[64];
+ struct tm *t;
if (diff_format != D_IFDEF && a > b && c > d)
return;
@@ -1298,12 +1302,35 @@ proceed:
/*
* Print the context/unidiff header first time through.
*/
+ t = localtime(&stb1.st_mtime);
+ (void)strftime(buf, sizeof(buf),
+ "%Y/%m/%d %H:%M:%S", t);
+
diff_output("%s %s %s",
diff_format == D_CONTEXT ? "***" : "---", diff_file,
- ctime(&stb1.st_mtime));
+ buf);
+
+ if (diff_rev1 != NULL) {
+ rcsnum_tostr(diff_rev1, buf, sizeof(buf));
+ diff_output("\t%s", buf);
+ }
+
+ printf("\n");
+
+ t = localtime(&stb2.st_mtime);
+ (void)strftime(buf, sizeof(buf),
+ "%Y/%m/%d %H:%M:%S", t);
+
diff_output("%s %s %s",
diff_format == D_CONTEXT ? "---" : "+++", diff_file,
- ctime(&stb2.st_mtime));
+ buf);
+
+ if (diff_rev2 != NULL) {
+ rcsnum_tostr(diff_rev2, buf, sizeof(buf));
+ diff_output("\t%s", buf);
+ }
+
+ printf("\n");
anychange = 1;
} else if (a > context_vec_ptr->b + (2 * context) + 1 &&
c > context_vec_ptr->d + (2 * context) + 1) {
diff --git a/usr.bin/cvs/diff.h b/usr.bin/cvs/diff.h
index 16abe669f7c..0e3c56480ee 100644
--- a/usr.bin/cvs/diff.h
+++ b/usr.bin/cvs/diff.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.h,v 1.9 2006/04/10 09:57:32 xsa Exp $ */
+/* $OpenBSD: diff.h,v 1.10 2006/04/14 23:29:01 joris Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -107,5 +107,7 @@ extern int diff3_conflicts;
extern char *diff_file;
extern char diffargs[128];
extern BUF *diffbuf;
+extern RCSNUM *diff_rev1;
+extern RCSNUM *diff_rev2;
#endif
diff --git a/usr.bin/rcs/rcsdiff.c b/usr.bin/rcs/rcsdiff.c
index 1bca7f4487c..dba1a4c99a5 100644
--- a/usr.bin/rcs/rcsdiff.c
+++ b/usr.bin/rcs/rcsdiff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsdiff.c,v 1.48 2006/04/13 16:10:29 joris Exp $ */
+/* $OpenBSD: rcsdiff.c,v 1.49 2006/04/14 23:29:01 joris Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -174,17 +174,23 @@ static int
rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename)
{
int ret;
+ time_t t;
char path1[MAXPATHLEN], path2[MAXPATHLEN];
BUF *b1, *b2;
char rbuf[64];
+ struct tm *tb;
struct stat st;
struct timeval tv[2], tv2[2];
+
memset(&tv, 0, sizeof(tv));
memset(&tv2, 0, sizeof(tv2));
ret = -1;
b1 = b2 = NULL;
+ diff_rev1 = rev;
+ diff_rev2 = NULL;
+
if (stat(filename, &st) == -1) {
cvs_log(LP_ERRNO, "%s", filename);
goto out;
@@ -210,8 +216,12 @@ rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename)
goto out;
}
- tv2[0].tv_sec = st.st_mtime;
- tv2[1].tv_sec = st.st_mtime;
+ /* XXX - GNU uses GMT */
+ tb = gmtime(&st.st_mtime);
+ t = mktime(tb);
+
+ tv2[0].tv_sec = t;
+ tv2[1].tv_sec = t;
strlcpy(path1, rcs_tmpdir, sizeof(path1));
strlcat(path1, "/diff1.XXXXXXXXXX", sizeof(path1));
@@ -259,9 +269,12 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2)
memset(&tv, 0, sizeof(tv));
memset(&tv2, 0, sizeof(tv2));
+ diff_rev1 = rev1;
+ diff_rev2 = rev2;
+
rcsnum_tostr(rev1, rbuf1, sizeof(rbuf1));
if (verbose == 1)
- printf("retrieving revision %s\n", rbuf1);
+ fprintf(stderr, "retrieving revision %s\n", rbuf1);
if ((b1 = rcs_getrev(file, rev1)) == NULL) {
cvs_log(LP_ERR, "failed to retrieve revision %s", rbuf1);
diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c
index f4bf4a40a75..5cc47489d97 100644
--- a/usr.bin/rcs/rcsprog.c
+++ b/usr.bin/rcs/rcsprog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsprog.c,v 1.102 2006/04/14 01:11:07 deraadt Exp $ */
+/* $OpenBSD: rcsprog.c,v 1.103 2006/04/14 23:29:01 joris Exp $ */
/*
* Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -232,7 +232,7 @@ char *
rcs_choosefile(const char *filename)
{
struct stat sb;
- char *ext, name[MAXPATHLEN], *next, *ptr, rcsdir[MAXPATHLEN],
+ char *p, *ext, name[MAXPATHLEN], *next, *ptr, rcsdir[MAXPATHLEN],
*ret, *suffixes, rcspath[MAXPATHLEN];
/* If -x flag was not given, use default. */
@@ -294,6 +294,17 @@ rcs_choosefile(const char *filename)
for (ret = NULL, next = suffixes; (ext = strsep(&next, "/")) != NULL;) {
char fpath[MAXPATHLEN];
+ if ((p = strrchr(rcspath, ',')) != NULL) {
+ if (!strcmp(p, ext)) {
+ if (stat(rcspath, &sb) == 0) {
+ ret = xstrdup(rcspath);
+ goto out;
+ }
+ }
+
+ continue;
+ }
+
/* Construct RCS file path. */
if (strlcpy(fpath, rcspath, sizeof(fpath)) >= sizeof(fpath) ||
strlcat(fpath, ext, sizeof(fpath)) >= sizeof(fpath))
@@ -338,7 +349,6 @@ rcs_statfile(char *fname, char *out, size_t len)
struct stat st;
char *rcspath;
- /* XXX - do this in rcs_choosefile? */
if ((rcspath = rcs_choosefile(fname)) == NULL)
fatal("rcs_statfile: path truncation");
diff --git a/usr.bin/rcs/rlog.c b/usr.bin/rcs/rlog.c
index b25707dab3d..b4b0ec17091 100644
--- a/usr.bin/rcs/rlog.c
+++ b/usr.bin/rcs/rlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rlog.c,v 1.44 2006/04/14 15:15:20 ray Exp $ */
+/* $OpenBSD: rlog.c,v 1.45 2006/04/14 23:29:01 joris Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -62,6 +62,7 @@ rlog_main(int argc, char **argv)
int i, ch;
char fpath[MAXPATHLEN];
+ rcsnum_flags |= RCSNUM_NO_MAGIC;
hflag = Rflag = rflag = 0;
while ((ch = rcs_getopt(argc, argv, RLOG_OPTSTRING)) != -1) {
switch (ch) {
@@ -169,14 +170,24 @@ rlog_file(const char *fname, RCSFILE *file)
struct rcs_access *acp;
struct rcs_delta *rdp;
struct rcs_lock *lkp;
+ char *workfile, *p;
if (rflag == 1)
nrev = rlog_rev_select(file);
else
nrev = file->rf_ndelta;
+ if ((workfile = basename(fname)) == NULL)
+ fatal("failed to get basename of '%s'", fname);
+
+ /*
+ * In case they specified 'foo,v' as argument.
+ */
+ if ((p = strrchr(workfile, ',')) != NULL)
+ *p = '\0';
+
printf("\nRCS file: %s", file->rf_path);
- printf("\nWorking file: %s", fname);
+ printf("\nWorking file: %s", workfile);
printf("\nhead:");
if (file->rf_head != NULL)
printf(" %s", rcsnum_tostr(file->rf_head, numb, sizeof(numb)));