-/* $OpenBSD: diff.c,v 1.157 2010/07/23 21:46:05 ray Exp $ */
+/* $OpenBSD: diff.c,v 1.158 2010/07/28 21:19:30 nicm Exp $ */
/*
* Copyright (c) 2008 Tobias Stoeckmann <tobias@openbsd.org>
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
"Show differences between revisions",
"[-abcdilNnpRuw] [[-D date] [-r rev] [-D date2 | -r rev2]] "
"[-k mode] [file ...]",
- "abcfdD:ik:lNnpr:Ruw",
+ "abcfC:dD:ik:lNnpr:RuU:w",
NULL,
cvs_diff
};
{
int ch, flags;
char *arg = ".";
+ const char *errstr;
struct cvs_recursion cr;
flags = CR_RECURSE_DIRS;
strlcat(diffargs, " -c", sizeof(diffargs));
diff_format = D_CONTEXT;
break;
+ case 'C':
+ diff_context = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr != NULL)
+ fatal("context lines %s: %s", errstr, optarg);
+ strlcat(diffargs, " -C ", sizeof(diffargs));
+ strlcat(diffargs, optarg, sizeof(diffargs));
+ diff_format = D_CONTEXT;
+ break;
case 'd':
strlcat(diffargs, " -d", sizeof(diffargs));
dflags |= D_MINIMAL;
strlcat(diffargs, " -u", sizeof(diffargs));
diff_format = D_UNIFIED;
break;
+ case 'U':
+ diff_context = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr != NULL)
+ fatal("context lines %s: %s", errstr, optarg);
+ strlcat(diffargs, " -U ", sizeof(diffargs));
+ strlcat(diffargs, optarg, sizeof(diffargs));
+ diff_format = D_UNIFIED;
+ break;
case 'V':
fatal("the -V option is obsolete "
"and should not be used");
switch (diff_format) {
case D_CONTEXT:
- cvs_client_send_request("Argument -c");
+ if (cvs_cmdop == CVS_OP_RDIFF)
+ cvs_client_send_request("Argument -c");
+ else {
+ cvs_client_send_request("Argument -C %d",
+ diff_context);
+ }
break;
case D_RCSDIFF:
cvs_client_send_request("Argument -n");
break;
case D_UNIFIED:
- cvs_client_send_request("Argument -u");
+ if (cvs_cmdop == CVS_OP_RDIFF)
+ cvs_client_send_request("Argument -u");
+ else {
+ cvs_client_send_request("Argument -U %d",
+ diff_context);
+ }
break;
default:
break;
-/* $OpenBSD: diff.h,v 1.21 2010/07/23 21:46:05 ray Exp $ */
+/* $OpenBSD: diff.h,v 1.22 2010/07/28 21:19:30 nicm Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
int ed_patch_lines(struct rcs_lines *, struct rcs_lines *);
extern int diff_format;
+extern int diff_context;
extern int diff3_conflicts;
extern int diff_aflag;
extern int diff_bflag;
-/* $OpenBSD: diff_internals.c,v 1.32 2010/07/23 21:46:05 ray Exp $ */
+/* $OpenBSD: diff_internals.c,v 1.33 2010/07/28 21:19:30 nicm Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
static char *preadline(int, size_t, off_t);
static int Tflag;
-static int context = 3;
+int diff_context = 3;
int diff_format = D_NORMAL;
const char *diff_file1 = NULL;
const char *diff_file2 = NULL;
diff_head();
anychange = 1;
- } else if (a > context_vec_ptr->b + (2 * context) + 1 &&
- c > context_vec_ptr->d + (2 * context) + 1) {
+ } else if (a > context_vec_ptr->b + (2 * diff_context) + 1 &&
+ c > context_vec_ptr->d + (2 * diff_context) + 1) {
/*
* If this change is more than 'context' lines from the
* previous change, dump the record and reset it.
return;
b = d = 0; /* gcc */
- lowa = MAX(1, cvp->a - context);
- upb = MIN(len[0], context_vec_ptr->b + context);
- lowc = MAX(1, cvp->c - context);
- upd = MIN(len[1], context_vec_ptr->d + context);
+ lowa = MAX(1, cvp->a - diff_context);
+ upb = MIN(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAX(1, cvp->c - diff_context);
+ upd = MIN(len[1], context_vec_ptr->d + diff_context);
diff_output("***************");
if ((flags & D_PROTOTYPE)) {
return;
b = d = 0; /* gcc */
- lowa = MAX(1, cvp->a - context);
- upb = MIN(len[0], context_vec_ptr->b + context);
- lowc = MAX(1, cvp->c - context);
- upd = MIN(len[1], context_vec_ptr->d + context);
+ lowa = MAX(1, cvp->a - diff_context);
+ upb = MIN(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAX(1, cvp->c - diff_context);
+ upd = MIN(len[1], context_vec_ptr->d + diff_context);
diff_output("@@ -");
uni_range(lowa, upb);