]> sjero.net Git - wget/blobdiff - src/wget.h
[svn] Define the IF_DEBUG macro.
[wget] / src / wget.h
index f7467bb7cd9e96cbbdf1888d2b93bd77996772da..7b76f8d83834cbf550680d0101bddb45a8019607 100644 (file)
@@ -40,21 +40,15 @@ so, delete this exception statement from your version.  */
 # define NDEBUG
 #endif
 
-#ifndef PARAMS
-# if PROTOTYPES
-#  define PARAMS(args) args
-# else
-#  define PARAMS(args) ()
-# endif
-#endif
-
 /* `gettext (FOO)' is long to write, so we use `_(FOO)'.  If NLS is
    unavailable, _(STRING) simply returns STRING.  */
 #ifdef HAVE_NLS
 # define _(string) gettext (string)
 # ifdef HAVE_LIBINTL_H
 #  include <libintl.h>
-# endif /* HAVE_LIBINTL_H */
+# else  /* not HAVE_LIBINTL_H */
+   const char *gettext ();
+# endif /* not HAVE_LIBINTL_H */
 #else  /* not HAVE_NLS */
 # define _(string) (string)
 #endif /* not HAVE_NLS */
@@ -104,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
@@ -219,9 +216,15 @@ typedef off_t wgint;
     (sizevar) = DR_newsize;                                            \
   }                                                                    \
   if (DR_newsize)                                                      \
-    basevar = (type *)xrealloc (basevar, DR_newsize * sizeof (type));  \
+    basevar = xrealloc (basevar, DR_newsize * sizeof (type));          \
 } while (0)
 
+/* Used to print pointers (usually for debugging).  Print pointers
+   using printf ("%0*lx", PTR_FORMAT (p)).  (%p is too unpredictable;
+   some implementations prepend 0x, while some don't, and most don't
+   0-pad the address.)  */
+#define PTR_FORMAT(p) 2 * sizeof (void *), (unsigned long) (p)
+
 extern const char *exec_name;
 \f
 /* Document type ("dt") flags */