Fix bug 674: sum's block count should always round up.
This commit is contained in:
parent
46e351d478
commit
02794e1516
@ -34,10 +34,10 @@ static int have_read_stdin;
|
|||||||
Return 1 if successful. */
|
Return 1 if successful. */
|
||||||
static int bsd_sum_file(const char *file, int print_name)
|
static int bsd_sum_file(const char *file, int print_name)
|
||||||
{
|
{
|
||||||
register FILE *fp;
|
FILE *fp;
|
||||||
register int checksum = 0; /* The checksum mod 2^16. */
|
int checksum = 0; /* The checksum mod 2^16. */
|
||||||
register uintmax_t total_bytes = 0; /* The number of bytes. */
|
uintmax_t total_bytes = 0; /* The number of bytes. */
|
||||||
register int ch; /* Each character read. */
|
int ch; /* Each character read. */
|
||||||
|
|
||||||
if (IS_STDIN(file)) {
|
if (IS_STDIN(file)) {
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
@ -66,8 +66,7 @@ static int bsd_sum_file(const char *file, int print_name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%05d %5s ", checksum,
|
printf("%05d %5ju ", checksum, (total_bytes+1023)/1024);
|
||||||
make_human_readable_str(total_bytes, 1, 1024));
|
|
||||||
if (print_name > 1)
|
if (print_name > 1)
|
||||||
puts(file);
|
puts(file);
|
||||||
else
|
else
|
||||||
@ -128,8 +127,7 @@ release_and_ret:
|
|||||||
int r = (s & 0xffff) + ((s & 0xffffffff) >> 16);
|
int r = (s & 0xffff) + ((s & 0xffffffff) >> 16);
|
||||||
s = (r & 0xffff) + (r >> 16);
|
s = (r & 0xffff) + (r >> 16);
|
||||||
|
|
||||||
printf("%d %s ", s,
|
printf("%d %ju ", s, (total_bytes+511)/512);
|
||||||
make_human_readable_str(total_bytes, 1, 512));
|
|
||||||
}
|
}
|
||||||
puts(print_name ? file : "");
|
puts(print_name ? file : "");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user