sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 70ba7a6e623a87723e61eb2899d3d92800336022
parent 10049d33a55ba7de87b15f720dc2c9dcb32859d9
Author: Connor Lane Smith <cls@lubutu.com>
Date:   Fri, 10 Jun 2011 04:36:40 +0100

cksum: error check
Diffstat:
Mcksum.1 | 3+--
Mcksum.c | 5+++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/cksum.1 b/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. diff --git a/cksum.c b/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');