From: hniksic Date: Thu, 4 Mar 2004 00:06:46 +0000 (-0800) Subject: [svn] * mswindows.c (ws_percenttitle): Guard against future changes by X-Git-Tag: v1.13~1307 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=3f374f6db145ba5b41618cb6191d9d9e75c4cb1a [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. --- diff --git a/src/ChangeLog b/src/ChangeLog index 98cf7e17..98b1d7be 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2004-03-02 David Fritz + + * 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 * retr.c (fd_read_body): Don't change console title if quiet. diff --git a/src/mswindows.c b/src/mswindows.c index a2094900..f4affdd1 100644 --- a/src/mswindows.c +++ b/src/mswindows.c @@ -180,19 +180,24 @@ ws_changetitle (const char *url) 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);