bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] [PATCH] Move duplicated code in http.c to a function


From: Giuseppe Scrivano
Subject: Re: [Bug-wget] [PATCH] Move duplicated code in http.c to a function
Date: Wed, 23 Feb 2011 10:38:44 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Thanks for your contribution.  I have just applied your patch.

Giuseppe



Steven Schubiger <address@hidden> writes:

> Patch attached. 
>
>
> === modified file 'src/ChangeLog'
> --- src/ChangeLog     2010-12-10 22:55:54 +0000
> +++ src/ChangeLog     2011-02-22 12:43:23 +0000
> @@ -1,3 +1,9 @@
> +2011-02-22  Steven Schubiger  <address@hidden>
> +
> +     * http.c (gethttp, http_loop): Move duplicated code which is run
> +     when an existing file is not to be clobbered to a function.
> +     (get_file_flags): New static function.
> +
>  2010-12-10  Evgeniy Philippov <address@hidden> (tiny change)
>  
>       * main.c (main): Initialize `total_downloaded_bytes'.
>
> === modified file 'src/http.c'
> --- src/http.c        2011-01-01 12:19:37 +0000
> +++ src/http.c        2011-02-18 18:56:57 +0000
> @@ -1448,6 +1448,20 @@
>    hs->error = NULL;
>  }
>  
> +static void
> +get_file_flags (const char *filename, int *dt)
> +{
> +  logprintf (LOG_VERBOSE, _("\
> +File %s already there; not retrieving.\n\n"), quote (filename));
> +  /* If the file is there, we suppose it's retrieved OK.  */
> +  *dt |= RETROKF;
> +
> +  /* #### Bogusness alert.  */
> +  /* If its suffix is "html" or "htm" or similar, assume text/html.  */
> +  if (has_html_suffix_p (filename))
> +    *dt |= TEXTHTML;
> +}
> +
>  #define BEGINS_WITH(line, string_constant)                               \
>    (!strncasecmp (line, string_constant, sizeof (string_constant) - 1)    \
>     && (c_isspace (line[sizeof (string_constant) - 1])                      \
> @@ -2158,16 +2172,7 @@
>            /* If opt.noclobber is turned on and file already exists, do not
>               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"), quote (hs->local_file));
> -          /* If the file is there, we suppose it's retrieved OK.  */
> -          *dt |= RETROKF;
> -
> -          /* #### Bogusness alert.  */
> -          /* If its suffix is "html" or "htm" or similar, assume text/html.  
> */
> -          if (has_html_suffix_p (hs->local_file))
> -            *dt |= TEXTHTML;
> -
> +          get_file_flags (hs->local_file, dt);
>            xfree (head);
>            xfree_null (message);
>            return RETRUNNEEDED;
> @@ -2639,24 +2644,12 @@
>        got_name = true;
>      }
>  
> -  /* 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 && 
> !opt.output_document)
>      {
>        /* If opt.noclobber is turned on and file already exists, do not
>           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"),
> -                 quote (hstat.local_file));
> -      /* If the file is there, we suppose it's retrieved OK.  */
> -      *dt |= RETROKF;
> -
> -      /* #### Bogusness alert.  */
> -      /* If its suffix is "html" or "htm" or similar, assume text/html.  */
> -      if (has_html_suffix_p (hstat.local_file))
> -        *dt |= TEXTHTML;
> -
> +      get_file_flags (hstat.local_file, dt);
>        ret = RETROK;
>        goto exit;
>      }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]