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