projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added "more" command
[unix-history]
/
usr
/
src
/
usr.bin
/
diff
/
diff
/
diffreg.c
diff --git
a/usr/src/usr.bin/diff/diff/diffreg.c
b/usr/src/usr.bin/diff/diff/diffreg.c
index
f727773
..
fd4e873
100644
(file)
--- a/
usr/src/usr.bin/diff/diff/diffreg.c
+++ b/
usr/src/usr.bin/diff/diff/diffreg.c
@@
-1,4
+1,4
@@
-static char sccsid[] = "@(#)diffreg.c 4.
4
%G%";
+static char sccsid[] = "@(#)diffreg.c 4.
9
%G%";
#include "diff.h"
/*
#include "diff.h"
/*
@@
-108,7
+108,6
@@
diffreg()
perror(diffh);
done();
}
perror(diffh);
done();
}
- dummy = malloc(1);
if ((stb1.st_mode & S_IFMT) == S_IFDIR)
file1 = splice(file1, file2);
else if ((stb2.st_mode & S_IFMT) == S_IFDIR)
if ((stb1.st_mode & S_IFMT) == S_IFDIR)
file1 = splice(file1, file2);
else if ((stb2.st_mode & S_IFMT) == S_IFDIR)
@@
-124,26
+123,25
@@
diffreg()
if ((f1 = fopen(file1, "r")) == NULL) {
fprintf(stderr, "diff: ");
perror(file1);
if ((f1 = fopen(file1, "r")) == NULL) {
fprintf(stderr, "diff: ");
perror(file1);
- fclose(f1);
done();
}
if ((f2 = fopen(file2, "r")) == NULL) {
fprintf(stderr, "diff: ");
perror(file2);
fclose(f1);
done();
}
if ((f2 = fopen(file2, "r")) == NULL) {
fprintf(stderr, "diff: ");
perror(file2);
fclose(f1);
- fclose(f2);
done();
}
if (stb1.st_size != stb2.st_size)
goto notsame;
for (;;) {
done();
}
if (stb1.st_size != stb2.st_size)
goto notsame;
for (;;) {
- i = fread(buf1,
BUFSIZ, 1
, f1);
- j = fread(buf2,
BUFSIZ, 1
, f2);
+ i = fread(buf1,
1, BUFSIZ
, f1);
+ j = fread(buf2,
1, BUFSIZ
, f2);
if (i < 0 || j < 0 || i != j)
goto notsame;
if (i == 0 && j == 0) {
fclose(f1);
fclose(f2);
if (i < 0 || j < 0 || i != j)
goto notsame;
if (i == 0 && j == 0) {
fclose(f1);
fclose(f2);
+ status = 0; /* files don't differ */
goto same;
}
for (j = 0; j < i; j++)
goto same;
}
for (j = 0; j < i; j++)
@@
-151,6
+149,10
@@
diffreg()
goto notsame;
}
notsame:
goto notsame;
}
notsame:
+ /*
+ * Files certainly differ at this point; set status accordingly
+ */
+ status = 1;
if (!asciifile(f1) || !asciifile(f2)) {
printf("Binary files %s and %s differ\n", file1, file2);
fclose(f1);
if (!asciifile(f1) || !asciifile(f2)) {
printf("Binary files %s and %s differ\n", file1, file2);
fclose(f1);
@@
-307,7
+309,7
@@
int *c;
stone(a,n,b,c)
int *a;
int *b;
stone(a,n,b,c)
int *a;
int *b;
-int *c;
+
register
int *c;
{
register int i, k,y;
int j, l;
{
register int i, k,y;
int j, l;
@@
-365,7
+367,10
@@
int *c;
return(k+1);
i = 0;
j = k+1;
return(k+1);
i = 0;
j = k+1;
- while((l=(i+j)/2) > i) {
+ while (1) {
+ l = i + j;
+ if ((l >>= 1) <= i)
+ break;
t = clist[c[l]].y;
if(t > y)
j = l;
t = clist[c[l]].y;
if(t > y)
j = l;
@@
-725,7
+730,7
@@
char *s;
* summing 1-s complement in 16-bit hunks
*/
readhash(f)
* summing 1-s complement in 16-bit hunks
*/
readhash(f)
-FILE *f;
+
register
FILE *f;
{
long sum;
register unsigned shift;
{
long sum;
register unsigned shift;
@@
-736,7
+741,7
@@
FILE *f;
if(!bflag) for(shift=0;(t=getc(f))!='\n';shift+=7) {
if(t==-1)
return(0);
if(!bflag) for(shift=0;(t=getc(f))!='\n';shift+=7) {
if(t==-1)
return(0);
- sum += (long)t << (shift
%=HALFLONG
);
+ sum += (long)t << (shift
&= HALFLONG - 1
);
}
else for(shift=0;;) {
switch(t=getc(f)) {
}
else for(shift=0;;) {
switch(t=getc(f)) {
@@
-751,7
+756,7
@@
FILE *f;
shift += 7;
space = 0;
}
shift += 7;
space = 0;
}
- sum += (long)t << (shift
%=HALFLONG
);
+ sum += (long)t << (shift
&= HALFLONG - 1
);
shift += 7;
continue;
case '\n':
shift += 7;
continue;
case '\n':
@@
-773,7
+778,7
@@
asciifile(f)
register char *cp;
fseek(f, (long)0, 0);
register char *cp;
fseek(f, (long)0, 0);
- cnt = fread(buf,
BUFSIZ, 1
, f);
+ cnt = fread(buf,
1, BUFSIZ
, f);
if (cnt >= sizeof (struct exec)) {
struct exec hdr;
hdr = *(struct exec *)buf;
if (cnt >= sizeof (struct exec)) {
struct exec hdr;
hdr = *(struct exec *)buf;