[svn] * mswindows.c (ws_percenttitle): Guard against future changes by

doing nothing if the proper variables have not been initialized.
Clamp percentage value.
Submitted by David Fritz.
This commit is contained in:
hniksic 2004-03-03 16:06:46 -08:00
parent 5c07512ec9
commit 3f374f6db1
2 changed files with 18 additions and 7 deletions

View File

@ -1,3 +1,9 @@
2004-03-02 David Fritz <zeroxdf@att.net>
* mswindows.c (ws_percenttitle): Guard against future changes by
doing nothing if the proper variables have not been initialized.
Clamp percentage value.
2004-03-04 Gisle Vanem <giva@bgnett.no>
* retr.c (fd_read_body): Don't change console title if quiet.

View File

@ -180,7 +180,18 @@ ws_changetitle (const char *url)
void
ws_percenttitle (double percentage_float)
{
int percentage = (int) percentage_float;
int percentage;
if (!title_buf || !curr_url)
return;
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)
@ -188,12 +199,6 @@ ws_percenttitle (double percentage_float)
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);
}