cksum: error check
This commit is contained in:
parent
10049d33a5
commit
70ba7a6e62
3
cksum.1
3
cksum.1
@ -6,5 +6,4 @@ cksum \- print file checksums
|
||||
.RI [ file ...]
|
||||
.SH DESCRIPTION
|
||||
.B cksum
|
||||
calculates and prints a cyclic redundancy check (CRC) for each input file, along
|
||||
with its size and name.
|
||||
calculates and prints a cyclic redundancy check (CRC) for each input file.
|
||||
|
5
cksum.c
5
cksum.c
@ -88,9 +88,10 @@ cksum(FILE *fp, const char *s)
|
||||
ck = (ck << 8) ^ crctab[(ck >> 24) ^ c];
|
||||
for(i = n; i > 0; i >>= 8)
|
||||
ck = (ck << 8) ^ crctab[(ck >> 24) ^ (i & 0377)];
|
||||
ck = ~ck;
|
||||
if(ferror(fp))
|
||||
eprintf("%s: read error:", s ? s : "<stdin>");
|
||||
|
||||
printf("%lu %lu", ck, n);
|
||||
printf("%lu %lu", ~ck, n);
|
||||
if(s != NULL)
|
||||
printf(" %s", s);
|
||||
putchar('\n');
|
||||
|
Loading…
Reference in New Issue
Block a user