]> sjero.net Git - wget/commitdiff
Merging heads.
authorMicah Cowan <micah@cowan.name>
Fri, 16 May 2008 05:36:20 +0000 (22:36 -0700)
committerMicah Cowan <micah@cowan.name>
Fri, 16 May 2008 05:36:20 +0000 (22:36 -0700)
1  2 
ChangeLog
src/ChangeLog
src/ftp.c
src/http.c
src/main.c

diff --combined ChangeLog
index 697f2ca6da2f469ccdc5b85e5731f946ec12da33,ad4c460c6bb45ec7f4c3abaf21386cc9868e2f97..1a20b3c6186bf140767485152f2ad0571981f260
+++ b/ChangeLog
@@@ -1,7 -1,8 +1,12 @@@
 -          conjunction with '-O file'.
 +2008-05-15  Micah Cowan  <micah@cowan.name>
 +
 +      * NEWS: Entry for --ask-password.
 +
+ 2008-05-14  Joao Ferreira  <joao@joaoff.com>
+       * src/main.c, src/http.c, src/ftp.c: -nc is now working in 
++      conjunction with '-O file'.
  2008-05-12  Micah Cowan  <micah@cowan.name>
  
        * NEWS: Translations and -N/-O.
  
        * NEWS: Added documentation for changes made in 1.11.2.
  
 +2008-04-30  Steven Schubiger  <stsc@members.fsf.org>
 +
 +      * lib/getdelim.c, lib/getline.c, lib/getpass.c,
 +      lib/getpass.h, lib/realloc.c, lib/stdio.h,
 +      lib/stdio.in.h, lib/stdlib.h, lib/stdlib.in.h: Imported 
 +      from gnulib.
 +      * m4/eoverflow.m4, m4/extensions.m4, m4/getdelim.m4, 
 +      m4/getline.m4, m4/getpass.m4, m4/malloc.m4, m4/realloc.m4, 
 +      m4/stdio_h.m4, m4/stdlib_h.m4: Imported from gnulib.
 +      * md5/stdint.h: Imported from gnulib.
 +      
 +      * GNUmakefile: Updated from gnulib.
 +      * lib/Makefile.am, lib/getopt.c, lib/unistd.in.h: Updated
 +      from gnulib.
 +      * m4/gnulib-cache.m4, m4/gnulib-common.m4, m4/gnulib-comp.m4,
 +      m4/include_next.m4, m4/unistd_h.m4: Updated from gnulib.
 +      * md5/Makefile.am, md5/m4/gnulib-cache.m4, md5/m4/gnulib-common.m4,
 +      md5/m4/gnulib-comp.m4, md5/m4/include_next.m4, md5/m4/md5.m4,
 +      md5/m4/stdint.m4, md5/md5.c, md5/md5.h, md5/stdint.in.h,
 +      md5/wchar.in.h: Updated from gnulib.
 + 
 +2008-04-14  Micah Cowan  <micah@cowan.name>
 +
 +      * GNUmakefile, lib/Makefile.am, lib/error.c, lib/error.h,
 +      lib/exitfail.c, lib/exitfail.h, lib/getopt.c, lib/intprops.h,
 +      lib/quote.c, lib/quote.h, lib/quotearg.c, lib/quotearg.h,
 +      lib/stdlib.in.h, lib/strerror.c, lib/string.in.h,
 +      lib/unistd.in.h, lib/wchar.in.h, lib/wctype.in.h,
 +      lib/xalloc-die.c, lib/xalloc.h, lib/xmalloc.c, m4/error.m4,
 +      m4/exitfail.m4, m4/extensions.m4, m4/gnulib-cache.m4,
 +      m4/gnulib-comp.m4, m4/include_next.m4, m4/inline.m4,
 +      m4/mbrtowc.m4, m4/mbstate_t.m4, m4/quote.m4, m4/quotearg.m4,
 +      m4/stdlib_h.m4, m4/strerror.m4, m4/string_h.m4, m4/unistd_h.m4,
 +      m4/wchar.m4, m4/wctype.m4, m4/wint_t.m4, m4/xalloc.m4,
 +      md5/Makefile.am, md5/m4/gnulib-cache.m4, md5/m4/gnulib-comp.m4,
 +      md5/m4/include_next.m4, md5/m4/md5.m4, md5/m4/stdint.m4,
 +      md5/md5.c, md5/md5.h, md5/stdint.in.h, md5/wchar.in.h: Update
 +      from Gnulib, and add the "quote" module.
 +
  2008-03-20  Micah Cowan  <micah@cowan.name>
  
        * ABOUT-NLS: Reinstated, but with a message mentioning that
diff --combined src/ChangeLog
index c5edf7a32f3eb5693395faa74237a5ef1feb4820,149bc521dc86a801bfe9022dcc76b98d0f0f3421..0d4c94b53a664c33e20ed55feb9f55ce24ffbf02
@@@ -1,12 -1,8 +1,17 @@@
+ 2008-05-15  Steven Schubiger  <schubiger@gmail.com>
+       * ftp.c (getftp): Verify that the file actually exists in FTP, by
+       checking it against the listing.
 +2008-05-15  Micah Cowan  <micah@cowan.name>
 +
 +      * main.c (prompt_for_password): Use the quote module.
 +
 +2008-05-14  Micah Cowan  <micah@cowan.name>
 +
 +      * ftp.c (ftp_retrieve_list): Symlinks and other filenames
 +      should be fully quoted.
 +
  2008-05-12  Micah Cowan  <micah@cowan.name>
  
        * main.c (main): Downgrade "-N with -O" to a warning, and switch
        printed on lines that don't display the ETA, in multibyte
        locales.
  
 +2008-04-30  Steven Schubiger  <stsc@members.fsf.org>
 +
 +      * main.c (main): New code that handles prompting for passwords
 +      when specified explicitly via command-line option (using gnulib's
 +      getpass-gnu module).
 +      (main): Include the getpass header.
 +
 +      * init.c: Add "ask-password" to the list of recognized commands.
 +
 +      * options.h: Add an according boolean member to the options
 +      struct.
 +      
 +      * sysdep.h: Comment the defines __EXTENSIONS__ and _GNU_SOURCE
 +      out, because they're now defined independently by config.h.
 +
  2008-04-27  Rabin Vincent  <rabin@rab.in>
  
        * http.c (http_loop): Fix return for the case where we don't
        * Makefile.am: Move @LIBS@ after other libraries, for better
        static-linking support. Fixes bug #22143.
  
 +2008-04-16  Steven Schubiger  <schubiger@gmail.com>
 +
 +      * ftp.c: Use Gnulib's quote function for printing filenames and
 +      such.
 +      * connect.c: Likewise.
 +      * convert.c: Likewise.
 +      * cookies.c: Likewise.
 +      * ftp-opie.c: Likewise.
 +      * gnutls.c: Likewise.
 +      * init.c: Likewise.
 +      * log.c: Likewise.
 +      * mswindows.c: Likewise.
 +      * openssl.c: Likewise.
 +      * progress.c: Likewise.
 +      * recur.c: Likewise.
 +      * res.c: Likewise.
 +      * utils.c: Likewise.
 +
 +2008-04-16  Steven Schubiger  <schubiger@gmail.com>
 +
 +      * sysdep.h: Comment the defines __EXTENSIONS__ and _GNU_SOURCE 
 +      out, because they're now defined independently by config.h.
 +
 +2008-04-14  Steven Schubiger  <schubiger@gmail.com>
 +
 +      * http.c: Use Gnulib's quote function for printing filenames and
 +      such.
 +      * wget.h: #include "quote.h".
 +
  2008-04-12  Rabin Vincent  <rabin@rab.in>
  
        * mswindows.c (fake_fork_child): Don't create a logfile for
diff --combined src/ftp.c
index 0ecc6bcb1dafbb417ed12922f75b3f433e83a812,5bfd2aa8ac526d8925bdd97177eab4287392f233..17df502996cae7154b8cb0d7b82f3fa3bd692d6f
+++ b/src/ftp.c
@@@ -227,6 -227,8 +227,8 @@@ print_length (wgint size, wgint start, 
    logputs (LOG_VERBOSE, !authoritative ? _(" (unauthoritative)\n") : "\n");
  }
  
+ static uerr_t ftp_get_listing (struct url *, ccon *, struct fileinfo **);
  /* Retrieves a file with denoted parameters through opening an FTP
     connection to the server.  It always closes the data connection,
     and closes the control connection in case of error.  */
@@@ -300,8 -302,7 +302,8 @@@ getftp (struct url *u, wgint *len, wgin
          con->csock = -1;
  
        /* Second: Login with proper USER/PASS sequence.  */
 -      logprintf (LOG_VERBOSE, _("Logging in as %s ... "), escnonprint (user));
 +      logprintf (LOG_VERBOSE, _("Logging in as %s ... "), 
 +                 quotearg_style (escape_quoting_style, user));
        if (opt.server_response)
          logputs (LOG_ALWAYS, "\n");
        err = ftp_login (csock, logname, passwd);
@@@ -546,8 -547,7 +548,8 @@@ Error in server response, closing contr
              }
  
            if (!opt.server_response)
 -            logprintf (LOG_VERBOSE, "==> CWD %s ... ", escnonprint (target));
 +            logprintf (LOG_VERBOSE, "==> CWD %s ... ", 
 +                       quotearg_style (escape_quoting_style, target));
            err = ftp_cwd (csock, target);
            /* FTPRERR, WRITEFAILED, FTPNSFOD */
            switch (err)
@@@ -568,8 -568,8 +570,8 @@@ Error in server response, closing contr
                return err;
              case FTPNSFOD:
                logputs (LOG_VERBOSE, "\n");
 -              logprintf (LOG_NOTQUIET, _("No such directory `%s'.\n\n"),
 -                         escnonprint (u->dir));
 +              logprintf (LOG_NOTQUIET, _("No such directory %s.\n\n"),
 +                         quote (u->dir));
                fd_close (csock);
                con->csock = -1;
                return err;
        if (opt.verbose)
          {
            if (!opt.server_response)
 -            logprintf (LOG_VERBOSE, "==> SIZE %s ... ", escnonprint (u->file));
 +            logprintf (LOG_VERBOSE, "==> SIZE %s ... ", 
 +                       quotearg_style (escape_quoting_style, u->file));
          }
  
        err = ftp_size (csock, u->file, len);
@@@ -779,12 -778,37 +781,37 @@@ Error in server response, closing contr
  
    if (cmd & DO_RETR)
      {
-       /* If we're in spider mode, don't really retrieve anything.  The
-          fact that we got to this point should be proof enough that
-          the file exists, vaguely akin to HTTP's concept of a "HEAD"
-          request.  */
+       /* If we're in spider mode, don't really retrieve anything except
+        the directory listing and verify whether the given "file" exists.  */
        if (opt.spider)
          {
+         bool exists = false;
+         uerr_t res;
+         struct fileinfo *f;
+         res = ftp_get_listing (u, con, &f);
+         /* Set the DO_RETR command flag again, because it gets unset when 
+            calling ftp_get_listing() and would otherwise cause an assertion 
+            failure earlier on when this function gets repeatedly called 
+            (e.g., when recursing).  */
+         con->cmd |= DO_RETR;
+         if (res == RETROK)
+           {
+             while (f) 
+               {
+                 if (!strcmp (f->name, u->file))
+                   {
+                     exists = true;
+                     break;
+                   }
+                 f = f->next;
+               }
+             if (!exists)
+               {
+                 logputs (LOG_VERBOSE, "\n");
+                 logprintf (LOG_NOTQUIET, _("No such file `%s'.\n"),
+                            escnonprint (u->file));
+               }
+           }
            fd_close (csock);
            con->csock = -1;
            fd_close (dtsock);
              {
                if (restval)
                  logputs (LOG_VERBOSE, "\n");
 -              logprintf (LOG_VERBOSE, "==> RETR %s ... ", escnonprint (u->file));
 +              logprintf (LOG_VERBOSE, "==> RETR %s ... ", 
 +                         quotearg_style (escape_quoting_style, u->file));
              }
          }
  
@@@ -827,8 -850,8 +854,8 @@@ Error in server response, closing contr
            return err;
          case FTPNSFOD:
            logputs (LOG_VERBOSE, "\n");
 -          logprintf (LOG_NOTQUIET, _("No such file `%s'.\n\n"),
 -                     escnonprint (u->file));
 +          logprintf (LOG_NOTQUIET, _("No such file %s.\n\n"),
 +                     quote (u->file));
            fd_close (dtsock);
            fd_close (local_sock);
            return err;
@@@ -874,8 -897,8 +901,8 @@@ Error in server response, closing contr
            return err;
          case FTPNSFOD:
            logputs (LOG_VERBOSE, "\n");
 -          logprintf (LOG_NOTQUIET, _("No such file or directory `%s'.\n\n"),
 -                     ".");
 +          logprintf (LOG_NOTQUIET, _("No such file or directory %s.\n\n"),
 +                     quote ("."));
            fd_close (dtsock);
            fd_close (local_sock);
            return err;
                char *p = strchr (line, '\0');
                while (p > line && (p[-1] == '\n' || p[-1] == '\r'))
                  *--p = '\0';
 -              logprintf (LOG_ALWAYS, "%s\n", escnonprint (line));
 +              logprintf (LOG_ALWAYS, "%s\n", 
 +                         quotearg_style (escape_quoting_style, line));
                xfree (line);
              }
            fclose (fp);
@@@ -1096,10 -1118,12 +1123,12 @@@ ftp_loop_internal (struct url *u, struc
    if (!con->target)
      con->target = url_file_name (u);
  
-   if (opt.noclobber && file_exists_p (con->target))
+   /* If the output_document was given, then this check was already done and
+      the file didn't exist. Hence the !opt.output_document */
+   if (opt.noclobber && !opt.output_document && file_exists_p (con->target))
      {
        logprintf (LOG_VERBOSE,
 -                 _("File `%s' already there; not retrieving.\n"), con->target);
 +                 _("File %s already there; not retrieving.\n"), quote (con->target));
        /* If the file is there, we suppose it's retrieved OK.  */
        return RETROK;
      }
            strcpy (tmp, "        ");
            if (count > 1)
              sprintf (tmp, _("(try:%2d)"), count);
 -          logprintf (LOG_VERBOSE, "--%s--  %s\n  %s => `%s'\n",
 -                     tms, hurl, tmp, locf);
 +          logprintf (LOG_VERBOSE, "--%s--  %s\n  %s => %s\n",
 +                     tms, hurl, tmp, quote (locf));
  #ifdef WINDOWS
            ws_changetitle (hurl);
  #endif
            con->csock = -1;
          }
        if (!opt.spider)
 -        logprintf (LOG_VERBOSE, _("%s (%s) - `%s' saved [%s]\n\n"),
 -                   tms, tmrate, locf, number_to_static_string (len));
 +        logprintf (LOG_VERBOSE, _("%s (%s) - %s saved [%s]\n\n"),
 +                   tms, tmrate, quote (locf), number_to_static_string (len));
        if (!opt.verbose && !opt.quiet)
          {
            /* Need to hide the password from the URL.  The `if' is here
@@@ -1323,7 -1347,7 +1352,7 @@@ ftp_get_listing (struct url *u, ccon *c
    uf = url_file_name (u);
    lf = file_merge (uf, LIST_FILENAME);
    xfree (uf);
 -  DEBUGP ((_("Using `%s' as listing tmp file.\n"), lf));
 +  DEBUGP ((_("Using %s as listing tmp file.\n"), quote (lf)));
  
    con->target = lf;
    err = ftp_loop_internal (u, NULL, con);
            if (unlink (lf))
              logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));
            else
 -            logprintf (LOG_VERBOSE, _("Removed `%s'.\n"), lf);
 +            logprintf (LOG_VERBOSE, _("Removed %s.\n"), quote (lf));
          }
      }
    else
@@@ -1444,15 -1468,15 +1473,15 @@@ ftp_retrieve_list (struct url *u, struc
                    /* Remote file is older, file sizes can be compared and
                       are both equal. */
                    logprintf (LOG_VERBOSE, _("\
 -Remote file no newer than local file `%s' -- not retrieving.\n"), con->target);
 +Remote file no newer than local file %s -- not retrieving.\n"), quote (con->target));
                    dlthis = false;
                  }
                else if (eq_size)
                  {
                    /* Remote file is newer or sizes cannot be matched */
                    logprintf (LOG_VERBOSE, _("\
 -Remote file is newer than local file `%s' -- retrieving.\n\n"),
 -                             con->target);
 +Remote file is newer than local file %s -- retrieving.\n\n"),
 +                             quote (con->target));
                  }
                else
                  {
@@@ -1494,15 -1518,14 +1523,15 @@@ The sizes do not match (local %s) -- re
                              {
                                logprintf (LOG_VERBOSE, _("\
  Already have correct symlink %s -> %s\n\n"),
 -                                         con->target, escnonprint (f->linkto));
 +                                         quote (con->target),
 +                                         quote (f->linkto));
                                dlthis = false;
                                break;
                              }
                          }
                      }
                    logprintf (LOG_VERBOSE, _("Creating symlink %s -> %s\n"),
 -                             con->target, escnonprint (f->linkto));
 +                             quote (con->target), quote (f->linkto));
                    /* Unlink before creating symlink!  */
                    unlink (con->target);
                    if (symlink (f->linkto, con->target) == -1)
                  } /* have f->linkto */
  #else  /* not HAVE_SYMLINK */
                logprintf (LOG_NOTQUIET,
 -                         _("Symlinks not supported, skipping symlink `%s'.\n"),
 -                         con->target);
 +                         _("Symlinks not supported, skipping symlink %s.\n"),
 +                         quote (con->target));
  #endif /* not HAVE_SYMLINK */
              }
            else                /* opt.retr_symlinks */
            break;
          case FT_DIRECTORY:
            if (!opt.recursive)
 -            logprintf (LOG_NOTQUIET, _("Skipping directory `%s'.\n"),
 -                       escnonprint (f->name));
 +            logprintf (LOG_NOTQUIET, _("Skipping directory %s.\n"),
 +                       quote (f->name));
            break;
          case FT_PLAINFILE:
            /* Call the retrieve loop.  */
            break;
          case FT_UNKNOWN:
            logprintf (LOG_NOTQUIET, _("%s: unknown/unsupported file type.\n"),
 -                     escnonprint (f->name));
 +                     quote (f->name));
            break;
          }       /* switch */
  
@@@ -1638,8 -1661,8 +1667,8 @@@ ftp_retrieve_dirs (struct url *u, struc
        if (!accdir (newdir))
          {
            logprintf (LOG_VERBOSE, _("\
 -Not descending to `%s' as it is excluded/not-included.\n"),
 -                     escnonprint (newdir));
 +Not descending to %s as it is excluded/not-included.\n"),
 +                     quote (newdir));
            continue;
          }
  
@@@ -1703,8 -1726,8 +1732,8 @@@ ftp_retrieve_glob (struct url *u, ccon 
          {
            if (f->type != FT_DIRECTORY && !acceptable (f->name))
              {
 -              logprintf (LOG_VERBOSE, _("Rejecting `%s'.\n"),
 -                         escnonprint (f->name));
 +              logprintf (LOG_VERBOSE, _("Rejecting %s.\n"),
 +                         quote (f->name));
                f = delelement (f, &start);
              }
            else
      {
        if (has_insecure_name_p (f->name))
          {
 -          logprintf (LOG_VERBOSE, _("Rejecting `%s'.\n"),
 -                     escnonprint (f->name));
 +          logprintf (LOG_VERBOSE, _("Rejecting %s.\n"),
 +                     quote (f->name));
            f = delelement (f, &start);
          }
        else
                if (matchres == -1)
                  {
                    logprintf (LOG_NOTQUIET, _("Error matching %s against %s: %s\n"),
 -                             u->file, escnonprint (f->name), strerror (errno));
 +                             u->file, quotearg_style (escape_quoting_style, f->name), 
 +                             strerror (errno));
                    break;
                  }
                if (matchres == FNM_NOMATCH)
            /* No luck.  */
            /* #### This message SUCKS.  We should see what was the
               reason that nothing was retrieved.  */
 -          logprintf (LOG_VERBOSE, _("No matches on pattern `%s'.\n"),
 -                     escnonprint (u->file));
 +          logprintf (LOG_VERBOSE, _("No matches on pattern %s.\n"),
 +                     quote (u->file));
          }
        else /* GLOB_GETONE or GLOB_GETALL */
          {
@@@ -1848,13 -1870,13 +1877,13 @@@ ftp_loop (struct url *u, int *dt, struc
                        else
                          sz = -1;
                        logprintf (LOG_NOTQUIET,
 -                                 _("Wrote HTML-ized index to `%s' [%s].\n"),
 -                                 filename, number_to_static_string (sz));
 +                                 _("Wrote HTML-ized index to %s [%s].\n"),
 +                                 quote (filename), number_to_static_string (sz));
                      }
                    else
                      logprintf (LOG_NOTQUIET,
 -                               _("Wrote HTML-ized index to `%s'.\n"),
 -                               filename);
 +                               _("Wrote HTML-ized index to %s.\n"),
 +                               quote (filename));
                  }
                xfree (filename);
              }
diff --combined src/http.c
index 0252d3421f07f491a59c443f50ab08aa6480d2af,20f0619ad570835dc531349a9cc1a8d5f482cc0d..11dc9cc8f7d08c2678e09a486f135e21118e16de
@@@ -403,13 -403,13 +403,13 @@@ maybe_send_basic_creds (const char *hos
    else if (basic_authed_hosts
        && hash_table_contains(basic_authed_hosts, hostname))
      {
 -      DEBUGP(("Found `%s' in basic_authed_hosts.\n", hostname));
 +      DEBUGP(("Found %s in basic_authed_hosts.\n", quote (hostname)));
        do_challenge = true;
      }
    else
      {
 -      DEBUGP(("Host `%s' has not issued a general basic challenge.\n",
 -              hostname));
 +      DEBUGP(("Host %s has not issued a general basic challenge.\n",
 +              quote (hostname)));
      }
    if (do_challenge)
      {
@@@ -430,7 -430,7 +430,7 @@@ register_basic_auth_host (const char *h
    if (!hash_table_contains(basic_authed_hosts, hostname))
      {
        hash_table_put (basic_authed_hosts, xstrdup(hostname), NULL);
 -      DEBUGP(("Inserted `%s' into basic_authed_hosts\n", hostname));
 +      DEBUGP(("Inserted %s into basic_authed_hosts\n", quote (hostname)));
      }
  }
  
@@@ -810,8 -810,7 +810,8 @@@ print_response_line(const char *prefix
  {
    char *copy;
    BOUNDED_TO_ALLOCA(b, e, copy);
 -  logprintf (LOG_ALWAYS, "%s%s\n", prefix, escnonprint(copy));
 +  logprintf (LOG_ALWAYS, "%s%s\n", prefix, 
 +             quotearg_style (escape_quoting_style, copy));
  }
  
  /* Print the server response, line by line, omitting the trailing CRLF
@@@ -1545,8 -1544,8 +1545,8 @@@ gethttp (struct url *u, struct http_sta
            post_data_size = file_size (opt.post_file_name);
            if (post_data_size == -1)
              {
 -              logprintf (LOG_NOTQUIET, _("POST data file `%s' missing: %s\n"),
 -                         opt.post_file_name, strerror (errno));
 +              logprintf (LOG_NOTQUIET, _("POST data file %s missing: %s\n"),
 +                         quote (opt.post_file_name), strerror (errno));
                post_data_size = 0;
              }
          }
            sock = pconn.socket;
            using_ssl = pconn.ssl;
            logprintf (LOG_VERBOSE, _("Reusing existing connection to %s:%d.\n"),
 -                     escnonprint (pconn.host), pconn.port);
 +                     quotearg_style (escape_quoting_style, pconn.host), 
 +                     pconn.port);
            DEBUGP (("Reusing fd %d.\n", sock));
            if (pconn.authorized)
              /* If the connection is already authorized, the "Basic"
          {
            request_free (req);
            logprintf(LOG_NOTQUIET,
 -                    _("%s: unable to resolve host address `%s'\n"),
 -                    exec_name, relevant->host);
 +                    _("%s: unable to resolve host address %s\n"),
 +                    exec_name, quote (relevant->host));
            return HOSTERR;
          }
      }
              {
              failed_tunnel:
                logprintf (LOG_NOTQUIET, _("Proxy tunneling failed: %s"),
 -                         message ? escnonprint (message) : "?");
 +                         message ? quotearg_style (escape_quoting_style, message) : "?");
                xfree_null (message);
                return CONSSLERR;
              }
    statcode = resp_status (resp, &message);
    if (!opt.server_response)
      logprintf (LOG_VERBOSE, "%2d %s\n", statcode,
 -               message ? escnonprint (message) : "");
 +               message ? quotearg_style (escape_quoting_style, message) : "");
    else
      {
        logprintf (LOG_VERBOSE, "\n");
    /* TODO: perform this check only once. */
    if (!hs->existence_checked && file_exists_p (hs->local_file))
      {
-       if (opt.noclobber)
+       if (opt.noclobber && !opt.output_document)
          {
            /* If opt.noclobber is turned on and file already exists, do not
-              retrieve the file */
+              retrieve the file. But if the output_document was given, then this
+              test was already done and the file didn't exist. Hence the !opt.output_document */
            logprintf (LOG_VERBOSE, _("\
 -File `%s' already there; not retrieving.\n\n"), hs->local_file);
 +File %s already there; not retrieving.\n\n"), quote (hs->local_file));
            /* If the file is there, we suppose it's retrieved OK.  */
            *dt |= RETROKF;
  
              logputs (LOG_VERBOSE,
                       opt.ignore_length ? _("ignored") : _("unspecified"));
            if (type)
 -            logprintf (LOG_VERBOSE, " [%s]\n", escnonprint (type));
 +            logprintf (LOG_VERBOSE, " [%s]\n", quotearg_style (escape_quoting_style, type));
            else
              logputs (LOG_VERBOSE, "\n");
          }
    /* Print fetch message, if opt.verbose.  */
    if (opt.verbose)
      {
 -      logprintf (LOG_NOTQUIET, _("Saving to: `%s'\n"), 
 -                 HYPHENP (hs->local_file) ? "STDOUT" : hs->local_file);
 +      logprintf (LOG_NOTQUIET, _("Saving to: %s\n"), 
 +                 HYPHENP (hs->local_file) ? quote ("STDOUT") : quote (hs->local_file));
      }
      
    /* This confuses the timestamping code that checks for file size.
@@@ -2376,13 -2375,14 +2377,14 @@@ http_loop (struct url *u, char **newloc
  
    /* TODO: Ick! This code is now in both gethttp and http_loop, and is
     * screaming for some refactoring. */
-   if (got_name && file_exists_p (hstat.local_file) && opt.noclobber)
+   if (got_name && file_exists_p (hstat.local_file) && opt.noclobber && !opt.output_document)
      {
        /* If opt.noclobber is turned on and file already exists, do not
-          retrieve the file */
+          retrieve the file. But if the output_document was given, then this
+          test was already done and the file didn't exist. Hence the !opt.output_document */
        logprintf (LOG_VERBOSE, _("\
 -File `%s' already there; not retrieving.\n\n"), 
 -                 hstat.local_file);
 +File %s already there; not retrieving.\n\n"), 
 +                 quote (hstat.local_file));
        /* If the file is there, we suppose it's retrieved OK.  */
        *dt |= RETROKF;
  
@@@ -2510,8 -2510,8 +2512,8 @@@ Spider mode enabled. Check if remote fi
          case FWRITEERR: case FOPENERR:
            /* Another fatal error.  */
            logputs (LOG_VERBOSE, "\n");
 -          logprintf (LOG_NOTQUIET, _("Cannot write to `%s' (%s).\n"),
 -                     hstat.local_file, strerror (errno));
 +          logprintf (LOG_NOTQUIET, _("Cannot write to %s (%s).\n"),
 +                     quote (hstat.local_file), strerror (errno));
          case HOSTERR: case CONIMPOSSIBLE: case PROXERR: case AUTHFAILED: 
          case SSLINITFAILED: case CONTNOTSUPPORTED:
            /* Fatal errors just return from the function.  */
@@@ -2579,8 -2579,7 +2581,8 @@@ Remote file does not exist -- broken li
            else
              {
                logprintf (LOG_NOTQUIET, _("%s ERROR %d: %s.\n"),
 -                         tms, hstat.statcode, escnonprint (hstat.error));
 +                         tms, hstat.statcode, 
 +                         quotearg_style (escape_quoting_style, hstat.error));
              }
            logputs (LOG_VERBOSE, "\n");
            ret = WRONGCODE;
@@@ -2634,8 -2633,8 +2636,8 @@@ Last-modified header invalid -- time-st
                                    || hstat.orig_file_size == hstat.contlen)
                                  {
                                    logprintf (LOG_VERBOSE, _("\
 -Server file no newer than local file `%s' -- not retrieving.\n\n"),
 -                                             hstat.orig_file_name);
 +Server file no newer than local file %s -- not retrieving.\n\n"),
 +                                             quote (hstat.orig_file_name));
                                    ret = RETROK;
                                    goto exit;
                                  }
@@@ -2738,8 -2737,8 +2740,8 @@@ Remote file exists.\n\n"))
            if (*dt & RETROKF)
              {
                logprintf (LOG_VERBOSE,
 -                         _("%s (%s) - `%s' saved [%s/%s]\n\n"),
 -                         tms, tmrate, hstat.local_file,
 +                         _("%s (%s) - %s saved [%s/%s]\n\n"),
 +                         tms, tmrate, quote (hstat.local_file),
                           number_to_static_string (hstat.len),
                           number_to_static_string (hstat.contlen));
                logprintf (LOG_NONVERBOSE,
                if (*dt & RETROKF)
                  {
                    logprintf (LOG_VERBOSE,
 -                             _("%s (%s) - `%s' saved [%s]\n\n"),
 -                             tms, tmrate, hstat.local_file,
 +                             _("%s (%s) - %s saved [%s]\n\n"),
 +                             tms, tmrate, quote (hstat.local_file),
                               number_to_static_string (hstat.len));
                    logprintf (LOG_NONVERBOSE,
                               "%s URL:%s [%s] -> \"%s\" [%d]\n",
diff --combined src/main.c
index e239b6d009ff0aa71456ed150aacc7a69c585e0b,fdf368a51fc2e897e9fc2e236a8d5e9744bea2f5..159973a0021a2e36e80d5c389f8c40fa38f3b91e
@@@ -56,8 -56,6 +56,8 @@@ as that of the covered work.  *
  #include "http.h"               /* for save_cookies */
  
  #include <getopt.h>
 +#include <getpass.h>
 +#include <quote.h>
  
  #ifndef PATH_SEPARATOR
  # define PATH_SEPARATOR '/'
@@@ -132,7 -130,6 +132,7 @@@ static struct cmdline_option option_dat
    {
      { "accept", 'A', OPT_VALUE, "accept", -1 },
      { "append-output", 'a', OPT__APPEND_OUTPUT, NULL, required_argument },
 +    { "ask-password", 0, OPT_BOOLEAN, "askpassword", -1 },
      { "auth-no-challenge", 0, OPT_BOOLEAN, "authnochallenge", -1 },
      { "background", 'b', OPT_BOOLEAN, "background", -1 },
      { "backup-converted", 'K', OPT_BOOLEAN, "backupconverted", -1 },
@@@ -475,8 -472,6 +475,8 @@@ Download:\n")
         --user=USER               set both ftp and http user to USER.\n"),
      N_("\
         --password=PASS           set both ftp and http password to PASS.\n"),
 +    N_("\
 +       --ask-password            prompt for passwords.\n"),
      "\n",
  
      N_("\
@@@ -678,16 -673,6 +678,16 @@@ secs_to_human_time (double interval
    return buf;
  }
  
 +static char *
 +prompt_for_password (void)
 +{
 +  if (opt.user)
 +    printf (_("Password for user %s: "), quote (opt.user));
 +  else
 +    printf (_("Password: "));
 +  return getpass("");
 +}
 +
  static void
  print_version (void)
  {
@@@ -920,15 -905,14 +920,21 @@@ WARNING: timestamping does nothing in c
  for details.\n\n"));
            opt.timestamping = false;
          }
+       if (opt.noclobber && file_exists_p(opt.output_document)) 
+            { 
+               /* Check if output file exists; if it does, exit. */
+               logprintf (LOG_VERBOSE, _("File `%s' already there; not retrieving.\n"), opt.output_document);
+               exit(1);
+            }  
      }
  
 +  if (opt.ask_passwd && opt.passwd)
 +    {
 +      printf (_("Cannot specify both --ask-password and --password.\n"));
 +      print_usage ();
 +      exit (1);
 +    }
 +
    if (!nurl && !opt.input_filename)
      {
        /* No URL specified.  */
        char *filename = NULL, *redirected_URL = NULL;
        int dt;
  
 +      if (opt.ask_passwd)
 +        opt.passwd = prompt_for_password ();
 +
        if ((opt.recursive || opt.page_requisites)
            && (url_scheme (*t) != SCHEME_FTP || url_uses_proxy (*t)))
          {