summaryrefslogtreecommitdiff
path: root/usr.bin/rcs
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/rcs')
-rw-r--r--usr.bin/rcs/diff3.c40
-rw-r--r--usr.bin/rcs/merge.c16
-rw-r--r--usr.bin/rcs/rcsmerge.c17
-rw-r--r--usr.bin/rcs/rcsprog.h20
4 files changed, 59 insertions, 34 deletions
diff --git a/usr.bin/rcs/diff3.c b/usr.bin/rcs/diff3.c
index 6a6f5f3866c..d852a5286db 100644
--- a/usr.bin/rcs/diff3.c
+++ b/usr.bin/rcs/diff3.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff3.c,v 1.13 2006/08/08 10:22:01 espie Exp $ */
+/* $OpenBSD: diff3.c,v 1.14 2006/08/11 08:18:19 xsa Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@@ -72,7 +72,7 @@ static const char copyright[] =
#ifndef lint
static const char rcsid[] =
- "$OpenBSD: diff3.c,v 1.13 2006/08/08 10:22:01 espie Exp $";
+ "$OpenBSD: diff3.c,v 1.14 2006/08/11 08:18:19 xsa Exp $";
#endif /* not lint */
#include "includes.h"
@@ -129,8 +129,8 @@ static int cline[3]; /* # of the last-read line in each file (0-2) */
* is stored in last[1-3];
*/
static int last[4];
-static int eflag;
-static int oflag; /* indicates whether to mark overlaps (-E or -X)*/
+static int eflag = 3; /* default -E for compatibility with former RCS */
+static int oflag = 1; /* default -E for compatibility with former RCS */
static int debug = 0;
static char f1mark[40], f3mark[40]; /* markers for -E and -X */
@@ -166,6 +166,9 @@ merge_diff3(char **av, int flags)
b1 = b2 = b3 = d1 = d2 = diffb = NULL;
dp13 = dp23 = path1 = path2 = path3 = NULL;
+ if ((flags & MERGE_EFLAG) && !(flags & MERGE_OFLAG))
+ oflag = 0;
+
if ((b1 = rcs_buf_load(av[0], BUF_AUTOEXT)) == NULL)
goto out;
if ((b2 = rcs_buf_load(av[1], BUF_AUTOEXT)) == NULL)
@@ -262,7 +265,7 @@ out:
}
BUF *
-rcs_diff3(RCSFILE *rf, char *workfile, RCSNUM *rev1, RCSNUM *rev2, int verbose)
+rcs_diff3(RCSFILE *rf, char *workfile, RCSNUM *rev1, RCSNUM *rev2, int flags)
{
int argc;
char *argv[5], r1[16], r2[16];
@@ -272,18 +275,21 @@ rcs_diff3(RCSFILE *rf, char *workfile, RCSNUM *rev1, RCSNUM *rev2, int verbose)
b1 = b2 = b3 = d1 = d2 = diffb = NULL;
dp13 = dp23 = path1 = path2 = path3 = NULL;
+ if ((flags & MERGE_EFLAG) && !(flags & MERGE_OFLAG))
+ oflag = 0;
+
rcsnum_tostr(rev1, r1, sizeof(r1));
rcsnum_tostr(rev2, r2, sizeof(r2));
if ((b1 = rcs_buf_load(workfile, BUF_AUTOEXT)) == NULL)
goto out;
- if (verbose == 1)
+ if (!(flags & QUIET))
(void)fprintf(stderr, "retrieving revision %s\n", r1);
if ((b2 = rcs_getrev(rf, rev1)) == NULL)
goto out;
- if (verbose == 1)
+ if (!(flags & QUIET))
(void)fprintf(stderr, "retrieving revision %s\n", r2);
if ((b3 = rcs_getrev(rf, rev2)) == NULL)
goto out;
@@ -343,7 +349,7 @@ rcs_diff3(RCSFILE *rf, char *workfile, RCSNUM *rev1, RCSNUM *rev2, int verbose)
if ((diffb = rcs_patchfile(b1, diffb, ed_patch_lines)) == NULL)
goto out;
- if (verbose == 1 && diff3_conflicts != 0)
+ if (!(flags & QUIET) && diff3_conflicts != 0)
warnx("warning: overlaps or other problems during merge");
out:
@@ -382,20 +388,18 @@ diff3_internal(int argc, char **argv, const char *fmark, const char *rmark)
size_t m, n;
int i;
- /* XXX */
- eflag = 3;
- oflag = 1;
-
if (argc < 5)
return (-1);
- i = snprintf(f1mark, sizeof(f1mark), "<<<<<<< %s", fmark);
- if (i < 0 || i >= sizeof(f1mark))
- errx(1, "diff3_internal: string truncated");
+ if (oflag) {
+ i = snprintf(f1mark, sizeof(f1mark), "<<<<<<< %s", fmark);
+ if (i < 0 || i >= sizeof(f1mark))
+ errx(1, "diff3_internal: string truncated");
- i = snprintf(f3mark, sizeof(f3mark), ">>>>>>> %s", rmark);
- if (i < 0 || i >= sizeof(f3mark))
- errx(1, "diff3_internal: string truncated");
+ i = snprintf(f3mark, sizeof(f3mark), ">>>>>>> %s", rmark);
+ if (i < 0 || i >= sizeof(f3mark))
+ errx(1, "diff3_internal: string truncated");
+ }
increase();
m = readin(argv[0], &d13);
diff --git a/usr.bin/rcs/merge.c b/usr.bin/rcs/merge.c
index 8f73a6fbadc..779a9e910ed 100644
--- a/usr.bin/rcs/merge.c
+++ b/usr.bin/rcs/merge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: merge.c,v 1.3 2006/08/01 05:14:17 ray Exp $ */
+/* $OpenBSD: merge.c,v 1.4 2006/08/11 08:18:19 xsa Exp $ */
/*
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -35,8 +35,6 @@ merge_main(int argc, char **argv)
int ch, flags, labels, status;
const char *label[3];
BUF *bp;
- extern char *optarg;
- extern int optind;
flags = labels = 0;
status = D_ERROR;
@@ -48,7 +46,17 @@ merge_main(int argc, char **argv)
*/
while ((ch = getopt(argc, argv, "AEeL:pqV")) != -1) {
switch(ch) {
- case 'A': case 'E': case 'e':
+ case 'A':
+ /*
+ * kept for compatibility
+ */
+ break;
+ case 'E':
+ flags |= MERGE_EFLAG;
+ flags |= MERGE_OFLAG;
+ break;
+ case 'e':
+ flags |= MERGE_EFLAG;
break;
case 'L':
if (3 <= labels)
diff --git a/usr.bin/rcs/rcsmerge.c b/usr.bin/rcs/rcsmerge.c
index 0bfab7a7e2f..1bbee41b896 100644
--- a/usr.bin/rcs/rcsmerge.c
+++ b/usr.bin/rcs/rcsmerge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsmerge.c,v 1.47 2006/08/01 05:14:17 ray Exp $ */
+/* $OpenBSD: rcsmerge.c,v 1.48 2006/08/11 08:18:19 xsa Exp $ */
/*
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -46,7 +46,17 @@ rcsmerge_main(int argc, char **argv)
while ((ch = rcs_getopt(argc, argv, "AEek:p::q::r::TVx::z:")) != -1) {
switch (ch) {
- case 'A': case 'E': case 'e':
+ case 'A':
+ /*
+ * kept for compatibility
+ */
+ break;
+ case 'E':
+ flags |= MERGE_EFLAG;
+ flags |= MERGE_OFLAG;
+ break;
+ case 'e':
+ flags |= MERGE_EFLAG;
break;
case 'k':
kflag = rcs_kflag_get(rcs_optarg);
@@ -133,8 +143,7 @@ rcsmerge_main(int argc, char **argv)
if (rcsnum_cmp(rev1, rev2, 0) == 0)
goto out;
- if ((bp = rcs_diff3(file, argv[0], rev1, rev2,
- !(flags & QUIET))) == NULL)
+ if ((bp = rcs_diff3(file, argv[0], rev1, rev2, flags)) == NULL)
errx(D_ERROR, "failed to merge");
if (!(flags & QUIET)) {
diff --git a/usr.bin/rcs/rcsprog.h b/usr.bin/rcs/rcsprog.h
index 9f5bf22548b..c9636fa6170 100644
--- a/usr.bin/rcs/rcsprog.h
+++ b/usr.bin/rcs/rcsprog.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsprog.h,v 1.58 2006/05/15 06:58:03 xsa Exp $ */
+/* $OpenBSD: rcsprog.h,v 1.59 2006/08/11 08:18:19 xsa Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -57,14 +57,18 @@
#define RCSPROG_NFLAG (1<<14)
#define RCSPROG_UFLAG (1<<15)
+/* flags shared between merge(1) and rcsmerge(1) */
+#define MERGE_EFLAG (1<<16)
+#define MERGE_OFLAG (1<<17)
+
/* shared flags */
-#define DESCRIPTION (1<<16)
-#define FORCE (1<<17)
-#define INTERACTIVE (1<<18)
-#define NEWFILE (1<<19)
-#define PIPEOUT (1<<20)
-#define PRESERVETIME (1<<21)
-#define QUIET (1<<22)
+#define DESCRIPTION (1<<18)
+#define FORCE (1<<19)
+#define INTERACTIVE (1<<20)
+#define NEWFILE (1<<21)
+#define PIPEOUT (1<<22)
+#define PRESERVETIME (1<<23)
+#define QUIET (1<<24)
extern char *__progname;
extern const char rcs_version[];