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; i<current->nlinks; i++)
if (current->links[i].col == cv)
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;
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)) {