[hackers] [sbase] cksum: error check || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Fri, 10 Jun 2011 05:39:24 +0200 (CEST)

changeset: 70:d0c99f546aef
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Fri Jun 10 04:36:40 2011 +0100
files: cksum.1 cksum.c
description:
cksum: error check

diff -r a4b68ba0c52f -r d0c99f546aef cksum.1
--- a/cksum.1 Fri Jun 10 04:22:59 2011 +0100
+++ b/cksum.1 Fri Jun 10 04:36:40 2011 +0100
@@ -6,5 +6,4 @@
 .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 -r a4b68ba0c52f -r d0c99f546aef cksum.c
--- a/cksum.c Fri Jun 10 04:22:59 2011 +0100
+++ b/cksum.c Fri Jun 10 04:36:40 2011 +0100
@@ -88,9 +88,10 @@
                 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');
Received on Fri Jun 10 2011 - 05:39:24 CEST

This archive was generated by hypermail 2.2.0 : Fri Jun 10 2011 - 05:48:05 CEST