From: Micah Cowan Date: Sat, 13 Jun 2009 11:48:18 +0000 (-0700) Subject: Merge in gerel's url-parsing stuff. X-Git-Tag: v1.13~345 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=94d6650817110c639975d45df57b345e10b0e396;hp=8d07fbcc9f653e36e7c9f8924baac0dafbcae62d Merge in gerel's url-parsing stuff. --- diff --git a/ChangeLog b/ChangeLog index ac384a49..e7b0060b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2009-06-12 Micah Cowan + + * configure.ac: Check for h_errno declaration. Idea thanks to + Maciej W. Rozycki. + +2009-03-03 Steven Schubiger + + * src/ftp.c, src/http.c, src/main.c, src/recur.h, + tests/Makefile.am: Update the copyright years. + +2009-01-23 Steven Schubiger + + * util/freeopts, util/rmold.pl, util/trunc.c: Remove + unnecessary whitespace. + 2008-11-10 Micah Cowan * MAILING-LIST: Mention Gmane, introduce subsections. diff --git a/configure.ac b/configure.ac index 2ccc703d..78fd5e14 100644 --- a/configure.ac +++ b/configure.ac @@ -163,6 +163,8 @@ AC_CHECK_HEADERS(unistd.h sys/time.h) AC_CHECK_HEADERS(termios.h sys/ioctl.h sys/select.h utime.h sys/utime.h) AC_CHECK_HEADERS(stdint.h inttypes.h pwd.h wchar.h) +AC_CHECK_DECLS(h_errno,,,[#include ]) + dnl dnl Check sizes of integer types. These are used to find n-bit dnl integral types on older systems that fail to provide intN_t and diff --git a/doc/ChangeLog b/doc/ChangeLog index 9c50b60d..06b05fe1 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,23 @@ +2009-06-12 Micah Cowan + + * wget.texi (Download Options): More accuracy on what happens when + -nd is used with -r or -p. + +2009-06-11 Micah Cowan + + * wget.texi (Contributors): Added Xin Zou, Benjamin Wolsley, and + Robert Millan. + +2009-06-11 Joao Ferreira + + * wget.texi (Option Syntax): Fixed contradictory and confusing + explanation of --folow-ftp and negation. + +2009-06-10 Micah Cowan + + * sample.wgetrc: Add "https_proxy" to the proxy examples. Thanks + to Martin Paul for the suggestion. + 2008-11-15 Steven Schubiger * sample.wgetrc: Comment the waitretry "default" value, diff --git a/doc/sample.wgetrc b/doc/sample.wgetrc index 08e810fd..62981c8f 100644 --- a/doc/sample.wgetrc +++ b/doc/sample.wgetrc @@ -73,8 +73,9 @@ # is *not* sent by default. #header = Accept-Language: en -# You can set the default proxies for Wget to use for http and ftp. +# You can set the default proxies for Wget to use for http, https, and ftp. # They will override the value in the environment. +#https_proxy = http://proxy.yoyodyne.com:18023/ #http_proxy = http://proxy.yoyodyne.com:18023/ #ftp_proxy = http://proxy.yoyodyne.com:18023/ diff --git a/doc/wget.texi b/doc/wget.texi index 6e0dd0a0..05f19d95 100644 --- a/doc/wget.texi +++ b/doc/wget.texi @@ -396,8 +396,8 @@ the option name; negative options can be negated by omitting the @samp{--no-} prefix. This might seem superfluous---if the default for an affirmative option is to not do something, then why provide a way to explicitly turn it off? But the startup file may in fact change -the default. For instance, using @code{follow_ftp = off} in -@file{.wgetrc} makes Wget @emph{not} follow FTP links by default, and +the default. For instance, using @code{follow_ftp = on} in +@file{.wgetrc} makes Wget @emph{follow} FTP links by default, and using @samp{--no-follow-ftp} is the only way to restore the factory default from the command line. @@ -582,23 +582,24 @@ behavior depends on a few options, including @samp{-nc}. In certain cases, the local file will be @dfn{clobbered}, or overwritten, upon repeated download. In other cases it will be preserved. -When running Wget without @samp{-N}, @samp{-nc}, @samp{-r}, or @samp{p}, -downloading the same file in the same directory will result in the -original copy of @var{file} being preserved and the second copy being -named @samp{@var{file}.1}. If that file is downloaded yet again, the -third copy will be named @samp{@var{file}.2}, and so on. When -@samp{-nc} is specified, this behavior is suppressed, and Wget will -refuse to download newer copies of @samp{@var{file}}. Therefore, -``@code{no-clobber}'' is actually a misnomer in this mode---it's not -clobbering that's prevented (as the numeric suffixes were already -preventing clobbering), but rather the multiple version saving that's -prevented. - -When running Wget with @samp{-r} or @samp{-p}, but without @samp{-N} -or @samp{-nc}, re-downloading a file will result in the new copy -simply overwriting the old. Adding @samp{-nc} will prevent this -behavior, instead causing the original version to be preserved and any -newer copies on the server to be ignored. +When running Wget without @samp{-N}, @samp{-nc}, @samp{-r}, or +@samp{-p}, downloading the same file in the same directory will result +in the original copy of @var{file} being preserved and the second copy +being named @samp{@var{file}.1}. If that file is downloaded yet +again, the third copy will be named @samp{@var{file}.2}, and so on. +(This is also the behavior with @samp{-nd}, even if @samp{-r} or +@samp{-p} are in effect.) When @samp{-nc} is specified, this behavior +is suppressed, and Wget will refuse to download newer copies of +@samp{@var{file}}. Therefore, ``@code{no-clobber}'' is actually a +misnomer in this mode---it's not clobbering that's prevented (as the +numeric suffixes were already preventing clobbering), but rather the +multiple version saving that's prevented. + +When running Wget with @samp{-r} or @samp{-p}, but without @samp{-N}, +@samp{-nd}, or @samp{-nc}, re-downloading a file will result in the +new copy simply overwriting the old. Adding @samp{-nc} will prevent +this behavior, instead causing the original version to be preserved +and any newer copies on the server to be ignored. When running Wget with @samp{-N}, with or without @samp{-r} or @samp{-p}, the decision as to whether or not to download a newer copy @@ -3964,6 +3965,7 @@ Aurelien Marchand, Matthew J.@: Mellon, Jordan Mendelson, Ted Mielczarek, +Robert Millan, Lin Zhe Min, Jan Minar, Tim Mooney, @@ -4039,6 +4041,7 @@ Charles G Waldman, Douglas E.@: Wegscheid, Ralf Wildenhues, Joshua David Williams, +Benjamin Wolsey, YAMAZAKI Makoto, Jasmin Zainul, @iftex @@ -4047,7 +4050,8 @@ Bojan @v{Z}drnja, @ifnottex Bojan Zdrnja, @end ifnottex -Kristijan Zimmer. +Kristijan Zimmer, +Xin Zou. Apologies to all who I accidentally left out, and many thanks to all the subscribers of the Wget mailing list. diff --git a/src/ChangeLog b/src/ChangeLog index 5eb9985e..58e44a87 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,94 @@ +2009-06-12 Micah Cowan + + * host.c: Include before . Not + required by POSIX any more, but some older systems (such as + FreeBSD 4.1) still need it, and it doesn't seem like it could + hurt... + + * build_info.c (library): Handle "https" as a feature in its own + right, apart from "gnutls" and "openssl". + + * host.c: Declare h_errno if no declaration is provided. Idea + thanks to Maciej W. Rozycki. + +2009-06-11 Xin Zou + + * http.c (gethttp): Fix some memory leaks. + +2009-06-11 Micah Cowan + + * http.c (http_atotm): Handle potential for setlocale's return + value to be static storage. Thanks to Benjamin Wolsey + . + + * sysdep.h: Need NAMESPACE_TWEAKS on non-Linux glibc-based + systems, too. Thanks to Robert Millan. + +2009-05-28 Steven Schubiger + + * ftp.c (ftp_get_listing): Update the "listing file" + string after calling ftp_loop_internal(). + +2009-05-27 Steven Schubiger + + * ftp.c (ftp_get_listing): Duplicate the "listing file" + string to avoid memory corruption when FOPEN_EXCL_ERR is + encountered. + +2009-05-17 Steven Schubiger + + * progress.c (eta_to_human_short): Fix the remaining hours + to be displayed. Spotted by Tadeu Martins (#26411). + +2009-04-24 Micah Cowan + + * hash.c: Change stdint.h inclusion to use HAVE_STDINT_H, not C99 + check. + + * connect.c: stdint.h inclusion added. + + Thanks to Markus Duft for a similar patch. + +2009-04-20 Micah Cowan + + * Makefile.am (version.c): Fix unportable use of "echo -n". + +2009-04-13 Steven Schubiger + + * ftp.c (ftp_retrieve_list): Move the duplicated code that + determines the local file to a function. + + * http.c (http_loop): Likewise. + + * retr.c (set_local_file): New function. + +2009-04-11 Steven Schubiger + + * init.c (initialize): Run a custom SYSTEM_WGETRC when + provided as an environment variable. + +2009-02-27 Gisle Vanem + + * main.c (main): "freopen (NULL,.." causes an assertion in MSVC + debug-mode. I.e. NULL isn't legal. But the "CONOUT$" device works + fine. + +2009-02-27 Steven Schubiger + + * ftp.c (ftp_loop_internal): Don't claim for FTP retrievals + when writing to standard output either that the document + has been saved. Addresses bug #20520 again. + +2009-02-21 Steven Schubiger + + * http.c (http_loop): When a document is written to + standard output, don't claim it has been saved to a file. + Addresses bug #20520. + +2009-02-18 Steven Schubiger + + * recur.h: Remove the dangling declaration for recursive_cleanup(). + 2009-02-01 Gerardo E. Gidoni * main.c, recur.c, recur.h, res.c, retr.c, retr.h: restructured code to diff --git a/src/Makefile.am b/src/Makefile.am index 441cfa1b..16e4bcb0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,7 +62,7 @@ version.c: $(wget_SOURCES) $(LDADD) $(srcdir)/Makefile.am echo '/* version.c */' > $@ echo '/* Autogenerated by Makefile - DO NOT EDIT */' >> $@ echo '' >> $@ - echo -n 'const char *version_string = "@VERSION@"' >> $@ + echo 'const char *version_string = "@VERSION@"' >> $@ -hg log -r . --template='" ({node|short})"\n' 2>/dev/null >> $@ echo ';' >> $@ echo 'const char *compilation_string = "'$(COMPILE)'";' \ diff --git a/src/build_info.c b/src/build_info.c index 551b7d94..f60c76ee 100644 --- a/src/build_info.c +++ b/src/build_info.c @@ -80,6 +80,12 @@ const char* (compiled_features[]) = "-md5", #endif +#ifdef HAVE_SSL + "+https", +#else + "-https", +#endif + #ifdef HAVE_LIBGNUTLS "+gnutls", #else diff --git a/src/connect.c b/src/connect.c index 1e8f07e5..f46f11c4 100644 --- a/src/connect.c +++ b/src/connect.c @@ -59,6 +59,11 @@ as that of the covered work. */ #include "connect.h" #include "hash.h" +/* Apparently needed for Interix: */ +#ifdef HAVE_STDINT_H +# include +#endif + /* Define sockaddr_storage where unavailable (presumably on IPv4-only hosts). */ diff --git a/src/ftp.c b/src/ftp.c index e4b90189..171a38a4 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -1,6 +1,6 @@ /* File Transfer Protocol support. Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -1275,8 +1275,17 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con) con->csock = -1; } if (!opt.spider) - logprintf (LOG_VERBOSE, _("%s (%s) - %s saved [%s]\n\n"), - tms, tmrate, quote (locf), number_to_static_string (len)); + { + bool write_to_stdout = (opt.output_document && HYPHENP (opt.output_document)); + + logprintf (LOG_VERBOSE, + write_to_stdout + ? _("%s (%s) - written to stdout %s[%s]\n\n") + : _("%s (%s) - %s saved [%s]\n\n"), + tms, tmrate, + write_to_stdout ? "" : quote (locf), + number_to_static_string (len)); + } if (!opt.verbose && !opt.quiet) { /* Need to hide the password from the URL. The `if' is here @@ -1361,8 +1370,11 @@ ftp_get_listing (struct url *u, ccon *con, struct fileinfo **f) xfree (uf); DEBUGP ((_("Using %s as listing tmp file.\n"), quote (lf))); - con->target = lf; + con->target = xstrdup (lf); + xfree (lf); err = ftp_loop_internal (u, NULL, con); + lf = xstrdup (con->target); + xfree (con->target); con->target = old_target; if (err == RETROK) @@ -1581,16 +1593,8 @@ Already have correct symlink %s -> %s\n\n"), && dlthis && file_exists_p (con->target)) { - /* #### This code repeats in http.c and ftp.c. Move it to a - function! */ const char *fl = NULL; - if (opt.output_document) - { - if (output_stream_regular) - fl = opt.output_document; - } - else - fl = con->target; + set_local_file (&fl, con->target); if (fl) touch (fl, f->tstamp); } diff --git a/src/hash.c b/src/hash.c index 1e19fd63..80922d0f 100644 --- a/src/hash.c +++ b/src/hash.c @@ -55,8 +55,8 @@ as that of the covered work. */ # endif # include # define c_tolower(x) tolower ((unsigned char) (x)) -# if __STDC_VERSION__ >= 199901L -# include /* for uintptr_t */ +# ifdef HAVE_STDINT_H +# include # else typedef unsigned long uintptr_t; # endif diff --git a/src/host.c b/src/host.c index fdb35b1c..7b8c4189 100644 --- a/src/host.c +++ b/src/host.c @@ -36,6 +36,7 @@ as that of the covered work. */ #include #ifndef WINDOWS +# include # include # include # ifndef __BEOS__ @@ -58,6 +59,11 @@ as that of the covered work. */ # define NO_ADDRESS NO_DATA #endif +#if !HAVE_DECL_H_ERRNO +extern int h_errno; +#endif + + /* Lists of IP addresses that result from running DNS queries. See lookup_host for details. */ diff --git a/src/http.c b/src/http.c index 090950d2..50f0c643 100644 --- a/src/http.c +++ b/src/http.c @@ -1,6 +1,6 @@ /* HTTP support. Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -1885,6 +1885,9 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy) register_basic_auth_host (u->host); } xfree (pth); + xfree_null (message); + resp_free (resp); + xfree (head); goto retry_with_auth; } else @@ -1895,6 +1898,9 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy) } logputs (LOG_NOTQUIET, _("Authorization failed.\n")); request_free (req); + xfree_null (message); + resp_free (resp); + xfree (head); return AUTHFAILED; } else /* statcode != HTTP_STATUS_UNAUTHORIZED */ @@ -1938,6 +1944,8 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file)); if (has_html_suffix_p (hs->local_file)) *dt |= TEXTHTML; + xfree (head); + xfree_null (message); return RETRUNNEEDED; } else if (!ALLOW_CLOBBER) @@ -2116,6 +2124,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file)); else CLOSE_INVALIDATE (sock); xfree_null (type); + xfree (head); return NEWLOCATION; } } @@ -2171,6 +2180,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file)); xfree_null (type); CLOSE_INVALIDATE (sock); /* would be CLOSE_FINISH, but there might be more bytes in the body. */ + xfree (head); return RETRUNNEEDED; } if ((contrange != 0 && contrange != hs->restval) @@ -2180,6 +2190,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file)); Bail out. */ xfree_null (type); CLOSE_INVALIDATE (sock); + xfree (head); return RANGEERR; } if (contlen == -1) @@ -2243,6 +2254,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file)); CLOSE_FINISH (sock); else CLOSE_INVALIDATE (sock); + xfree (head); return RETRFINISHED; } @@ -2269,6 +2281,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file)); _("%s has sprung into existence.\n"), hs->local_file); CLOSE_INVALIDATE (sock); + xfree (head); return FOPEN_EXCL_ERR; } } @@ -2276,6 +2289,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file)); { logprintf (LOG_NOTQUIET, "%s: %s\n", hs->local_file, strerror (errno)); CLOSE_INVALIDATE (sock); + xfree (head); return FOPENERR; } } @@ -2347,6 +2361,7 @@ http_loop (struct url *u, char **newloc, char **local_file, const char *referer, struct http_stat hstat; /* HTTP status */ struct_stat st; bool send_head_first = true; + char *file_name; /* Assert that no value for *LOCAL_FILE was passed. */ assert (local_file == NULL || *local_file == NULL); @@ -2419,10 +2434,12 @@ File %s already there; not retrieving.\n\n"), /* Send preliminary HEAD request if -N is given and we have an existing * destination file. */ + file_name = url_file_name (u); if (opt.timestamping && !opt.content_disposition - && file_exists_p (url_file_name (u))) + && file_exists_p (file_name)) send_head_first = true; + xfree (file_name); /* THE loop */ do @@ -2723,16 +2740,8 @@ Remote file exists.\n\n")); && ((hstat.len == hstat.contlen) || ((hstat.res == 0) && (hstat.contlen == -1)))) { - /* #### This code repeats in http.c and ftp.c. Move it to a - function! */ const char *fl = NULL; - if (opt.output_document) - { - if (output_stream_regular) - fl = opt.output_document; - } - else - fl = hstat.local_file; + set_local_file (&fl, hstat.local_file); if (fl) { time_t newtmr = -1; @@ -2756,9 +2765,14 @@ Remote file exists.\n\n")); { if (*dt & RETROKF) { + bool write_to_stdout = (opt.output_document && HYPHENP (opt.output_document)); + logprintf (LOG_VERBOSE, - _("%s (%s) - %s saved [%s/%s]\n\n"), - tms, tmrate, quote (hstat.local_file), + write_to_stdout + ? _("%s (%s) - written to stdout %s[%s/%s]\n\n") + : _("%s (%s) - %s saved [%s/%s]\n\n"), + tms, tmrate, + write_to_stdout ? "" : quote (hstat.local_file), number_to_static_string (hstat.len), number_to_static_string (hstat.contlen)); logprintf (LOG_NONVERBOSE, @@ -2787,9 +2801,14 @@ Remote file exists.\n\n")); { if (*dt & RETROKF) { + bool write_to_stdout = (opt.output_document && HYPHENP (opt.output_document)); + logprintf (LOG_VERBOSE, - _("%s (%s) - %s saved [%s]\n\n"), - tms, tmrate, quote (hstat.local_file), + write_to_stdout + ? _("%s (%s) - written to stdout %s[%s]\n\n") + : _("%s (%s) - %s saved [%s]\n\n"), + tms, tmrate, + write_to_stdout ? "" : quote (hstat.local_file), number_to_static_string (hstat.len)); logprintf (LOG_NONVERBOSE, "%s URL:%s [%s] -> \"%s\" [%d]\n", @@ -2933,6 +2952,7 @@ http_atotm (const char *time_string) Netscape cookie specification.) */ }; const char *oldlocale; + char savedlocale[256]; size_t i; time_t ret = (time_t) -1; @@ -2940,6 +2960,16 @@ http_atotm (const char *time_string) non-English locales, which we work around by temporarily setting locale to C before invoking strptime. */ oldlocale = setlocale (LC_TIME, NULL); + if (oldlocale) + { + size_t l = strlen (oldlocale); + if (l >= sizeof savedlocale) + savedlocale[0] = '\0'; + else + memcpy (savedlocale, oldlocale, l); + } + else savedlocale[0] = '\0'; + setlocale (LC_TIME, "C"); for (i = 0; i < countof (time_formats); i++) @@ -2959,7 +2989,8 @@ http_atotm (const char *time_string) } /* Restore the previous locale. */ - setlocale (LC_TIME, oldlocale); + if (savedlocale[0]) + setlocale (LC_TIME, savedlocale); return ret; } diff --git a/src/init.c b/src/init.c index 06a4d3c8..5bed28f6 100644 --- a/src/init.c +++ b/src/init.c @@ -1,6 +1,6 @@ /* Reading/parsing the initialization file. Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -542,15 +542,20 @@ run_wgetrc (const char *file) void initialize (void) { - char *file; + char *file, *env_sysrc; int ok = true; /* Load the hard-coded defaults. */ defaults (); - - /* If SYSTEM_WGETRC is defined, use it. */ + + /* Run a non-standard system rc file when the according environment + variable has been set. For internal testing purposes only! */ + env_sysrc = getenv ("SYSTEM_WGETRC"); + if (env_sysrc && file_exists_p (env_sysrc)) + ok &= run_wgetrc (env_sysrc); + /* Otherwise, if SYSTEM_WGETRC is defined, use it. */ #ifdef SYSTEM_WGETRC - if (file_exists_p (SYSTEM_WGETRC)) + else if (file_exists_p (SYSTEM_WGETRC)) ok &= run_wgetrc (SYSTEM_WGETRC); #endif /* Override it with your own, if one exists. */ diff --git a/src/main.c b/src/main.c index 73882918..b8039d6b 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,6 @@ /* Command line parsing. Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -1124,7 +1124,7 @@ for details.\n\n")); { #ifdef WINDOWS FILE *result; - result = freopen (NULL, "wb", stdout); + result = freopen ("CONOUT$", "wb", stdout); if (result == NULL) { logputs (LOG_NOTQUIET, _("\ diff --git a/src/progress.c b/src/progress.c index 2f1c2225..9b9d1e49 100644 --- a/src/progress.c +++ b/src/progress.c @@ -1157,7 +1157,7 @@ eta_to_human_short (int secs, bool condensed) else if (secs < 48 * 3600) sprintf (buf, "%dh%s%dm", secs / 3600, space, (secs / 60) % 60); else if (secs < 100 * 86400) - sprintf (buf, "%dd%s%dh", secs / 86400, space, (secs / 3600) % 60); + sprintf (buf, "%dd%s%dh", secs / 86400, space, (secs / 3600) % 24); else /* even (2^31-1)/86400 doesn't overflow BUF. */ sprintf (buf, "%dd", secs / 86400); diff --git a/src/recur.h b/src/recur.h index 40a8c2de..7eeb5642 100644 --- a/src/recur.h +++ b/src/recur.h @@ -1,6 +1,6 @@ /* Declarations for recur.c. Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of GNU Wget. diff --git a/src/retr.c b/src/retr.c index 4fabd757..9627f9e3 100644 --- a/src/retr.c +++ b/src/retr.c @@ -1082,3 +1082,16 @@ no_proxy_match (const char *host, const char **no_proxy) else return sufmatch (no_proxy, host); } + +/* Set the file parameter to point to the local file string. */ +void +set_local_file (const char **file, const char *default_file) +{ + if (opt.output_document) + { + if (output_stream_regular) + *file = opt.output_document; + } + else + *file = default_file; +} diff --git a/src/sysdep.h b/src/sysdep.h index 84301b78..a7416f9a 100644 --- a/src/sysdep.h +++ b/src/sysdep.h @@ -57,7 +57,7 @@ as that of the covered work. */ # define NAMESPACE_TWEAKS #endif -#ifdef __linux__ +#if defined(__linux__) || defined(__GLIBC__) # define NAMESPACE_TWEAKS #endif diff --git a/tests/ChangeLog b/tests/ChangeLog index c3155848..2d0dc392 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,22 @@ +2009-06-11 Benjamin Wolsey + + * Test-proxied-https-auth.px: Take an optional argument for the + top source directory, so we can find the cert and key. + + * run-px: Provide the top source directory as an argument, so + scripts can find their way around. + +2009-04-11 Steven Schubiger + + * run-px: Skip testing with real rc files by setting + SYSTEM_WGETRC and WGETRC to /dev/null. + +2009-02-25 Benjamin Wolsey + + * Makefile.am (run-px-tests): Ensure run-px is run from srcdir. + + * run-px: Include modules from srcdir. + 2008-11-25 Steven Schubiger * WgetTest.pm.in: Remove the magic interpreter line; diff --git a/tests/Makefile.am b/tests/Makefile.am index 6e703f01..aa8dd53c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ # Makefile for `wget' utility # Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, -# 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -55,7 +55,7 @@ run-unit-tests: unit-tests$(EXEEXT) ./unit-tests$(EXEEXT) run-px-tests: WgetTest.pm ../src/wget$(EXEEXT) - ./run-px $(top_srcdir) + $(srcdir)/run-px $(top_srcdir) EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \ Test-auth-basic.px Test-c-full.px Test-c-partial.px \ diff --git a/tests/Test-proxied-https-auth.px b/tests/Test-proxied-https-auth.px index 4e3fb206..2b37f32b 100755 --- a/tests/Test-proxied-https-auth.px +++ b/tests/Test-proxied-https-auth.px @@ -5,6 +5,15 @@ use warnings; use WgetTest; # For $WGETPATH. +my $cert_path; +my $key_path; + +if (@ARGV) { + my $top_srcdir = shift @ARGV; + $key_path = "$top_srcdir/tests/certs/server-key.pem"; + $cert_path = "$top_srcdir/tests/certs/server-cert.pem"; +} + # Have we even built an HTTPS-supporting Wget? { my @version_lines = `${WgetTest::WGETPATH} --version`; @@ -55,8 +64,16 @@ sub do_server { $rspn = HTTP::Response->new(200, 'OK'); $conn->send_response($rspn); - $conn = IO::Socket::SSL->new_from_fd($conn->fileno, SSL_server => 1, - SSL_passwd_cb => sub { return "Hello"; }) + my %options = ( + SSL_server => 1, + SSL_passwd_cb => sub { return "Hello"; }); + + $options{SSL_cert_file} = $cert_path if ($cert_path); + $options{SSL_key_file} = $key_path if ($key_path); + + my @options = %options; + + $conn = IO::Socket::SSL->new_from_fd($conn->fileno, @options) or die "Couldn't initiate SSL"; $rqst = &get_request($conn) diff --git a/tests/run-px b/tests/run-px index 0f8f2964..33e4c600 100755 --- a/tests/run-px +++ b/tests/run-px @@ -55,14 +55,22 @@ my @tests = ( 'Test--spider-r.px', ); +foreach my $var (qw(SYSTEM_WGETRC WGETRC)) { + $ENV{$var} = '/dev/null'; +} + my @tested; foreach my $test (@tests) { print "Running $test\n\n"; - system("$^X $top_srcdir/tests/$test"); + system("$^X -I$top_srcdir/tests $top_srcdir/tests/$test $top_srcdir"); push @tested, { name => $test, result => $? }; } +foreach my $var (qw(SYSTEM_WGETRC WGETRC)) { + delete $ENV{$var}; +} + print "\n"; foreach my $test (@tested) { ($test->{result} == 0) diff --git a/util/freeopts b/util/freeopts index 75f594a1..ce43a02d 100755 --- a/util/freeopts +++ b/util/freeopts @@ -28,7 +28,7 @@ elsif ( END { my $cols = 0; my $max_cols = 13; - my $opt_chars = + my $opt_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; print "Free chars:\n\t"; for (my $i = 0; $i < length $opt_chars; ++$i, ++$cols) { diff --git a/util/rmold.pl b/util/rmold.pl index f08deac1..c227e2c0 100755 --- a/util/rmold.pl +++ b/util/rmold.pl @@ -45,7 +45,7 @@ sub procdir local(@lcfiles, @lcdirs, %files, @fl); print STDERR "Processing directory '$dir':\n" if $verbose; - + opendir(DH, $dir) || die("Cannot open $dir: $!\n"); @lcfiles = (); @lcdirs = (); diff --git a/util/trunc.c b/util/trunc.c index fb52ec25..55cb19d3 100644 --- a/util/trunc.c +++ b/util/trunc.c @@ -3,7 +3,7 @@ * * Copyright (C) 2008 Micah J. Cowan * - * Copying and distribution of this file, with or without modification, + * Copying and distribution of this file, with or without modification, * are permitted in any medium without royalty provided the copyright * notice and this notice are preserved. */ @@ -62,7 +62,7 @@ get_size (const char str[]) { val *= 1024 * 1024; } - + return val; }