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
31 libId(mergerId, "$FreeBSD$")
33 static char const *normalize_arg P((char const*,char**));
39 * If S looks like an option, prepend ./ to it. Yield the result.
40 * Set *B to the address of any storage that was allocated.
45 *b = t = testalloc(strlen(s) + 3);
46 VOID sprintf(t, ".%c%s", SLASH, s);
55 merge(tostdout, edarg, label, argv)
58 char const *const label[3];
59 char const *const argv[3];
61 * Do `merge [-p] EDARG -L l0 -L l1 -L l2 a0 a1 a2',
62 * where TOSTDOUT specifies whether -p is present,
63 * EDARG gives the editing type (e.g. "-A", or null for the default),
64 * LABEL gives l0, l1 and l2, and ARGV gives a0, a1 and a2.
65 * Yield DIFF_SUCCESS or DIFF_FAILURE.
79 a[i] = normalize_arg(argv[i], &b[i]);
94 a[0], a[1], a[2], (char*)0
100 warn("conflicts during merge");
106 if (!(f = fopenSafer(argv[0], "w")))
108 if (!(rt = Iopen(t, "r", (struct stat*)0)))
117 -1, d[i]=maketemp(i),
118 DIFF, a[i], a[2], (char*)0
120 case DIFF_FAILURE: case DIFF_SUCCESS: break;
121 default: faterror("diff failed");
126 DIFF3, edarg, d[0], d[1], a[0], a[1], a[2],
127 label[0], label[2], (char*)0
129 if (s != DIFF_SUCCESS) {
131 warn("overlaps or other problems during merge");
133 if (!(f = fopenSafer(t, "a+")))
135 aputs(tostdout ? "1,$p\n" : "w\n", f);
138 if (run(fileno(f), (char*)0, ED, "-", a[0], (char*)0))