From: Ian Jackson Date: Mon, 29 Jun 2009 15:56:46 +0000 (+0100) Subject: Pack findchar's args into a struct X-Git-Tag: 1.9.2~94 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=commitdiff_plain;h=83b1dc4a5d774abe3c0c4a89c67f78b7c5974c51 Pack findchar's args into a struct --- diff --git a/pctb/ocr.c b/pctb/ocr.c index ecfac97..bc80577 100644 --- a/pctb/ocr.c +++ b/pctb/ocr.c @@ -277,17 +277,25 @@ static void add_result(OcrReader *rd, const char *s, int l, int r, const char *ocr_celltype_name(OcrCellType ct) { return ct->name; } -static DatabaseNode *findchar(OcrReader *rd, int w, Pixcol cols[], - int x, int ctxi, int *matchx_r) { - DatabaseNode *current= &rd->contexts[ctxi]; +typedef struct { + OcrReader *rd; + int w; + Pixcol *cols; + int x; +} FindCharArgs; + +static DatabaseNode *findchar(const FindCharArgs *fca, + DatabaseNode *start, int *matchx_r) { + DatabaseNode *current= start; DatabaseNode *bestmatch= 0; int i; + int x= fca->x; for (;;) { debug_flush(); debugf(" | x=%d",x); - if (x>w) break; - Pixcol cv= cols[x]; + if (x > fca->w) break; + Pixcol cv= fca->cols[x]; debugf(" cv=%"PSPIXCOL(PRIx),cv); for (i=0; inlinks; i++) if (current->links[i].col == cv) @@ -348,6 +356,12 @@ OcrResultGlyph *ocr(OcrReader *rd, OcrCellType ct, int w, Pixcol cols[]) { add_result(rd," ",x-nspaces,x+1,0); nspaces=0; + FindCharArgs fca; + fca.rd= rd; + fca.w= w; + fca.cols= cols; + fca.x= x; + DatabaseNode *uniquematch= 0; int uniquematch_rx=-1; @@ -358,7 +372,7 @@ OcrResultGlyph *ocr(OcrReader *rd, OcrCellType ct, int w, Pixcol cols[]) { debugf(" || %s",context_names[ctxi]); DatabaseNode *match= - findchar(rd,w,cols, x,ctxi, &uniquematch_rx); + findchar(&fca, &rd->contexts[ctxi], &uniquematch_rx); if (!match) continue; if (uniquematch && strcmp(match->str, uniquematch->str)) {