No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / usr.bin / rcs / merge / merge.c
bloba58cfd703d4a69507b0230cae1d17d08f3b767a1
1 /* $NetBSD: merge.c,v 1.1.1.2 1996/10/13 21:57:34 veego Exp $ */
3 /* merge - three-way file merge */
5 /* Copyright 1991, 1992, 1993, 1994, 1995 Paul Eggert
6 Distributed under license by the Free Software Foundation, Inc.
8 This file is part of RCS.
10 RCS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
15 RCS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with RCS; see the file COPYING.
22 If not, write to the Free Software Foundation,
23 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 Report problems and direct all questions to:
27 rcs-bugs@cs.purdue.edu
31 #include "rcsbase.h"
33 static void badoption P((char const*));
35 static char const usage[] =
36 "\nmerge: usage: merge [-AeEpqxX3] [-L lab [-L lab [-L lab]]] file1 file2 file3";
38 static void
39 badoption(a)
40 char const *a;
42 error("unknown option: %s%s", a, usage);
46 mainProg(mergeId, "merge", "Id: merge.c,v 1.8 1995/06/16 06:19:24 eggert Exp")
48 register char const *a;
49 char const *arg[3], *label[3], *edarg = 0;
50 int labels, tostdout;
52 labels = 0;
53 tostdout = false;
55 for (; (a = *++argv) && *a++ == '-'; --argc) {
56 switch (*a++) {
57 case 'A': case 'E': case 'e':
58 if (edarg && edarg[1] != (*argv)[1])
59 error("%s and %s are incompatible",
60 edarg, *argv
62 edarg = *argv;
63 break;
65 case 'p': tostdout = true; break;
66 case 'q': quietflag = true; break;
68 case 'L':
69 if (3 <= labels)
70 faterror("too many -L options");
71 if (!(label[labels++] = *++argv))
72 faterror("-L needs following argument");
73 --argc;
74 break;
76 case 'V':
77 printf("RCS version %s\n", RCS_version_string);
78 exitmain(0);
80 default:
81 badoption(a - 2);
82 continue;
84 if (*a)
85 badoption(a - 2);
88 if (argc != 4)
89 faterror("%s arguments%s",
90 argc<4 ? "not enough" : "too many", usage
93 /* This copy keeps us `const'-clean. */
94 arg[0] = argv[0];
95 arg[1] = argv[1];
96 arg[2] = argv[2];
98 for (; labels < 3; labels++)
99 label[labels] = arg[labels];
101 if (nerror)
102 exiterr();
103 exitmain(merge(tostdout, edarg, label, arg));
107 #if RCS_lint
108 # define exiterr mergeExit
109 #endif
110 void
111 exiterr()
113 tempunlink();
114 _exit(DIFF_TROUBLE);