Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / gnu / usr.bin / rcs / merge / merge.c
1 /* merge - three-way file merge */
2
3 /* Copyright 1991, 1992, 1993, 1994, 1995 Paul Eggert
4    Distributed under license by the Free Software Foundation, Inc.
5
6 This file is part of RCS.
7
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)
11 any later version.
12
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.
17
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.
22
23 Report problems and direct all questions to:
24
25     rcs-bugs@cs.purdue.edu
26
27 */
28 /*
29  * $FreeBSD: src/gnu/usr.bin/rcs/merge/merge.c,v 1.5 1999/08/27 23:36:51 peter Exp $
30  * $DragonFly: src/gnu/usr.bin/rcs/merge/merge.c,v 1.2 2003/06/17 04:25:47 dillon Exp $
31  */
32
33 #include "rcsbase.h"
34
35 static void badoption P((char const*));
36
37 static char const usage[] =
38  "\nmerge: usage: merge [-AeEpqxX3] [-L lab [-L lab [-L lab]]] file1 file2 file3";
39
40         static void
41 badoption(a)
42         char const *a;
43 {
44         error("unknown option: %s%s", a, usage);
45 }
46
47
48 mainProg(mergeId, "merge", "$DragonFly: src/gnu/usr.bin/rcs/merge/merge.c,v 1.2 2003/06/17 04:25:47 dillon Exp $")
49 {
50         register char const *a;
51         char const *arg[3], *label[3], *edarg = 0;
52         int labels, tostdout;
53
54         labels = 0;
55         tostdout = false;
56
57         for (;  (a = *++argv)  &&  *a++ == '-';  --argc) {
58                 switch (*a++) {
59                         case 'A': case 'E': case 'e':
60                                 if (edarg  &&  edarg[1] != (*argv)[1])
61                                         error("%s and %s are incompatible",
62                                                 edarg, *argv
63                                         );
64                                 edarg = *argv;
65                                 break;
66
67                         case 'p': tostdout = true; break;
68                         case 'q': quietflag = true; break;
69
70                         case 'L':
71                                 if (3 <= labels)
72                                         faterror("too many -L options");
73                                 if (!(label[labels++] = *++argv))
74                                         faterror("-L needs following argument");
75                                 --argc;
76                                 break;
77
78                         case 'V':
79                                 printf("RCS version %s\n", RCS_version_string);
80                                 exitmain(0);
81
82                         default:
83                                 badoption(a - 2);
84                                 continue;
85                 }
86                 if (*a)
87                         badoption(a - 2);
88         }
89
90         if (argc != 4)
91                 faterror("%s arguments%s",
92                         argc<4 ? "not enough" : "too many",  usage
93                 );
94
95         /* This copy keeps us `const'-clean.  */
96         arg[0] = argv[0];
97         arg[1] = argv[1];
98         arg[2] = argv[2];
99
100         for (;  labels < 3;  labels++)
101                 label[labels] = arg[labels];
102
103         if (nerror)
104                 exiterr();
105         exitmain(merge(tostdout, edarg, label, arg));
106 }
107
108
109 #if RCS_lint
110 #       define exiterr mergeExit
111 #endif
112         void
113 exiterr()
114 {
115         tempunlink();
116         _exit(DIFF_TROUBLE);
117 }