Re: Windows titlebar fix

2004-03-03 Thread Hrvoje Niksic
"Gisle Vanem" <[EMAIL PROTECTED]> writes:

> ws_percenttitle() should not be called in quiet mode since
> ws_changetitle() AFAICS is only called in verbose mode. That caused
> an assert in mswindows.c. An easy patch:
[...]

I've applied this patch, thanks.



Re: Windows titlebar fix

2004-03-03 Thread Hrvoje Niksic
Applied now, thanks.



Re: Windows titlebar fix

2004-03-03 Thread Hrvoje Niksic
"Gisle Vanem" <[EMAIL PROTECTED]> writes:

>> We could also fix this by calling ws_changetitle() unconditionally.
>> Should the title bar be affected by verbosity?
>
> IMHO yes, Quiet is quiet.

I agree.



Re: Windows titlebar fix

2004-03-02 Thread David Fritz
The attached patch will cause ws_percenttitle() to do nothing if the relevant 
variables have not been initialized.  This is what the code did before I changed 
it.  I changed it because it seemed that the code was making allowances for 
things that should not happen and I thought an assert would be more appropriate. 
 Though, I guess doing thing this way will make the code more robust against 
future changes (and thus make the Windows port less of a maintenance burden). 
The patch also clamps the percentage value instead of just returning when it's 
out-of-range.  This is so it will update the title to display the percentage as 
100 in the arcane case when the previous percentage was < 100 and the new 
percentage is > 100.  It also includes Gisle Vanem's fix for retr.c.

[I know my assignment is pending but hopefully this patch is small enough to 
squeak-by until it's been processed.]

2004-03-02  David Fritz  <[EMAIL PROTECTED]>

* retr.c (fd_read_body): Under Windows, only call
ws_percenttitle() if verbose.  Fix by Gisle Vanem.
* mswindows.c (ws_percenttitle): Guard against future changes by
doing nothing if the proper variables have not been initialized.
Clamp percentage value.




Index: src/mswindows.c
===
RCS file: /pack/anoncvs/wget/src/mswindows.c,v
retrieving revision 1.27
diff -u -r1.27 mswindows.c
--- src/mswindows.c 2004/02/26 14:34:17 1.27
+++ src/mswindows.c 2004/03/03 03:21:27
@@ -180,19 +180,24 @@
 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);
Index: src/retr.c
===
RCS file: /pack/anoncvs/wget/src/retr.c,v
retrieving revision 1.84
diff -u -r1.84 retr.c
--- src/retr.c  2003/12/14 13:35:27 1.84
+++ src/retr.c  2004/03/03 03:21:31
@@ -311,7 +311,7 @@
   if (progress)
progress_update (progress, ret, wtimer_read (timer));
 #ifdef WINDOWS
-  if (toread > 0)
+  if (opt.verbose && toread > 0)
ws_percenttitle (100.0 *
 (startpos + sum_read) / (startpos + toread));
 #endif







Re: Windows titlebar fix

2004-03-02 Thread Gisle Vanem
> We could also fix this by calling ws_changetitle() unconditionally.  Should the 
> title bar be affected by verbosity?

IMHO yes, Quiet is quiet.

--gv



Re: Windows titlebar fix

2004-03-02 Thread David Fritz
Gisle Vanem wrote:

ws_percenttitle() should not be called in quiet mode since ws_changetitle() 
AFAICS is only called in verbose mode. That caused an assert in 
mswindows.c. An easy patch:

--- CVS-latest\src\retr.c   Sun Dec 14 14:35:27 2003
+++ src\retr.c  Tue Mar 02 21:18:55 2004
@@ -311,7 +311,7 @@
   if (progress)
progress_update (progress, ret, wtimer_read (timer));
 #ifdef WINDOWS
-  if (toread > 0)
+  if (toread > 0 && !opt.quiet)
ws_percenttitle (100.0 *
 (startpos + sum_read) / (startpos + toread));
 #endif
--gv


This is because of a patch I recently submitted.  The code in ws_percenttitle() 
used to just return if the relevant pointers were null.  I replaced that with 
the assert()s.  I failed to notice that ws_changetitle() is only called when 
opt.verbose is non-zero.  (After I removed the call to it from main().)  Sorry 
about that.

We could also fix this by calling ws_changetitle() unconditionally.  Should the 
title bar be affected by verbosity?

One minor nit regarding the above patch:  It should use opt.verbose instead of 
!opt.quiet so Wget won't assert when –nv is used.