summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/cvs/cvs.127
-rw-r--r--usr.bin/cvs/diff.c22
-rw-r--r--usr.bin/cvs/diff.h6
-rw-r--r--usr.bin/cvs/diff_internals.c24
4 files changed, 62 insertions, 17 deletions
diff --git a/usr.bin/cvs/cvs.1 b/usr.bin/cvs/cvs.1
index 9efa2f8b5b8..1ec7ca9a497 100644
--- a/usr.bin/cvs/cvs.1
+++ b/usr.bin/cvs/cvs.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: cvs.1,v 1.122 2009/03/25 09:47:26 joris Exp $
+.\" $OpenBSD: cvs.1,v 1.123 2009/04/28 09:05:39 sthen Exp $
.\"
.\" Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
.\" Copyright (c) 2004-2008 Xavier Santolaria <xsa@openbsd.org>
@@ -24,7 +24,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: March 25 2009 $
+.Dd $Mdocdate: April 28 2009 $
.Dt CVS 1
.Os
.Sh NAME
@@ -517,7 +517,7 @@ command is very similar to the
program, except that the differential comparisons that it generates are
between local or remote revisions of files stored in the CVS repository.
.Bd -literal -offset indent
-usage: cvs diff [-cilNnpRu]
+usage: cvs diff [-abcdilNnpRuw]
[[-D date1 | -r rev1] [-D date2 | -r rev2]]
[-k mode] [file ...]
.Ed
@@ -526,11 +526,24 @@ The
.Ic diff
command takes the following options:
.Bl -tag -width Ds -offset 3n
+.It Fl a
+Treat all files as ASCII text.
+See
+.Xr diff 1
+for more information.
+.It Fl b
+Causes trailing blanks (spaces and tabs) to be ignored, and other
+strings of blanks to compare equal.
.It Fl c
Produces a diff with three lines of context.
See
.Xr diff 1
for more information.
+.It Fl d
+Try very hard to produce a diff as small as possible.
+See
+.Xr diff 1
+for more information.
.It Xo Fl D Ar date1
.Op Fl D Ar date2
.Xc
@@ -583,6 +596,14 @@ Produces a unified diff with three lines of context.
See
.Xr diff 1
for more information.
+.It Fl w
+Is similar to
+.Fl b
+but causes whitespace (blanks and tabs) to be totally ignored.
+E.g.,
+.Dq if (\ \&a == b \&)
+will compare equal to
+.Dq if(a==b) .
.El
.Pp
Aliases:
diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c
index 2fdef195f97..989e272c8b1 100644
--- a/usr.bin/cvs/diff.c
+++ b/usr.bin/cvs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.151 2009/04/03 19:46:56 joris Exp $ */
+/* $OpenBSD: diff.c,v 1.152 2009/04/28 09:05:40 sthen Exp $ */
/*
* Copyright (c) 2008 Tobias Stoeckmann <tobias@openbsd.org>
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
@@ -46,9 +46,9 @@ struct cvs_cmd cvs_cmd_diff = {
CVS_OP_DIFF, CVS_USE_WDIR, "diff",
{ "di", "dif" },
"Show differences between revisions",
- "[-cilNnpRu] [[-D date] [-r rev] [-D date2 | -r rev2]] "
+ "[-abcdilNnpRuw] [[-D date] [-r rev] [-D date2 | -r rev2]] "
"[-k mode] [file ...]",
- "cfD:ik:lNnpr:Ru",
+ "bcfD:ik:lNnpr:Ruw",
NULL,
cvs_diff
};
@@ -78,10 +78,22 @@ cvs_diff(int argc, char **argv)
while ((ch = getopt(argc, argv, cvs_cmdop == CVS_OP_DIFF ?
cvs_cmd_diff.cmd_opts : cvs_cmd_rdiff.cmd_opts)) != -1) {
switch (ch) {
+ case 'a':
+ strlcat(diffargs, " -a", sizeof(diffargs));
+ diff_aflag = 1;
+ break;
+ case 'b':
+ strlcat(diffargs, " -b", sizeof(diffargs));
+ diff_bflag = 1;
+ break;
case 'c':
strlcat(diffargs, " -c", sizeof(diffargs));
diff_format = D_CONTEXT;
break;
+ case 'd':
+ strlcat(diffargs, " -d", sizeof(diffargs));
+ diff_dflag = 1;
+ break;
case 'D':
if (date1 == -1 && rev1 == NULL) {
date1 = cvs_date_parse(optarg);
@@ -147,6 +159,10 @@ cvs_diff(int argc, char **argv)
case 'V':
fatal("the -V option is obsolete "
"and should not be used");
+ case 'w':
+ strlcat(diffargs, " -w", sizeof(diffargs));
+ diff_wflag = 1;
+ break;
default:
fatal("%s", cvs_cmdop == CVS_OP_DIFF ?
cvs_cmd_diff.cmd_synopsis :
diff --git a/usr.bin/cvs/diff.h b/usr.bin/cvs/diff.h
index 60d629d3e4b..afedf4a7021 100644
--- a/usr.bin/cvs/diff.h
+++ b/usr.bin/cvs/diff.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.h,v 1.17 2008/03/08 20:26:34 joris Exp $ */
+/* $OpenBSD: diff.h,v 1.18 2009/04/28 09:05:40 sthen Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -98,8 +98,12 @@ int ed_patch_lines(struct cvs_lines *, struct cvs_lines *);
extern int diff_format;
extern int diff3_conflicts;
+extern int diff_aflag;
+extern int diff_bflag;
+extern int diff_dflag;
extern int diff_iflag;
extern int diff_pflag;
+extern int diff_wflag;
extern char *diff_file;
extern char diffargs[128];
extern BUF *diffbuf;
diff --git a/usr.bin/cvs/diff_internals.c b/usr.bin/cvs/diff_internals.c
index 5c6a8b1dd50..77fea52e6ff 100644
--- a/usr.bin/cvs/diff_internals.c
+++ b/usr.bin/cvs/diff_internals.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff_internals.c,v 1.25 2008/06/11 03:38:28 tobias Exp $ */
+/* $OpenBSD: diff_internals.c,v 1.26 2009/04/28 09:05:40 sthen Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -197,11 +197,15 @@ static int files_differ(FILE *, FILE *);
static char *match_function(const long *, int, FILE *);
static char *preadline(int, size_t, off_t);
-static int aflag, bflag, dflag, tflag, Tflag, wflag;
+static int tflag, Tflag;
static int context = 3;
int diff_format = D_NORMAL;
+int diff_aflag = 0;
+int diff_bflag = 0;
+int diff_dflag = 0;
int diff_iflag = 0;
int diff_pflag = 0;
+int diff_wflag = 0;
const char *diff_file1 = NULL;
const char *diff_file2 = NULL;
RCSNUM *diff_rev1 = NULL;
@@ -541,7 +545,7 @@ stone(int *a, int n, int *b, int *c)
u_int numtries;
/* XXX move the isqrt() out of the macro to avoid multiple calls */
- const u_int bound = dflag ? UINT_MAX : MAX(256, (u_int)isqrt(n));
+ const u_int bound = diff_dflag ? UINT_MAX : MAX(256, (u_int)isqrt(n));
k = 0;
c[0] = newcand(0, 0, 0);
@@ -657,7 +661,7 @@ check(FILE *f1, FILE *f2)
ixnew[j] = ctnew += skipline(f2);
j++;
}
- if (bflag == 1 || wflag == 1 || diff_iflag == 1) {
+ if (diff_bflag == 1 || diff_wflag == 1 || diff_iflag == 1) {
for (;;) {
c = getc(f1);
d = getc(f2);
@@ -665,14 +669,14 @@ check(FILE *f1, FILE *f2)
* GNU diff ignores a missing newline
* in one file for -b or -w.
*/
- if ((bflag == 1 || wflag == 1) &&
+ if ((diff_bflag == 1 || diff_wflag == 1) &&
((c == EOF && d == '\n') ||
(c == '\n' && d == EOF))) {
break;
}
ctold++;
ctnew++;
- if (bflag == 1 && isspace(c) && isspace(d)) {
+ if (diff_bflag == 1 && isspace(c) && isspace(d)) {
do {
if (c == '\n')
break;
@@ -683,7 +687,7 @@ check(FILE *f1, FILE *f2)
break;
ctnew++;
} while (isspace(d = getc(f2)));
- } else if (wflag == 1) {
+ } else if (diff_wflag == 1) {
while (isspace(c) && c != '\n') {
c = getc(f1);
ctold++;
@@ -1141,7 +1145,7 @@ readhash(FILE *f)
sum = 1;
space = 0;
- if (bflag != 1 && wflag != 1) {
+ if (diff_bflag != 1 && diff_wflag != 1) {
if (diff_iflag == 1)
for (i = 0; (t = getc(f)) != '\n'; i++) {
if (t == EOF) {
@@ -1171,7 +1175,7 @@ readhash(FILE *f)
space++;
continue;
default:
- if (space != 0 && wflag != 1) {
+ if (space != 0 && diff_wflag != 1) {
i++;
space = 0;
}
@@ -1201,7 +1205,7 @@ asciifile(FILE *f)
unsigned char buf[BUFSIZ];
size_t i, cnt;
- if (aflag == 1 || f == NULL)
+ if (diff_aflag == 1 || f == NULL)
return (1);
rewind(f);