1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
--- diffreg.c.orig 1994-01-11 05:39:33 UTC
+++ diffreg.c
@@ -2,7 +2,7 @@
static char sccsid[] = "@(#)diffreg.c 4.16.1 (2.11BSD) 1/1/94";
#endif
-#include "diff.h"
+#include "diffextern.h"
/*
* diff - compare two files.
*/
@@ -84,6 +84,25 @@ struct line {
int serial;
int value;
} *file[2], line;
+
+/* declarations */
+void equiv(struct line *, int, struct line *, int, int *);
+int asciifile(FILE *);
+void prepare(int, FILE *);
+void sort(struct line *, int);
+void unsort(struct line *, int, int *);
+void unravel(int);
+void check();
+void output();
+int stone(int *, int, int *, register int *);
+int readhash(FILE *);
+int newcand(int, int, int);
+int search(int *, int, int);
+void change(int, int, int, int);
+void dump_context_vec();
+void range(int, int, char *);
+void fetch(long *, int, int, FILE *, char *, int);
+
int len[2];
struct line *sfile[2]; /* shortened by pruning common prefix and suffix */
int slen[2];
@@ -140,7 +159,7 @@ char cup2low[256] = {
0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff
};
-diffreg()
+void diffreg()
{
register int i, j;
FILE *f1, *f2;
@@ -270,12 +289,12 @@ copytemp()
char buf[BUFSIZ];
register int i, f;
- signal(SIGHUP,done);
- signal(SIGINT,done);
- signal(SIGPIPE,done);
- signal(SIGTERM,done);
- tempfile = mktemp("/tmp/dXXXXX");
- f = creat(tempfile,0600);
+ signal(SIGHUP, (sig_t) done);
+ signal(SIGINT, (sig_t) done);
+ signal(SIGPIPE, (sig_t) done);
+ signal(SIGTERM, (sig_t) done);
+ strcpy(tempfile, "/tmp/dXXXXX");
+ f = mkstemp(tempfile);
if (f < 0) {
fprintf(stderr, "diff: ");
perror(tempfile);
@@ -311,16 +330,16 @@ splice(dir, file)
return (savestr(buf));
}
-prepare(i, fd)
+void prepare(i, fd)
int i;
FILE *fd;
{
register struct line *p;
- register j,h;
+ register int j,h;
fseek(fd, (long)0, 0);
p = (struct line *)talloc(3*sizeof(line));
- for(j=0; h=readhash(fd);) {
+ for(j=0; (h=readhash(fd));) {
p = (struct line *)ralloc((char *)p,(++j+3)*sizeof(line));
p[j].value = h;
}
@@ -328,9 +347,9 @@ prepare(i, fd)
file[i] = p;
}
-prune()
+void prune()
{
- register i,j;
+ register int i,j;
for(pref=0;pref<len[0]&&pref<len[1]&&
file[0][pref+1].value==file[1][pref+1].value;
pref++ ) ;
@@ -345,7 +364,7 @@ prune()
}
}
-equiv(a,n,b,m,c)
+void equiv(a,n,b,m,c)
struct line *a, *b;
int *c;
{
@@ -373,7 +392,7 @@ int *c;
c[j] = -1;
}
-stone(a,n,b,c)
+int stone(a,n,b,c)
int *a;
int *b;
register int *c;
@@ -414,7 +433,7 @@ register int *c;
return(k);
}
-newcand(x,y,pred)
+int newcand(x,y,pred)
{
register struct cand *q;
clist = (struct cand *)ralloc((char *)clist,++clen*sizeof(cand));
@@ -425,7 +444,7 @@ newcand(x,y,pred)
return(clen-1);
}
-search(c, k, y)
+int search(c, k, y)
int *c;
{
register int i, j, l;
@@ -449,7 +468,7 @@ int *c;
return(l+1);
}
-unravel(p)
+void unravel(p)
{
register int i;
register struct cand *q;
@@ -466,7 +485,7 @@ unravel(p)
to confounding by hashing (which result in "jackpot")
2. collect random access indexes to the two files */
-check()
+void check()
{
register int i, j;
int jackpot;
@@ -565,7 +584,7 @@ check()
*/
}
-sort(a,n) /*shellsort CACM #201*/
+void sort(a,n) /*shellsort CACM #201*/
struct line *a;
{
struct line w;
@@ -586,8 +605,8 @@ struct line *a;
if(aim < ai)
break; /*wraparound*/
if(aim->value > ai[0].value ||
- aim->value == ai[0].value &&
- aim->serial > ai[0].serial)
+ (aim->value == ai[0].value &&
+ aim->serial > ai[0].serial))
break;
w.value = ai[0].value;
ai[0].value = aim->value;
@@ -600,7 +619,7 @@ struct line *a;
}
}
-unsort(f, l, b)
+void unsort(f, l, b)
struct line *f;
int *b;
{
@@ -614,9 +633,9 @@ int *b;
free((char *)a);
}
-skipline(f)
+int skipline(f)
{
- register i, c;
+ register int i, c;
for(i=1;(c=getc(input[f]))!='\n';i++)
if (c < 0)
@@ -624,7 +643,7 @@ skipline(f)
return(i);
}
-output()
+void output()
{
int m;
register int i0, i1, j1;
@@ -691,7 +710,7 @@ struct context_vec *context_vec_start,
and this means that there were lines appended (beginning at b).
If c is greater than d then there are lines missing from the to file.
*/
-change(a,b,c,d)
+void change(a,b,c,d)
{
int ch;
int lowa,upb,lowc,upd;
@@ -781,7 +800,7 @@ change(a,b,c,d)
}
}
-range(a,b,separator)
+void range(a,b,separator)
char *separator;
{
printf("%d", a>b?b:a);
@@ -790,7 +809,7 @@ char *separator;
}
}
-fetch(f,a,b,lb,s,oldfile)
+void fetch(f,a,b,lb,s,oldfile)
long *f;
FILE *lb;
char *s;
@@ -869,13 +888,13 @@ char *s;
* arranging line in 7-bit bytes and then
* summing 1-s complement in 16-bit hunks
*/
-readhash(f)
+int readhash(f)
register FILE *f;
{
register long sum;
register unsigned shift;
- register t;
- register space;
+ register int t;
+ register int space;
sum = 1;
space = 0;
@@ -931,12 +950,12 @@ register FILE *f;
}
}
sum = low(sum) + high(sum);
- return((short)low(sum) + (short)high(sum));
+ return((int)low(sum) + (int)high(sum));
}
#include <a.out.h>
-asciifile(f)
+int asciifile(f)
FILE *f;
{
char buf[BUFSIZ];
@@ -960,7 +979,7 @@ asciifile(f)
/* dump accumulated "context" diff changes */
-dump_context_vec()
+void dump_context_vec()
{
register int a, b, c, d;
register char ch;
@@ -1003,15 +1022,15 @@ dump_context_vec()
ch = (a <= b) ? 'd' : 'a';
if (ch == 'a')
- fetch(ixold,lowa,b,input[0]," ");
+ fetch(ixold,lowa,b,input[0]," ", 0);
else {
- fetch(ixold,lowa,a-1,input[0]," ");
- fetch(ixold,a,b,input[0],ch == 'c' ? "! " : "- ");
+ fetch(ixold,lowa,a-1,input[0]," ", 0);
+ fetch(ixold,a,b,input[0],ch == 'c' ? "! " : "- ", 0);
}
lowa = b + 1;
cvp++;
}
- fetch(ixold, b+1, upb, input[0], " ");
+ fetch(ixold, b+1, upb, input[0], " ", 0);
}
/* output changes to the "new" file */
@@ -1037,15 +1056,15 @@ dump_context_vec()
ch = (a <= b) ? 'd' : 'a';
if (ch == 'd')
- fetch(ixnew,lowc,d,input[1]," ");
+ fetch(ixnew,lowc,d,input[1]," ", 0);
else {
- fetch(ixnew,lowc,c-1,input[1]," ");
- fetch(ixnew,c,d,input[1],ch == 'c' ? "! " : "+ ");
+ fetch(ixnew,lowc,c-1,input[1]," ", 0);
+ fetch(ixnew,c,d,input[1],ch == 'c' ? "! " : "+ ", 0);
}
lowc = d + 1;
cvp++;
}
- fetch(ixnew, d+1, upd, input[1], " ");
+ fetch(ixnew, d+1, upd, input[1], " ", 0);
}
context_vec_ptr = context_vec_start - 1;
|