From 35bfcb34b0eb5ccc28c1e9f308678fd476f6fe22 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 0e0fad64..68ac883b 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-11-01 Giuseppe Scrivano * http.c (gethttp): Do not check for "Connection: close" header diff --git a/src/progress.c b/src/progress.c index 5ba542d7..a0b48e4f 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