]> sjero.net Git - wget/commitdiff
[svn] * mswindows.c (ws_percenttitle): Guard against future changes by
authorhniksic <devnull@localhost>
Thu, 4 Mar 2004 00:06:46 +0000 (16:06 -0800)
committerhniksic <devnull@localhost>
Thu, 4 Mar 2004 00:06:46 +0000 (16:06 -0800)
doing nothing if the proper variables have not been initialized.
Clamp percentage value.
Submitted by David Fritz.

src/ChangeLog
src/mswindows.c

index 98cf7e17995b3b23266e1c02eec82ca706ed3a57..98b1d7beb60adca2633a401d08e7e8e6994f0335 100644 (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.
index a2094900e1963eb43551dcc18c5e2dd670b3ba37..f4affdd1c0ad5dc7cc879d254c1c0e4b8dff01a0 100644 (file)
@@ -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);