From 8216f0acc5e257b5f80f8b8d6ee25bb5342bddfe Mon Sep 17 00:00:00 2001
From: Gisle Vanem <gvanem@broadpark.no>
Date: Tue, 2 Sep 2008 15:57:43 -0700
Subject: [PATCH 01/33] Ensure stdio.h is included.

---
 src/ChangeLog   | 5 +++++
 src/mswindows.h | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/src/ChangeLog b/src/ChangeLog
index 8acab925..9aab3a4b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-02  Gisle Vanem  <gvanem@broadpark.no>
+
+	* mswindows.h: Must ensure <stdio.h> is included before
+	we redefine ?vsnprintf().
+
 2008-08-08  Steven Schubiger  <stsc@members.fsf.org>
 
 	* main.c, utils.h: Removed some dead conditional DEBUG_MALLOC code.
diff --git a/src/mswindows.h b/src/mswindows.h
index 54821a7c..71687278 100644
--- a/src/mswindows.h
+++ b/src/mswindows.h
@@ -78,6 +78,8 @@ as that of the covered work.  */
 # define strncasecmp strnicmp
 #endif
 
+#include <stdio.h>
+
 /* The same for snprintf() and vsnprintf().  */
 #define snprintf _snprintf
 #define vsnprintf _vsnprintf

From 351619538982993bd3613cf5ab0c1e8abd5c5e83 Mon Sep 17 00:00:00 2001
From: Gisle Vanem <gvanem@broadpark.no>
Date: Tue, 9 Sep 2008 09:29:50 -0700
Subject: [PATCH 02/33] HAVE_STDINT_H, SIZEOF_LONG_LONG.

---
 windows/ChangeLog         | 8 ++++++++
 windows/config-compiler.h | 2 ++
 windows/config.h          | 4 +---
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/windows/ChangeLog b/windows/ChangeLog
index 8890265a..fd8d8157 100644
--- a/windows/ChangeLog
+++ b/windows/ChangeLog
@@ -1,3 +1,11 @@
+2008-09-09  Gisle Vanem  <gvanem@broadpark.no>
+
+	* config-compiler.h: MingW do have <stdint.h>; added HAVE_STDINT_H.
+	Added _CRT_SECURE_NO_WARNINGS to supress warnings in MSVC8+ about
+	using "old" ANSI-functions.
+
+	* config.h: config-post.h is gone. SIZEOF_LONG_LONG is 8.
+
 2008-01-25  Micah Cowan  <micah@cowan.name>
 
 	* Makefile.am, Makefile.doc, Makefile.src, Makefile.top,
diff --git a/windows/config-compiler.h b/windows/config-compiler.h
index 3ee0e638..a71fb429 100644
--- a/windows/config-compiler.h
+++ b/windows/config-compiler.h
@@ -83,6 +83,7 @@ as that of the covered work.  */
 
 /* MinGW and GCC support some POSIX and C99 features.  */
 #define HAVE_INTTYPES_H 1
+#define HAVE_STDINT_H 1
 
 #define HAVE__BOOL 1
 #undef SIZEOF_LONG_LONG		/* avoid redefinition warning */
@@ -128,6 +129,7 @@ as that of the covered work.  */
 #if _MSC_VER >= 1400
 #pragma warning ( disable : 4996 )
 #define _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_WARNINGS
 #endif
 
 
diff --git a/windows/config.h b/windows/config.h
index 9736b196..20aa7724 100644
--- a/windows/config.h
+++ b/windows/config.h
@@ -158,7 +158,7 @@
 #define SIZEOF_LONG 4
 
 /* The size of a `long long', as computed by sizeof. */
-#define SIZEOF_LONG_LONG 0
+#define SIZEOF_LONG_LONG 8
 
 /* The size of a `off_t', as computed by sizeof. */
 #define SIZEOF_OFF_T 4
@@ -214,5 +214,3 @@
 /* Include compiler-specific defines. */
 #include "config-compiler.h"
 
-#include "config-post.h"
-

From abeb6c4a9e8ede91354b6768628860638b98796f Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Tue, 9 Sep 2008 09:40:13 -0700
Subject: [PATCH 03/33] Define program_name, for lib/error.c.

---
 src/ChangeLog | 4 ++++
 src/main.c    | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/src/ChangeLog b/src/ChangeLog
index 9aab3a4b..015be198 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2008-09-09  Micah Cowan  <micah@cowan.name>
+
+	* main.c: Define program_name for lib/error.c.
+
 2008-09-02  Gisle Vanem  <gvanem@broadpark.no>
 
 	* mswindows.h: Must ensure <stdio.h> is included before
diff --git a/src/main.c b/src/main.c
index 3896afd0..b30fc3f2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -826,6 +826,8 @@ There is NO WARRANTY, to the extent permitted by law.\n"), stdout);
   exit (0);
 }
 
+char *program_name; /* Needed by lib/error.c. */
+
 int
 main (int argc, char **argv)
 {
@@ -834,6 +836,8 @@ main (int argc, char **argv)
   int nurl, status;
   bool append_to_log = false;
 
+  program_name = argv[0];
+
   i18n_initialize ();
 
   /* Construct the name of the executable, without the directory part.  */

From a38d9e7e7a35d7d6ddfb3be4f2191eebc3f04a38 Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Tue, 9 Sep 2008 10:20:21 -0700
Subject: [PATCH 04/33] Avoid unnecessary vars, and make wgetrc_file_name build
 properly on Windows.

---
 src/ChangeLog    |  7 ++++++
 src/build_info.c |  3 ---
 src/init.c       | 57 +++++++++++++++++++++++++++++-------------------
 src/main.c       | 12 ++++++----
 4 files changed, 49 insertions(+), 30 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 015be198..74f3653a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,12 @@
 2008-09-09  Micah Cowan  <micah@cowan.name>
 
+	* init.c (home_dir): Save the calculated value for home,
+	to avoid duplicated work on repeated calls.
+	(wgetrc_file_name) [WINDOWS]: Define and initialize home var.
+
+	* build_info.c: Remove unnecessary extern vars system_wgetrc and
+	locale_dir.
+
 	* main.c: Define program_name for lib/error.c.
 
 2008-09-02  Gisle Vanem  <gvanem@broadpark.no>
diff --git a/src/build_info.c b/src/build_info.c
index ee843ce9..551b7d94 100644
--- a/src/build_info.c
+++ b/src/build_info.c
@@ -33,9 +33,6 @@ as that of the covered work.  */
 #include "wget.h"
 #include <stdio.h>
 
-char *system_wgetrc = SYSTEM_WGETRC;
-char *locale_dir = LOCALEDIR;
-
 const char* (compiled_features[]) =
 {
 
diff --git a/src/init.c b/src/init.c
index a774061b..768bebd1 100644
--- a/src/init.c
+++ b/src/init.c
@@ -338,35 +338,41 @@ defaults (void)
 char *
 home_dir (void)
 {
-  char *home = getenv ("HOME");
+  static char buf[PATH_MAX];
+  static char *home;
 
   if (!home)
     {
+      home = getenv ("HOME");
+      if (!home)
+        {
 #if defined(MSDOS)
-      /* Under MSDOS, if $HOME isn't defined, use the directory where
-         `wget.exe' resides.  */
-      const char *_w32_get_argv0 (void); /* in libwatt.a/pcconfig.c */
-      char *p, buf[PATH_MAX];
+          /* Under MSDOS, if $HOME isn't defined, use the directory where
+             `wget.exe' resides.  */
+          const char *_w32_get_argv0 (void); /* in libwatt.a/pcconfig.c */
+          char *p;
 
-      strcpy (buf, _w32_get_argv0 ());
-      p = strrchr (buf, '/');            /* djgpp */
-      if (!p)
-        p = strrchr (buf, '\\');          /* others */
-      assert (p);
-      *p = '\0';
-      home = buf;
+          strcpy (buf, _w32_get_argv0 ());
+          p = strrchr (buf, '/');            /* djgpp */
+          if (!p)
+            p = strrchr (buf, '\\');          /* others */
+          assert (p);
+          *p = '\0';
+          home = buf;
 #elif !defined(WINDOWS)
-      /* If HOME is not defined, try getting it from the password
-         file.  */
-      struct passwd *pwd = getpwuid (getuid ());
-      if (!pwd || !pwd->pw_dir)
-        return NULL;
-      home = pwd->pw_dir;
+          /* If HOME is not defined, try getting it from the password
+             file.  */
+          struct passwd *pwd = getpwuid (getuid ());
+          if (!pwd || !pwd->pw_dir)
+            return NULL;
+          strcpy (buf, pwd->pw_dir);
+          home = buf;
 #else  /* !WINDOWS */
-      /* Under Windows, if $HOME isn't defined, use the directory where
-         `wget.exe' resides.  */
-      home = ws_mypath ();
+          /* Under Windows, if $HOME isn't defined, use the directory where
+             `wget.exe' resides.  */
+          home = ws_mypath ();
 #endif /* WINDOWS */
+        }
     }
 
   return home ? xstrdup (home) : NULL;
@@ -392,12 +398,13 @@ wgetrc_env_file_name (void)
     }
   return NULL;
 }
+
 /* Check for the existance of '$HOME/.wgetrc' and return it's path
    if it exists and is set.  */
 char *
 wgetrc_user_file_name (void) 
 {
-  char *home = home_dir();
+  char *home = home_dir ();
   char *file = NULL;
   if (home)
     file = aprintf ("%s/.wgetrc", home);
@@ -411,6 +418,7 @@ wgetrc_user_file_name (void)
     }
   return file;
 }
+
 /* Return the path to the user's .wgetrc.  This is either the value of
    `WGETRC' environment variable, or `$HOME/.wgetrc'.
 
@@ -419,10 +427,11 @@ wgetrc_user_file_name (void)
 char *
 wgetrc_file_name (void)
 {
+  char *home = NULL;
   char *file = wgetrc_env_file_name ();
   if (file && *file)
     return file;
-
+  
   file = wgetrc_user_file_name ();
 
 #ifdef WINDOWS
@@ -430,6 +439,7 @@ wgetrc_file_name (void)
      `wget.ini' in the directory where `wget.exe' resides; we do this for
      backward compatibility with previous versions of Wget.
      SYSTEM_WGETRC should not be defined under WINDOWS.  */
+  home = home_dir ();
   if (!file || !file_exists_p (file))
     {
       xfree_null (file);
@@ -438,6 +448,7 @@ wgetrc_file_name (void)
       if (home)
         file = aprintf ("%s/wget.ini", home);
     }
+  xfree_null (home);
 #endif /* WINDOWS */
 
   if (!file)
diff --git a/src/main.c b/src/main.c
index b30fc3f2..268a603f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -72,8 +72,6 @@ extern char *system_getrc;
 extern char *link_string;
 /* defined in build_info.c */
 extern char *compiled_features[];
-extern char *system_wgetrc;
-extern char *locale_dir;
 /* Used for --version output in print_version */
 static const int max_chars_per_line = 72;
 
@@ -743,6 +741,10 @@ format_and_print_line (char* prefix, char* line,
     }
 
   printf ("\n");
+
+  /* FIXME: Responsibility for deallocation should be handled by
+     whatever allocated it, wherever possible. These two lines result
+     in unnecessary strdup calls in the print_version function. */
   xfree (prefix);
   xfree (line);
 }
@@ -794,10 +796,12 @@ print_version (void)
       printf ("%s (user)\n%s", user_wgetrc, prefix_spaces);
       xfree (user_wgetrc);
     }
-  printf ("%s (system)\n", system_wgetrc);
+#ifdef SYSTEM_WGETRC
+  printf ("%s (system)\n", SYSTEM_WGETRC);
+#endif
 
   format_and_print_line (strdup (locale_title),
-			 strdup (locale_dir), 
+			 strdup (LOCALEDIR), 
 			 max_chars_per_line);
   
   format_and_print_line (strdup (compile_title),

From b58816ed33c2f167ce2e199df37fe1749d67605e Mon Sep 17 00:00:00 2001
From: Gisle Vanem <gvanem@broadpark.no>
Date: Tue, 9 Sep 2008 10:26:44 -0700
Subject: [PATCH 05/33] aprintf, not asprintf.

---
 src/ChangeLog | 8 ++++++--
 src/url.c     | 4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 74f3653a..8fe0e34b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,11 +1,15 @@
+2008-09-09  Gisle Vanem  <gvanem@broadpark.no>
+
+	* url.c (url_error): Use aprintf, not asprintf.
+	
 2008-09-09  Micah Cowan  <micah@cowan.name>
 
 	* init.c (home_dir): Save the calculated value for home,
 	to avoid duplicated work on repeated calls.
 	(wgetrc_file_name) [WINDOWS]: Define and initialize home var.
 
-	* build_info.c: Remove unnecessary extern vars system_wgetrc and
-	locale_dir.
+	* build_info.c, main.c: Remove unnecessary extern vars
+	system_wgetrc and locale_dir.
 
 	* main.c: Define program_name for lib/error.c.
 
diff --git a/src/url.c b/src/url.c
index 3f4b8992..fea95584 100644
--- a/src/url.c
+++ b/src/url.c
@@ -900,9 +900,9 @@ url_error (const char *url, int error_code)
       if ((p = strchr (scheme, ':')))
         *p = '\0';
       if (!strcasecmp (scheme, "https"))
-        asprintf (&error, _("HTTPS support not compiled in"));
+        error = aprintf (_("HTTPS support not compiled in"));
       else
-        asprintf (&error, _(parse_errors[error_code]), quote (scheme));
+        error = aprintf (_(parse_errors[error_code]), quote (scheme));
       xfree (scheme);
 
       return error;

From 86d716810504787bc30ce3d248f646b423a5ff15 Mon Sep 17 00:00:00 2001
From: Michael Kessler <kessler.michael@aon.at>
Date: Wed, 10 Sep 2008 08:42:42 -0700
Subject: [PATCH 06/33] downloads => download

---
 doc/ChangeLog | 5 +++++
 doc/wget.texi | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/doc/ChangeLog b/doc/ChangeLog
index cea5f7b5..398e4e51 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-10  Michael Kessler  <kessler.michael@aon.at>
+
+	* wget.texi (Robot Exclusion): Fixed typo "downloads" ->
+	"download"
+
 2008-08-03  Micah Cowan  <micah@cowan.name>
 
 	* wget.texi: Don't set UPDATED; already set by version.texi.
diff --git a/doc/wget.texi b/doc/wget.texi
index 9cb5db99..c3209235 100644
--- a/doc/wget.texi
+++ b/doc/wget.texi
@@ -3599,7 +3599,7 @@ avoid.  To be found by the robots, the specifications must be placed in
 download and parse.
 
 Although Wget is not a web robot in the strictest sense of the word, it
-can downloads large parts of the site without the user's intervention to
+can download large parts of the site without the user's intervention to
 download an individual page.  Because of that, Wget honors RES when
 downloading recursively.  For instance, when you issue:
 

From a32d41c5d0b878e312174f4c438e5bf40d170b60 Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Sat, 25 Oct 2008 06:49:35 -0700
Subject: [PATCH 07/33] How many options remain available?

---
 util/freeopts | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100755 util/freeopts

diff --git a/util/freeopts b/util/freeopts
new file mode 100755
index 00000000..0df22a79
--- /dev/null
+++ b/util/freeopts
@@ -0,0 +1,48 @@
+#!/usr/bin/perl -n
+# NOTE the use of -n above; this script is called in a loop.
+use warnings;
+use strict;
+
+our $scanning;
+our %used_chars;
+BEGIN {
+    $scanning = 0;
+    %used_chars = ();
+
+    open STDIN, "../src/main.c" or die "main.c: $!\n";
+}
+
+if (/^static struct cmdline_option option_data/) {
+    $scanning = 1;
+}
+elsif (/[}];/) {
+    $scanning = 0;
+}
+elsif (
+    $scanning &&
+    /^[\t ]*\{ "[^"]*", '(.)', OPT_[A-Z0-9_]*, /
+) {
+    $used_chars{$1} = 1;
+}
+
+END {
+    my $cols = 0;
+    my $max_cols = 13;
+    my $opt_chars = 
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%+/";
+    print "Free chars:\n\t";
+    for (my $i = 0; $i < length $opt_chars; ++$i, ++$cols) {
+        if ($cols == $max_cols) {
+            $cols = 0;
+            print "\n\t";
+        }
+        my $opt = substr($opt_chars,$i,1);
+        print ' ';
+        if (!$used_chars{ $opt }) {
+            print $opt;
+        } else {
+            print ' ';
+        }
+    }
+    print "\n";
+}

From b4ebafa39cc21ad4b2dc840f35fd2570dd88cbe8 Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Sat, 25 Oct 2008 07:13:24 -0700
Subject: [PATCH 08/33] Minor tweaks to freeopts.

---
 util/freeopts | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/util/freeopts b/util/freeopts
index 0df22a79..75f594a1 100755
--- a/util/freeopts
+++ b/util/freeopts
@@ -29,7 +29,7 @@ END {
     my $cols = 0;
     my $max_cols = 13;
     my $opt_chars = 
-    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%+/";
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
     print "Free chars:\n\t";
     for (my $i = 0; $i < length $opt_chars; ++$i, ++$cols) {
         if ($cols == $max_cols) {
@@ -39,9 +39,9 @@ END {
         my $opt = substr($opt_chars,$i,1);
         print ' ';
         if (!$used_chars{ $opt }) {
-            print $opt;
+            print "-$opt";
         } else {
-            print ' ';
+            print '  ';
         }
     }
     print "\n";

From 871992e247a5838dbb5a6d2580460b2fec67b2c1 Mon Sep 17 00:00:00 2001
From: Gisle Vanem <gvanem@broadpark.no>
Date: Sun, 26 Oct 2008 13:18:36 -0700
Subject: [PATCH 09/33] Compatibility tweaks to format_and_print_line.

---
 src/ChangeLog |  6 ++++++
 src/main.c    | 22 +++++++++++++++-------
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 8fe0e34b..e4f98d75 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2008-10-26  Gisle Vanem  <gvanem@broadpark.no>
+
+	* main.c (format_and_print_line): Put variables on top of
+	blocks (not all compilers are C99). Add an extra '\n' if
+	SYSTEM_WGETRC isn't defined and printed.
+
 2008-09-09  Gisle Vanem  <gvanem@broadpark.no>
 
 	* url.c (url_error): Use aprintf, not asprintf.
diff --git a/src/main.c b/src/main.c
index 268a603f..46e54445 100644
--- a/src/main.c
+++ b/src/main.c
@@ -709,17 +709,21 @@ static void
 format_and_print_line (char* prefix, char* line,
 		       int line_length) 
 {
+  int leading_spaces;
+  int remaining_chars;
+  char *token;
+  
   assert (prefix != NULL);
   assert (line != NULL);
 
   if (line_length <= 0)
     line_length = max_chars_per_line;
 
-  const int leading_spaces = strlen (prefix);
+  leading_spaces = strlen (prefix);
   printf ("%s", prefix);
-  int remaining_chars = line_length - leading_spaces;
+  remaining_chars = line_length - leading_spaces;
   /* We break on spaces. */
-  char* token = strtok (line, " ");
+  token = strtok (line, " ");
   while (token != NULL) 
     {
       /* If however a token is much larger than the maximum
@@ -727,8 +731,9 @@ format_and_print_line (char* prefix, char* line,
          token on the next line. */
       if (remaining_chars <= strlen (token)) 
         {
+          int j;
           printf ("\n");
-          int j = 0;
+          j = 0;
           for (j = 0; j < leading_spaces; j++) 
             {
               printf (" ");
@@ -759,13 +764,14 @@ print_version (void)
   const char *link_title    = "Link       : ";
   const char *prefix_spaces = "             ";
   const int prefix_space_length = strlen (prefix_spaces);
+  char *env_wgetrc, *user_wgetrc;
+  int i;
 
   printf ("GNU Wget %s\n", version_string);
   printf (options_title);
   /* compiled_features is a char*[]. We limit the characters per
      line to max_chars_per_line and prefix each line with a constant
      number of spaces for proper alignment. */
-  int i =0;
   for (i = 0; compiled_features[i] != NULL; ) 
     {
       int line_length = max_chars_per_line - prefix_space_length;
@@ -784,13 +790,13 @@ print_version (void)
   /* Handle the case when $WGETRC is unset and $HOME/.wgetrc is 
      absent. */
   printf (wgetrc_title);
-  char *env_wgetrc = wgetrc_env_file_name ();
+  env_wgetrc = wgetrc_env_file_name ();
   if (env_wgetrc && *env_wgetrc) 
     {
       printf ("%s (env)\n%s", env_wgetrc, prefix_spaces);
       xfree (env_wgetrc);
     }
-  char *user_wgetrc = wgetrc_user_file_name ();
+  user_wgetrc = wgetrc_user_file_name ();
   if (user_wgetrc) 
     {
       printf ("%s (user)\n%s", user_wgetrc, prefix_spaces);
@@ -798,6 +804,8 @@ print_version (void)
     }
 #ifdef SYSTEM_WGETRC
   printf ("%s (system)\n", SYSTEM_WGETRC);
+#else
+  putchar ('\n');
 #endif
 
   format_and_print_line (strdup (locale_title),

From 1228f812fa6dfb3f63f20fe82113ced88e558fd1 Mon Sep 17 00:00:00 2001
From: Steven Schubiger <stsc@members.fsf.org>
Date: Sun, 26 Oct 2008 14:32:11 -0700
Subject: [PATCH 10/33] Document missing wgetrc options.

---
 NEWS          |  3 +++
 doc/ChangeLog |  5 +++++
 doc/wget.texi | 13 +++++++++++++
 3 files changed, 21 insertions(+)

diff --git a/NEWS b/NEWS
index 7d15a98a..a570318b 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,9 @@ support password prompts at the console.
  
 ** The --input-file option now also handles retrieving links from
 an external file.
+
+** Several previously existing, but undocumented .wgetrc options
+are now documented: save_headers, spider, and user_agent.
 
 * Changes in Wget 1.11.4
 
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 398e4e51..b440bb49 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-30  Steven Schubiger  <stsc@members.fsf.org>
+
+	* wget.texi (Wgetrc Commands): Add default_page, save_headers, 
+	spider and user_agent to the list of recognized commands.
+
 2008-09-10  Michael Kessler  <kessler.michael@aon.at>
 
 	* wget.texi (Robot Exclusion): Fixed typo "downloads" ->
diff --git a/doc/wget.texi b/doc/wget.texi
index c3209235..222ae494 100644
--- a/doc/wget.texi
+++ b/doc/wget.texi
@@ -2671,6 +2671,9 @@ Ignore @var{n} remote directory components.  Equivalent to
 @item debug = on/off
 Debug mode, same as @samp{-d}.
 
+@item default_page = @var{string}
+Default page name---the same as @samp{--default-page=@var{string}}.
+
 @item delete_after = on/off
 Delete after download---the same as @samp{--delete-after}.
 
@@ -2963,6 +2966,9 @@ this off.
 Save cookies to @var{file}.  The same as @samp{--save-cookies
 @var{file}}.
 
+@item save_headers = on/off
+Same as @samp{--save-headers}.
+
 @item secure_protocol = @var{string}
 Choose the secure protocol to be used.  Legal values are @samp{auto}
 (the default), @samp{SSLv2}, @samp{SSLv3}, and @samp{TLSv1}.  The same
@@ -2975,6 +2981,9 @@ responses---the same as @samp{-S}.
 @item span_hosts = on/off
 Same as @samp{-H}.
 
+@item spider = on/off
+Same as @samp{--spider}.
+
 @item strict_comments = on/off
 Same as @samp{--strict-comments}.
 
@@ -2998,6 +3007,10 @@ Specify username @var{string} for both @sc{ftp} and @sc{http} file retrieval.
 This command can be overridden using the @samp{ftp_user} and 
 @samp{http_user} command for @sc{ftp} and @sc{http} respectively.
 
+@item user_agent = @var{string}
+User agent identification sent to the HTTP Server---the same as
+@samp{--user-agent=@var{string}}.
+
 @item verbose = on/off
 Turn verbose on/off---the same as @samp{-v}/@samp{-nv}.
 

From b0bdf9549464dcf6058d55aeb81220b73cd9701c Mon Sep 17 00:00:00 2001
From: Alexander Drozdov <dzal_mail@mtu-net.ru>
Date: Fri, 31 Oct 2008 11:13:10 -0700
Subject: [PATCH 11/33] Fix underflow, incorrect assertion.

---
 src/ChangeLog | 6 ++++++
 src/ftp-ls.c  | 1 +
 src/retr.c    | 2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index e4f98d75..8a162245 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2008-10-31  Alexander Drozdov  <dzal_mail@mtu-net.ru>
+
+	* retr.c (fd_read_hunk): Make assert deal with maxsize == 0.
+
+	* ftp-ls.c (clean_line): Prevent underflow on empty lines.
+
 2008-10-26  Gisle Vanem  <gvanem@broadpark.no>
 
 	* main.c (format_and_print_line): Put variables on top of
diff --git a/src/ftp-ls.c b/src/ftp-ls.c
index 409996c3..660302e5 100644
--- a/src/ftp-ls.c
+++ b/src/ftp-ls.c
@@ -75,6 +75,7 @@ clean_line(char *line)
   if (!len) return 0; 
   if (line[len - 1] == '\n')
     line[--len] = '\0';
+  if (!len) return 0; 
   if (line[len - 1] == '\r')
     line[--len] = '\0';
   for ( ; *line ; line++ ) if (*line == '\t') *line = ' '; 
diff --git a/src/retr.c b/src/retr.c
index 85774297..21c9002e 100644
--- a/src/retr.c
+++ b/src/retr.c
@@ -393,7 +393,7 @@ fd_read_hunk (int fd, hunk_terminator_t terminator, long sizehint, long maxsize)
   char *hunk = xmalloc (bufsize);
   int tail = 0;                 /* tail position in HUNK */
 
-  assert (maxsize >= bufsize);
+  assert (!maxsize || maxsize >= bufsize);
 
   while (1)
     {

From fc7e412bd3f8d91b2f2722eb0bdb545f2dd63e70 Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Fri, 31 Oct 2008 23:15:06 -0700
Subject: [PATCH 12/33] Mailing list move.

---
 ChangeLog     |  6 ++++++
 MAILING-LIST  | 50 +++++++++++++++++++++-----------------------------
 NEWS          |  2 ++
 doc/ChangeLog |  5 +++++
 doc/wget.texi | 49 ++++++++++++++++++++++++-------------------------
 src/ChangeLog |  4 ++++
 src/main.c    |  2 ++
 7 files changed, 64 insertions(+), 54 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4bd9e3b3..ce3f42cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-10-31  Micah Cowan  <micah@cowan.name>
+
+	* MAILING-LIST: Update information.
+
+	* NEWS: Add mention of mailing list move.
+
 2008-08-01  Joao Ferreira  <joao@joaoff.com>
 
 	* NEWS: Added option --default-page to support alternative
diff --git a/MAILING-LIST b/MAILING-LIST
index bab1629c..93a5b2d4 100644
--- a/MAILING-LIST
+++ b/MAILING-LIST
@@ -1,33 +1,25 @@
 Mailing List
-================
+============
 
-There are several Wget-related mailing lists.  The general discussion
-list is at <wget@sunsite.dk>.  It is the preferred place for support
-requests and suggestions, as well as for discussion of development.
-You are invited to subscribe.
+The primary mailinglist for discussion, bug-reports, or questions about
+GNU Wget is at <bug-wget@gnu.org>. To subscribe, send an email to
+<bug-wget-join@gnu.org>, or visit
+`http://lists.gnu.org/mailman/listinfo/bug-wget'.
 
-   To subscribe, simply send mail to <wget-subscribe@sunsite.dk> and
-follow the instructions.  Unsubscribe by mailing to
-<wget-unsubscribe@sunsite.dk>.  The mailing list is archived at
-`http://www.mail-archive.com/wget%40sunsite.dk/' and at
-`http://news.gmane.org/gmane.comp.web.wget.general'.
-
-   Another mailing list is at <wget-patches@sunsite.dk>, and is used to
-submit patches for review by Wget developers.  A "patch" is a textual
-representation of change to source code, readable by both humans and
-programs.  The file `PATCHES' that comes with Wget covers the creation
-and submitting of patches in detail.  Please don't send general
-suggestions or bug reports to `wget-patches'; use it only for patch
-submissions.
-
-   Subscription is the same as above for <wget@sunsite.dk>, except that
-you send to <wget-patches-subscribe@sunsite.dk>, instead.  The mailing
-list is archived at `http://news.gmane.org/gmane.comp.web.wget.patches'.
-
-   Finally, there is the <wget-notify@addictivecode.org> mailing list.
-This is a non-discussion list that receives commit notifications from
-the source repository, and also bug report-change notifications.  This
-is the highest-traffic list for Wget, and is recommended only for
-people who are seriously interested in ongoing Wget development.
-Subscription is through the `mailman' interface at
+   Additionally, there is the <wget-notify@addictivecode.org> mailing
+list. This is a non-discussion list that receives bug report
+notifications from the bug-tracker. To subscribe to this list, send an
+email to <wget-notify-join@addictivecode.org>, or visit
 `http://addictivecode.org/mailman/listinfo/wget-notify'.
+
+   Previously, the mailing list <wget@sunsite.dk> was used as the main
+discussion list, and another list, <wget-patches@sunsite.dk> was used
+for submitting and discussing patches to GNU Wget.
+
+   Messages from <wget@sunsite.dk> are archived at
+     `http://www.mail-archive.com/wget%40sunsite.dk/' and at
+
+     `http://news.gmane.org/gmane.comp.web.wget.general'.
+
+   Messages from <wget-patches@sunsite.dk> are archived at
+     `http://news.gmane.org/gmane.comp.web.wget.patches'.
diff --git a/NEWS b/NEWS
index a570318b..3ae5e5ad 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ Please send GNU Wget bug reports to <bug-wget@gnu.org>.
 
 * Changes in Wget 1.12 (MAINLINE)
 
+** Mailing list MOVED to bug-wget@gnu.org
+
 ** --default-page option added to support alternative default names for
 index.html.
 
diff --git a/doc/ChangeLog b/doc/ChangeLog
index b440bb49..5d5067ae 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-31  Micah Cowan  <micah@cowan.name>
+
+	* wget.texi (Mailing List): Update info to reflect change to
+	bug-wget@gnu.org.
+
 2008-09-30  Steven Schubiger  <stsc@members.fsf.org>
 
 	* wget.texi (Wgetrc Commands): Add default_page, save_headers, 
diff --git a/doc/wget.texi b/doc/wget.texi
index 222ae494..b0891c0a 100644
--- a/doc/wget.texi
+++ b/doc/wget.texi
@@ -3409,36 +3409,35 @@ information resides at ``The Wget Wgiki'',
 @cindex mailing list
 @cindex list
 
-There are several Wget-related mailing lists.  The general discussion
-list is at @email{wget@@sunsite.dk}.  It is the preferred place for
-support requests and suggestions, as well as for discussion of
-development.  You are invited to subscribe.
+The primary mailinglist for discussion, bug-reports, or questions
+about GNU Wget is at @email{bug-wget@@gnu.org}. To subscribe, send an
+email to @email{bug-wget-join@@gnu.org}, or visit
+@url{http://lists.gnu.org/mailman/listinfo/bug-wget}.
 
-To subscribe, simply send mail to @email{wget-subscribe@@sunsite.dk}
-and follow the instructions.  Unsubscribe by mailing to
-@email{wget-unsubscribe@@sunsite.dk}.  The mailing list is archived at
+Additionally, there is the @email{wget-notify@@addictivecode.org} mailing
+list. This is a non-discussion list that receives bug report
+notifications from the bug-tracker. To subscribe to this list,
+send an email to @email{wget-notify-join@@addictivecode.org},
+or visit @url{http://addictivecode.org/mailman/listinfo/wget-notify}.
+
+Previously, the mailing list @email{wget@@sunsite.dk} was used as the
+main discussion list, and another list,
+@email{wget-patches@@sunsite.dk} was used for submitting and
+discussing patches to GNU Wget.
+
+Messages from @email{wget@@sunsite.dk} are archived at
+@itemize @tie{}
+@item
 @url{http://www.mail-archive.com/wget%40sunsite.dk/} and at
+@item
 @url{http://news.gmane.org/gmane.comp.web.wget.general}.
+@end itemize
 
-Another mailing list is at @email{wget-patches@@sunsite.dk}, and is
-used to submit patches for review by Wget developers.  A ``patch'' is
-a textual representation of change to source code, readable by both
-humans and programs.  The
-@url{http://wget.addictivecode.org/PatchGuidelines} page
-covers the creation and submitting of patches in detail.  Please don't
-send general suggestions or bug reports to @samp{wget-patches}; use it
-only for patch submissions.
-
-Subscription is the same as above for @email{wget@@sunsite.dk}, except
-that you send to @email{wget-patches-subscribe@@sunsite.dk}, instead.
-The mailing list is archived at
+Messages from @email{wget-patches@@sunsite.dk} are archived at
+@itemize @tie{}
+@item
 @url{http://news.gmane.org/gmane.comp.web.wget.patches}.
-
-Finally, there is the @email{wget-notify@@addictivecode.org} mailing
-list. This is a non-discussion list that receives bug report-change
-notifications from the bug-tracker.  Unlike for the other mailing lists,
-subscription is through the @code{mailman} interface at
-@url{http://addictivecode.org/mailman/listinfo/wget-notify}.
+@end itemize
 
 @node Internet Relay Chat
 @section Internet Relay Chat
diff --git a/src/ChangeLog b/src/ChangeLog
index 8a162245..79104873 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-31  Micah Cowan  <micah@cowan.name>
+
+	* main.c (print_version): Add information about the mailing list.
+
 2008-10-31  Alexander Drozdov  <dzal_mail@mtu-net.ru>
 
 	* retr.c (fd_read_hunk): Make assert deal with maxsize == 0.
diff --git a/src/main.c b/src/main.c
index 46e54445..c39a98aa 100644
--- a/src/main.c
+++ b/src/main.c
@@ -835,6 +835,8 @@ There is NO WARRANTY, to the extent permitted by law.\n"), stdout);
          stdout);
   fputs (_("Currently maintained by Micah Cowan <micah@cowan.name>.\n"),
          stdout);
+  fputs (_("Please send bug reports and questions to <bug-wget@gnu.org>.\n"),
+         stdout);
   exit (0);
 }
 

From a791aaded39be27c0d20df1d395500fa5a4db053 Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Fri, 31 Oct 2008 23:15:45 -0700
Subject: [PATCH 13/33] Removed no-longer-used README.maint.

---
 doc/README.maint | 130 -----------------------------------------------
 1 file changed, 130 deletions(-)
 delete mode 100644 doc/README.maint

diff --git a/doc/README.maint b/doc/README.maint
deleted file mode 100644
index 71eccbf1..00000000
--- a/doc/README.maint
+++ /dev/null
@@ -1,130 +0,0 @@
-
-TO RELEASE WGET X.Y.Z:
-
-1) update PO files from the TP
-
-cd po
-../util/update_po_files.sh
-
-
-2) generate tarball
-
-from the trunk:
-
-cd ~/tmp
-~/code/svn/wget/trunk/util/dist-wget --force-version X.Y.Z
-
-from a branch:
-
-cd ~/tmp
-~/code/svn/wget/branches/X.Y/util/dist-wget --force-version X.Y.Z -b branches/X.Y
-
-
-3) test the tarball
-
-
-4) set new version number "X.Y.Z" on the repository
-
-
-5) tag the sources in subversion
-
-from the trunk:
-
-svn copy -m "Tagging release X.Y.Z" http://svn.dotsrc.org/repo/wget/trunk http://svn.dotsrc.org/repo/wget/tags/WGET_X_Y_Z/
-
-from a branch:
-
-svn copy -m "Tagging release X.Y.Z" http://svn.dotsrc.org/repo/wget/branches/X.Y/ http://svn.dotsrc.org/repo/wget/tags/WGET_X_Y_Z/
-
-
-6) upload the tarball on gnu.org
-
-RELEASE=X.Y.Z
-TARBALL=wget-${RELEASE}.tar.gz
-gpg --default-key 7B2FD4B0 --detach-sign -b --output ${TARBALL}.sig $TARBALL
-echo -e "version: 1.1\ndirectory: wget\nfilename: $TARBALL\ncomment: Wget release ${RELEASE}" > ${TARBALL}.directive
-gpg --default-key 7B2FD4B0 --clearsign ${TARBALL}.directive
-
-lftp ftp://ftp-upload.gnu.org/incoming/ftp
-(use ftp://ftp-upload.gnu.org/incoming/alpha for pre-releases)
-
-put wget-X.Y.Z.tar.gz
-put wget-X.Y.Z.tar.gz.sig
-put wget-X.Y.Z.tar.gz.directive.asc
-
-
-
-7) update wget.sunsite.dk and gnu.org/software/wget
-
-
-8) send announcement on wget@sunsite.dk:
-
-hi to everybody,
-
-i have just uploaded the wget X.Y.Z tarball on ftp.gnu.org:
-
-ftp://ftp.gnu.org/gnu/wget/wget-X.Y.Z.tar.gz
-
-you can find the GPG signature of the tarball at these URLs:
-
-ftp://ftp.gnu.org/gnu/wget/wget-X.Y.Z.tar.gz.sig
-
-and the GPG key i have used for the signature at this URL:
-
-http://www.tortonesi.com/GNU-GPG-Key.txt
-
-the key fingerprint is:
-
-pub  1024D/7B2FD4B0 2005-06-02 Mauro Tortonesi (GNU Wget Maintainer) 
-<mauro@ferrara.linux.it>
-     Key fingerprint = 1E90 AEA8 D511 58F0 94E5  B106 7220 24E9 7B2F D4B0
-
-the MD5 checksum of the tarball is:
-
-MD5 of tarball    wget-X.Y.Z.tar.gz
-
-{DESCRIPTION OF THE CHANGES}
-
-
-9) send announcement on info-gnu@gnu.org
-
-I'm very pleased to announce the availability of GNU Wget X.Y.Z. 
-
-GNU Wget is a non-interactive command-line tool for retrieving files using 
-HTTP, HTTPS and FTP, which may easily be called from scripts, cron jobs, 
-terminals without X-Windows support, etc.
-
-For more information, please see:
-
-    http://www.gnu.org/software/wget
-    http://wget.sunsite.dk
-
-Here are the compressed sources and the GPG detached signature:
-
-ftp://ftp.gnu.org/gnu/wget/wget-X.Y.Z.tar.gz
-ftp://ftp.gnu.org/gnu/wget/wget-X.Y.Z.tar.gz.sig
-
-The MD5 checksums of the tarball is:
-
-MD5 of tarball    wget-X.Y.Z.tar.gz
-
-
-The GPG key I have used for the tarball signature is available at this URL:
-
-http://www.tortonesi.com/GNU-GPG-Key.txt
-
-the key fingerprint is:
-
-pub  1024D/7B2FD4B0 2005-06-02 Mauro Tortonesi (GNU Wget Maintainer) 
-<mauro@ferrara.linux.it>
-     Key fingerprint = 1E90 AEA8 D511 58F0 94E5  B106 7220 24E9 7B2F D4B0
-
-{DESCRIPTION OF THE CHANGES}
-
-
-10) post announcement on freshmeat.net
-
-
-11) set new version number "X.Y.Z+devel" on the repository
-
-

From c1871f41c6e681d5f1e7037a4aaaafdf3961287d Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Tue, 4 Nov 2008 01:27:44 -0800
Subject: [PATCH 14/33] Update FDL to version 1.3.

---
 doc/ChangeLog |  4 +++
 doc/fdl.texi  | 88 +++++++++++++++++++++++++++++++++++++++++----------
 doc/wget.texi |  4 +++
 3 files changed, 79 insertions(+), 17 deletions(-)

diff --git a/doc/ChangeLog b/doc/ChangeLog
index 5d5067ae..cc6f2aa9 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2008-11-04  Micah Cowan  <micah@cowan.name>
+
+	* wget.texi, fdl.texi: Updated to FDL version 1.3.
+
 2008-10-31  Micah Cowan  <micah@cowan.name>
 
 	* wget.texi (Mailing List): Update info to reflect change to
diff --git a/doc/fdl.texi b/doc/fdl.texi
index 9c6d9afe..8805f1a4 100644
--- a/doc/fdl.texi
+++ b/doc/fdl.texi
@@ -1,13 +1,12 @@
+@c The GNU Free Documentation License.
+@center Version 1.3, 3 November 2008
 
-@node GNU Free Documentation License
-@appendixsec GNU Free Documentation License
-
-@cindex FDL, GNU Free Documentation License
-@center Version 1.2, November 2002
+@c This file is intended to be included within another document,
+@c hence no sectioning command or @node.
 
 @display
-Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
-51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
+Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
+@uref{http://fsf.org/}
 
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.
@@ -112,6 +111,9 @@ formats which do not have any title page as such, ``Title Page'' means
 the text near the most prominent appearance of the work's title,
 preceding the beginning of the body of the text.
 
+The ``publisher'' means any person or entity that distributes copies
+of the Document to the public.
+
 A section ``Entitled XYZ'' means a named subunit of the Document whose
 title either is precisely XYZ or contains XYZ in parentheses following
 text that translates XYZ in another language.  (Here XYZ stands for a
@@ -380,13 +382,30 @@ title.
 @item
 TERMINATION
 
-You may not copy, modify, sublicense, or distribute the Document except
-as expressly provided for under this License.  Any other attempt to
-copy, modify, sublicense or distribute the Document is void, and will
-automatically terminate your rights under this License.  However,
-parties who have received copies, or rights, from you under this
-License will not have their licenses terminated so long as such
-parties remain in full compliance.
+You may not copy, modify, sublicense, or distribute the Document
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense, or distribute it is void, and
+will automatically terminate your rights under this License.
+
+However, if you cease all violation of this License, then your license
+from a particular copyright holder is reinstated (a) provisionally,
+unless and until the copyright holder explicitly and finally
+terminates your license, and (b) permanently, if the copyright holder
+fails to notify you of the violation by some reasonable means prior to
+60 days after the cessation.
+
+Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, receipt of a copy of some or all of the same material does
+not give you any rights to use it.
 
 @item
 FUTURE REVISIONS OF THIS LICENSE
@@ -404,7 +423,42 @@ following the terms and conditions either of that specified version or
 of any later version that has been published (not as a draft) by the
 Free Software Foundation.  If the Document does not specify a version
 number of this License, you may choose any version ever published (not
-as a draft) by the Free Software Foundation.
+as a draft) by the Free Software Foundation.  If the Document
+specifies that a proxy can decide which future versions of this
+License can be used, that proxy's public statement of acceptance of a
+version permanently authorizes you to choose that version for the
+Document.
+
+@item
+RELICENSING
+
+``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any
+World Wide Web server that publishes copyrightable works and also
+provides prominent facilities for anybody to edit those works.  A
+public wiki that anybody can edit is an example of such a server.  A
+``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the
+site means any set of copyrightable works thus published on the MMC
+site.
+
+``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0
+license published by Creative Commons Corporation, a not-for-profit
+corporation with a principal place of business in San Francisco,
+California, as well as future copyleft versions of that license
+published by that same organization.
+
+``Incorporate'' means to publish or republish a Document, in whole or
+in part, as part of another Document.
+
+An MMC is ``eligible for relicensing'' if it is licensed under this
+License, and if all works that were first published under this License
+somewhere other than this MMC, and subsequently incorporated in whole
+or in part into the MMC, (1) had no cover texts or invariant sections,
+and (2) were thus incorporated prior to November 1, 2008.
+
+The operator of an MMC Site may republish an MMC contained in the site
+under CC-BY-SA on the same site at any time before August 1, 2009,
+provided the MMC is eligible for relicensing.
+
 @end enumerate
 
 @page
@@ -418,7 +472,7 @@ license notices just after the title page:
 @group
   Copyright (C)  @var{year}  @var{your name}.
   Permission is granted to copy, distribute and/or modify this document
-  under the terms of the GNU Free Documentation License, Version 1.2
+  under the terms of the GNU Free Documentation License, Version 1.3
   or any later version published by the Free Software Foundation;
   with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
   Texts.  A copy of the license is included in the section entitled ``GNU
@@ -427,7 +481,7 @@ license notices just after the title page:
 @end smallexample
 
 If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
-replace the ``with...Texts.'' line with this:
+replace the ``with@dots{}Texts.'' line with this:
 
 @smallexample
 @group
diff --git a/doc/wget.texi b/doc/wget.texi
index b0891c0a..470bea75 100644
--- a/doc/wget.texi
+++ b/doc/wget.texi
@@ -4038,6 +4038,10 @@ subscribers of the Wget mailing list.
 * GNU Free Documentation License::  Licnse for copying this manual.
 @end menu
 
+@node GNU Free Documentation License
+@appendixsec GNU Free Documentation License
+@cindex FDL, GNU Free Documentation License
+
 @include fdl.texi
 
 

From d7d0c1f79c795ffb2c997850fe512f80ac6c2d5b Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Wed, 5 Nov 2008 09:11:33 -0800
Subject: [PATCH 15/33] Move --no-http-keep-alive to HTTP Options section.

---
 doc/ChangeLog |  5 +++++
 doc/wget.texi | 26 +++++++++++++-------------
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/doc/ChangeLog b/doc/ChangeLog
index b440bb49..e26fd89d 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-05  Micah Cowan  <micah@cowan.name>
+
+	* wget.texi: Move --no-http-keep-alive from FTP Options to HTTP
+	Options.
+
 2008-09-30  Steven Schubiger  <stsc@members.fsf.org>
 
 	* wget.texi (Wgetrc Commands): Add default_page, save_headers, 
diff --git a/doc/wget.texi b/doc/wget.texi
index 222ae494..29dc4e96 100644
--- a/doc/wget.texi
+++ b/doc/wget.texi
@@ -1131,6 +1131,19 @@ For more information about security issues with Wget, @xref{Security
 Considerations}.
 @end iftex
 
+@cindex Keep-Alive, turning off
+@cindex Persistent Connections, disabling
+@item --no-http-keep-alive
+Turn off the ``keep-alive'' feature for HTTP downloads.  Normally, Wget
+asks the server to keep the connection open so that, when you download
+more than one document from the same server, they get transferred over
+the same TCP connection.  This saves time and at the same time reduces
+the load on the server.
+
+This option is useful when, for some reason, persistent (keep-alive)
+connections don't work for you, for example due to a server bug or due
+to the inability of server-side scripts to cope with the connections.
+
 @cindex proxy
 @cindex cache
 @item --no-cache
@@ -1633,19 +1646,6 @@ Note that when retrieving a file (not a directory) because it was
 specified on the command-line, rather than because it was recursed to,
 this option has no effect.  Symbolic links are always traversed in this
 case.
-
-@cindex Keep-Alive, turning off
-@cindex Persistent Connections, disabling
-@item --no-http-keep-alive
-Turn off the ``keep-alive'' feature for HTTP downloads.  Normally, Wget
-asks the server to keep the connection open so that, when you download
-more than one document from the same server, they get transferred over
-the same TCP connection.  This saves time and at the same time reduces
-the load on the server.
-
-This option is useful when, for some reason, persistent (keep-alive)
-connections don't work for you, for example due to a server bug or due
-to the inability of server-side scripts to cope with the connections.
 @end table
 
 @node Recursive Retrieval Options

From 8f5ffd9589d15c97ab91c494d9b511165f424c93 Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Wed, 5 Nov 2008 13:38:50 -0800
Subject: [PATCH 16/33] Only print remaining size when > 1k.

---
 src/ChangeLog | 5 +++++
 src/ftp.c     | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 79104873..c7a378ea 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-05  Micah Cowan  <micah@cowan.name>
+
+	* ftp.c (print_length): Should print humanized "size remaining"
+	only when it's at least 1k.
+
 2008-10-31  Micah Cowan  <micah@cowan.name>
 
 	* main.c (print_version): Add information about the mailing list.
diff --git a/src/ftp.c b/src/ftp.c
index 482651be..9f65cc34 100644
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -216,7 +216,7 @@ print_length (wgint size, wgint start, bool authoritative)
     logprintf (LOG_VERBOSE, " (%s)", human_readable (size));
   if (start > 0)
     {
-      if (start >= 1024)
+      if (size - start >= 1024)
         logprintf (LOG_VERBOSE, _(", %s (%s) remaining"),
                    number_to_static_string (size - start),
                    human_readable (size - start));

From 620876d149825e02d43760e9ef224802e1cf515f Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Wed, 5 Nov 2008 14:22:40 -0800
Subject: [PATCH 17/33] ML archive, moderation

---
 ChangeLog     |  5 +++++
 MAILING-LIST  |  9 ++++++++-
 doc/ChangeLog |  2 ++
 doc/wget.texi | 10 +++++++++-
 4 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ce3f42cc..921ce2ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-05  Micah Cowan  <micah@cowan.name>
+
+	* MAILING-LIST: Mention moderation for unsubscribed posts, and
+	archive location.
+
 2008-10-31  Micah Cowan  <micah@cowan.name>
 
 	* MAILING-LIST: Update information.
diff --git a/MAILING-LIST b/MAILING-LIST
index 93a5b2d4..97552642 100644
--- a/MAILING-LIST
+++ b/MAILING-LIST
@@ -4,7 +4,14 @@ Mailing List
 The primary mailinglist for discussion, bug-reports, or questions about
 GNU Wget is at <bug-wget@gnu.org>. To subscribe, send an email to
 <bug-wget-join@gnu.org>, or visit
-`http://lists.gnu.org/mailman/listinfo/bug-wget'.
+`http://lists.gnu.org/mailman/listinfo/bug-wget'. You do not need to
+subscribe to send a message to the list; however, please note that
+unsubscribed messages are moderated, and may take a while before they
+hit the list--*usually around a day*.  If you want your message to show
+up immediately, please subscribe to the list before posting.
+
+   Archives for this list may be found at
+`http://lists.gnu.org/pipermail/bug-wget/'.
 
    Additionally, there is the <wget-notify@addictivecode.org> mailing
 list. This is a non-discussion list that receives bug report
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 8f498325..b74021ab 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -2,6 +2,8 @@
 
 	* wget.texi: Move --no-http-keep-alive from FTP Options to HTTP
 	Options.
+	(Mailing List): Mention moderation for unsubscribed posts, and
+	archive location.
 
 2008-11-04  Micah Cowan  <micah@cowan.name>
 
diff --git a/doc/wget.texi b/doc/wget.texi
index 3022a9f6..3e4dd5e8 100644
--- a/doc/wget.texi
+++ b/doc/wget.texi
@@ -3412,7 +3412,15 @@ information resides at ``The Wget Wgiki'',
 The primary mailinglist for discussion, bug-reports, or questions
 about GNU Wget is at @email{bug-wget@@gnu.org}. To subscribe, send an
 email to @email{bug-wget-join@@gnu.org}, or visit
-@url{http://lists.gnu.org/mailman/listinfo/bug-wget}.
+@url{http://lists.gnu.org/mailman/listinfo/bug-wget}. You do not need
+to subscribe to send a message to the list; however, please note that
+unsubscribed messages are moderated, and may take a while before they
+hit the list---@strong{usually around a day}.  If you want your
+message to show up immediately, please subscribe to the list before
+posting.
+
+Archives for this list may be found at
+@url{http://lists.gnu.org/pipermail/bug-wget/}.
 
 Additionally, there is the @email{wget-notify@@addictivecode.org} mailing
 list. This is a non-discussion list that receives bug report

From 0dd8271f32f705048ef87c898ec90d3813d68fb8 Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Thu, 6 Nov 2008 11:38:16 -0800
Subject: [PATCH 18/33] use strict in run-px.

---
 tests/ChangeLog | 4 ++++
 tests/run-px    | 1 +
 2 files changed, 5 insertions(+)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 36bc35dc..19270b6f 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2008-11-06  Micah Cowan  <micah@cowan.name>
+
+	* run-px: Use strict (thanks Steven Schubiger!).
+
 2008-06-22  Micah Cowan  <micah@cowan.name>
 
 	* Test-proxied-https-auth.px: Shift exit code so it falls in the
diff --git a/tests/run-px b/tests/run-px
index 50db5819..05f6eda6 100755
--- a/tests/run-px
+++ b/tests/run-px
@@ -1,5 +1,6 @@
 #!/usr/bin/env perl
 use warnings;
+use strict;
 
 die "Please specify the top source directory.\n" if (!@ARGV);
 my $top_srcdir = shift @ARGV;

From cf4c155c0c16da198c88fb5087aa0b732c364da6 Mon Sep 17 00:00:00 2001
From: sts <sts@kronos>
Date: Fri, 7 Nov 2008 00:01:25 +0100
Subject: [PATCH 19/33] Call tests with executable name.

---
 tests/ChangeLog | 5 +++++
 tests/run-px    | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 19270b6f..a401c297 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-06  Steven Schubiger  <stsc@members.fsf.org>
+
+	* run-px: When executing test scripts, invoke them with the
+	current perl executable name as determined by env.
+
 2008-11-06  Micah Cowan  <micah@cowan.name>
 
 	* run-px: Use strict (thanks Steven Schubiger!).
diff --git a/tests/run-px b/tests/run-px
index 05f6eda6..60b848d1 100755
--- a/tests/run-px
+++ b/tests/run-px
@@ -52,7 +52,7 @@ my @results;
 
 for my $test (@tests) {
     print "Running $test\n\n";
-    system("$top_srcdir/tests/$test");
+    system("$^X $top_srcdir/tests/$test");
     push @results, $?;
 }
 

From 7fc928183366c256ef4c425c19ea2f054d68aafd Mon Sep 17 00:00:00 2001
From: Steven Schubiger <stsc@members.fsf.org>
Date: Fri, 7 Nov 2008 22:06:38 +0100
Subject: [PATCH 20/33] Add colors to test summary.

---
 tests/ChangeLog |  6 +++++
 tests/run-px    | 67 +++++++++++++++++++++++++++++++++++++------------
 2 files changed, 57 insertions(+), 16 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index a401c297..751402d0 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-07  Steven Schubiger  <stsc@members.fsf.org>
+
+	* run-px: Use some colors for the summary part of the test
+	output to strengthen the distinction between a successful
+	or failing run.
+
 2008-11-06  Steven Schubiger  <stsc@members.fsf.org>
 
 	* run-px: When executing test scripts, invoke them with the
diff --git a/tests/run-px b/tests/run-px
index 60b848d1..92e9061e 100755
--- a/tests/run-px
+++ b/tests/run-px
@@ -1,7 +1,12 @@
 #!/usr/bin/env perl
+
+use 5.006;
 use warnings;
 use strict;
 
+use Term::ANSIColor ':constants';
+$Term::ANSIColor::AUTORESET = 1;
+
 die "Please specify the top source directory.\n" if (!@ARGV);
 my $top_srcdir = shift @ARGV;
 
@@ -48,26 +53,56 @@ my @tests = (
     'Test--spider-r.px',
 );
 
-my @results;
+my @tested;
 
-for my $test (@tests) {
+foreach my $test (@tests) {
     print "Running $test\n\n";
     system("$^X $top_srcdir/tests/$test");
-    push @results, $?;
-}
-
-for (my $i=0; $i != @tests; ++$i) {
-    if ($results[$i] == 0) {
-        print "pass: ";
-    } else {
-        print "FAIL: ";
-    }
-    print "$tests[$i]\n";
+    push @tested, { name => $test, result => $? };
 }
 
 print "\n";
-print scalar(@results) . " tests were run\n";
-print scalar(grep $_ == 0, @results) . " PASS\n";
-print scalar(grep $_ != 0, @results) . " FAIL\n";
+foreach my $test (@tested) {
+    ($test->{result} == 0)
+      ? print GREEN 'pass: '
+      : print RED 'FAIL: ';
+   print $test->{name}, "\n";
+}
 
-exit scalar (grep $_ != 0, @results);
+my $count = sub
+{
+    return {
+      pass => sub { scalar grep $_->{result} == 0, @tested },
+      fail => sub { scalar grep $_->{result} != 0, @tested },
+    }->{$_[0]}->();
+};
+
+my $summary = sub
+{
+    my @lines = (
+        "${\scalar @tested} tests were run",
+        "${\$count->('pass')} PASS, ${\$count->('fail')} FAIL",
+    );
+    my $len_longest = sub
+    {
+        local $_ = 0;
+        foreach my $line (@lines) {
+            if (length $line > $_) {
+                $_ = length $line;
+            }
+        }
+        return $_;
+    }->();
+    return join "\n",
+      '=' x $len_longest,
+      @lines,
+      '=' x $len_longest;
+}->();
+
+print "\n";
+print $count->('fail')
+  ? RED $summary
+  : GREEN $summary;
+print "\n";
+
+exit $count->('fail');

From 381f14290d94dda82a844531ab97d440175f69fe Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Mon, 10 Nov 2008 11:21:17 -0800
Subject: [PATCH 21/33] Mention Gmane portal, add subsections to "Mailing
 Lists".

---
 ChangeLog     |  4 ++++
 MAILING-LIST  | 40 +++++++++++++++++++++++++++++-----------
 doc/ChangeLog |  5 +++++
 doc/wget.texi | 38 ++++++++++++++++++++++++++------------
 4 files changed, 64 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 921ce2ba..ac384a49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-11-10  Micah Cowan  <micah@cowan.name>
+
+	* MAILING-LIST: Mention Gmane, introduce subsections.
+
 2008-11-05  Micah Cowan  <micah@cowan.name>
 
 	* MAILING-LIST: Mention moderation for unsubscribed posts, and
diff --git a/MAILING-LIST b/MAILING-LIST
index 97552642..9f6212a8 100644
--- a/MAILING-LIST
+++ b/MAILING-LIST
@@ -1,32 +1,50 @@
-Mailing List
-============
+Mailing Lists
+=============
+
+Primary List
+------------
 
 The primary mailinglist for discussion, bug-reports, or questions about
 GNU Wget is at <bug-wget@gnu.org>. To subscribe, send an email to
 <bug-wget-join@gnu.org>, or visit
-`http://lists.gnu.org/mailman/listinfo/bug-wget'. You do not need to
-subscribe to send a message to the list; however, please note that
-unsubscribed messages are moderated, and may take a while before they
-hit the list--*usually around a day*.  If you want your message to show
-up immediately, please subscribe to the list before posting.
+`http://lists.gnu.org/mailman/listinfo/bug-wget'.
 
-   Archives for this list may be found at
+   You do not need to subscribe to send a message to the list; however,
+please note that unsubscribed messages are moderated, and may take a
+while before they hit the list--*usually around a day*.  If you want
+your message to show up immediately, please subscribe to the list
+before posting. Archives for the list may be found at
 `http://lists.gnu.org/pipermail/bug-wget/'.
 
-   Additionally, there is the <wget-notify@addictivecode.org> mailing
+   An NNTP/Usenettish gateway is also available via Gmane
+(http://gmane.org/about.php). You can see the Gmane archives at
+`http://news.gmane.org/gmane.comp.web.wget.general'. Note that the
+Gmane archives conveniently include messages from both the current
+list, and the previous one. Messages also show up in the Gmane archives
+sooner than they do at `lists.gnu.org'.
+
+Bug Notices List
+----------------
+
+Additionally, there is the <wget-notify@addictivecode.org> mailing
 list. This is a non-discussion list that receives bug report
 notifications from the bug-tracker. To subscribe to this list, send an
 email to <wget-notify-join@addictivecode.org>, or visit
 `http://addictivecode.org/mailman/listinfo/wget-notify'.
 
-   Previously, the mailing list <wget@sunsite.dk> was used as the main
+Obsolete Lists
+--------------
+
+Previously, the mailing list <wget@sunsite.dk> was used as the main
 discussion list, and another list, <wget-patches@sunsite.dk> was used
 for submitting and discussing patches to GNU Wget.
 
    Messages from <wget@sunsite.dk> are archived at
      `http://www.mail-archive.com/wget%40sunsite.dk/' and at
 
-     `http://news.gmane.org/gmane.comp.web.wget.general'.
+     `http://news.gmane.org/gmane.comp.web.wget.general' (which also
+     continues to archive the current list, <bug-wget@gnu.org>).
 
    Messages from <wget-patches@sunsite.dk> are archived at
      `http://news.gmane.org/gmane.comp.web.wget.patches'.
+
diff --git a/doc/ChangeLog b/doc/ChangeLog
index b74021ab..602390b1 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-10  Micah Cowan  <micah@cowan.name>
+
+	* wget.texi (Mailing Lists): Added information aboug Gmane portal,
+	added subsection headings.
+
 2008-11-05  Micah Cowan  <micah@cowan.name>
 
 	* wget.texi: Move --no-http-keep-alive from FTP Options to HTTP
diff --git a/doc/wget.texi b/doc/wget.texi
index 3e4dd5e8..93ec9985 100644
--- a/doc/wget.texi
+++ b/doc/wget.texi
@@ -3303,7 +3303,7 @@ This chapter contains all the stuff that could not fit anywhere else.
 * Proxies::             Support for proxy servers.
 * Distribution::        Getting the latest version.
 * Web Site::            GNU Wget's presence on the World Wide Web.
-* Mailing List::        Wget mailing list for announcements and discussion.
+* Mailing Lists::       Wget mailing list for announcements and discussion.
 * Internet Relay Chat:: Wget's presence on IRC.
 * Reporting Bugs::      How and where to report bugs.
 * Portability::         The systems Wget works on.
@@ -3404,30 +3404,43 @@ The official web site for GNU Wget is at
 information resides at ``The Wget Wgiki'',
 @url{http://wget.addictivecode.org/}.
 
-@node Mailing List
-@section Mailing List
+@node Mailing Lists
+@section Mailing Lists
 @cindex mailing list
 @cindex list
 
+@unnumberedsubsec Primary List
+
 The primary mailinglist for discussion, bug-reports, or questions
 about GNU Wget is at @email{bug-wget@@gnu.org}. To subscribe, send an
 email to @email{bug-wget-join@@gnu.org}, or visit
-@url{http://lists.gnu.org/mailman/listinfo/bug-wget}. You do not need
-to subscribe to send a message to the list; however, please note that
-unsubscribed messages are moderated, and may take a while before they
-hit the list---@strong{usually around a day}.  If you want your
-message to show up immediately, please subscribe to the list before
-posting.
+@url{http://lists.gnu.org/mailman/listinfo/bug-wget}.
 
-Archives for this list may be found at
+You do not need to subscribe to send a message to the list; however,
+please note that unsubscribed messages are moderated, and may take a
+while before they hit the list---@strong{usually around a day}.  If
+you want your message to show up immediately, please subscribe to the
+list before posting. Archives for the list may be found at
 @url{http://lists.gnu.org/pipermail/bug-wget/}.
 
+An NNTP/Usenettish gateway is also available via
+@uref{http://gmane.org/about.php,Gmane}. You can see the Gmane
+archives at
+@url{http://news.gmane.org/gmane.comp.web.wget.general}. Note that the
+Gmane archives conveniently include messages from both the current
+list, and the previous one. Messages also show up in the Gmane
+archives sooner than they do at @url{lists.gnu.org}.
+
+@unnumberedsubsec Bug Notices List
+
 Additionally, there is the @email{wget-notify@@addictivecode.org} mailing
 list. This is a non-discussion list that receives bug report
 notifications from the bug-tracker. To subscribe to this list,
 send an email to @email{wget-notify-join@@addictivecode.org},
 or visit @url{http://addictivecode.org/mailman/listinfo/wget-notify}.
 
+@unnumberedsubsec Obsolete Lists
+
 Previously, the mailing list @email{wget@@sunsite.dk} was used as the
 main discussion list, and another list,
 @email{wget-patches@@sunsite.dk} was used for submitting and
@@ -3438,7 +3451,8 @@ Messages from @email{wget@@sunsite.dk} are archived at
 @item
 @url{http://www.mail-archive.com/wget%40sunsite.dk/} and at
 @item
-@url{http://news.gmane.org/gmane.comp.web.wget.general}.
+@url{http://news.gmane.org/gmane.comp.web.wget.general} (which also
+continues to archive the current list, @email{bug-wget@@gnu.org}).
 @end itemize
 
 Messages from @email{wget-patches@@sunsite.dk} are archived at
@@ -3476,7 +3490,7 @@ Wget crashes, it's a bug.  If Wget does not behave as documented,
 it's a bug.  If things work strange, but you are not sure about the way
 they are supposed to work, it might well be a bug, but you might want to
 double-check the documentation and the mailing lists (@pxref{Mailing
-List}).
+Lists}).
 
 @item
 Try to repeat the bug in as simple circumstances as possible.  E.g. if

From d7e1e5be19ef4b5d632552d1fe5de84e009356c1 Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Mon, 10 Nov 2008 11:24:04 -0800
Subject: [PATCH 22/33] Update node references.

---
 doc/ChangeLog |   2 +
 doc/wget.texi | 100 +++++++++++++++++++++++++-------------------------
 2 files changed, 52 insertions(+), 50 deletions(-)

diff --git a/doc/ChangeLog b/doc/ChangeLog
index 602390b1..edd6b028 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -3,6 +3,8 @@
 	* wget.texi (Mailing Lists): Added information aboug Gmane portal,
 	added subsection headings.
 
+	Update node pointers.
+	
 2008-11-05  Micah Cowan  <micah@cowan.name>
 
 	* wget.texi: Move --no-http-keep-alive from FTP Options to HTTP
diff --git a/doc/wget.texi b/doc/wget.texi
index 93ec9985..8af74d94 100644
--- a/doc/wget.texi
+++ b/doc/wget.texi
@@ -82,7 +82,7 @@ Info entry for @file{wget}.
 @contents
 
 @ifnottex
-@node Top
+@node Top, Overview, (dir), (dir)
 @top Wget @value{VERSION}
 
 @insertcopying
@@ -102,7 +102,7 @@ Info entry for @file{wget}.
 * Concept Index::       Topics covered by this manual.
 @end menu
 
-@node Overview
+@node Overview, Invoking, Top, Top
 @chapter Overview
 @cindex overview
 @cindex features
@@ -211,7 +211,7 @@ Public License, as published by the Free Software Foundation (see the
 file @file{COPYING} that came with GNU Wget, for details).
 @end itemize
 
-@node Invoking
+@node Invoking, Recursive Download, Overview, Top
 @chapter Invoking
 @cindex invoking
 @cindex command line
@@ -248,7 +248,7 @@ the command line.
 * Recursive Accept/Reject Options::
 @end menu
 
-@node URL Format
+@node URL Format, Option Syntax, Invoking, Invoking
 @section URL Format
 @cindex URL
 @cindex URL syntax
@@ -326,7 +326,7 @@ with your favorite browser, like @code{Lynx} or @code{Netscape}.
 
 @c man begin OPTIONS
 
-@node Option Syntax
+@node Option Syntax, Basic Startup Options, URL Format, Invoking
 @section Option Syntax
 @cindex option syntax
 @cindex syntax of options
@@ -401,7 +401,7 @@ the default.  For instance, using @code{follow_ftp = off} in
 using @samp{--no-follow-ftp} is the only way to restore the factory
 default from the command line.
 
-@node Basic Startup Options
+@node Basic Startup Options, Logging and Input File Options, Option Syntax, Invoking
 @section Basic Startup Options
 
 @table @samp
@@ -429,7 +429,7 @@ instances of @samp{-e}.
 
 @end table
 
-@node Logging and Input File Options
+@node Logging and Input File Options, Download Options, Basic Startup Options, Invoking
 @section Logging and Input File Options
 
 @table @samp
@@ -517,7 +517,7 @@ Prepends @var{URL} to relative links read from the file specified with
 the @samp{-i} option.
 @end table
 
-@node Download Options
+@node Download Options, Directory Options, Logging and Input File Options, Invoking
 @section Download Options
 
 @table @samp
@@ -999,7 +999,7 @@ Prompt for a password for each connection established. Cannot be specified
 when @samp{--password} is being used, because they are mutually exclusive.
 @end table
 
-@node Directory Options
+@node Directory Options, HTTP Options, Download Options, Invoking
 @section Directory Options
 
 @table @samp       
@@ -1071,7 +1071,7 @@ i.e. the top of the retrieval tree.  The default is @samp{.} (the
 current directory).
 @end table
 
-@node HTTP Options
+@node HTTP Options, HTTPS (SSL/TLS) Options, Directory Options, Invoking
 @section HTTP Options
 
 @table @samp
@@ -1418,7 +1418,7 @@ form-based authentication.
 
 @end table
 
-@node HTTPS (SSL/TLS) Options
+@node HTTPS (SSL/TLS) Options, FTP Options, HTTP Options, Invoking
 @section HTTPS (SSL/TLS) Options
 
 @cindex SSL
@@ -1543,7 +1543,7 @@ not used), EGD is never contacted.  EGD is not needed on modern Unix
 systems that support @file{/dev/random}.
 @end table
 
-@node FTP Options
+@node FTP Options, Recursive Retrieval Options, HTTPS (SSL/TLS) Options, Invoking
 @section FTP Options
 
 @table @samp
@@ -1648,7 +1648,7 @@ this option has no effect.  Symbolic links are always traversed in this
 case.
 @end table
 
-@node Recursive Retrieval Options
+@node Recursive Retrieval Options, Recursive Accept/Reject Options, FTP Options, Invoking
 @section Recursive Retrieval Options
 
 @table @samp
@@ -1853,7 +1853,7 @@ If, for whatever reason, you want strict comment parsing, use this
 option to turn it on.
 @end table
 
-@node Recursive Accept/Reject Options
+@node Recursive Accept/Reject Options,  , Recursive Retrieval Options, Invoking
 @section Recursive Accept/Reject Options
 
 @table @samp
@@ -1948,7 +1948,7 @@ This is a useful option, since it guarantees that only the files
 
 @c man end
 
-@node Recursive Download
+@node Recursive Download, Following Links, Invoking, Top
 @chapter Recursive Download
 @cindex recursion
 @cindex retrieving
@@ -2016,7 +2016,7 @@ about this.
 Recursive retrieval should be used with care.  Don't say you were not
 warned.
 
-@node Following Links
+@node Following Links, Time-Stamping, Recursive Download, Top
 @chapter Following Links
 @cindex links
 @cindex following links
@@ -2040,7 +2040,7 @@ links it will follow.
 * FTP Links::              Following FTP links.
 @end menu
 
-@node Spanning Hosts
+@node Spanning Hosts, Types of Files, Following Links, Following Links
 @section Spanning Hosts
 @cindex spanning hosts
 @cindex hosts, spanning
@@ -2097,7 +2097,7 @@ wget -rH -Dfoo.edu --exclude-domains sunsite.foo.edu \
 
 @end table
 
-@node Types of Files
+@node Types of Files, Directory-Based Limits, Spanning Hosts, Following Links
 @section Types of Files
 @cindex types of files
 
@@ -2202,7 +2202,7 @@ local filenames, and so @emph{do} contribute to filename matching.
 This behavior, too, is considered less-than-desirable, and may change
 in a future version of Wget.
 
-@node Directory-Based Limits
+@node Directory-Based Limits, Relative Links, Types of Files, Following Links
 @section Directory-Based Limits
 @cindex directories
 @cindex directory limits
@@ -2286,7 +2286,7 @@ directory, while in @samp{http://foo/bar} (no trailing slash),
 meaningless, as its parent is @samp{/}).
 @end table
 
-@node Relative Links
+@node Relative Links, FTP Links, Directory-Based Limits, Following Links
 @section Relative Links
 @cindex relative links
 
@@ -2315,7 +2315,7 @@ to ``just work'' without having to convert links.
 This option is probably not very useful and might be removed in a future
 release.
 
-@node FTP Links
+@node FTP Links,  , Relative Links, Following Links
 @section Following FTP Links
 @cindex following ftp links
 
@@ -2335,7 +2335,7 @@ effect on such downloads.  On the other hand, domain acceptance
 Also note that followed links to @sc{ftp} directories will not be
 retrieved recursively further.
 
-@node Time-Stamping
+@node Time-Stamping, Startup File, Following Links, Top
 @chapter Time-Stamping
 @cindex time-stamping
 @cindex timestamping
@@ -2385,7 +2385,7 @@ say.
 * FTP Time-Stamping Internals::
 @end menu
 
-@node Time-Stamping Usage
+@node Time-Stamping Usage, HTTP Time-Stamping Internals, Time-Stamping, Time-Stamping
 @section Time-Stamping Usage
 @cindex time-stamping usage
 @cindex usage, time-stamping
@@ -2441,7 +2441,7 @@ gives a timestamp.  For @sc{http}, this depends on getting a
 directory listing with dates in a format that Wget can parse
 (@pxref{FTP Time-Stamping Internals}).
 
-@node HTTP Time-Stamping Internals
+@node HTTP Time-Stamping Internals, FTP Time-Stamping Internals, Time-Stamping Usage, Time-Stamping
 @section HTTP Time-Stamping Internals
 @cindex http time-stamping
 
@@ -2473,7 +2473,7 @@ with @samp{-N}, server file @samp{@var{X}} is compared to local file
 Arguably, @sc{http} time-stamping should be implemented using the
 @code{If-Modified-Since} request.
 
-@node FTP Time-Stamping Internals
+@node FTP Time-Stamping Internals,  , HTTP Time-Stamping Internals, Time-Stamping
 @section FTP Time-Stamping Internals
 @cindex ftp time-stamping
 
@@ -2502,7 +2502,7 @@ that is supported by some @sc{ftp} servers (including the popular
 @code{wu-ftpd}), which returns the exact time of the specified file.
 Wget may support this command in the future.
 
-@node Startup File
+@node Startup File, Examples, Time-Stamping, Top
 @chapter Startup File
 @cindex startup file
 @cindex wgetrc
@@ -2530,7 +2530,7 @@ commands.
 * Sample Wgetrc::     A wgetrc example.
 @end menu
 
-@node Wgetrc Location
+@node Wgetrc Location, Wgetrc Syntax, Startup File, Startup File
 @section Wgetrc Location
 @cindex wgetrc location
 @cindex location of wgetrc
@@ -2551,7 +2551,7 @@ means that in case of collision user's wgetrc @emph{overrides} the
 system-wide wgetrc (in @file{/usr/local/etc/wgetrc} by default).
 Fascist admins, away!
 
-@node Wgetrc Syntax
+@node Wgetrc Syntax, Wgetrc Commands, Wgetrc Location, Startup File
 @section Wgetrc Syntax
 @cindex wgetrc syntax
 @cindex syntax of wgetrc
@@ -2578,7 +2578,7 @@ global @file{wgetrc}, you can do it with:
 reject =
 @end example
 
-@node Wgetrc Commands
+@node Wgetrc Commands, Sample Wgetrc, Wgetrc Syntax, Startup File
 @section Wgetrc Commands
 @cindex wgetrc commands
 
@@ -3024,7 +3024,7 @@ only---the same as @samp{--waitretry=@var{n}}.  Note that this is
 turned on by default in the global @file{wgetrc}.
 @end table
 
-@node Sample Wgetrc
+@node Sample Wgetrc,  , Wgetrc Commands, Startup File
 @section Sample Wgetrc
 @cindex sample wgetrc
 
@@ -3041,7 +3041,7 @@ its line.
 @include sample.wgetrc.munged_for_texi_inclusion
 @end example
 
-@node Examples
+@node Examples, Various, Startup File, Top
 @chapter Examples
 @cindex examples
 
@@ -3055,7 +3055,7 @@ complexity.
 * Very Advanced Usage::  The hairy stuff.
 @end menu
 
-@node Simple Usage
+@node Simple Usage, Advanced Usage, Examples, Examples
 @section Simple Usage
 
 @itemize @bullet
@@ -3108,7 +3108,7 @@ links index.html
 @end example
 @end itemize
 
-@node Advanced Usage
+@node Advanced Usage, Very Advanced Usage, Simple Usage, Examples
 @section Advanced Usage
 
 @itemize @bullet
@@ -3244,7 +3244,7 @@ wget -O - http://cool.list.com/ | wget --force-html -i -
 @end example
 @end itemize
 
-@node Very Advanced Usage
+@node Very Advanced Usage,  , Advanced Usage, Examples
 @section Very Advanced Usage
 
 @cindex mirroring
@@ -3293,7 +3293,7 @@ wget -m -k -K -E http://www.gnu.org/ -o /home/me/weeklog
 @end itemize
 @c man end
 
-@node Various
+@node Various, Appendices, Examples, Top
 @chapter Various
 @cindex various
 
@@ -3310,7 +3310,7 @@ This chapter contains all the stuff that could not fit anywhere else.
 * Signals::             Signal-handling performed by Wget.
 @end menu
 
-@node Proxies
+@node Proxies, Distribution, Various, Various
 @section Proxies
 @cindex proxies
 
@@ -3386,7 +3386,7 @@ Alternatively, you may use the @samp{proxy-user} and
 settings @code{proxy_user} and @code{proxy_password} to set the proxy
 username and password.
 
-@node Distribution
+@node Distribution, Web Site, Proxies, Various
 @section Distribution
 @cindex latest version
 
@@ -3395,7 +3395,7 @@ master GNU archive site ftp.gnu.org, and its mirrors.  For example,
 Wget @value{VERSION} can be found at
 @url{ftp://ftp.gnu.org/pub/gnu/wget/wget-@value{VERSION}.tar.gz}
 
-@node Web Site
+@node Web Site, Mailing Lists, Distribution, Various
 @section Web Site
 @cindex web site
 
@@ -3404,7 +3404,7 @@ The official web site for GNU Wget is at
 information resides at ``The Wget Wgiki'',
 @url{http://wget.addictivecode.org/}.
 
-@node Mailing Lists
+@node Mailing Lists, Internet Relay Chat, Web Site, Various
 @section Mailing Lists
 @cindex mailing list
 @cindex list
@@ -3461,7 +3461,7 @@ Messages from @email{wget-patches@@sunsite.dk} are archived at
 @url{http://news.gmane.org/gmane.comp.web.wget.patches}.
 @end itemize
 
-@node Internet Relay Chat
+@node Internet Relay Chat, Reporting Bugs, Mailing Lists, Various
 @section Internet Relay Chat
 @cindex Internet Relay Chat
 @cindex IRC
@@ -3470,7 +3470,7 @@ Messages from @email{wget-patches@@sunsite.dk} are archived at
 In addition to the mailinglists, we also have a support channel set up
 via IRC at @code{irc.freenode.org}, @code{#wget}. Come check it out!
 
-@node Reporting Bugs
+@node Reporting Bugs, Portability, Internet Relay Chat, Various
 @section Reporting Bugs
 @cindex bugs
 @cindex reporting bugs
@@ -3529,7 +3529,7 @@ safe to try.
 @end enumerate
 @c man end
 
-@node Portability
+@node Portability, Signals, Reporting Bugs, Various
 @section Portability
 @cindex portability
 @cindex operating systems
@@ -3562,7 +3562,7 @@ Support for building on MS-DOS via DJGPP has been contributed by Gisle
 Vanem; a port to VMS is maintained by Steven Schweda, and is available
 at @url{http://antinode.org/}.
 
-@node Signals
+@node Signals,  , Portability, Various
 @section Signals
 @cindex signal handling
 @cindex hangup
@@ -3583,7 +3583,7 @@ SIGHUP received, redirecting output to `wget-log'.
 Other than that, Wget will not try to interfere with signals in any way.
 @kbd{C-c}, @code{kill -TERM} and @code{kill -KILL} should kill it alike.
 
-@node Appendices
+@node Appendices, Copying this manual, Various, Top
 @chapter Appendices
 
 This chapter contains some references I consider useful.
@@ -3594,7 +3594,7 @@ This chapter contains some references I consider useful.
 * Contributors::            People who helped.
 @end menu
 
-@node Robot Exclusion
+@node Robot Exclusion, Security Considerations, Appendices, Appendices
 @section Robot Exclusion
 @cindex robot exclusion
 @cindex robots.txt
@@ -3677,7 +3677,7 @@ robot exclusion, set the @code{robots} variable to @samp{off} in your
 @file{.wgetrc}.  You can achieve the same effect from the command line
 using the @code{-e} switch, e.g. @samp{wget -e robots=off @var{url}...}.
 
-@node Security Considerations
+@node Security Considerations, Contributors, Robot Exclusion, Appendices
 @section Security Considerations
 @cindex security
 
@@ -3708,7 +3708,7 @@ being careful when you send debug logs (yes, even when you send them to
 me).
 @end enumerate
 
-@node Contributors
+@node Contributors,  , Security Considerations, Appendices
 @section Contributors
 @cindex contributors
 
@@ -4053,21 +4053,21 @@ Kristijan Zimmer.
 Apologies to all who I accidentally left out, and many thanks to all the
 subscribers of the Wget mailing list.
 
-@node Copying this manual
+@node Copying this manual, Concept Index, Appendices, Top
 @appendix Copying this manual
   
 @menu
 * GNU Free Documentation License::  Licnse for copying this manual.
 @end menu
 
-@node GNU Free Documentation License
+@node GNU Free Documentation License,  , Copying this manual, Copying this manual
 @appendixsec GNU Free Documentation License
 @cindex FDL, GNU Free Documentation License
 
 @include fdl.texi
 
 
-@node Concept Index
+@node Concept Index,  , Copying this manual, Top
 @unnumbered Concept Index
 @printindex cp
 

From 662da5e235618c28b9348bcd23133d95c079f0d4 Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Mon, 10 Nov 2008 14:41:03 -0800
Subject: [PATCH 23/33] Remove README.maint from EXTRA_DIST.

---
 doc/ChangeLog   | 3 +++
 doc/Makefile.am | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/doc/ChangeLog b/doc/ChangeLog
index edd6b028..a879fcb8 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,5 +1,8 @@
 2008-11-10  Micah Cowan  <micah@cowan.name>
 
+	* Makefile.am (EXTRA_DIST): Removed no-longer-present
+	README.maint (shouldn't have been there in the first place).
+
 	* wget.texi (Mailing Lists): Added information aboug Gmane portal,
 	added subsection headings.
 
diff --git a/doc/Makefile.am b/doc/Makefile.am
index c0e10dbf..74abe7f6 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -48,7 +48,8 @@ $(SAMPLERCTEXI): $(srcdir)/sample.wgetrc
 info_TEXINFOS = wget.texi
 wget_TEXINFOS = fdl.texi sample.wgetrc.munged_for_texi_inclusion
 
-EXTRA_DIST = README.maint sample.wgetrc $(SAMPLERCTEXI) \
+EXTRA_DIST = sample.wgetrc \
+	     $(SAMPLERCTEXI) \
 	     texi2pod.pl
 
 wget.pod: $(srcdir)/wget.texi $(srcdir)/version.texi

From 65ab102f072cd801528da4f478915bd8e5272725 Mon Sep 17 00:00:00 2001
From: Saint Xavier <wget@sxav.eu>
Date: Mon, 10 Nov 2008 23:17:17 -0800
Subject: [PATCH 24/33] Make --auth-no-challenge work with user:pass@ in URLs.

---
 src/ChangeLog | 4 ++++
 src/http.c    | 7 ++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index c7a378ea..12a77e5f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2008-11-10  Saint Xavier  <wget@sxav.eu>
+
+	* http.c: Make --auth-no-challenge works with user:pass@ in URLs.
+
 2008-11-05  Micah Cowan  <micah@cowan.name>
 
 	* ftp.c (print_length): Should print humanized "size remaining"
diff --git a/src/http.c b/src/http.c
index 52f65fed..0866f922 100644
--- a/src/http.c
+++ b/src/http.c
@@ -1495,9 +1495,10 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
   user = user ? user : (opt.http_user ? opt.http_user : opt.user);
   passwd = passwd ? passwd : (opt.http_passwd ? opt.http_passwd : opt.passwd);
 
-  if (user && passwd
-      && !u->user) /* We only do "site-wide" authentication with "global"
-                      user/password values; URL user/password info overrides. */
+  /* We only do "site-wide" authentication with "global" user/password
+   * values unless --auth-no-challange has been requested; URL user/password
+   * info overrides. */
+  if (user && passwd && (!u->user || opt.auth_without_challenge))
     {
       /* If this is a host for which we've already received a Basic
        * challenge, we'll go ahead and send Basic authentication creds. */

From c60c7b9941da3756a0b46130dfa15ad31132dbfa Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Tue, 11 Nov 2008 12:53:01 -0800
Subject: [PATCH 25/33] Test --auth-no-challenge, for URL- and option-specified
 user/pass.

---
 tests/ChangeLog                     | 11 +++++++
 tests/HTTPServer.pm                 |  6 ++--
 tests/Test-auth-no-challenge-url.px | 49 ++++++++++++++++++++++++++++
 tests/Test-auth-no-challenge.px     | 50 +++++++++++++++++++++++++++++
 tests/run-px                        |  2 ++
 5 files changed, 116 insertions(+), 2 deletions(-)
 create mode 100755 tests/Test-auth-no-challenge-url.px
 create mode 100755 tests/Test-auth-no-challenge.px

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 751402d0..e432c35c 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,14 @@
+2008-11-11  Micah Cowan  <micah@cowan.name>
+
+	* HTTPServer.pm (handle_auth): Allow testing of
+	--auth-no-challenge.
+
+	* Test-auth-no-challenge.px, Test-auth-no-challenge-url.px:
+	Added.
+
+	* run-px: Add Test-auth-no-challenge.px,
+	Test-auth-no-challenge-url.px.
+
 2008-11-07  Steven Schubiger  <stsc@members.fsf.org>
 
 	* run-px: Use some colors for the summary part of the test
diff --git a/tests/HTTPServer.pm b/tests/HTTPServer.pm
index b76f0985..57b0499f 100644
--- a/tests/HTTPServer.pm
+++ b/tests/HTTPServer.pm
@@ -144,8 +144,7 @@ sub handle_auth {
     my $authhdr = $req->header('Authorization');
 
     # Have we sent the challenge yet?
-    unless (defined $url_rec->{auth_challenged}
-        && $url_rec->{auth_challenged}) {
+    unless ($url_rec->{auth_challenged} || $url_rec->{auth_no_challenge}) {
         # Since we haven't challenged yet, we'd better not
         # have received authentication (for our testing purposes).
         if ($authhdr) {
@@ -166,6 +165,9 @@ sub handle_auth {
         # failed it.
         $code = 400;
         $msg  = "You didn't send auth after I sent challenge";
+        if ($url_rec->{auth_no_challenge}) {
+            $msg = "--auth-no-challenge but no auth sent."
+        }
     } else {
         my ($sent_method) = ($authhdr =~ /^(\S+)/g);
         unless ($sent_method eq $url_rec->{'auth_method'}) {
diff --git a/tests/Test-auth-no-challenge-url.px b/tests/Test-auth-no-challenge-url.px
new file mode 100755
index 00000000..53f6245b
--- /dev/null
+++ b/tests/Test-auth-no-challenge-url.px
@@ -0,0 +1,49 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $wholefile = "You're all authenticated.\n";
+
+# code, msg, headers, content
+my %urls = (
+    '/needs-auth.txt' => {
+        auth_no_challenge => 1,
+        auth_method => 'Basic',
+        user => 'fiddle-dee-dee',
+        passwd => 'Dodgson',
+        code => "200",
+        msg => "You want fries with that?",
+        headers => {
+            "Content-type" => "text/plain",
+        },
+        content => $wholefile,
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " --auth-no-challenge "
+    . "http://fiddle-dee-dee:Dodgson\@localhost:{{port}}/needs-auth.txt";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+    'needs-auth.txt' => {
+        content => $wholefile,
+    },
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test-auth-no-challenge-url",
+                              input => \%urls, 
+                              cmdline => $cmdline, 
+                              errcode => $expected_error_code, 
+                              output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test-auth-no-challenge.px b/tests/Test-auth-no-challenge.px
new file mode 100755
index 00000000..19b2a6d6
--- /dev/null
+++ b/tests/Test-auth-no-challenge.px
@@ -0,0 +1,50 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $wholefile = "You're all authenticated.\n";
+
+# code, msg, headers, content
+my %urls = (
+    '/needs-auth.txt' => {
+        auth_no_challenge => 1,
+        auth_method => 'Basic',
+        user => 'fiddle-dee-dee',
+        passwd => 'Dodgson',
+        code => "200",
+        msg => "You want fries with that?",
+        headers => {
+            "Content-type" => "text/plain",
+        },
+        content => $wholefile,
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " --auth-no-challenge"
+    . " --user=fiddle-dee-dee --password=Dodgson"
+    . " http://localhost:{{port}}/needs-auth.txt";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+    'needs-auth.txt' => {
+        content => $wholefile,
+    },
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test-auth-no-challenge",
+                              input => \%urls, 
+                              cmdline => $cmdline, 
+                              errcode => $expected_error_code, 
+                              output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/run-px b/tests/run-px
index 92e9061e..ef38418c 100755
--- a/tests/run-px
+++ b/tests/run-px
@@ -12,6 +12,8 @@ my $top_srcdir = shift @ARGV;
 
 my @tests = (
     'Test-auth-basic.px',
+    'Test-auth-no-challenge.px',
+    'Test-auth-no-challenge-url.px',
     'Test-proxy-auth-basic.px',
     'Test-proxied-https-auth.px',
     'Test-N-HTTP-Content-Disposition.px',

From fafd83c097b578be8581726cc5b52bc10bdc9238 Mon Sep 17 00:00:00 2001
From: Steven Schubiger <stsc@members.fsf.org>
Date: Tue, 11 Nov 2008 23:00:05 +0100
Subject: [PATCH 26/33] Do not handle memory within format_and_print_line.

---
 src/ChangeLog |  5 +++++
 src/main.c    | 30 ++++++++++++++++--------------
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 12a77e5f..3c023d66 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-11  Steven Schubiger  <stsc@members.fsf.org>
+
+	* main.c (format_and_print_line): Move both the memory
+	allocating and freeing bits upwards to print_version().
+
 2008-11-10  Saint Xavier  <wget@sxav.eu>
 
 	* http.c: Make --auth-no-challenge works with user:pass@ in URLs.
diff --git a/src/main.c b/src/main.c
index c39a98aa..d4fea4f3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -706,8 +706,8 @@ prompt_for_password (void)
    and an appropriate number of spaces are added on subsequent
    lines.*/
 static void
-format_and_print_line (char* prefix, char* line,
-		       int line_length) 
+format_and_print_line (const char *prefix, char *line,
+                       int line_length) 
 {
   int leading_spaces;
   int remaining_chars;
@@ -746,12 +746,6 @@ format_and_print_line (char* prefix, char* line,
     }
 
   printf ("\n");
-
-  /* FIXME: Responsibility for deallocation should be handled by
-     whatever allocated it, wherever possible. These two lines result
-     in unnecessary strdup calls in the print_version function. */
-  xfree (prefix);
-  xfree (line);
 }
 
 static void
@@ -764,6 +758,7 @@ print_version (void)
   const char *link_title    = "Link       : ";
   const char *prefix_spaces = "             ";
   const int prefix_space_length = strlen (prefix_spaces);
+  char *line;
   char *env_wgetrc, *user_wgetrc;
   int i;
 
@@ -808,17 +803,24 @@ print_version (void)
   putchar ('\n');
 #endif
 
-  format_and_print_line (strdup (locale_title),
-			 strdup (LOCALEDIR), 
+  line = xstrdup (LOCALEDIR);
+  format_and_print_line (locale_title,
+			 line, 
 			 max_chars_per_line);
+  xfree (line);
   
-  format_and_print_line (strdup (compile_title),
-			 strdup (compilation_string),
+  line = xstrdup (compilation_string);
+  format_and_print_line (compile_title,
+			 line,
 			 max_chars_per_line);
+  xfree (line);
 
-  format_and_print_line (strdup (link_title),
-			 strdup (link_string),
+  line = xstrdup (link_string);
+  format_and_print_line (link_title,
+			 line,
 			 max_chars_per_line);
+  xfree (line);
+
   printf ("\n");
   /* TRANSLATORS: When available, an actual copyright character
      (cirle-c) should be used in preference to "(C)". */

From 3c1725e7a1805c8c99f021a04f03bf5a783ffecf Mon Sep 17 00:00:00 2001
From: Steven Schubiger <stsc@members.fsf.org>
Date: Wed, 12 Nov 2008 12:02:37 +0100
Subject: [PATCH 27/33] Return some memory control back to
 format_and_print_line.

---
 src/ChangeLog |  5 +++++
 src/main.c    | 22 ++++++++++------------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 3c023d66..27f29874 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-12  Steven Schubiger  <stsc@members.fsf.org>
+
+	* main.c (print_version): Hand the relevant
+	xstrdup/xfree calls back to format_and_print_line().
+
 2008-11-11  Steven Schubiger  <stsc@members.fsf.org>
 
 	* main.c (format_and_print_line): Move both the memory
diff --git a/src/main.c b/src/main.c
index d4fea4f3..b0fceae0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -706,16 +706,18 @@ prompt_for_password (void)
    and an appropriate number of spaces are added on subsequent
    lines.*/
 static void
-format_and_print_line (const char *prefix, char *line,
+format_and_print_line (const char *prefix, const char *line,
                        int line_length) 
 {
   int leading_spaces;
   int remaining_chars;
-  char *token;
+  char *line_dup, *token;
   
   assert (prefix != NULL);
   assert (line != NULL);
 
+  line_dup = xstrdup (line);
+
   if (line_length <= 0)
     line_length = max_chars_per_line;
 
@@ -723,7 +725,7 @@ format_and_print_line (const char *prefix, char *line,
   printf ("%s", prefix);
   remaining_chars = line_length - leading_spaces;
   /* We break on spaces. */
-  token = strtok (line, " ");
+  token = strtok (line_dup, " ");
   while (token != NULL) 
     {
       /* If however a token is much larger than the maximum
@@ -746,6 +748,8 @@ format_and_print_line (const char *prefix, char *line,
     }
 
   printf ("\n");
+
+  xfree (line_dup);
 }
 
 static void
@@ -803,23 +807,17 @@ print_version (void)
   putchar ('\n');
 #endif
 
-  line = xstrdup (LOCALEDIR);
   format_and_print_line (locale_title,
-			 line, 
+			 LOCALEDIR, 
 			 max_chars_per_line);
-  xfree (line);
   
-  line = xstrdup (compilation_string);
   format_and_print_line (compile_title,
-			 line,
+			 compilation_string,
 			 max_chars_per_line);
-  xfree (line);
 
-  line = xstrdup (link_string);
   format_and_print_line (link_title,
-			 line,
+			 link_string,
 			 max_chars_per_line);
-  xfree (line);
 
   printf ("\n");
   /* TRANSLATORS: When available, an actual copyright character

From 124f1050af0476082167582bed258b20b95df7db Mon Sep 17 00:00:00 2001
From: Steven Schubiger <stsc@members.fsf.org>
Date: Wed, 12 Nov 2008 21:18:27 +0100
Subject: [PATCH 28/33] Remove shebang line from test libraries.

---
 tests/ChangeLog     | 6 ++++++
 tests/FTPServer.pm  | 3 +--
 tests/FTPTest.pm    | 3 +--
 tests/HTTPServer.pm | 3 +--
 tests/HTTPTest.pm   | 3 +--
 5 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index e432c35c..187a65a4 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-12  Steven Schubiger  <stsc@members.fsf.org>
+
+	* FTPServer.pm, FTPTest.pm, HTTPServer.pm, HTTPTest.pm:
+	Remove the magic interpreter line, because it cannot be
+	used fully. Substitute -w with use warnings.
+
 2008-11-11  Micah Cowan  <micah@cowan.name>
 
 	* HTTPServer.pm (handle_auth): Allow testing of
diff --git a/tests/FTPServer.pm b/tests/FTPServer.pm
index 8c7cada7..94f3b9a7 100644
--- a/tests/FTPServer.pm
+++ b/tests/FTPServer.pm
@@ -1,11 +1,10 @@
-#!/usr/bin/perl -w
-
 # Part of this code was borrowed from Richard Jones's Net::FTPServer
 # http://www.annexia.org/freeware/netftpserver
 
 package FTPServer;
 
 use strict;
+use warnings;
 
 use Cwd;
 use Socket;
diff --git a/tests/FTPTest.pm b/tests/FTPTest.pm
index eed2eb89..0b45c36c 100644
--- a/tests/FTPTest.pm
+++ b/tests/FTPTest.pm
@@ -1,8 +1,7 @@
-#!/usr/bin/perl -w
-
 package FTPTest;
 
 use strict;
+use warnings;
 
 use FTPServer;
 use WgetTest;
diff --git a/tests/HTTPServer.pm b/tests/HTTPServer.pm
index 57b0499f..ac055c32 100644
--- a/tests/HTTPServer.pm
+++ b/tests/HTTPServer.pm
@@ -1,8 +1,7 @@
-#!/usr/bin/perl -w
-
 package HTTPServer;
 
 use strict;
+use warnings;
 
 use HTTP::Daemon;
 use HTTP::Status;
diff --git a/tests/HTTPTest.pm b/tests/HTTPTest.pm
index 0fdcb8f0..d1f5e54f 100644
--- a/tests/HTTPTest.pm
+++ b/tests/HTTPTest.pm
@@ -1,8 +1,7 @@
-#!/usr/bin/perl -w
-
 package HTTPTest;
 
 use strict;
+use warnings;
 
 use HTTPServer;
 use WgetTest;

From 1777835073cad695bce04848aa6f33e9686e7fc1 Mon Sep 17 00:00:00 2001
From: Steven Schubiger <stsc@members.fsf.org>
Date: Wed, 12 Nov 2008 22:54:49 +0100
Subject: [PATCH 29/33] Use lexical warnings in test scripts.

---
 tests/ChangeLog                               | 31 +++++++++++++++++++
 tests/Test--no-content-disposition-trivial.px |  3 +-
 tests/Test--no-content-disposition.px         |  3 +-
 tests/Test--spider-fail.px                    |  3 +-
 ...pider-r--no-content-disposition-trivial.px |  3 +-
 .../Test--spider-r--no-content-disposition.px |  3 +-
 ...Test--spider-r-HTTP-Content-Disposition.px |  3 +-
 tests/Test--spider-r.px                       |  3 +-
 tests/Test--spider.px                         |  3 +-
 tests/Test-E-k-K.px                           |  3 +-
 tests/Test-E-k.px                             |  3 +-
 tests/Test-HTTP-Content-Disposition-1.px      |  3 +-
 tests/Test-HTTP-Content-Disposition-2.px      |  3 +-
 tests/Test-HTTP-Content-Disposition.px        |  3 +-
 .../Test-N--no-content-disposition-trivial.px |  3 +-
 tests/Test-N--no-content-disposition.px       |  3 +-
 tests/Test-N-HTTP-Content-Disposition.px      |  3 +-
 tests/Test-N-current.px                       |  3 +-
 tests/Test-N-no-info.px                       |  3 +-
 tests/Test-N-old.px                           |  3 +-
 tests/Test-N-smaller.px                       |  3 +-
 tests/Test-N.px                               |  3 +-
 .../Test-O--no-content-disposition-trivial.px |  3 +-
 tests/Test-O--no-content-disposition.px       |  3 +-
 tests/Test-O-HTTP-Content-Disposition.px      |  3 +-
 tests/Test-O-nc.px                            |  3 +-
 tests/Test-O-nonexisting.px                   |  3 +-
 tests/Test-O.px                               |  3 +-
 tests/Test-Restrict-Lowercase.px              |  3 +-
 tests/Test-Restrict-Uppercase.px              |  3 +-
 tests/Test-auth-basic.px                      |  3 +-
 tests/Test-auth-no-challenge-url.px           |  3 +-
 tests/Test-auth-no-challenge.px               |  3 +-
 tests/Test-c-full.px                          |  3 +-
 tests/Test-c-partial.px                       |  3 +-
 tests/Test-c-shorter.px                       |  3 +-
 tests/Test-c.px                               |  3 +-
 tests/Test-ftp.px                             |  3 +-
 tests/Test-nonexisting-quiet.px               |  3 +-
 tests/Test-noop.px                            |  3 +-
 tests/Test-np.px                              |  3 +-
 tests/Test-proxied-https-auth.px              |  3 +-
 tests/Test-proxy-auth-basic.px                |  3 +-
 tests/run-px                                  |  2 +-
 44 files changed, 116 insertions(+), 43 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 187a65a4..4c1b7de7 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,34 @@
+2008-11-12  Steven Schubiger  <stsc@members.fsf.org>
+
+	* Test-auth-basic.px, Test-auth-no-challenge.px,
+	Test-auth-no-challenge-url.px, Test-c-full.px,
+	Test-c-partial.px, Test-c.px, Test-c-shorter.px,
+	Test-E-k-K.px, Test-E-k.px, Test-ftp.px, 
+	Test-HTTP-Content-Disposition-1.px, 
+	Test-HTTP-Content-Disposition-2.px,
+	Test-HTTP-Content-Disposition.px, Test-N-current.px,
+	Test-N-HTTP-Content-Disposition.px,
+	Test-N--no-content-disposition.px,
+	Test-N--no-content-disposition-trivial.px,
+	Test-N-no-info.px, Test--no-content-disposition.px,
+	Test--no-content-disposition-trivial.px, Test-N-old.px,
+	Test-nonexisting-quiet.px, Test-noop.px, Test-np.px,
+	Test-N.px, Test-N-smaller.px, 
+	Test-O-HTTP-Content-Disposition.px, Test-O-nc.px,
+	Test-O--no-content-disposition.px, 
+	Test-O--no-content-disposition-trivial.px,
+	Test-O-nonexisting.px, Test-O.px,
+	Test-proxy-auth-basic.px, Test-Restrict-Lowercase.px,
+	Test-Restrict-Uppercase.px,
+	Test--spider-fail.pxm, Test--spider.px,
+	Test--spider-r-HTTP-Content-Disposition.px,
+	Test--spider-r--no-content-disposition.px,
+	Test--spider-r--no-content-disposition-trivial.px,
+	Test--spider-r.px: Enforce lexically scoped warnings.
+
+	* Test-proxied-https-auth.px, run-px: Place use strict
+	before use warnings.
+
 2008-11-12  Steven Schubiger  <stsc@members.fsf.org>
 
 	* FTPServer.pm, FTPTest.pm, HTTPServer.pm, HTTPTest.pm:
diff --git a/tests/Test--no-content-disposition-trivial.px b/tests/Test--no-content-disposition-trivial.px
index 6a5b1def..43eb7bfd 100755
--- a/tests/Test--no-content-disposition-trivial.px
+++ b/tests/Test--no-content-disposition-trivial.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test--no-content-disposition.px b/tests/Test--no-content-disposition.px
index 4975913b..7736a2e5 100755
--- a/tests/Test--no-content-disposition.px
+++ b/tests/Test--no-content-disposition.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test--spider-fail.px b/tests/Test--spider-fail.px
index b30ef755..6e5c976d 100755
--- a/tests/Test--spider-fail.px
+++ b/tests/Test--spider-fail.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test--spider-r--no-content-disposition-trivial.px b/tests/Test--spider-r--no-content-disposition-trivial.px
index 1e850d40..0bd7d29e 100755
--- a/tests/Test--spider-r--no-content-disposition-trivial.px
+++ b/tests/Test--spider-r--no-content-disposition-trivial.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test--spider-r--no-content-disposition.px b/tests/Test--spider-r--no-content-disposition.px
index 4eba8579..78beb18d 100755
--- a/tests/Test--spider-r--no-content-disposition.px
+++ b/tests/Test--spider-r--no-content-disposition.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test--spider-r-HTTP-Content-Disposition.px b/tests/Test--spider-r-HTTP-Content-Disposition.px
index 09f93fa3..e79152f7 100755
--- a/tests/Test--spider-r-HTTP-Content-Disposition.px
+++ b/tests/Test--spider-r-HTTP-Content-Disposition.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test--spider-r.px b/tests/Test--spider-r.px
index a315d974..b32f792d 100755
--- a/tests/Test--spider-r.px
+++ b/tests/Test--spider-r.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test--spider.px b/tests/Test--spider.px
index dbc97135..6e8ba499 100755
--- a/tests/Test--spider.px
+++ b/tests/Test--spider.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-E-k-K.px b/tests/Test-E-k-K.px
index d71c39e5..4a2cf614 100755
--- a/tests/Test-E-k-K.px
+++ b/tests/Test-E-k-K.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-E-k.px b/tests/Test-E-k.px
index 4581ed71..40d6b6dc 100755
--- a/tests/Test-E-k.px
+++ b/tests/Test-E-k.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-HTTP-Content-Disposition-1.px b/tests/Test-HTTP-Content-Disposition-1.px
index 01fb0901..3d270143 100755
--- a/tests/Test-HTTP-Content-Disposition-1.px
+++ b/tests/Test-HTTP-Content-Disposition-1.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-HTTP-Content-Disposition-2.px b/tests/Test-HTTP-Content-Disposition-2.px
index 46c16a17..6550d36f 100755
--- a/tests/Test-HTTP-Content-Disposition-2.px
+++ b/tests/Test-HTTP-Content-Disposition-2.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-HTTP-Content-Disposition.px b/tests/Test-HTTP-Content-Disposition.px
index 3b6eb2c9..afc964a4 100755
--- a/tests/Test-HTTP-Content-Disposition.px
+++ b/tests/Test-HTTP-Content-Disposition.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-N--no-content-disposition-trivial.px b/tests/Test-N--no-content-disposition-trivial.px
index c58f451a..83f0e4ed 100755
--- a/tests/Test-N--no-content-disposition-trivial.px
+++ b/tests/Test-N--no-content-disposition-trivial.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-N--no-content-disposition.px b/tests/Test-N--no-content-disposition.px
index 78fe522f..f142d306 100755
--- a/tests/Test-N--no-content-disposition.px
+++ b/tests/Test-N--no-content-disposition.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-N-HTTP-Content-Disposition.px b/tests/Test-N-HTTP-Content-Disposition.px
index 32f87710..d33155e4 100755
--- a/tests/Test-N-HTTP-Content-Disposition.px
+++ b/tests/Test-N-HTTP-Content-Disposition.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-N-current.px b/tests/Test-N-current.px
index b8e05a94..0ef47289 100755
--- a/tests/Test-N-current.px
+++ b/tests/Test-N-current.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-N-no-info.px b/tests/Test-N-no-info.px
index 301a9101..9dec6eda 100755
--- a/tests/Test-N-no-info.px
+++ b/tests/Test-N-no-info.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-N-old.px b/tests/Test-N-old.px
index 6ae116e5..fe16dbfb 100755
--- a/tests/Test-N-old.px
+++ b/tests/Test-N-old.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-N-smaller.px b/tests/Test-N-smaller.px
index 71e34d96..e5dceae6 100755
--- a/tests/Test-N-smaller.px
+++ b/tests/Test-N-smaller.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-N.px b/tests/Test-N.px
index 2e235e08..2f139b51 100755
--- a/tests/Test-N.px
+++ b/tests/Test-N.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-O--no-content-disposition-trivial.px b/tests/Test-O--no-content-disposition-trivial.px
index 501fd44d..75a3e6f1 100755
--- a/tests/Test-O--no-content-disposition-trivial.px
+++ b/tests/Test-O--no-content-disposition-trivial.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-O--no-content-disposition.px b/tests/Test-O--no-content-disposition.px
index 592f0fec..3369ec42 100755
--- a/tests/Test-O--no-content-disposition.px
+++ b/tests/Test-O--no-content-disposition.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-O-HTTP-Content-Disposition.px b/tests/Test-O-HTTP-Content-Disposition.px
index 934f54aa..e18880a7 100755
--- a/tests/Test-O-HTTP-Content-Disposition.px
+++ b/tests/Test-O-HTTP-Content-Disposition.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-O-nc.px b/tests/Test-O-nc.px
index 08819e4b..530ac654 100755
--- a/tests/Test-O-nc.px
+++ b/tests/Test-O-nc.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-O-nonexisting.px b/tests/Test-O-nonexisting.px
index 89744fc8..60ef7c70 100755
--- a/tests/Test-O-nonexisting.px
+++ b/tests/Test-O-nonexisting.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-O.px b/tests/Test-O.px
index 1f4e8efe..552c6654 100755
--- a/tests/Test-O.px
+++ b/tests/Test-O.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-Restrict-Lowercase.px b/tests/Test-Restrict-Lowercase.px
index 2b35f1e4..e5d270dc 100755
--- a/tests/Test-Restrict-Lowercase.px
+++ b/tests/Test-Restrict-Lowercase.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-Restrict-Uppercase.px b/tests/Test-Restrict-Uppercase.px
index 14fa81f4..1175fbd2 100755
--- a/tests/Test-Restrict-Uppercase.px
+++ b/tests/Test-Restrict-Uppercase.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-auth-basic.px b/tests/Test-auth-basic.px
index 75013609..e60be4c7 100755
--- a/tests/Test-auth-basic.px
+++ b/tests/Test-auth-basic.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-auth-no-challenge-url.px b/tests/Test-auth-no-challenge-url.px
index 53f6245b..4b947ed2 100755
--- a/tests/Test-auth-no-challenge-url.px
+++ b/tests/Test-auth-no-challenge-url.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-auth-no-challenge.px b/tests/Test-auth-no-challenge.px
index 19b2a6d6..ec322844 100755
--- a/tests/Test-auth-no-challenge.px
+++ b/tests/Test-auth-no-challenge.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-c-full.px b/tests/Test-c-full.px
index f277a023..2d107453 100755
--- a/tests/Test-c-full.px
+++ b/tests/Test-c-full.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-c-partial.px b/tests/Test-c-partial.px
index 02234242..57095472 100755
--- a/tests/Test-c-partial.px
+++ b/tests/Test-c-partial.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-c-shorter.px b/tests/Test-c-shorter.px
index 432cab92..9823e746 100755
--- a/tests/Test-c-shorter.px
+++ b/tests/Test-c-shorter.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-c.px b/tests/Test-c.px
index 8c61eb06..2fb705f1 100755
--- a/tests/Test-c.px
+++ b/tests/Test-c.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-ftp.px b/tests/Test-ftp.px
index 8cef5a55..a98d745f 100755
--- a/tests/Test-ftp.px
+++ b/tests/Test-ftp.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use FTPTest;
 
diff --git a/tests/Test-nonexisting-quiet.px b/tests/Test-nonexisting-quiet.px
index 2766b5c5..04e11587 100755
--- a/tests/Test-nonexisting-quiet.px
+++ b/tests/Test-nonexisting-quiet.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-noop.px b/tests/Test-noop.px
index 14bd851c..1e0d1871 100755
--- a/tests/Test-noop.px
+++ b/tests/Test-noop.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-np.px b/tests/Test-np.px
index 28d13eec..f674193a 100755
--- a/tests/Test-np.px
+++ b/tests/Test-np.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/Test-proxied-https-auth.px b/tests/Test-proxied-https-auth.px
index a2efe5eb..4e3fb206 100755
--- a/tests/Test-proxied-https-auth.px
+++ b/tests/Test-proxied-https-auth.px
@@ -1,6 +1,7 @@
 #!/usr/bin/perl
-use warnings;
+
 use strict;
+use warnings;
 
 use WgetTest;  # For $WGETPATH.
 
diff --git a/tests/Test-proxy-auth-basic.px b/tests/Test-proxy-auth-basic.px
index e440a392..7b3a638f 100755
--- a/tests/Test-proxy-auth-basic.px
+++ b/tests/Test-proxy-auth-basic.px
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 
 use HTTPTest;
 
diff --git a/tests/run-px b/tests/run-px
index ef38418c..0f8f2964 100755
--- a/tests/run-px
+++ b/tests/run-px
@@ -1,8 +1,8 @@
 #!/usr/bin/env perl
 
 use 5.006;
-use warnings;
 use strict;
+use warnings;
 
 use Term::ANSIColor ':constants';
 $Term::ANSIColor::AUTORESET = 1;

From cf93ce7f4b428c78ca705f0f905ba75bbb2806d5 Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Wed, 12 Nov 2008 20:47:52 -0800
Subject: [PATCH 30/33] Applied Alexander Belopolsky's patch for htmlified FTP
 listings.

---
 src/ChangeLog | 7 +++++++
 src/ftp-ls.c  | 5 ++++-
 src/url.c     | 9 +++++++++
 src/url.h     | 1 +
 4 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 27f29874..da701d6c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2008-11-12  Alexander Belopolsky  <alexander.belopolsky@gmail.com>
+
+	* url.c, url.h (url_escape_unsafe_and_reserved): Added.
+
+	* ftp-ls.c (ftp_index): URL-escape, rather than HTML-escape, the
+	filename appearing in the link.
+
 2008-11-12  Steven Schubiger  <stsc@members.fsf.org>
 
 	* main.c (print_version): Hand the relevant
diff --git a/src/ftp-ls.c b/src/ftp-ls.c
index 660302e5..dd6caa66 100644
--- a/src/ftp-ls.c
+++ b/src/ftp-ls.c
@@ -851,6 +851,7 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
   FILE *fp;
   char *upwd;
   char *htclfile;               /* HTML-clean file name */
+  char *urlclfile;              /* URL-clean file name */
 
   if (!output_stream)
     {
@@ -923,13 +924,14 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
           break;
         }
       htclfile = html_quote_string (f->name);
+      urlclfile = url_escape_unsafe_and_reserved (f->name);
       fprintf (fp, "<a href=\"ftp://%s%s:%d", upwd, u->host, u->port);
       if (*u->dir != '/')
         putc ('/', fp);
       fprintf (fp, "%s", u->dir);
       if (*u->dir)
         putc ('/', fp);
-      fprintf (fp, "%s", htclfile);
+      fprintf (fp, "%s", urlclfile);
       if (f->type == FT_DIRECTORY)
         putc ('/', fp);
       fprintf (fp, "\">%s", htclfile);
@@ -942,6 +944,7 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
         fprintf (fp, "-> %s", f->linkto ? f->linkto : "(nil)");
       putc ('\n', fp);
       xfree (htclfile);
+      xfree (urlclfile);
       f = f->next;
     }
   fprintf (fp, "</pre>\n</body>\n</html>\n");
diff --git a/src/url.c b/src/url.c
index fea95584..d416fcf7 100644
--- a/src/url.c
+++ b/src/url.c
@@ -252,6 +252,15 @@ url_escape (const char *s)
   return url_escape_1 (s, urlchr_unsafe, false);
 }
 
+/* URL-escape the unsafe and reserved characters (see urlchr_table) in
+   a given string, returning a freshly allocated string.  */
+
+char *
+url_escape_unsafe_and_reserved (const char *s)
+{
+  return url_escape_1 (s, urlchr_unsafe|urlchr_reserved, false);
+}
+
 /* URL-escape the unsafe characters (see urlchr_table) in a given
    string.  If no characters are unsafe, S is returned.  */
 
diff --git a/src/url.h b/src/url.h
index ce308f6f..f523e2ef 100644
--- a/src/url.h
+++ b/src/url.h
@@ -83,6 +83,7 @@ struct url
 /* Function declarations */
 
 char *url_escape (const char *);
+char *url_escape_unsafe_and_reserved (const char *);
 
 struct url *url_parse (const char *, int *);
 char *url_error (const char *, int);

From ca12585a0e221e31a59898fe33f1a0caf7918f26 Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Wed, 12 Nov 2008 21:00:05 -0800
Subject: [PATCH 31/33] HTML-escape dir name in title, h1.

---
 src/ChangeLog |  4 ++++
 src/ftp-ls.c  | 10 ++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index da701d6c..1d09c933 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2008-11-12  Micah Cowan  <micah@cowan.name>
+
+	* ftp-ls.c (ftp_index): HTML-escape dir name in title, h1.
+
 2008-11-12  Alexander Belopolsky  <alexander.belopolsky@gmail.com>
 
 	* url.c, url.h (url_escape_unsafe_and_reserved): Added.
diff --git a/src/ftp-ls.c b/src/ftp-ls.c
index dd6caa66..d996b8ad 100644
--- a/src/ftp-ls.c
+++ b/src/ftp-ls.c
@@ -850,6 +850,7 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
 {
   FILE *fp;
   char *upwd;
+  char *htcldir;                /* HTML-clean dir name */
   char *htclfile;               /* HTML-clean file name */
   char *urlclfile;              /* URL-clean file name */
 
@@ -879,12 +880,17 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
     }
   else
     upwd = xstrdup ("");
+
+  htcldir = html_quote_string (u->dir);
+
   fprintf (fp, "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n");
   fprintf (fp, "<html>\n<head>\n<title>");
-  fprintf (fp, _("Index of /%s on %s:%d"), u->dir, u->host, u->port);
+  fprintf (fp, _("Index of /%s on %s:%d"), htcldir, u->host, u->port);
   fprintf (fp, "</title>\n</head>\n<body>\n<h1>");
-  fprintf (fp, _("Index of /%s on %s:%d"), u->dir, u->host, u->port);
+  fprintf (fp, _("Index of /%s on %s:%d"), htcldir, u->host, u->port);
   fprintf (fp, "</h1>\n<hr>\n<pre>\n");
+
+  xfree (htcldir);
   while (f)
     {
       fprintf (fp, "  ");

From 02c211d47cb7ec6f3fdf6c10607c7172665327f0 Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Wed, 12 Nov 2008 21:44:48 -0800
Subject: [PATCH 32/33] HTML-escape dirname in href (not perfect, good enough).

---
 src/ChangeLog | 2 +-
 src/ftp-ls.c  | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 1d09c933..736a90e0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,6 +1,6 @@
 2008-11-12  Micah Cowan  <micah@cowan.name>
 
-	* ftp-ls.c (ftp_index): HTML-escape dir name in title, h1.
+	* ftp-ls.c (ftp_index): HTML-escape dir name in title, h1, a:href.
 
 2008-11-12  Alexander Belopolsky  <alexander.belopolsky@gmail.com>
 
diff --git a/src/ftp-ls.c b/src/ftp-ls.c
index d996b8ad..181c8d45 100644
--- a/src/ftp-ls.c
+++ b/src/ftp-ls.c
@@ -890,7 +890,6 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
   fprintf (fp, _("Index of /%s on %s:%d"), htcldir, u->host, u->port);
   fprintf (fp, "</h1>\n<hr>\n<pre>\n");
 
-  xfree (htcldir);
   while (f)
     {
       fprintf (fp, "  ");
@@ -934,7 +933,11 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
       fprintf (fp, "<a href=\"ftp://%s%s:%d", upwd, u->host, u->port);
       if (*u->dir != '/')
         putc ('/', fp);
-      fprintf (fp, "%s", u->dir);
+      /* XXX: Should probably URL-escape dir components here, rather
+       * than just HTML-escape, for consistency with the next bit where
+       * we use urlclfile for the file component. Anyway, this is safer
+       * than what we had... */
+      fprintf (fp, "%s", htcldir);
       if (*u->dir)
         putc ('/', fp);
       fprintf (fp, "%s", urlclfile);
@@ -954,6 +957,7 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
       f = f->next;
     }
   fprintf (fp, "</pre>\n</body>\n</html>\n");
+  xfree (htcldir);
   xfree (upwd);
   if (!output_stream)
     fclose (fp);

From c7f74c62d3e518387a8eaa51011ec83259440105 Mon Sep 17 00:00:00 2001
From: Micah Cowan <micah@cowan.name>
Date: Thu, 13 Nov 2008 00:59:53 -0800
Subject: [PATCH 33/33] Don't download content just to ignore it.

---
 src/ChangeLog | 5 +++++
 src/http.c    | 8 ++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 736a90e0..99cd940c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-13  Micah Cowan  <micah@cowan.name>
+
+	* http.c (gethttp): Don't do anything when content-length >= our
+	requested range.
+
 2008-11-12  Micah Cowan  <micah@cowan.name>
 
 	* ftp-ls.c (ftp_index): HTML-escape dir name in title, h1, a:href.
diff --git a/src/http.c b/src/http.c
index 0866f922..cd0dba85 100644
--- a/src/http.c
+++ b/src/http.c
@@ -2148,11 +2148,15 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
         }
     }
 
-  if (statcode == HTTP_STATUS_RANGE_NOT_SATISFIABLE)
+  if (statcode == HTTP_STATUS_RANGE_NOT_SATISFIABLE
+      || (hs->restval > 0 && statcode == HTTP_STATUS_OK
+          && contrange == 0 && hs->restval >= contlen)
+     )
     {
       /* If `-c' is in use and the file has been fully downloaded (or
          the remote file has shrunk), Wget effectively requests bytes
-         after the end of file and the server response with 416.  */
+         after the end of file and the server response with 416
+         (or 200 with a <= Content-Length.  */
       logputs (LOG_VERBOSE, _("\
 \n    The file is already fully retrieved; nothing to do.\n\n"));
       /* In case the caller inspects. */