[pacman-dev] [PATCH] Fix speed output edge case

Allan McRae allan at archlinux.org
Thu Nov 3 09:32:21 EDT 2011


Occasionally when the download rate showed 100.0 the output got messed up.
This was caused by the rounding of a number between 99.95 and 100. Adjust
the threshold to avoid this rounding issue.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 src/pacman/callback.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 5d7aed3..03d6266 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -698,11 +698,8 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
 
 	printf(" %ls%-*s ", wcfname, padwid, "");
 	/* We will show 1.6M/s, 11.6M/s, but 116K/s and 1116K/s */
-	if(rate_human < 9.95) {
-		printf("%6.1f %3s  %1.2f%c/s ",
-				xfered_human, xfered_label, rate_human, rate_label[0]);
-	} else if(rate_human < 99.95) {
-		printf("%6.1f %3s  %2.1f%c/s ",
+        if(rate_human < 99.95) {
+		printf("%6.1f %3s  %4.1f%c/s ",
 				xfered_human, xfered_label, rate_human, rate_label[0]);
 	} else {
 		printf("%6.1f %3s  %4.f%c/s ",
-- 
1.7.7.2



More information about the pacman-dev mailing list