diff --git a/dat.h b/dat.h index 08cc56c..dc56a54 100644 --- a/dat.h +++ b/dat.h @@ -58,8 +58,8 @@ struct Hnode int next; char *key; int klen; - char *kana; - int kanalen; + char *val; + int vlen; }; typedef struct Hmap Hmap; diff --git a/dict.c b/dict.c index ff33540..1e8e1ad 100644 --- a/dict.c +++ b/dict.c @@ -2,7 +2,7 @@ #include "fn.h" static void -dictlkup(Dictreq *req, Dictres *res) +dictlookup(Dictreq *req, Dictres *res) { Lang *l; Hmap *dict; @@ -18,10 +18,10 @@ dictlkup(Dictreq *req, Dictres *res) if(dict == nil) return; n = hmapget(dict, &req->key); - if(n == nil || n->kanalen == 0) + if(n == nil || n->vlen == 0) return; - p = n->kana; - e = p + n->kanalen; + p = n->val; + e = p + n->vlen; while(res->nkouho < Maxkouho && p < e){ sp = p; while(p < e && *p != ' ') @@ -46,14 +46,14 @@ dictthread(void*) break; while(channbrecv(dictreqc, &req) > 0) ; - dictlkup(&req, &res); + dictlookup(&req, &res); res.key = req.pre; chansend(dictresc, &res); } } static Hmap* -opendict(char *path) +dictopen(char *path) { Hmap *h; Biobuf *b; @@ -96,7 +96,7 @@ dictinit(char *dir) if(langs[i].dictname == nil) continue; snprint(path, sizeof(path), "%s/%s.dict", dir, langs[i].dictname); - langs[i].dict = opendict(path); + langs[i].dict = dictopen(path); } } diff --git a/hash.c b/hash.c index 187e59a..347a7dc 100644 --- a/hash.c +++ b/hash.c @@ -65,7 +65,7 @@ hmapget(Hmap *h, Str *key) } static char* -str2dup(Str *s) +sdup(Str *s) { char buf[256]; char *p; @@ -79,7 +79,7 @@ str2dup(Str *s) } int -hmapset(Hmap **store, Str *key, Str *kana) +hmapset(Hmap **store, Str *key, Str *val) { Hnode *n; uchar *v; @@ -116,14 +116,14 @@ hmapset(Hmap **store, Str *key, Str *kana) n = (Hnode*)v; replace: if(n->filled == 0){ - n->key = str2dup(key); + n->key = sdup(key); n->klen = strlen(n->key); n->filled = 1; } n->next = next; - if(kana->n > 0){ - n->kana = str2dup(kana); - n->kanalen = strlen(n->kana); + if(val->n > 0){ + n->val = sdup(val); + n->vlen = strlen(n->val); } return 0; } diff --git a/strans.c b/strans.c index 1c9fa04..7f0a3a3 100644 --- a/strans.c +++ b/strans.c @@ -316,9 +316,9 @@ mapget(Hmap *h, Str *key, Str *out) if(key->n == 0) return 0; n = hmapget(h, key); - if(n == nil || n->kanalen == 0) + if(n == nil || n->vlen == 0) return 0; - sinit(out, n->kana, n->kanalen); + sinit(out, n->val, n->vlen); return 1; }