Changeset 1360


Ignore:
Timestamp:
Nov 12, 2006, 2:11:01 PM (15 years ago)
Author:
Sam Hocevar
Message:
  • Add a debug() function and a --enable-debug configure flag.
Location:
libcaca/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/common.h

    r1304 r1360  
    3131typedef long int intptr_t;
    3232typedef unsigned long int uintptr_t;
     33#endif
     34
     35#if defined DEBUG && !defined __KERNEL__
     36#   include <stdio.h>
     37#   include <stdarg.h>
     38#   if defined(HAVE_ERRNO_H)
     39#       include <errno.h>
     40#   endif
     41static inline void debug(const char *format, ...)
     42{
     43#   if defined(HAVE_ERRNO_H)
     44    int saved_errno = errno;
     45#   endif
     46    va_list args;
     47    va_start(args, format);
     48    fprintf(stderr, "** libcaca debug ** ");
     49    vfprintf(stderr, format, args);
     50    fprintf(stderr, "\n");
     51    va_end(args);
     52#   if defined(HAVE_ERRNO_H)
     53    errno = saved_errno;
     54#   endif
     55}
     56#else
     57#   define debug(format, ...) do {} while(0)
    3358#endif
    3459
  • libcaca/trunk/configure.ac

    r1285 r1360  
    6363
    6464dnl conditional builds
     65AC_ARG_ENABLE(debug,
     66  [  --enable-debug          build debug versions of the library])
    6567AC_ARG_ENABLE(plugins,
    6668  [  --enable-plugins        build X11 and GL drivers as plugins])
     
    227229AM_CONDITIONAL(USE_KERNEL, test "${ac_cv_my_have_vga}" = "yes")
    228230
     231if test "${enable_debug}" = "yes"; then
     232  AC_DEFINE(DEBUG, 1, Define to 1 to activate debug)
     233fi
     234
    229235if test "${enable_plugins}" = "yes"; then
    230236  ac_cv_my_have_plugins="yes"
  • libcaca/trunk/cucul/export.c

    r1357 r1360  
    277277
    278278    /* Crop to really used size */
     279    debug("utf8 export: alloc %li bytes, realloc %li\n",
     280          (long int)*bytes, (long int)(uintptr_t)(cur - data));
    279281    *bytes = (uintptr_t)(cur - data);
    280282    data = realloc(data, *bytes);
     
    355357
    356358    /* Crop to really used size */
     359    debug("ansi export: alloc %li bytes, realloc %li\n",
     360          (long int)*bytes, (long int)(uintptr_t)(cur - data));
    357361    *bytes = (uintptr_t)(cur - data);
    358362    data = realloc(data, *bytes);
     
    429433
    430434    /* Crop to really used size */
     435    debug("html export: alloc %li bytes, realloc %li\n",
     436          (long int)*bytes, (long int)(uintptr_t)(cur - data));
    431437    *bytes = (uintptr_t)(cur - data);
    432438    data = realloc(data, *bytes);
     
    522528
    523529    /* Crop to really used size */
     530    debug("html3 export: alloc %li bytes, realloc %li\n",
     531          (long int)*bytes, (long int)(uintptr_t)(cur - data));
    524532    *bytes = (uintptr_t)(cur - data);
    525533    data = realloc(data, *bytes);
     
    627635
    628636    /* Crop to really used size */
     637    debug("IRC export: alloc %li bytes, realloc %li\n",
     638          (long int)*bytes, (long int)(uintptr_t)(cur - data));
    629639    *bytes = (uintptr_t)(cur - data);
    630640    data = realloc(data, *bytes);
     
    734744
    735745    /* Crop to really used size */
     746    debug("PS export: alloc %li bytes, realloc %li\n",
     747          (long int)*bytes, (long int)(uintptr_t)(cur - data));
    736748    *bytes = (uintptr_t)(cur - data);
    737749    data = realloc(data, *bytes);
     
    818830
    819831    /* Crop to really used size */
     832    debug("SVG export: alloc %li bytes, realloc %li\n",
     833          (long int)*bytes, (long int)(uintptr_t)(cur - data));
    820834    *bytes = (uintptr_t)(cur - data);
    821835    data = realloc(data, *bytes);
Note: See TracChangeset for help on using the changeset viewer.