Fix segmentation fault when -NF and -pri, and fix fuzzy -pri

This commit is contained in:
Jacob 2023-07-11 17:21:30 +02:00
parent d935122998
commit 97ad50ce74

View file

@ -83,8 +83,8 @@ void fuzzymatch(void) {
if (sortmatches && it->hp) if (sortmatches && it->hp)
appenditem(it, &lhpprefix, &hpprefixend); appenditem(it, &lhpprefix, &hpprefixend);
else
appenditem(it, &matches, &matchend); appenditem(it, &matches, &matchend);
} }
free(fuzzymatches); free(fuzzymatches);
} }
@ -145,10 +145,10 @@ void match(void) {
appenditem(item, &matches, &matchend); appenditem(item, &matches, &matchend);
else { else {
// exact matches go first, then prefixes with high priority, then prefixes, then substrings // exact matches go first, then prefixes with high priority, then prefixes, then substrings
if (item->hp && !fstrncmp(tokv[0], item->text, len)) if (!tokc || !fstrncmp(tx.text, item->text, textsize))
appenditem(item, &lhpprefix, &hpprefixend);
else if (!tokc || !fstrncmp(tx.text, item->text, textsize))
appenditem(item, &matches, &matchend); appenditem(item, &matches, &matchend);
else if (item->hp && !fstrncmp(tokv[0], item->text, len))
appenditem(item, &lhpprefix, &hpprefixend);
else if (!fstrncmp(tokv[0], item->text, len)) else if (!fstrncmp(tokv[0], item->text, len))
appenditem(item, &lprefix, &prefixend); appenditem(item, &lprefix, &prefixend);
else else