diff options
| author | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-02-14 17:47:05 +0000 |
|---|---|---|
| committer | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-02-14 17:47:05 +0000 |
| commit | 78f86409549faa383de5d405fdaae57c0ff932cb (patch) | |
| tree | e4c5e7972b510c3760ef01498fb12d8c84872a24 | |
| parent | 62298b18588400e57e35810fbe5c39483c0f5608 (diff) | |
| download | busybox-w32-78f86409549faa383de5d405fdaae57c0ff932cb.tar.gz busybox-w32-78f86409549faa383de5d405fdaae57c0ff932cb.tar.bz2 busybox-w32-78f86409549faa383de5d405fdaae57c0ff932cb.zip | |
Fix bug 674: sum's block count should always round up.
git-svn-id: svn://busybox.net/trunk/busybox@14014 69ca8d6d-28ef-0310-b511-8ec308f3f277
| -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 | ||
