use bb_xbind/bb_xlisten
[oweals/busybox.git] / coreutils / sum.c
index 3b4941d28460c3d461d2c7e88f8736d91af764f1..2edd92036d48a1f8284bceec95b81951d5b5ecd7 100644 (file)
@@ -18,7 +18,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <getopt.h>
 
 #include "busybox.h"
 
@@ -35,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;
@@ -67,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
@@ -84,7 +82,7 @@ static int bsd_sum_file(const char *file, int print_name)
 #define MY_BUF_SIZE 8192
 static int sysv_sum_file(const char *file, int print_name)
 {
-       RESERVE_CONFIG_UBUFFER(buf, MY_BUF_SIZE);
+       RESERVE_CONFIG_BUFFER(buf, MY_BUF_SIZE);
        int fd;
        uintmax_t total_bytes = 0;
 
@@ -129,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 : "");