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 ...]
|
.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.
|
|
||||||
|
|
5
cksum.c
5
cksum.c
|
@ -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');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user