GNU Wget is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
-\(at your option) any later version.
+(at your option) any later version.
GNU Wget is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
};
static struct progress_implementation *current_impl;
-/* Default progress implementation should be something that works
+/* Progress implementation used by default. Can be overriden in
+ wgetrc or by the fallback one. */
+
+#define DEFAULT_PROGRESS_IMPLEMENTATION "bar"
+
+/* Fallnback 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
infloop. */
-#define DEFAULT_PROGRESS_IMPLEMENTATION "dot"
+#define FALLBACK_PROGRESS_IMPLEMENTATION "dot"
/* Return non-zero if NAME names a valid progress bar implementation.
The characters after the first : will be ignored. */
/* Align the [ skipping ... ] line with the dots. To do
that, insert the number of spaces equal to the number of
digits in the skipped amount in K. */
- logprintf (LOG_VERBOSE, "\n%*s%s",
- 2 + skipped_k_len, "", _("[ skipping %dK ]"));
+ logprintf (LOG_VERBOSE, _("\n%*s[ skipping %dK ]"),
+ 2 + skipped_k_len, "", skipped_k);
}
logprintf (LOG_VERBOSE, "\n%5ldK", skipped / 1024);
++dp->dots;
if (dp->dots >= opt.dots_in_line)
{
+ long row_qty = row_bytes;
+ if (dp->rows == dp->initial_length / row_bytes)
+ row_qty -= dp->initial_length % row_bytes;
+
++dp->rows;
dp->dots = 0;
if (dp->total_length)
print_percentage (dp->rows * row_bytes, dp->total_length);
-
- print_download_speed (dp,
- row_bytes - (dp->initial_length % row_bytes),
- dltime);
+ print_download_speed (dp, row_qty, dltime);
}
}
log_set_flush (0);
+ if (dp->dots == 0)
+ logprintf (LOG_VERBOSE, "\n%5ldK", dp->rows * row_bytes / 1024);
for (i = dp->dots; i < opt.dots_in_line; i++)
{
if (i % opt.dot_spacing == 0)
dp->total_length);
}
- print_download_speed (dp, dp->dots * dot_bytes
- + dp->accumulated
- - dp->initial_length % row_bytes,
- dltime);
- logputs (LOG_VERBOSE, "\n\n");
+ {
+ long row_qty = dp->dots * dot_bytes + dp->accumulated;
+ if (dp->rows == dp->initial_length / row_bytes)
+ row_qty -= dp->initial_length % row_bytes;
+ print_download_speed (dp, row_qty, dltime);
+ }
+ logputs (LOG_VERBOSE, "\n\n");
log_set_flush (0);
xfree (dp);
}
/* This function interprets the progress "parameters". For example,
- if Wget is invoked with --progress=bar:mega, it will set the
+ if Wget is invoked with --progress=dot:mega, it will set the
"dot-style" to "mega". Valid styles are default, binary, mega, and
giga. */
static void
dot_set_params (const char *params)
{
+ if (!params || !*params)
+ params = opt.dot_style;
+
if (!params)
return;
bp->width = screen_width;
bp->buffer = xmalloc (bp->width + 1);
- logputs (LOG_VERBOSE, "\n\n");
+ logputs (LOG_VERBOSE, "\n");
create_image (bp, 0);
display_image (bp->buffer);
/* We're not printing to a TTY, so revert to the fallback
display. #### We're recursively calling
set_progress_implementation here, which is slightly kludgy.
- It would be nicer if that function could resolve this problem
- itself. */
- set_progress_implementation (NULL);
+ It would be nicer if we provided that function a return value
+ indicating a failure of some sort. */
+ set_progress_implementation (FALLBACK_PROGRESS_IMPLEMENTATION);
return;
}