X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=blobdiff_plain;f=pctb%2Focr.c;h=f4bc77d56118ae8b4caebfce168a3336cd2eecc2;hp=78542398abe3edcfdbc2078db667a1d135d01d01;hb=74e4e249f2c3e848592984cb193aded6a77a341d;hpb=2aaae8ee04d0a6a8ab85751ceb67f222d259eba8 diff --git a/pctb/ocr.c b/pctb/ocr.c index 7854239..f4bc77d 100644 --- a/pctb/ocr.c +++ b/pctb/ocr.c @@ -86,17 +86,7 @@ DEBUG_DEFINE_DEBUGF(ocr) fatal("Error in character set database.\n" \ " Requirement not met: %s:%d: %s", __FILE__,__LINE__, #x)) -static void fgetsline(FILE *f, char *lbuf, size_t lbufsz) { - errno=0; - char *s= fgets(lbuf,lbufsz,f); - sysassert(!ferror(f)); - dbassert(!feof(f)); - assert(s); - int l= strlen(lbuf); - dbassert(l>0); dbassert(lbuf[--l]='\n'); - lbuf[l]= 0; -} -#define FGETSLINE(f,buf) (fgetsline(f,buf,sizeof(buf))) +#define FGETSLINE (fgetsline(db,lbuf,sizeof(lbuf))) static void cleardb_node(DatabaseNode *n) { int i; @@ -129,7 +119,7 @@ static void readdb(OcrReader *rd) { return; } - FGETSLINE(db,lbuf); + FGETSLINE; dbassert(!strcmp(lbuf,"# ypp-sc-tools pctb font v1")); r= fscanf(db, "%d", &h); @@ -137,7 +127,7 @@ static void readdb(OcrReader *rd) { dbassert(h==rd->h); for (;;) { - FGETSLINE(db,lbuf); + FGETSLINE; if (!lbuf || lbuf[0]=='#') continue; if (!strcmp(lbuf,".")) break; @@ -145,7 +135,7 @@ static void readdb(OcrReader *rd) { if (!strcmp(lbuf,context_names[ctxi])) goto found_ctx; /* not found, just skip */ - for (;;) { FGETSLINE(db,lbuf); if (!lbuf[0]) break; } + for (;;) { FGETSLINE; if (!lbuf[0]) break; } continue; found_ctx: @@ -171,7 +161,7 @@ static void readdb(OcrReader *rd) { current= &rd->contexts[ctxi]; for (;;) { - FGETSLINE(db,lbuf); + FGETSLINE; if (!lbuf[0]) { dbassert(current != &rd->contexts[ctxi]); break; } char *ep; cv= strtoul(lbuf,&ep,16); dbassert(!*ep);