From 1a29f21bb24c531f450dd59446a0c5a0f7e81110 Mon Sep 17 00:00:00 2001 From: Darshit Shah Date: Sat, 1 Nov 2014 05:34:04 +0530 Subject: [PATCH] Remove extra padding from the progress bar --- src/ChangeLog | 7 +++++++ src/progress.c | 7 ++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 58bf905..214441f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2014-11-01 Darshit Shah + + * progress.c (create_image): Extra padding for size_grouped_diff has already + been added. Do not add that again. + (create_image): Assert that the progress bar being drawn is lesser than the + size of the screen. + 2014-10-29 Peter Meiser (tiny change) * openssl.c (ssl_init) [! OPENSSL_NO_SSL3]: Add guard for OpenSSL diff --git a/src/progress.c b/src/progress.c index 5ba542d..f211998 100644 --- a/src/progress.c +++ b/src/progress.c @@ -907,10 +907,6 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done) char *p = bp->buffer; wgint size = bp->initial_length + bp->count; - const char *size_grouped = with_thousand_seps (size); - int size_grouped_len = count_cols (size_grouped); - /* Difference between num cols and num bytes: */ - int size_grouped_diff = strlen (size_grouped) - size_grouped_len; int size_grouped_pad; /* Used to pad the field width for size_grouped. */ struct bar_progress_hist *hist = &bp->hist; @@ -1159,9 +1155,10 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done) move_to_end (p); } - while (p - bp->buffer - bytes_cols_diff - size_grouped_diff < bp->width) + while (p - bp->buffer - bytes_cols_diff < bp->width) *p++ = ' '; *p = '\0'; + assert (count_cols(bp->buffer) <= bp->width); } /* Print the contents of the buffer as a one-line ASCII "image" so -- 2.1.2