[pacman-dev] [PATCH] Fix speed output edge case
Dan McGee
dpmcgee at gmail.com
Thu Nov 3 10:51:37 EDT 2011
On Thu, Nov 3, 2011 at 8:42 AM, Allan McRae <allan at archlinux.org> wrote:
> On 03/11/11 23:32, Allan McRae wrote:
>>
>> 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(-)
>>
>
> Seriously stuffed up creating this patch... Here is the actual diff which
> is on my working-maint branch:
Haha- I stared reading and then decided I needed more coffee before I
could understand it!
On that note, we have room for what you did there- is it worth it to
show an extra decimal place on the first one?
2.48M/s (this one shows as 2.4M/s now)
36.7M/s
103M/s
1004M/s
The diff for this, similar to your first one:
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 6f39013..14d8048 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -699,8 +699,11 @@ void cb_dl_progress(const char *filename, off_t
file_xfered, off_t file_total)
xfered_human = humanize_size(xfered, '\0', &xfered_label);
printf(" %ls%-*s ", wcfname, padwid, "");
- /* We will show 1.6M/s, 11.6M/s, but 116K/s and 1116K/s */
- if(rate_human < 100.0) {
+ /* We will show 1.62M/s, 11.6M/s, but 116K/s and 1116K/s */
+ if(rate_human < 9.995) {
+ printf("%6.1f %3s %4.2f%c/s ",
+ xfered_human, xfered_label,
rate_human, rate_label[0]);
+ } else if(rate_human < 99.95) {
printf("%6.1f %3s %4.1f%c/s ",
xfered_human, xfered_label,
rate_human, rate_label[0]);
} else {
More information about the pacman-dev
mailing list