From: Micah Cowan Date: Wed, 22 Apr 2009 18:44:13 +0000 (-0700) Subject: Automated merge. X-Git-Tag: v1.13~361 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=bb2cba2cc7fcd0055d978aea4b31b8fc01841fc8;hp=1cc32c30145e83e7d67cc54f588e9d85addfe867 Automated merge. --- diff --git a/src/ChangeLog b/src/ChangeLog index 697919d3..28cb6640 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -2,6 +2,15 @@ * 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 diff --git a/src/ftp.c b/src/ftp.c index 7c509377..fe6ecd0a 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -1590,16 +1590,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/http.c b/src/http.c index e0e1e013..c3adbf40 100644 --- a/src/http.c +++ b/src/http.c @@ -2723,16 +2723,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; diff --git a/src/retr.c b/src/retr.c index 21c9002e..f081d831 100644 --- a/src/retr.c +++ b/src/retr.c @@ -1070,3 +1070,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; +}