#define NCONTEXTS (sizeof(context_names)/sizeof(context_names[0]))
+#define SPACE_SPACES 3
+
struct OcrReader {
int h;
DatabaseNode contexts[NCONTEXTS];
char lbuf[100];
FILE *db;
+ for (ctxi=0; ctxi<NCONTEXTS; ctxi++)
+ cleardb_node(&rd->contexts[ctxi]);
+
char *dbfname=0;
asprintf(&dbfname,"%s/charset-%d.txt",get_vardir(),rd->h);
eassert(dbfname);
- db= fopen(dbfname,"r"); eassert(db);
+ db= fopen(dbfname,"r");
free(dbfname);
+ if (!db) {
+ eassert(errno==ENOENT);
+ return;
+ }
FGETSLINE(db,lbuf);
eassert(!strcmp(lbuf,"# ypp-sc-tools pctb font v1"));
eassert(r==1);
eassert(h==rd->h);
- for (ctxi=0; ctxi<NCONTEXTS; ctxi++)
- cleardb_node(&rd->contexts[ctxi]);
-
for (;;) {
FGETSLINE(db,lbuf);
if (!lbuf || lbuf[0]=='#') continue;
if (!cols[x]) {
nspaces++;
x++;
- if (nspaces==3) {
+ if (nspaces==SPACE_SPACES) {
fprintf(debug,"OCR x=%x nspaces=%d space\n",x,nspaces);
- add_result(rd," ",x-nspaces,x+1,0);
ctxmap= ct->nextword;
}
continue;
}
+
+ /* something here, so we need to add the spaces */
+ if (nspaces>=SPACE_SPACES)
+ add_result(rd," ",x-nspaces,x+1,0);
nspaces=0;
/* find character */