jdict

command line tool for looking up terms in yomidict dictionaries
git clone anongit@rnpnr.xyz:jdict.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 91f1034c51059623ae958101b564248ed4f22a67
Parent: f9293fd95f8395fd6295c99cbfe98ed956b48231
Author: Randy Palamar
Date:   Sat,  3 Jun 2023 07:19:17 -0600

yomidict.c: parse(): simplify check for YOMI_ARRAY

Diffstat:
Myomidict.c | 16++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/yomidict.c b/yomidict.c @@ -122,7 +122,7 @@ int yomi_parse(YomiParser *p, YomiTok *toks, size_t ntoks, const char *bank, size_t blen) { - YomiTok *tok, *t; + YomiTok *tok; int r, count = p->toknext; if (toks == NULL) @@ -137,16 +137,12 @@ yomi_parse(YomiParser *p, YomiTok *toks, size_t ntoks, if (!tok) return YOMI_ERROR_NOMEM; - t = NULL; - if (p->parent != -1) { - t = &toks[p->parent]; - t->len++; - } - - if (t && t->type == YOMI_ARRAY) - tok->type = YOMI_ENTRY; - else + if (p->parent == -1 || toks[p->parent].type != YOMI_ARRAY) { tok->type = YOMI_ARRAY; + } else { + tok->type = YOMI_ENTRY; + toks[p->parent].len++; + } tok->start = p->pos; tok->parent = p->parent;