1 /* three-way file merge internals */
3 /* Copyright 1991, 1992, 1993, 1994, 1995 Paul Eggert
4 Distributed under license by the Free Software Foundation, Inc.
6 This file is part of RCS.
8 RCS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 RCS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with RCS; see the file COPYING.
20 If not, write to the Free Software Foundation,
21 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 Report problems and direct all questions to:
25 rcs-bugs@cs.purdue.edu
29 * $FreeBSD: src/gnu/usr.bin/rcs/lib/merger.c,v 1.5 1999/08/27 23:36:44 peter Exp $
30 * $DragonFly: src/gnu/usr.bin/rcs/lib/merger.c,v 1.2 2003/06/17 04:25:47 dillon Exp $
35 libId(mergerId, "$DragonFly: src/gnu/usr.bin/rcs/lib/merger.c,v 1.2 2003/06/17 04:25:47 dillon Exp $")
37 static char const *normalize_arg P((char const*,char**));
43 * If S looks like an option, prepend ./ to it. Yield the result.
44 * Set *B to the address of any storage that was allocated.
49 *b = t = testalloc(strlen(s) + 3);
50 VOID sprintf(t, ".%c%s", SLASH, s);
59 merge(tostdout, edarg, label, argv)
62 char const *const label[3];
63 char const *const argv[3];
65 * Do `merge [-p] EDARG -L l0 -L l1 -L l2 a0 a1 a2',
66 * where TOSTDOUT specifies whether -p is present,
67 * EDARG gives the editing type (e.g. "-A", or null for the default),
68 * LABEL gives l0, l1 and l2, and ARGV gives a0, a1 and a2.
69 * Yield DIFF_SUCCESS or DIFF_FAILURE.
83 a[i] = normalize_arg(argv[i], &b[i]);
98 a[0], a[1], a[2], (char*)0
104 warn("conflicts during merge");
110 if (!(f = fopenSafer(argv[0], "w")))
112 if (!(rt = Iopen(t, "r", (struct stat*)0)))
121 -1, d[i]=maketemp(i),
122 DIFF, a[i], a[2], (char*)0
124 case DIFF_FAILURE: case DIFF_SUCCESS: break;
125 default: faterror("diff failed");
130 DIFF3, edarg, d[0], d[1], a[0], a[1], a[2],
131 label[0], label[2], (char*)0
133 if (s != DIFF_SUCCESS) {
135 warn("overlaps or other problems during merge");
137 if (!(f = fopenSafer(t, "a+")))
139 aputs(tostdout ? "1,$p\n" : "w\n", f);
142 if (run(fileno(f), (char*)0, ED, "-", a[0], (char*)0))