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 ...]
.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.

View File

@ -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');