Bump to version 1.22.1
[platform/upstream/busybox.git] / coreutils / sum.c
index 35e89a6..deb068e 100644 (file)
  * Written by Kayvan Aghaiepour and David MacKenzie
  * Taken from coreutils and turned into a busybox applet by Mike Frysinger
  *
- * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
+//usage:#define sum_trivial_usage
+//usage:       "[-rs] [FILE]..."
+//usage:#define sum_full_usage "\n\n"
+//usage:       "Checksum and count the blocks in a file\n"
+//usage:     "\n       -r      Use BSD sum algorithm (1K blocks)"
+//usage:     "\n       -s      Use System V sum algorithm (512byte blocks)"
+
 #include "libbb.h"
 
 enum { SUM_BSD, PRINT_NAME, SUM_SYSV };
@@ -63,9 +70,9 @@ static unsigned sum_file(const char *file, unsigned type)
        if (type >= SUM_SYSV) {
                r = (s & 0xffff) + ((s & 0xffffffff) >> 16);
                s = (r & 0xffff) + (r >> 16);
-               printf("%d %llu %s\n", s, (total_bytes + 511) / 512, file);
+               printf("%u %llu %s\n", s, (total_bytes + 511) / 512, file);
        } else
-               printf("%05d %5llu %s\n", s, (total_bytes + 1023) / 1024, file);
+               printf("%05u %5llu %s\n", s, (total_bytes + 1023) / 1024, file);
        return 1;
 #undef buf
 }
@@ -87,8 +94,8 @@ int sum_main(int argc UNUSED_PARAM, char **argv)
                n = sum_file("-", type);
        } else {
                /* Need to print the name if either
-                  - more than one file given
-                  - doing sysv */
+                * - more than one file given
+                * - doing sysv */
                type += (argv[1] || type == SUM_SYSV);
                n = 1;
                do {