added CHAR_OFFSET

This commit is contained in:
Andrew Tridgell committed 1996-07-04 13:08:07 +00:00
1 parent ebb0a6f618
commit 1b01b295c9
3 files changed
+11 -5

No files matched your search

+4 -3
View File
@@ -37,11 +37,12 @@ uint32 get_checksum1(char *buf,int len)
s1 = s2 = 0;
for (i = 0; i < (len-4); i+=4) {
s2 += 4*(s1 + buf[i]) + 3*buf[i+1] + 2*buf[i+2] + buf[i+3] + 10;
s1 += (buf[i+0] + buf[i+1] + buf[i+2] + buf[i+3] + 4);
s2 += 4*(s1 + buf[i]) + 3*buf[i+1] + 2*buf[i+2] + buf[i+3] +
10*CHAR_OFFSET;
s1 += (buf[i+0] + buf[i+1] + buf[i+2] + buf[i+3] + 4*CHAR_OFFSET);
}
for (; i < len; i++) {
s1 += (buf[i]+1); s2 += s1;
s1 += (buf[i]+CHAR_OFFSET); s2 += s1;
}
return (s1 & 0xffff) + (s2 << 16);
}
+2 -2
View File
@@ -222,11 +222,11 @@ static void hash_search(int f,struct sum_struct *s,
/* Trim off the first byte from the checksum */
map = window_ptr(buf,offset,k+1);
s1 -= map[0] + 1;
s2 -= k * (map[0]+1);
s2 -= k * (map[0]+CHAR_OFFSET);
/* Add on the next byte (if there is one) to the checksum */
if (k < (len-offset)) {
s1 += (map[k]+1);
s1 += (map[k]+CHAR_OFFSET);
s2 += s1;
} else {
--k;
+5
View File
@@ -23,6 +23,11 @@
#define RSYNC_NAME "rsync"
#define BACKUP_SUFFIX "~"
/* a non-zero CHAR_OFFSET makes the rolling sum stronger, but is
imcompatible with older versions :-( */
#define CHAR_OFFSET 0
#define FILE_VALID 1
#define SAME_MODE (1<<1)
#define SAME_RDEV (1<<2)