chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.web-live.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
allow nonexistent charset db
[ypp-sc-tools.web-live.git]
/
pctb
/
ocr.c
diff --git
a/pctb/ocr.c
b/pctb/ocr.c
index 48c25c085661579d75d4eca2622802dcfb19151c..bb9576769e10a1d633ed6ebb7786d75e3bfcf585 100644
(file)
--- a/
pctb/ocr.c
+++ b/
pctb/ocr.c
@@
-63,12
+63,19
@@
static void readdb(OcrReader *rd) {
char lbuf[100];
FILE *db;
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);
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);
free(dbfname);
+ if (!db) {
+ eassert(errno==ENOENT);
+ return;
+ }
FGETSLINE(db,lbuf);
eassert(!strcmp(lbuf,"# ypp-sc-tools pctb font v1"));
FGETSLINE(db,lbuf);
eassert(!strcmp(lbuf,"# ypp-sc-tools pctb font v1"));
@@
-77,9
+84,6
@@
static void readdb(OcrReader *rd) {
eassert(r==1);
eassert(h==rd->h);
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;
for (;;) {
FGETSLINE(db,lbuf);
if (!lbuf || lbuf[0]=='#') continue;