From 3f374f6db145ba5b41618cb6191d9d9e75c4cb1a Mon Sep 17 00:00:00 2001 From: hniksic Date: Wed, 3 Mar 2004 16:06:46 -0800 Subject: [PATCH] [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. --- src/ChangeLog | 6 ++++++ src/mswindows.c | 17 +++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) 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); -- 2.39.2