#define DEFAULT_PROGRESS_IMPLEMENTATION "bar"
-/* Fallnback progress implementation should be something that works
+/* Fallback progress implementation should be something that works
under all display types. If you put something other than "dot"
here, remember that bar_set_params tries to switch to this if we're
not running on a TTY. So changing this to "bar" could cause
{
int i, namelen;
struct progress_implementation *pi = implementations;
- char *colon;
+ const char *colon;
if (!name)
name = DEFAULT_PROGRESS_IMPLEMENTATION;
wgint total_length; /* expected total byte count when the
download finishes */
- int accumulated;
+ int accumulated; /* number of bytes accumulated after
+ the last printed dot */
int rows; /* number of rows printed so far */
int dots; /* number of dots printed in this row */
int dot_bytes = opt.dot_bytes;
wgint row_bytes = opt.dot_bytes * opt.dots_in_line;
- int remainder = (int) (dp->initial_length % row_bytes);
+ int remainder = dp->initial_length % row_bytes;
wgint skipped = dp->initial_length - remainder;
if (skipped)
{
- int skipped_k = (int) (skipped / 1024); /* skipped amount in K */
+ int skipped_k = skipped / 1024; /* skipped amount in K */
int skipped_k_len = numdigit (skipped_k);
if (skipped_k_len < 5)
skipped_k_len = 5;
static void
print_percentage (wgint bytes, wgint expected)
{
- int percentage = (int)(100.0 * bytes / expected);
+ /* Round to the floor value in order to gauge how much data *has*
+ been retrieved. 12.8% will round to 12% because the 13% mark has
+ not yet been reached. 100% is only shown when done. */
+ int percentage = 100.0 * bytes / expected;
logprintf (LOG_VERBOSE, "%3d%%", percentage);
}
/* "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)
/* Translation note: "ETA" is English-centric, but this must
be short, ideally 3 chars. Abbreviate if necessary. */
- sprintf (p, " eta %s", eta_to_human_short (eta));
+ sprintf (p, _(" eta %s"), eta_to_human_short (eta));
move_to_end (p);
}
else if (bp->total_length > 0)
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 */
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)
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;