Better handling of various content difference situations

This commit is contained in:
Thomas Schmitt 2008-01-25 16:32:38 +00:00
parent 06ddbbe6d8
commit 05fabf5149

View File

@ -137,7 +137,6 @@ int Compare_2_files(char *adr1, char *adr2, char *adrc, int flag)
if(s1.st_size > r1count + r1)
printf("- %s : early EOF after %d bytes\n", adr1, r1count);
differs= 1;
break;
}
r1count+= r1;
if(r2==EOF || r2<r1) {
@ -146,15 +145,15 @@ int Compare_2_files(char *adr1, char *adr2, char *adrc, int flag)
if(s2.st_size > r2count + r2)
printf("- %s : early EOF after %d bytes\n", adr2, r2count);
differs= 1;
break;
}
if(r2>r1) {
if(s1.st_size > r1count + r1)
printf("- %s : early EOF after %d bytes\n", adr1, r1count);
differs= 1;
break;
}
r2count+= r2;
if(r1>r2)
r1= r2;
for(i= 0; i<r1; i++) {
if(buf1[i]!=buf2[i]) {
if(first_diff<0)
@ -163,10 +162,13 @@ int Compare_2_files(char *adr1, char *adr2, char *adrc, int flag)
}
}
}
if(diffcount>0) {
printf("%s : %s : differs by at least %.f bytes. First at %.f\n",
a, (s1.st_size==s2.st_size || s1.st_mtime==s2.st_mtime ?
"CONTENT":"content"), (double) diffcount, (double) first_diff);
if(diffcount>0 || r1count!=r2count) {
if(first_diff<0)
first_diff= (r1count>r2count ? r2count : r1count);
printf("%s : %s : differs by at least %.f bytes. First at %.f\n", a,
(s1.st_size==s2.st_size || s1.st_mtime==s2.st_mtime ?
"CONTENT":"content"),
(double) (diffcount + abs(r1count-r2count)), (double) first_diff);
differs= 1;
}
}