]> sjero.net Git - wget/commitdiff
[svn] Define the IF_DEBUG macro.
authorhniksic <devnull@localhost>
Wed, 22 Jun 2005 01:26:22 +0000 (18:26 -0700)
committerhniksic <devnull@localhost>
Wed, 22 Jun 2005 01:26:22 +0000 (18:26 -0700)
src/ChangeLog
src/connect.c
src/cookies.c
src/host.c
src/main.c
src/openssl.c
src/wget.h

index 927be7246b65b7fdaddefa4ad38f94a110e52953..326835a6474c9db94c1962cd876699f176f799cb 100644 (file)
@@ -1,3 +1,13 @@
+2005-06-22  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * openssl.c, connect.c, host.c: Replace instances of #ifdef
+       ENABLE_DEBUG if (opt.debug) {...} #endif with IF_DEBUG {...}.
+
+       * main.c: Rename the IF_DEBUG defined here to WHEN_DEBUG.
+
+       * wget.h (IF_DEBUG): New macro.
+       (DEBUGP): Define in terms of IF_DEBUG.
+
 2005-06-22  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * http.c (gethttp): Only handle --set-cookies (and assert that
index 0b58ffadae37e5456be93ea4e336cf8b8ad7ecfc..69a2e5e6ab9a1f3fe5b071933f04de25efaec559 100644 (file)
@@ -278,10 +278,9 @@ connect_to_ip (const ip_address *ip, int port, const char *print)
     int on = 1;
     /* In case of error, we will go on anyway... */
     int err = setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof (on));
-#ifdef ENABLE_DEBUG
-    if (err < 0) 
-      DEBUGP (("Failed setting IPV6_V6ONLY: %s", strerror (errno)));
-#endif
+    IF_DEBUG
+      if (err < 0) 
+       DEBUGP (("Failed setting IPV6_V6ONLY: %s", strerror (errno)));
   }
 #endif
 
index a75799e5fbf2939283eebd19bfd593d4364a278f..0b690c66b7a4fa119d0b3432499389af8cbeee45 100644 (file)
@@ -258,8 +258,7 @@ store_cookie (struct cookie_jar *jar, struct cookie *cookie)
   hash_table_put (jar->chains, chain_key, cookie);
   ++jar->cookie_count;
 
-#ifdef ENABLE_DEBUG
-  if (opt.debug)
+  IF_DEBUG
     {
       time_t exptime = cookie->expiry_time;
       DEBUGP (("\nStored cookie %s %d%s %s <%s> <%s> [expiry %s] %s %s\n",
@@ -271,7 +270,6 @@ store_cookie (struct cookie_jar *jar, struct cookie *cookie)
               cookie->expiry_time ? datetime_str (&exptime) : "none",
               cookie->attr, cookie->value));
     }
-#endif
 }
 
 /* Discard a cookie matching COOKIE's domain, port, path, and
index d9753ab63f1ee7df741eb108928d923b1862fe82..fccc0d6dc19f704a7fa3cd337cfe2bbb7e2cf326 100644 (file)
@@ -622,8 +622,7 @@ cache_store (const char *host, struct address_list *al)
   ++al->refcount;
   hash_table_put (host_name_addresses_map, xstrdup_lower (host), al);
 
-#ifdef ENABLE_DEBUG
-  if (opt.debug)
+  IF_DEBUG
     {
       int i;
       debug_logprintf ("Caching %s =>", host);
@@ -631,7 +630,6 @@ cache_store (const char *host, struct address_list *al)
        debug_logprintf (" %s", pretty_print_address (al->addresses + i));
       debug_logprintf ("\n");
     }
-#endif
 }
 
 /* Remove HOST from the DNS cache.  Does nothing is HOST is not in
index 997a2de738f48d4c30941ab1e9b6c6f010ea2705..5cb383a1818b34855d28f6562f340e2acb113e88 100644 (file)
@@ -112,9 +112,9 @@ static void print_version (void);
 #endif
 
 #ifdef ENABLE_DEBUG
-# define IF_DEBUG(x) x
+# define WHEN_DEBUG(x) x
 #else
-# define IF_DEBUG(x) NULL
+# define WHEN_DEBUG(x) NULL
 #endif
 
 struct cmdline_option {
@@ -158,7 +158,7 @@ struct cmdline_option option_data[] =
     { "convert-links", 'k', OPT_BOOLEAN, "convertlinks", -1 },
     { "cookies", 0, OPT_BOOLEAN, "cookies", -1 },
     { "cut-dirs", 0, OPT_VALUE, "cutdirs", -1 },
-    { IF_DEBUG ("debug"), 'd', OPT_BOOLEAN, "debug", -1 },
+    { WHEN_DEBUG ("debug"), 'd', OPT_BOOLEAN, "debug", -1 },
     { "delete-after", 0, OPT_BOOLEAN, "deleteafter", -1 },
     { "directories", 0, OPT_BOOLEAN, "dirstruct", -1 },
     { "directory-prefix", 'P', OPT_VALUE, "dirprefix", -1 },
@@ -254,7 +254,7 @@ struct cmdline_option option_data[] =
     { "waitretry", 0, OPT_VALUE, "waitretry", -1 },
   };
 
-#undef IF_DEBUG
+#undef WHEN_DEBUG
 #undef IF_SSL
 
 /* Return a string that contains S with "no-" prepended.  The string
index 5850b96f7733d3ba4d13acf82a5131719ba9b4c5..6fd9d6564982d23a8d62facb5a77a4e6f62fd35b 100644 (file)
@@ -422,8 +422,7 @@ ssl_check_certificate (int fd, const char *host)
       goto no_cert;            /* must bail out since CERT is NULL */
     }
 
-#ifdef ENABLE_DEBUG
-  if (opt.debug)
+  IF_DEBUG
     {
       char *subject = X509_NAME_oneline (X509_get_subject_name (cert), 0, 0);
       char *issuer = X509_NAME_oneline (X509_get_issuer_name (cert), 0, 0);
@@ -432,7 +431,6 @@ ssl_check_certificate (int fd, const char *host)
       OPENSSL_free (subject);
       OPENSSL_free (issuer);
     }
-#endif
 
   vresult = SSL_get_verify_result (ssl);
   if (vresult != X509_V_OK)
index d382d3da91f2225aa6db3c36b298e78c1a7f00f7..7b76f8d83834cbf550680d0101bddb45a8019607 100644 (file)
@@ -98,13 +98,16 @@ so, delete this exception statement from your version.  */
 # define UNLIKELY(exp) (exp)
 #endif
 
-/* Print X if debugging is enabled; a no-op otherwise.  */
+/* Execute the following statement if debugging is both enabled at
+   compile-time and requested at run-time; a no-op otherwise.  */
 
 #ifdef ENABLE_DEBUG
-# define DEBUGP(x) do if (UNLIKELY (opt.debug)) {debug_logprintf x;} while (0)
-#else  /* not ENABLE_DEBUG */
-# define DEBUGP(x) do {} while (0)
-#endif /* not ENABLE_DEBUG */
+# define IF_DEBUG if (UNLIKELY (opt.debug))
+#else
+# define IF_DEBUG if (0)
+#endif
+
+#define DEBUGP(x) do { IF_DEBUG { debug_logprintf x; } } while (0)
 
 /* Define an integer type that works for file sizes, content lengths,
    and such.  Normally we could just use off_t, but off_t is always