The dictionary thread ran in imthread's own proc, so a lookup could only start once the engine blocked, and it was a trie probe anyway; the emoji and Hanja searches already called dictlookup directly. The request/result channels, sequence numbers, staleness checks and the second draw per Japanese key are gone; dictqjp fills the candidates in place. Emit.dict and Lang.dictq only ever triggered lookups for Vietnamese, which has no dictionary. dictlookup(Lang*, key, out, max) returns the count. The Hanja lookup no longer pre-checks for a single syllable; a reading either has an entry or it does not.
67 lines
966 B
C
67 lines
966 B
C
#include "dat.h"
|
|
#include "fn.h"
|
|
|
|
Channel *drawc;
|
|
Channel *keyc;
|
|
|
|
void
|
|
usage(void)
|
|
{
|
|
fprint(2, "usage: strans mapdir\n");
|
|
threadexitsall("usage");
|
|
}
|
|
|
|
void
|
|
die(char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
|
|
fprint(2, "strans: ");
|
|
va_start(ap, fmt);
|
|
vfprint(2, fmt, ap);
|
|
va_end(ap);
|
|
fprint(2, "\n");
|
|
threadexitsall("die");
|
|
}
|
|
|
|
void*
|
|
emalloc(ulong n)
|
|
{
|
|
void *p;
|
|
|
|
p = mallocz(n, 1);
|
|
if(p == nil)
|
|
die("out of memory");
|
|
return p;
|
|
}
|
|
|
|
void*
|
|
erealloc(void *p, ulong n)
|
|
{
|
|
p = realloc(p, n);
|
|
if(p == nil)
|
|
die("out of memory");
|
|
return p;
|
|
}
|
|
|
|
void
|
|
threadmain(int argc, char **argv)
|
|
{
|
|
char *display;
|
|
|
|
if(argc != 2)
|
|
usage();
|
|
|
|
drawc = chancreate(sizeof(Drawcmd), 4);
|
|
keyc = chancreate(sizeof(Keyreq), 0);
|
|
langinit(argv[1]);
|
|
srvinit();
|
|
proccreate(drawthread, nil, 16384);
|
|
proccreate(srvthread, nil, 16384);
|
|
proccreate(ibusthread, nil, 32768);
|
|
display = getenv("DISPLAY");
|
|
if(display != nil && display[0] != '\0')
|
|
proccreate(ximthread, nil, 32768);
|
|
imthread(nil);
|
|
}
|