Plus a chunk of small changes removing mixed code and declarations.

>From 7abed480eb448a2e49ce991094049398c732edb3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81ngel=20Gonz=C3=A1lez?= <[email protected]>
Date: Wed, 14 Nov 2012 17:56:12 +0100
Subject: [PATCH] Removed mixed declarations and code, making more C89
 compatible.

Only warc.c and main.c have mixed declarations now.
---
 src/ChangeLog  |  2 ++
 src/gnutls.c   |  6 +++---
 src/html-url.c |  3 ++-
 src/http.c     |  9 ++++++---
 src/main.c     | 11 ++++++-----
 src/retr.c     |  2 +-
 6 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 98aac1d..5ab9321 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -3,6 +3,8 @@
 	gcc -std=c89
 	* host.c (cache_query): Fix warning about format '%p' expecting
 	an argument of type 'void *', but being given a 'struct address_list *'
+	* gnutls.c, html-url.c, http.c, retr.c, main.c: Removed mixed 
+	declarations and code, making more C89 compatible.
 
 2012-11-13  Giuseppe Scrivano  <[email protected]>
 
diff --git a/src/gnutls.c b/src/gnutls.c
index af0b697..14720e0 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -82,13 +82,13 @@ ssl_init (void)
   /* Becomes true if GnuTLS is initialized. */
   static bool ssl_initialized = false;
 
+  const char *ca_directory;
+  DIR *dir;
+
   /* GnuTLS should be initialized only once. */
   if (ssl_initialized)
     return true;
 
-  const char *ca_directory;
-  DIR *dir;
-
   gnutls_global_init ();
   gnutls_certificate_allocate_credentials (&credentials);
   gnutls_certificate_set_verify_flags(credentials,
diff --git a/src/html-url.c b/src/html-url.c
index f029821..01449ac 100644
--- a/src/html-url.c
+++ b/src/html-url.c
@@ -772,6 +772,7 @@ get_urls_file (const char *file)
       char *url_text;
       struct urlpos *entry;
       struct url *url;
+      char *new_url;
 
       const char *line_beg = text;
       const char *line_end = memchr (text, '\n', text_end - text);
@@ -804,7 +805,7 @@ get_urls_file (const char *file)
           url_text = merged;
         }
 
-      char *new_url = rewrite_shorthand_url (url_text);
+      new_url = rewrite_shorthand_url (url_text);
       if (new_url)
         {
           xfree (url_text);
diff --git a/src/http.c b/src/http.c
index 5888474..b496ffc 100644
--- a/src/http.c
+++ b/src/http.c
@@ -1076,6 +1076,7 @@ extract_param (const char **source, param_token *name, param_token *value,
                char separator)
 {
   const char *p = *source;
+  int param_type;
 
   while (c_isspace (*p)) ++p;
   if (!*p)
@@ -1131,7 +1132,7 @@ extract_param (const char **source, param_token *name, param_token *value,
     }
   *source = p;
 
-  int param_type = modify_param_name(name);
+  param_type = modify_param_name(name);
   if (NOT_RFC2231 != param_type)
     {
       modify_param_value(value, param_type);
@@ -1521,6 +1522,7 @@ read_response_body (struct http_stat *hs, int sock, FILE *fp, wgint contlen,
   int warc_payload_offset = 0;
   FILE *warc_tmp = NULL;
   int warcerr = 0;
+  int flags = 0;
 
   if (opt.warc_filename != NULL)
     {
@@ -1557,7 +1559,6 @@ read_response_body (struct http_stat *hs, int sock, FILE *fp, wgint contlen,
     }
 
   /* Read the response body.  */
-  int flags = 0;
   if (contlen != -1)
     /* If content-length is present, read that much; otherwise, read
        until EOF.  The HTTP spec doesn't require the server to
@@ -2134,11 +2135,13 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
           write_error = fd_write (sock, opt.post_data, post_data_size, -1);
           if (write_error >= 0 && warc_tmp != NULL)
             {
+              int warc_tmp_written;
+
               /* Remember end of headers / start of payload. */
               warc_payload_offset = ftello (warc_tmp);
 
               /* Write a copy of the data to the WARC record. */
-              int warc_tmp_written = fwrite (opt.post_data, 1, post_data_size, warc_tmp);
+              warc_tmp_written = fwrite (opt.post_data, 1, post_data_size, warc_tmp);
               if (warc_tmp_written != post_data_size)
                 write_error = -2;
             }
diff --git a/src/main.c b/src/main.c
index 4c2eb45..76f9a30 100644
--- a/src/main.c
+++ b/src/main.c
@@ -972,13 +972,13 @@ main (int argc, char **argv)
   int nurl;
   bool append_to_log = false;
 
+  struct ptimer *timer = ptimer_new ();
+  double start_time = ptimer_measure (timer);
+
   total_downloaded_bytes = 0;
 
   program_name = argv[0];
 
-  struct ptimer *timer = ptimer_new ();
-  double start_time = ptimer_measure (timer);
-
   i18n_initialize ();
 
   /* Construct the name of the executable, without the directory part.  */
@@ -1597,10 +1597,11 @@ outputting to a regular file.\n"));
       total_downloaded_bytes != 0)
     {
       double end_time = ptimer_measure (timer);
+      char *wall_time, download_time;
       ptimer_destroy (timer);
 
-      char *wall_time = xstrdup (secs_to_human_time (end_time - start_time));
-      char *download_time = xstrdup (secs_to_human_time (total_download_time));
+      wall_time = xstrdup (secs_to_human_time (end_time - start_time));
+      download_time = xstrdup (secs_to_human_time (total_download_time));
       logprintf (LOG_NOTQUIET,
 		 _("FINISHED --%s--\nTotal wall clock time: %s\n"
 		   "Downloaded: %d files, %s in %s (%s)\n"),
diff --git a/src/retr.c b/src/retr.c
index 5bbae80..b8646c2 100644
--- a/src/retr.c
+++ b/src/retr.c
@@ -374,8 +374,8 @@ fd_read_body (int fd, FILE *out, wgint toread, wgint startpos,
 
       if (ret > 0)
         {
-          sum_read += ret;
           int write_res = write_data (out, out2, dlbuf, ret, &skip, &sum_written);
+          sum_read += ret;
           if (write_res < 0)
             {
               ret = (write_res == -3) ? -3 : -2;
-- 
1.8.0

Reply via email to