diff options
author | Phil Jones <philj56@gmail.com> | 2022-10-23 13:24:48 +0100 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-10-23 13:24:59 +0100 |
commit | 3bbd8ff839354a6f488c8481d5e6336a3f637cee (patch) | |
tree | f793acfea9c8115d30bd00d1a7dde5fc9fc079d7 /src/fuzzy_match.c | |
parent | dd3a4a84d6676b51025e8feeb7af662a07b1e73c (diff) |
Replace wchar and friends with Unicode handling.
All text handling should now be explicitly UTF-8 or UTF-32, removing the
ambiguity around wchar_t and related functions.
Diffstat (limited to 'src/fuzzy_match.c')
-rw-r--r-- | src/fuzzy_match.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/fuzzy_match.c b/src/fuzzy_match.c index 2b6518f..e9f1dcb 100644 --- a/src/fuzzy_match.c +++ b/src/fuzzy_match.c @@ -5,7 +5,7 @@ #include <string.h> #include "fuzzy_match.h" -#include "utf8.h" +#include "unicode.h" #include "xmalloc.h" #undef MAX @@ -146,7 +146,7 @@ int32_t fuzzy_match_recurse( } const char *match = str; - uint32_t search = utf8_get_char(pattern); + uint32_t search = utf8_to_utf32(pattern); int32_t best_score = INT32_MIN; @@ -208,18 +208,18 @@ int32_t compute_score(int32_t jump, bool first_char, const char *restrict match) int32_t score = 0; - const uint32_t cur = utf8_get_char(match); + const uint32_t cur = utf8_to_utf32(match); /* Apply bonuses. */ if (!first_char && jump == 0) { score += adjacency_bonus; } if (!first_char || jump > 0) { - const uint32_t prev = utf8_get_char(utf8_prev_char(match)); - if (utf8_isupper(cur) && utf8_islower(prev)) { + const uint32_t prev = utf8_to_utf32(utf8_prev_char(match)); + if (utf32_isupper(cur) && utf32_islower(prev)) { score += camel_bonus; } - if (utf8_isalnum(cur) && !utf8_isalnum(prev)) { + if (utf32_isalnum(cur) && !utf32_isalnum(prev)) { score += separator_bonus; } } |