Use unicode is_word/to_{lower/upper} function in ranked match

This commit is contained in:
Maxime Coste 2024-02-12 07:50:04 +11:00
parent bd91a255e4
commit e0c7a34bc1

View File

@ -45,8 +45,8 @@ static int count_word_boundaries_match(StringView candidate, StringView query)
{
const Codepoint c = *it;
const bool is_word_boundary = prev == 0 or
(!iswalnum((wchar_t)prev) and iswalnum((wchar_t)c)) or
(iswlower((wchar_t)prev) and iswupper((wchar_t)c));
(!is_word(prev, {}) and is_word(c, {})) or
(is_lower(prev) and is_upper(c));
prev = c;
if (not is_word_boundary)
@ -56,7 +56,7 @@ static int count_word_boundaries_match(StringView candidate, StringView query)
for (auto qit = query_it; qit != query.end(); ++qit)
{
const Codepoint qc = *qit;
if (qc == (iswlower((wchar_t)qc) ? lc : c))
if (qc == (is_lower(qc) ? lc : c))
{
++count;
query_it = qit+1;
@ -71,7 +71,7 @@ static int count_word_boundaries_match(StringView candidate, StringView query)
static bool smartcase_eq(Codepoint candidate, Codepoint query)
{
return query == (iswlower((wchar_t)query) ? to_lower(candidate) : candidate);
return query == (is_lower(query) ? to_lower(candidate) : candidate);
}
struct SubseqRes