X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Fprogress.c;h=6f24cd290e027094504b7479910e109141256f33;hb=bb0194c6e7181825cd6a1cf6440c05d9f99f6449;hp=613162fe9496aa87f8f8088f2cabe5aca15042ad;hpb=2e7aa7f76d7c45ba9d42be1f4425c9b7a67edf51;p=wget diff --git a/src/progress.c b/src/progress.c index 613162fe..6f24cd29 100644 --- a/src/progress.c +++ b/src/progress.c @@ -258,7 +258,13 @@ dot_create (wgint initial, wgint total) static void print_percentage (wgint bytes, wgint expected) { - int percentage = (int)(100.0 * bytes / expected); + /* This intentionally rounds to the floor value because it is a + measure of how much data *has* been retrieved. Therefore 12.8% + rounds to 12% because the 13% mark has not yet been reached. + Likewise, 100% is only shown when all data has been retrieved, + not before. */ + + int percentage = 100.0 * bytes / expected; logprintf (LOG_VERBOSE, "%3d%%", percentage); } @@ -754,7 +760,7 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done) /* "xx% " */ if (bp->total_length > 0) { - int percentage = (int)(100.0 * size / bp->total_length); + int percentage = 100.0 * size / bp->total_length; assert (percentage <= 100); if (percentage < 100) @@ -900,7 +906,7 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done) strcpy (p, eta_to_human_short ((int) (secs + 0.5))); else /* For very quick downloads show more exact timing information. */ - sprintf (p, _("%.*fs"), + sprintf (p, "%.*fs", secs < 0.001 ? 0 : /* 0s instead of 0.000s */ secs < 0.01 ? 3 : /* 0.00x */ secs < 0.1 ? 2 : /* 0.0x */ @@ -980,7 +986,12 @@ progress_handle_sigwinch (int sig) and hours are shown. This ensures brevity while still displaying as much as possible. - It never occupies more than 7 characters of screen space. */ + If SEP is false, the separator between minutes and seconds (and + hours and minutes, etc.) is not included, shortening the display by + one additional character. This is used for dot progress. + + The display never occupies more than 7 characters of screen + space. */ static const char * eta_to_human_short (int secs) @@ -988,9 +999,9 @@ eta_to_human_short (int secs) static char buf[10]; /* 8 should be enough, but just in case */ static int last = -1; - /* Trivial optimization. This function can be called every 200 - msecs (see bar_update) for fast downloads, but ETA will only - change once per 900 msecs (see create_image). */ + /* Trivial optimization. create_image can call us every 200 msecs + (see bar_update) for fast downloads, but ETA will only change + once per 900 msecs. */ if (secs == last) return buf; last = secs;