Quellcode durchsuchen

* Add a debug() function and a --enable-debug configure flag.

tags/v0.99.beta14
Sam Hocevar sam vor 18 Jahren
Ursprung
Commit
18f1f68be7
3 geänderte Dateien mit 45 neuen und 0 gelöschten Zeilen
  1. +25
    -0
      common.h
  2. +6
    -0
      configure.ac
  3. +14
    -0
      cucul/export.c

+ 25
- 0
common.h Datei anzeigen

@@ -32,6 +32,31 @@ typedef long int intptr_t;
typedef unsigned long int uintptr_t;
#endif

#if defined DEBUG && !defined __KERNEL__
# include <stdio.h>
# include <stdarg.h>
# if defined(HAVE_ERRNO_H)
# include <errno.h>
# endif
static inline void debug(const char *format, ...)
{
# if defined(HAVE_ERRNO_H)
int saved_errno = errno;
# endif
va_list args;
va_start(args, format);
fprintf(stderr, "** libcaca debug ** ");
vfprintf(stderr, format, args);
fprintf(stderr, "\n");
va_end(args);
# if defined(HAVE_ERRNO_H)
errno = saved_errno;
# endif
}
#else
# define debug(format, ...) do {} while(0)
#endif

#if defined HAVE_HTONS
# if defined __KERNEL__
/* Nothing to do */


+ 6
- 0
configure.ac Datei anzeigen

@@ -62,6 +62,8 @@ AC_ARG_ENABLE(imlib2,
[ --enable-imlib2 Imlib2 graphics support (default enabled)])

dnl conditional builds
AC_ARG_ENABLE(debug,
[ --enable-debug build debug versions of the library])
AC_ARG_ENABLE(plugins,
[ --enable-plugins build X11 and GL drivers as plugins])
AC_ARG_ENABLE(doc,
@@ -226,6 +228,10 @@ if test "${enable_vga}" = "yes"; then
fi
AM_CONDITIONAL(USE_KERNEL, test "${ac_cv_my_have_vga}" = "yes")

if test "${enable_debug}" = "yes"; then
AC_DEFINE(DEBUG, 1, Define to 1 to activate debug)
fi

if test "${enable_plugins}" = "yes"; then
ac_cv_my_have_plugins="yes"
AC_DEFINE(USE_PLUGINS, 1, Define to 1 to activate plugins)


+ 14
- 0
cucul/export.c Datei anzeigen

@@ -276,6 +276,8 @@ static void *export_utf8(cucul_canvas_t *cv, unsigned long int *bytes, int cr)
}

/* Crop to really used size */
debug("utf8 export: alloc %li bytes, realloc %li\n",
(long int)*bytes, (long int)(uintptr_t)(cur - data));
*bytes = (uintptr_t)(cur - data);
data = realloc(data, *bytes);

@@ -354,6 +356,8 @@ static void *export_ansi(cucul_canvas_t *cv, unsigned long int *bytes)
}

/* Crop to really used size */
debug("ansi export: alloc %li bytes, realloc %li\n",
(long int)*bytes, (long int)(uintptr_t)(cur - data));
*bytes = (uintptr_t)(cur - data);
data = realloc(data, *bytes);

@@ -428,6 +432,8 @@ static void *export_html(cucul_canvas_t *cv, unsigned long int *bytes)
cur += sprintf(cur, "</div></body></html>\n");

/* Crop to really used size */
debug("html export: alloc %li bytes, realloc %li\n",
(long int)*bytes, (long int)(uintptr_t)(cur - data));
*bytes = (uintptr_t)(cur - data);
data = realloc(data, *bytes);

@@ -521,6 +527,8 @@ static void *export_html3(cucul_canvas_t *cv, unsigned long int *bytes)
cur += sprintf(cur, "</table>\n");

/* Crop to really used size */
debug("html3 export: alloc %li bytes, realloc %li\n",
(long int)*bytes, (long int)(uintptr_t)(cur - data));
*bytes = (uintptr_t)(cur - data);
data = realloc(data, *bytes);

@@ -626,6 +634,8 @@ static void *export_irc(cucul_canvas_t *cv, unsigned long int *bytes)
}

/* Crop to really used size */
debug("IRC export: alloc %li bytes, realloc %li\n",
(long int)*bytes, (long int)(uintptr_t)(cur - data));
*bytes = (uintptr_t)(cur - data);
data = realloc(data, *bytes);

@@ -733,6 +743,8 @@ static void *export_ps(cucul_canvas_t *cv, unsigned long int *bytes)
cur += sprintf(cur, "showpage\n");

/* Crop to really used size */
debug("PS export: alloc %li bytes, realloc %li\n",
(long int)*bytes, (long int)(uintptr_t)(cur - data));
*bytes = (uintptr_t)(cur - data);
data = realloc(data, *bytes);

@@ -817,6 +829,8 @@ static void *export_svg(cucul_canvas_t *cv, unsigned long int *bytes)
cur += sprintf(cur, "</svg>\n");

/* Crop to really used size */
debug("SVG export: alloc %li bytes, realloc %li\n",
(long int)*bytes, (long int)(uintptr_t)(cur - data));
*bytes = (uintptr_t)(cur - data);
data = realloc(data, *bytes);



Laden…
Abbrechen
Speichern