diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-11-21 15:01:11 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-11-21 15:01:11 +0000 |
commit | a0ebbe9d71e73c4a215c20803e49e5e71d95c805 (patch) | |
tree | ba50d5a3ea5ba76606e74f87ffd321f2e9a45790 | |
parent | e819c0e21dfa7606a6d74692c0eacf3630f38bea (diff) |
- print some more informative messages
- minor knf
niallo ok
-rw-r--r-- | usr.bin/cvs/diff.c | 4 | ||||
-rw-r--r-- | usr.bin/cvs/diff.h | 7 | ||||
-rw-r--r-- | usr.bin/rcs/rcsdiff.c | 34 |
3 files changed, 28 insertions, 17 deletions
diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c index df0c6cbc3d7..8a454b58ace 100644 --- a/usr.bin/cvs/diff.c +++ b/usr.bin/cvs/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.65 2005/11/18 10:30:34 xsa Exp $ */ +/* $OpenBSD: diff.c,v 1.66 2005/11/21 15:01:10 xsa Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -215,12 +215,12 @@ static char *preadline(int, size_t, off_t); #if !defined(RCSPROG) static int Nflag; -static char diffargs[128]; #endif static int aflag, bflag, dflag, iflag, pflag, tflag, Tflag, wflag; static int context; int diff_format = D_NORMAL; char *diff_file = NULL; +char diffargs[128]; static struct stat stb1, stb2; static char *ifdefname, *ignore_pats; regex_t ignore_re; diff --git a/usr.bin/cvs/diff.h b/usr.bin/cvs/diff.h index 67d52f71d79..7d0d7f38f1a 100644 --- a/usr.bin/cvs/diff.h +++ b/usr.bin/cvs/diff.h @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.h,v 1.6 2005/10/26 18:13:58 xsa Exp $ */ +/* $OpenBSD: diff.h,v 1.7 2005/11/21 15:01:10 xsa Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -102,9 +102,10 @@ void diff_output(const char *, ...); int cvs_diffreg(const char *, const char *, BUF *out); int ed_patch_lines(struct cvs_lines *, struct cvs_lines *); -extern int diff_format; -extern int diff3_conflicts; +extern int diff_format; +extern int diff3_conflicts; extern char *diff_file; +extern char diffargs[128]; extern BUF *diffbuf; #endif diff --git a/usr.bin/rcs/rcsdiff.c b/usr.bin/rcs/rcsdiff.c index cbd198e071d..9c808935f66 100644 --- a/usr.bin/rcs/rcsdiff.c +++ b/usr.bin/rcs/rcsdiff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsdiff.c,v 1.15 2005/11/16 09:57:04 xsa Exp $ */ +/* $OpenBSD: rcsdiff.c,v 1.16 2005/11/21 15:01:10 xsa Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -38,7 +38,7 @@ #include "rcsprog.h" static int rcsdiff_file(RCSFILE *, RCSNUM *, const char *); -static int rcsdiff_rev(RCSFILE *rfp, RCSNUM *rev, RCSNUM *rev2); +static int rcsdiff_rev(RCSFILE *, RCSNUM *, RCSNUM *, const char *); int rcsdiff_main(int argc, char **argv) @@ -52,18 +52,23 @@ rcsdiff_main(int argc, char **argv) rev2 = NULL; status = 0; + strlcpy(diffargs, "diff", sizeof(diffargs)); + while ((ch = rcs_getopt(argc, argv, "cnqr:uV")) != -1) { switch (ch) { case 'c': + strlcat(diffargs, " -c", sizeof(diffargs)); diff_format = D_CONTEXT; break; case 'n': + strlcat(diffargs, " -n", sizeof(diffargs)); diff_format = D_RCSDIFF; break; case 'q': verbose = 0; break; case 'u': + strlcat(diffargs, " -u", sizeof(diffargs)); diff_format = D_UNIFIED; break; case 'V': @@ -110,8 +115,8 @@ rcsdiff_main(int argc, char **argv) frev = rev; if (verbose == 1) { - cvs_printf("%s\n", RCS_DIFF_DIV); - cvs_printf("RCS file: %s\n", fpath); + printf("%s\n", RCS_DIFF_DIV); + printf("RCS file: %s\n", fpath); } diff_file = argv[i]; @@ -123,7 +128,7 @@ rcsdiff_main(int argc, char **argv) continue; } } else { - if (rcsdiff_rev(file, rev, rev2) < 0) { + if (rcsdiff_rev(file, rev, rev2, argv[i]) < 0) { rcs_close(file); status = 2; continue; @@ -157,8 +162,10 @@ rcsdiff_file(RCSFILE *rfp, RCSNUM *rev, const char *filename) } rcsnum_tostr(rev, rbuf, sizeof(rbuf)); - if (verbose == 1) + if (verbose == 1) { printf("retrieving revision %s\n", rbuf); + printf("%s -r%s %s\n", diffargs, rbuf, filename); + } if ((b1 = rcs_getrev(rfp, rev)) == NULL) { cvs_log(LP_ERR, "failed to retrieve revision"); @@ -198,30 +205,33 @@ rcsdiff_file(RCSFILE *rfp, RCSNUM *rev, const char *filename) } static int -rcsdiff_rev(RCSFILE *rfp, RCSNUM *rev1, RCSNUM *rev2) +rcsdiff_rev(RCSFILE *rfp, RCSNUM *rev1, RCSNUM *rev2, const char *filename) { char path1[MAXPATHLEN], path2[MAXPATHLEN]; BUF *b1, *b2; - char rbuf[64]; + char rbuf1[64], rbuf2[64]; - rcsnum_tostr(rev1, rbuf, sizeof(rbuf)); + rcsnum_tostr(rev1, rbuf1, sizeof(rbuf1)); if (verbose == 1) - printf("retrieving revision %s\n", rbuf); + printf("retrieving revision %s\n", rbuf1); if ((b1 = rcs_getrev(rfp, rev1)) == NULL) { cvs_log(LP_ERR, "failed to retrieve revision"); return (-1); } - rcsnum_tostr(rev2, rbuf, sizeof(rbuf)); + rcsnum_tostr(rev2, rbuf2, sizeof(rbuf2)); if (verbose == 1) - printf("retrieving revision %s\n", rbuf); + printf("retrieving revision %s\n", rbuf2); if ((b2 = rcs_getrev(rfp, rev2)) == NULL) { cvs_log(LP_ERR, "failed to retrieve revision"); return (-1); } + if (verbose == 1) + printf("%s -r%s -r%s %s\n", diffargs, rbuf1, rbuf2, filename); + strlcpy(path1, rcs_tmpdir, sizeof(path1)); strlcat(path1, "/diff1.XXXXXXXXXX", sizeof(path1)); if (cvs_buf_write_stmp(b1, path1, 0600) == -1) { |