hi.
i'm maintaining wget in mandrake linux distribution.

here're some patches we apply on top of wget:

- this patch print more usefull progression info:
--- ./src/progress.c.orig	2003-09-23 22:48:10.000000000 +0200
+++ ./src/progress.c	2003-12-11 10:29:23.000000000 +0100
@@ -253,10 +253,58 @@
 }
 
 static void
-print_percentage (long bytes, long expected)
-{
-  int percentage = (int)(100.0 * bytes / expected);
-  logprintf (LOG_VERBOSE, "%3d%%", percentage);
+print_percentage (long bytes, long expected,
+                  long row_size,
+                  long dltime, struct dot_progress *dp )
+{
+  int percentage = -1;
+  long d_time = 0; /* time elapsed since last call */
+  long speed = 0; /* download speed in bytes/sec */
+  long estimate = 0; /* estimated remaining time in seconds */
+  char buf[100];
+  char* pc;
+  
+  pc = buf;
+  *pc = 0;
+
+  if( dltime > dp->last_timer_value ) 
+    {
+    d_time = dltime - dp->last_timer_value;
+    speed = (long)( row_size / ( d_time / 1000.0 ) );
+    if ( speed > 0 )
+      estimate = ( expected - bytes ) / speed;
+    dp->last_timer_value = dltime;
+    }
+
+  if ( expected )
+    percentage = (int)(100.0 * bytes / expected);
+  pc += sprintf( pc, percentage >= 0 ? "%3d%% " : " ??%% ", percentage );
+
+  if ( d_time == 0 ) { /* we are too fast :) -- print percentage only */
+    logprintf( LOG_VERBOSE, "%s", buf );
+    return;
+    }
+
+  /* print download rate */
+  if ( speed < 1024 )
+    pc += sprintf( pc, "%4ldB", speed );
+  else if ( speed < 1024*10 )
+    pc += sprintf( pc, "%4.2fK", speed / 1024.0 );
+  else if ( speed < 1024*100 )
+    pc += sprintf( pc, "%4.1fK", speed / 1024.0 );
+  else if ( speed < 1024*1000 )
+    pc += sprintf( pc, "%4.0fK", speed / 1024.0 );
+  else if ( speed < 1024*1024*10 )
+    pc += sprintf( pc, "%4.2fM", speed / (1024.0*1024.0) );
+  else if ( speed < 1024*1024*100 )
+    pc += sprintf( pc, "%4.1fM", speed / (1024.0*1024.0) );
+  else
+    pc += sprintf( pc, "%4.0fM", speed / (1024.0*1024.0) );
+
+  /* print ETA in minutes:seconds */
+  pc += sprintf( pc, estimate > 0 ? "%4ld:%02ld" : "       ", estimate / 60, estimate % 60 );
+
+  logprintf( LOG_VERBOSE, "%s", buf );
 }
 
 static void
@@ -298,9 +346,8 @@
 	  ++dp->rows;
 	  dp->dots = 0;
 
-	  if (dp->total_length)
-	    print_percentage (dp->rows * row_bytes, dp->total_length);
-	  print_download_speed (dp, row_qty, dltime);
+    print_percentage (dp->rows * row_bytes, dp->total_length,
+                      row_qty, dltime, dp );
 	}
     }
 
@@ -327,19 +374,14 @@
 	logputs (LOG_VERBOSE, " ");
       logputs (LOG_VERBOSE, " ");
     }
-  if (dp->total_length)
-    {
-      print_percentage (dp->rows * row_bytes
-			+ dp->dots * dot_bytes
-			+ dp->accumulated,
-			dp->total_length);
-    }
-
   {
     long row_qty = dp->dots * dot_bytes + dp->accumulated;
     if (dp->rows == dp->initial_length / row_bytes)
       row_qty -= dp->initial_length % row_bytes;
-    print_download_speed (dp, row_qty, dltime);
+    print_percentage (dp->rows * row_bytes
+			+ dp->dots * dot_bytes
+			+ dp->accumulated,
+			dp->total_length, row_qty, dltime, dp );
   }
 
   logputs (LOG_VERBOSE, "\n\n");
- fix quotations of : and @ in username and password:
--- wget-1.8.1.orig/src/url.c
+++ wget-1.8.1/src/url.c
@@ -528,6 +528,11 @@
   memcpy (*user, str, len);
   (*user)[len] = '\0';
 
+  if (*user)
+    decode_string (*user);
+  if (*passwd)
+    decode_string (*passwd);
+  
   return 1;
 }
 
- allow allow @ in url passwords:
--- ./src/url.c.url_password	2003-12-11 10:30:58.000000000 +0100
+++ ./src/url.c	2003-12-11 10:32:38.000000000 +0100
@@ -466,12 +466,19 @@
 static int
 url_skip_credentials (const char *url)
 {
   /* Look for '@' that comes before terminators, such as '/', '?',
      '#', or ';'.  */
-  const char *p = (const char *)strpbrk (url, "@/?#;");
+  const char *p, *pp;
+  
-  if (!p || *p != '@')
-    return 0;
-  return p + 1 - url;
+  pp = url;
+  while ((p = (const char *)strpbrk (pp, "/?@")) != NULL) {
+    if (*p != '@')
+      break;
+    /* Found '@' character so go on with possible next '@'. */
+    pp = p + 1;
+  }
+  
+  return pp != url ? pp - url: 0;
 }
 
 /* Parse credentials contained in [BEG, END).  The region is expected
- allow log to stdout if one pass "-o - ":
--- wget-1.8.2/src/log.c.logstdout	2002-05-18 05:05:19.000000000 +0200
+++ wget-1.8.2/src/log.c	2003-01-22 22:36:55.000000000 +0100
@@ -560,11 +560,18 @@
 {
   if (file)
     {
-      logfp = fopen (file, appendp ? "a" : "w");
-      if (!logfp)
+      if (strcmp(file, "-"))
 	{
-	  perror (opt.lfilename);
-	  exit (1);
+          logfp = fopen (file, appendp ? "a" : "w");
+          if (!logfp)
+	    {
+	      perror (opt.lfilename);
+	      exit (1);
+	    }
+        }
+      else
+        {
+	  logfp = stdout;
 	}
     }
   else
- add --referrer on --referer due to typo fix:
Index: init.c 
=================================================================== 
RCS file: /pack/anoncvs/wget/src/init.c,v 
retrieving revision 1.54 
diff -u -c -r1.54 init.c 
--- src/init.c      2002/08/03 20:34:57     1.54 
+++ src/init.c      2003/05/23 15:47:42 
@@ -177,6 +177,7 @@
   { "reclevel",		&opt.reclevel,		cmd_number_inf },
   { "recursive",	NULL,			cmd_spec_recursive },
   { "referer",		&opt.referer,		cmd_string },
+  { "referrer",               &opt.referer,           cmd_string }, 
   { "reject",		&opt.rejects,		cmd_vector },
   { "relativeonly",	&opt.relative_only,	cmd_boolean },
   { "removelisting",	&opt.remove_listing,	cmd_boolean },
Index: main.c 
=================================================================== 
RCS file: /pack/anoncvs/wget/src/main.c,v 
retrieving revision 1.74 
diff -u -c -r1.74 main.c 
--- src/main.c      2002/05/18 02:16:23     1.74 
+++ src/main.c      2003/05/23 15:47:42 
@@ -330,6 +330,7 @@
     { "tries", required_argument, NULL, 't' },
     { "user-agent", required_argument, NULL, 'U' },
     { "referer", required_argument, NULL, 157 },
+    { "referrer", required_argument, NULL, 157 }, 
     { "use-proxy", required_argument, NULL, 'Y' },
 #ifdef HAVE_SSL
     { "sslcertfile", required_argument, NULL, 158 },
- fix french translation:
--- ./po/fr.po.frtypo	2003-10-14 17:03:20.000000000 +0200
+++ ./po/fr.po	2003-12-11 10:37:10.000000000 +0100
@@ -261,7 +261,7 @@
 
 #: src/ftp.c:910
 msgid " (unauthoritative)\n"
-msgstr " (non certifiée)\n"
+msgstr " (non sûre)\n"
 
 #: src/ftp.c:936
 #, c-format

Reply via email to