svn commit: trunk/busybox/coreutils

landley at busybox.net landley at busybox.net
Tue Feb 14 17:47:07 UTC 2006


Author: landley
Date: 2006-02-14 09:47:05 -0800 (Tue, 14 Feb 2006)
New Revision: 14014

Log:
Fix bug 674: sum's block count should always round up.


Modified:
   trunk/busybox/coreutils/sum.c


Changeset:
Modified: trunk/busybox/coreutils/sum.c
===================================================================
--- trunk/busybox/coreutils/sum.c	2006-02-14 16:05:32 UTC (rev 14013)
+++ trunk/busybox/coreutils/sum.c	2006-02-14 17:47:05 UTC (rev 14014)
@@ -34,10 +34,10 @@
    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 @@
 		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 @@
 		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 : "");
 




More information about the busybox-cvs mailing list