diff options
author | Rob Landley <rob@landley.net> | 2006-02-14 17:47:05 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-02-14 17:47:05 +0000 |
commit | 02794e151602911a520e67c8589503eb14f4e744 (patch) | |
tree | e4c5e7972b510c3760ef01498fb12d8c84872a24 | |
parent | 46e351d478293e530a5bb448656729b7250616b8 (diff) | |
download | busybox-w32-02794e151602911a520e67c8589503eb14f4e744.tar.gz busybox-w32-02794e151602911a520e67c8589503eb14f4e744.tar.bz2 busybox-w32-02794e151602911a520e67c8589503eb14f4e744.zip |
Fix bug 674: sum's block count should always round up.
-rw-r--r-- | coreutils/sum.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/coreutils/sum.c b/coreutils/sum.c index 0a9c9734f..eb919ab15 100644 --- a/coreutils/sum.c +++ b/coreutils/sum.c | |||
@@ -34,10 +34,10 @@ static int have_read_stdin; | |||
34 | Return 1 if successful. */ | 34 | Return 1 if successful. */ |
35 | static int bsd_sum_file(const char *file, int print_name) | 35 | static int bsd_sum_file(const char *file, int print_name) |
36 | { | 36 | { |
37 | register FILE *fp; | 37 | FILE *fp; |
38 | register int checksum = 0; /* The checksum mod 2^16. */ | 38 | int checksum = 0; /* The checksum mod 2^16. */ |
39 | register uintmax_t total_bytes = 0; /* The number of bytes. */ | 39 | uintmax_t total_bytes = 0; /* The number of bytes. */ |
40 | register int ch; /* Each character read. */ | 40 | int ch; /* Each character read. */ |
41 | 41 | ||
42 | if (IS_STDIN(file)) { | 42 | if (IS_STDIN(file)) { |
43 | fp = stdin; | 43 | fp = stdin; |
@@ -66,8 +66,7 @@ static int bsd_sum_file(const char *file, int print_name) | |||
66 | return 0; | 66 | return 0; |
67 | } | 67 | } |
68 | 68 | ||
69 | printf("%05d %5s ", checksum, | 69 | printf("%05d %5ju ", checksum, (total_bytes+1023)/1024); |
70 | make_human_readable_str(total_bytes, 1, 1024)); | ||
71 | if (print_name > 1) | 70 | if (print_name > 1) |
72 | puts(file); | 71 | puts(file); |
73 | else | 72 | else |
@@ -128,8 +127,7 @@ release_and_ret: | |||
128 | int r = (s & 0xffff) + ((s & 0xffffffff) >> 16); | 127 | int r = (s & 0xffff) + ((s & 0xffffffff) >> 16); |
129 | s = (r & 0xffff) + (r >> 16); | 128 | s = (r & 0xffff) + (r >> 16); |
130 | 129 | ||
131 | printf("%d %s ", s, | 130 | printf("%d %ju ", s, (total_bytes+511)/512); |
132 | make_human_readable_str(total_bytes, 1, 512)); | ||
133 | } | 131 | } |
134 | puts(print_name ? file : ""); | 132 | puts(print_name ? file : ""); |
135 | 133 | ||