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 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. 20If not, write to the Free Software Foundation, 2159 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 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*)); 32 33static char const usage[] = 34 "\nmerge: usage: merge [-AeEpqxX3] [-L lab [-L lab [-L lab]]] file1 file2 file3"; 35 36 static void 37badoption(a) 38 char const *a; 39{ 40 error("unknown option: %s%s", a, usage); 41} 42 43 44mainProg(mergeId, "merge", "$FreeBSD: releng/11.0/gnu/usr.bin/rcs/merge/merge.c 50472 1999-08-27 23:37:10Z peter $") 45{ 46 register char const *a; 47 char const *arg[3], *label[3], *edarg = 0; 48 int labels, tostdout; 49 50 labels = 0; 51 tostdout = false; 52 53 for (; (a = *++argv) && *a++ == '-'; --argc) { 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 63 case 'p': tostdout = true; break; 64 case 'q': quietflag = true; break; 65 66 case 'L': 67 if (3 <= labels) 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 78 default: 79 badoption(a - 2); 80 continue; 81 } 82 if (*a) 83 badoption(a - 2); 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 96 for (; labels < 3; labels++) 97 label[labels] = arg[labels]; 98 99 if (nerror) 100 exiterr(); 101 exitmain(merge(tostdout, edarg, label, arg)); 102} 103 104 105#if RCS_lint 106# define exiterr mergeExit 107#endif 108 void 109exiterr() 110{ 111 tempunlink(); 112 _exit(DIFF_TROUBLE); 113} 114