- if (num_urls == 1 && title_buf && curr_url && fabs(percent) <= 100.0)
- {
- sprintf (title_buf, "Wget [%.0f%%] %s", percent, curr_url);
- SetConsoleTitle (title_buf);
- }
+ int percentage = (int) percentage_float;
+
+ /* Only update the title when the percentage has changed. */
+ if (percentage == old_percentage)
+ return;
+
+ old_percentage = percentage;
+
+ if (percentage > 100)
+ return;
+
+ assert (title_buf != NULL);
+ assert (curr_url != NULL);
+
+ sprintf (title_buf, "Wget [%d%%] %s", percentage, curr_url);
+ SetConsoleTitle (title_buf);