1: /*
2: * RCS file comparison
3: */
4: static char rcsid[]=
5: "$Header: /usr/wft/RCS/SRC/RCS/rcsfcmp.c,v 3.1 82/12/04 13:21:40 wft Exp $ Purdue CS";
6: /*****************************************************************************
7: * rcsfcmp()
8: * Testprogram: define FCMPTEST
9: *****************************************************************************
10: *
11: * Copyright (C) 1982 by Walter F. Tichy
12: * Purdue University
13: * Computer Science Department
14: * West Lafayette, IN 47907
15: *
16: * All rights reserved. No part of this software may be sold or distributed
17: * in any form or by any means without the prior written permission of the
18: * author.
19: * Report problems and direct all inquiries to Tichy@purdue (ARPA net).
20: */
21:
22:
23:
24: /* $Log: rcsfcmp.c,v $
25: * Revision 3.1 82/12/04 13:21:40 wft
26: * Initial revision.
27: *
28: */
29:
30: /*
31: #define FCMPTEST
32: /* Testprogram; prints out whether two files are identical,
33: * except for keywords
34: */
35:
36: #include "rcsbase.h"
37: extern FILE * fopen();
38:
39:
40: rcsfcmp(xfname,uxfname,delta)
41: char * xfname, *uxfname; struct hshentry *delta;
42: /* Function: compares the files xfname and uxfname. Returns true
43: * if xfname has the same contents as uxfname, while disregarding
44: * keyword values. For the LOG-keyword, rcsfcmp skips the log message
45: * given by the parameter delta in xfname. Thus, rcsfcmp returns true
46: * if xfname contains the same as uxfname, with the keywords expanded.
47: */
48: {
49: register int xc,uxc;
50: char xkeyword[keylength+2], uxkeyword[keylength+2];
51: register char * tp;
52: FILE * xfp, * uxfp;
53: int result;
54:
55: if ((xfp=fopen(tp=xfname,"r"))==NULL || (uxfp=fopen(tp=uxfname,"r"))==NULL) {
56: faterror("Can't open %s\n", tp);
57: return false;
58: }
59: result=false;
60: xc=getc(xfp); uxc=getc(uxfp);
61: while( xc == uxc) { /* comparison loop */
62: if (xc==EOF) { /* finished; everything is the same*/
63: result=true;
64: break;
65: }
66: if ( xc!=KDELIM) {
67: /* get the next characters */
68: xc=getc(xfp); uxc=getc(uxfp);
69: } else {
70: /* try to get both keywords */
71: tp = xkeyword;
72: while( ctab[(xc=getc(xfp))]==LETTER && tp< xkeyword+keylength)
73: *tp++ = xc;
74: *tp='\0';
75: tp = uxkeyword;
76: while( ctab[(uxc=getc(uxfp))]==LETTER && tp< uxkeyword+keylength)
77: *tp++ = uxc;
78: *tp='\0';
79: /* now we have 2 keywords, or something thal looks like it.*/
80: if (strcmp(xkeyword,uxkeyword)!=0) break; /* not the same! */
81: /* now check whether it's really a keyword */
82: if (!(strcmp(xkeyword,AUTHOR)==0 || strcmp(xkeyword,DATE) ==0 ||
83: strcmp(xkeyword,HEADER)==0 || strcmp(xkeyword,LOCKER) ==0 ||
84: strcmp(xkeyword,LOG) ==0 || strcmp(xkeyword,REVISION)==0 ||
85: strcmp(xkeyword,SOURCE)==0 || strcmp(xkeyword,STATE) ==0 )) {
86: /* it's not a keyword, so continue normally */
87: continue;
88: } else {
89: /* it's a keyword, so skip value */
90: while (xc!=KDELIM && xc!='\n' && xc!=EOF) xc=getc(xfp);
91: while (uxc!=KDELIM && uxc!='\n' && uxc!=EOF) uxc=getc(uxfp);
92: if (xc==uxc && xc==KDELIM) {
93: xc=getc(xfp); uxc=getc(uxfp); /* skip KDELIM */
94: /* if the keyword is LOG, also skip the log message in xfp*/
95: if (strcmp(xkeyword,LOG)==0) {
96: /* first, compute the number of line feeds in log msg */
97: int lncnt;
98: lncnt=2; tp=delta->log;
99: while(*tp) if(*tp++=='\n') lncnt++;
100: while(xc!=EOF) {
101: if (xc=='\n')
102: if(--lncnt==0) break;
103: xc=getc(xfp);
104: }
105: /* skip last comment leader */
106: for (lncnt=strlen(Comment); lncnt>=0; lncnt--) xc=getc(xfp);
107: }
108: }
109: }
110: }
111: }
112: fclose(xfp);fclose(uxfp);
113: return result;
114: }
115:
116:
117:
118: #ifdef FCMPTEST
119: cleanup(){} /* dummy */
120:
121: char * ;
122:
123: main(argc, argv)
124: int argc; char *argv[];
125: /* first argument: comment leader; 2nd: log message, 3rd: expanded file,
126: * 4th: unexpanded file
127: */
128: { struct hshentry delta;
129:
130: cmdid="rcsfcmp";
131: Comment=argv[1];
132: delta.log=argv[2];
133: if (rcsfcmp(argv[3],argv[4],&delta))
134: printf("files are the same\n");
135: else printf("files are different\n");
136: }
137: #endif
Defined functions
main
defined in line
123;
never used
Defined variables
defined in line
121; used 2 times
rcsid
defined in line
4;
never used