void
ws_percenttitle (double percentage_float)
{
- int percentage = (int) percentage_float;
+ int percentage;
- /* Only update the title when the percentage has changed. */
- if (percentage == old_percentage)
+ if (!title_buf || !curr_url)
return;
- old_percentage = percentage;
+ percentage = (int) percentage_float;
+ /* Clamp percentage value. */
+ if (percentage < 0)
+ percentage = 0;
if (percentage > 100)
+ percentage = 100;
+
+ /* Only update the title when the percentage has changed. */
+ if (percentage == old_percentage)
return;
- assert (title_buf != NULL);
- assert (curr_url != NULL);
+ old_percentage = percentage;
sprintf (title_buf, "Wget [%d%%] %s", percentage, curr_url);
SetConsoleTitle (title_buf);