+static DatabaseNode *findchar(OcrReader *rd, int w, Pixcol cols[],
+ int x, int ctxi, int *matchx_r) {
+ DatabaseNode *current= &rd->contexts[ctxi];
+ DatabaseNode *bestmatch= 0;
+ int i;
+
+ for (;;) {
+ debug_flush();
+ debugf(" | x=%d",x);
+ if (x>w) break;
+ Pixcol cv= cols[x];
+ debugf(" cv=%"PSPIXCOL(PRIx),cv);
+ for (i=0; i<current->nlinks; i++)
+ if (current->links[i].col == cv)
+ goto found;
+ /* not found */
+ debugf(" ?");
+ break;
+
+ found:
+ current= current->links[i].then;
+ if (current->match) {
+ debugf(" \"%s\"%s",current->str,current->endsword?"_":"");
+ bestmatch= current;
+ *matchx_r= x;
+ } else {
+ debugf(" ...");
+ }
+
+ x++;
+ }
+ return bestmatch;
+}
+