cksum: error check

This commit is contained in:
Connor Lane Smith 2011-06-10 04:36:40 +01:00
parent 10049d33a5
commit 70ba7a6e62
2 changed files with 4 additions and 4 deletions

View File

@ -6,5 +6,4 @@ cksum \- print file checksums
.RI [ file ...] .RI [ file ...]
.SH DESCRIPTION .SH DESCRIPTION
.B cksum .B cksum
calculates and prints a cyclic redundancy check (CRC) for each input file, along calculates and prints a cyclic redundancy check (CRC) for each input file.
with its size and name.

View File

@ -88,9 +88,10 @@ cksum(FILE *fp, const char *s)
ck = (ck << 8) ^ crctab[(ck >> 24) ^ c]; ck = (ck << 8) ^ crctab[(ck >> 24) ^ c];
for(i = n; i > 0; i >>= 8) for(i = n; i > 0; i >>= 8)
ck = (ck << 8) ^ crctab[(ck >> 24) ^ (i & 0377)]; 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) if(s != NULL)
printf(" %s", s); printf(" %s", s);
putchar('\n'); putchar('\n');