From: Ian Jackson Date: Sat, 4 Jul 2009 19:01:42 +0000 (+0100) Subject: make AADEPTH configurable X-Git-Tag: 1.9.2~25 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=commitdiff_plain;h=d79262d3c0bc002beb7888568d74d26e27852699 make AADEPTH configurable --- diff --git a/pctb/common.h b/pctb/common.h index fe87e16..5044bb3 100644 --- a/pctb/common.h +++ b/pctb/common.h @@ -166,4 +166,6 @@ char *masprintf(const char *fmt, ...) FMT(1,2); #define ARRAYSIZE(a) ((sizeof((a)) / sizeof((a)[0]))) #define FILLZERO(obj) (memset(&(obj),0,sizeof((obj)))) +#define STRING(x) #x + #endif /*COMMON_H*/ diff --git a/pctb/dictionary-manager b/pctb/dictionary-manager index 365aecb..7091964 100755 --- a/pctb/dictionary-manager +++ b/pctb/dictionary-manager @@ -42,6 +42,9 @@ # if it wrote a byte to fd 4, it can take another question +set aadepth 3 + + #---------- library routines ---------- proc manyset {list args} { @@ -898,7 +901,7 @@ proc recursor {} { # $database($context 0x 0x...) = $hex -set database_magic/char {# ypp-sc-tools pctb font v2} +set database_magic/char "# ypp-sc-tools pctb font v3 depth=$aadepth" proc read_database_header/char {f} { global rows @@ -1134,10 +1137,10 @@ proc chop_counted {var} { } proc approve_decompose_data {specdata} { - global data + global data aadepth set data $specdata - regsub-data {^ypp-sc-tools dictionary update v2\n} {} + regsub-data "^ypp-sc-tools dictionary update v3 depth=$aadepth\\n" {} uplevel 1 chop_counted pirate uplevel 1 chop_counted caller uplevel 1 chop_counted dict diff --git a/pctb/dictionary-update-receiver b/pctb/dictionary-update-receiver index 99a580e..d80ab21 100755 --- a/pctb/dictionary-update-receiver +++ b/pctb/dictionary-update-receiver @@ -19,6 +19,8 @@ use CGI qw/:standard -private_tempfiles/; use IO::Pipe; use IO::Handle; +my $aadepth=3; + #---------- pixmaps ---------- sub parseentryin__pixmap ($) { @@ -78,9 +80,12 @@ print STDERR ">@d<\n"; my $w= @d; - my $pgm= "P2\n$h $w\n7\n"; + my $maxval= (1<<$aadepth)-1; + die 'cannot do [^0...$maxval]!' if $maxval>9; + + my $pgm= "P2\n$h $w\n$maxval\n"; map { # x, left to right - m/[^0-7]/ and die "$_ ?"; + m/[^0-$maxval]/ and die "$_ ?"; my $l= $_; $l =~ s/./ $&/g; $pgm .= "$l\n"; @@ -257,7 +262,7 @@ open F, "> $fn_t" or die "$fn_t $!"; (stat F) or die $!; my $fn_i= sprintf "_update.$$-%016x.rdy", (stat _)[1]; -print F "ypp-sc-tools dictionary update v2\n"; +print F "ypp-sc-tools dictionary update v3 depth=$aadepth\n"; foreach my $v ($pirate,$caller,$dict,$ctx,$def,$image,$key,$val) { printf F "%d\n", length($v) or die $!; diff --git a/pctb/ocr.c b/pctb/ocr.c index 4b9fa50..8d1b88b 100644 --- a/pctb/ocr.c +++ b/pctb/ocr.c @@ -132,7 +132,7 @@ static void readdb1(OcrReader *rd, const char *which, int local) { o_flags |= ff_charset_havelocal; FGETSLINE; - dbassert(!strcmp(lbuf,"# ypp-sc-tools pctb font v2")); + dbassert(!strcmp(lbuf,"# ypp-sc-tools pctb font v3 depth=" STRING(AADEPTH))); dbassert( dbfile_scanf("%d", &h) == 1); dbassert(h==rd->h); diff --git a/pctb/ocr.h b/pctb/ocr.h index 7848ae7..93d619a 100644 --- a/pctb/ocr.h +++ b/pctb/ocr.h @@ -34,6 +34,10 @@ #define AADEPTH 3 #define AAMAXVAL ((1<