From: Ian Jackson Date: Sat, 6 Jun 2009 19:48:17 +0000 (+0100) Subject: factor out DEBUG_DEFINE_DEBUGF X-Git-Tag: 1.9.2~159 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=commitdiff_plain;h=80646aad7ee5fdbb1ce28b3fe40c5776241d540d factor out DEBUG_DEFINE_DEBUGF --- diff --git a/pctb/ocr.c b/pctb/ocr.c index 436aa8d..f5826df 100644 --- a/pctb/ocr.c +++ b/pctb/ocr.c @@ -37,6 +37,8 @@ static FILE *resolver; static pid_t resolver_pid; static int resolver_done; +DEBUG_DEFINE_DEBUGF(ocr) + static void fgetsline(FILE *f, char *lbuf, size_t lbufsz) { char *s= fgets(lbuf,lbufsz,f); eassert(s); @@ -288,14 +290,6 @@ const struct OcrCellTypeInfo ocr_celltype_text= { .midword=1 /* Lower only */ }; -static void vdebugf(const char *fmt, va_list al) { - if (DEBUGP(ocr)) - vfprintf(debug,fmt,al); -} -static void debugf(const char *fmt, ...) { - va_list al; va_start(al,fmt); vdebugf(fmt,al); va_end(al); -} - OcrResultGlyph *ocr(OcrReader *rd, OcrCellType ct, int w, Pixcol cols[]) { int nspaces; unsigned ctxmap; diff --git a/pctb/ocr.h b/pctb/ocr.h index a688742..93b158b 100644 --- a/pctb/ocr.h +++ b/pctb/ocr.h @@ -81,4 +81,13 @@ void debug_flush(void); const char *get_vardir(void); +#define DEBUG_DEFINE_DEBUGF(f) \ + static void vdebugf(const char *fmt, va_list al) { \ + if (DEBUGP(f)) \ + vfprintf(debug,fmt,al); \ + } \ + static void debugf(const char *fmt, ...) { \ + va_list al; va_start(al,fmt); vdebugf(fmt,al); va_end(al); \ + } + #endif /*OCR_H*/