]> sjero.net Git - wget/commitdiff
Move duplicated code to a function.
authorSteven Schubiger <stsc@member.fsf.org>
Mon, 13 Apr 2009 20:19:13 +0000 (22:19 +0200)
committerSteven Schubiger <stsc@member.fsf.org>
Mon, 13 Apr 2009 20:19:13 +0000 (22:19 +0200)
src/ChangeLog
src/ftp.c
src/http.c
src/retr.c

index ca2450885d97bad112ffce0c75d6f2a3720588be..37d39d80fd54b5960c74a94c1ea442ef72895a3a 100644 (file)
@@ -1,3 +1,12 @@
+2009-04-13  Steven Schubiger  <stsc@member.fsf.org>
+
+       * 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  <stsc@member.fsf.org>
 
        * init.c (initialize): Run a custom SYSTEM_WGETRC when 
index 7c5093770e11ee6c1fe9e42c59f51041ef01324a..fe6ecd0a9e606d7c4331c7078767f7e483a66ae9 100644 (file)
--- 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);
         }
index e0e1e01379e97c5ab79199fe2522504d5cb34013..c3adbf40755150d2ab158f674941302b8dd521cb 100644 (file)
@@ -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;
index 21c9002eaaf5905f16c5c845172645128f3bf559..f081d83160e332275ad3231b6cdc2ab9cc5fd905 100644 (file)
@@ -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;
+}