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: 53c4625aea0b09dbaf8c46a380454b4a015a6991
Parent: c23ff689c1ee113a43410b7fec98ffe46bef453e
Author: Randy Palamar
Date:   Thu, 30 Nov 2023 09:59:17 -0700

use a fn pointer cast to make entcmp more readable

K&R reminded me that you can use a cast so that your comparison
function doesn't need to take void *.

Diffstat:
Mjdict.c | 5++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/jdict.c b/jdict.c @@ -66,9 +66,8 @@ free_ents(DictEnt *ents, size_t nents) } static int -entcmp(const void *va, const void *vb) +entcmp(DictEnt *a, DictEnt *b) { - const DictEnt *a = va, *b = vb; if (a->term == NULL || b->term == NULL) { if (a->term == NULL && b->term) return -1; @@ -335,7 +334,7 @@ make_dict(Dict *d) d->nents += parallel_parse_term_banks(&d->ents[d->nents], lents - d->nents, path, nbanks, 2); - qsort(d->ents, d->nents, sizeof(DictEnt), entcmp); + qsort(d->ents, d->nents, sizeof(DictEnt), (int (*)(const void *, const void *))entcmp); return dedup(d); }