summaryrefslogtreecommitdiff
path: root/coreutils/sum.c
diff options
context:
space:
mode:
authorRob Landley2006-02-14 17:47:05 +0000
committerRob Landley2006-02-14 17:47:05 +0000
commit02794e151602911a520e67c8589503eb14f4e744 (patch)
treee4c5e7972b510c3760ef01498fb12d8c84872a24 /coreutils/sum.c
parent46e351d478293e530a5bb448656729b7250616b8 (diff)
downloadbusybox-02794e151602911a520e67c8589503eb14f4e744.zip
busybox-02794e151602911a520e67c8589503eb14f4e744.tar.gz
Fix bug 674: sum's block count should always round up.
Diffstat (limited to 'coreutils/sum.c')
-rw-r--r--coreutils/sum.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/coreutils/sum.c b/coreutils/sum.c
index 0a9c973..eb919ab 100644
--- a/coreutils/sum.c
+++ b/coreutils/sum.c
@@ -34,10 +34,10 @@ static int have_read_stdin;
Return 1 if successful. */
static int bsd_sum_file(const char *file, int print_name)
{
- register FILE *fp;
- register int checksum = 0; /* The checksum mod 2^16. */
- register uintmax_t total_bytes = 0; /* The number of bytes. */
- register int ch; /* Each character read. */
+ FILE *fp;
+ int checksum = 0; /* The checksum mod 2^16. */
+ uintmax_t total_bytes = 0; /* The number of bytes. */
+ int ch; /* Each character read. */
if (IS_STDIN(file)) {
fp = stdin;
@@ -66,8 +66,7 @@ static int bsd_sum_file(const char *file, int print_name)
return 0;
}
- printf("%05d %5s ", checksum,
- make_human_readable_str(total_bytes, 1, 1024));
+ printf("%05d %5ju ", checksum, (total_bytes+1023)/1024);
if (print_name > 1)
puts(file);
else
@@ -128,8 +127,7 @@ release_and_ret:
int r = (s & 0xffff) + ((s & 0xffffffff) >> 16);
s = (r & 0xffff) + (r >> 16);
- printf("%d %s ", s,
- make_human_readable_str(total_bytes, 1, 512));
+ printf("%d %ju ", s, (total_bytes+511)/512);
}
puts(print_name ? file : "");