- r= fscanf(db, "%d %d", &ctx, &nchrs);
- if (r==EOF) break;
- eassert(r==2);
- eassert(ctx>=0 && ctx<N_OCR_CONTEXTS);
- eassert(nchrs>0 && nchrs<=MAXGLYPHCHRS);
-
- for (i=0; i<nchrs; i++) {
- int c;
- r= fscanf(db, "%x", &c); eassert(r==1);
- eassert(c>0 && c<=255);
- chrs[i]= c;
+ FGETSLINE(db,lbuf);
+ if (!lbuf || lbuf[0]=='#') continue;
+ if (!strcmp(lbuf,".")) break;
+
+ for (ctxi=0; ctxi<NCONTEXTS; ctxi++)
+ if (!strcmp(lbuf,context_names[ctxi]))
+ goto found_ctx;
+ /* not found, just skip */
+ for (;;) { FGETSLINE(db,lbuf); if (!lbuf[0]) break; }
+ continue;
+
+ found_ctx:
+ for (nchrs=0;;) {
+ int c= fgetc(db); eassert(c!=EOF);
+ if (c=='\n') { eassert(nchrs); break; }
+ eassert(nchrs<MAXGLYPHCHRS);
+ if (c=='\\') {
+ unsigned cr;
+ c= fgetc(db); eassert(c=='x');
+ r= fscanf(db, "%2x", &cr); eassert(r==1);
+ assert(cr>0 && cr<=255);
+ c= cr;
+ }
+ chrs[nchrs++]= c;
+ }
+ endsword= 0;
+ if (nchrs>1 && chrs[nchrs-1]==' ') {
+ endsword= 1;
+ nchrs--;