Index: vfile.h =================================================================== RCS file: /cvsroot/installer/poldek/vfile/vfile.h,v retrieving revision 1.29.4.3 retrieving revision 1.29.4.4 diff -u -r1.29.4.3 -r1.29.4.4 --- vfile/vfile.h 29 Mar 2004 00:26:25 -0000 1.29.4.3 +++ vfile/vfile.h 6 Jun 2004 20:38:53 -0000 1.29.4.4 @@ -10,7 +10,7 @@ 59 Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id$ */ +/* $Id$ */ #ifndef POLDEK_VFILE_H #define POLDEK_VFILE_H @@ -172,6 +172,7 @@ time_t time_last; float transfer_rate; float eta; /* estimatet time of arrival */ + int maxlen; }; void vfile_progress_init(struct vf_progress_bar *bar); Index: vfprogress.c =================================================================== RCS file: /cvsroot/installer/poldek/vfile/vfprogress.c,v retrieving revision 1.7.4.6 retrieving revision 1.7.4.7 diff -u -r1.7.4.6 -r1.7.4.7 --- vfile/vfprogress.c 9 May 2004 12:32:10 -0000 1.7.4.6 +++ vfile/vfprogress.c 6 Jun 2004 20:38:53 -0000 1.7.4.7 @@ -11,7 +11,7 @@ */ /* - $Id$ + $Id$ */ #include @@ -27,7 +27,7 @@ #define VFILE_INTERNAL #include "vfile.h" -#define PROGRESSBAR_WIDTH 30 +#define PROGRESSBAR_WIDTH 25 void vfile_progress_init(struct vf_progress_bar *bar) { @@ -118,6 +118,7 @@ } bar->time_base = bar->time_last = time(NULL); bar->state = VF_PROGRESS_RUNNING; + bar->maxlen = 0; } #define HASH_SIZE 8192 @@ -159,7 +160,7 @@ } else { char unit_line[45], amount_str[16], total_str[16]; - int nn, unit_n; + int nn; nbytes2str(total_str, sizeof(total_str), total); nbytes2str(amount_str, sizeof(amount_str), amount); @@ -182,10 +183,16 @@ n ? ", ": "", n ? eta_str : ""); } + if (nn > bar->maxlen) + bar->maxlen = nn; + - unit_n = sizeof(unit_line) - nn - 1; - if (unit_n > 0) + if (nn < bar->maxlen) { + int unit_n = bar->maxlen - nn; + n_assert(sizeof(unit_line) > nn + unit_n); memset(&unit_line[nn], ' ', unit_n); + } + unit_line[sizeof(unit_line) - 1] = '\0'; n_assert(n >= 0);