diff options
-rw-r--r-- | degesch.c | 50 | ||||
m--------- | liberty | 0 |
2 files changed, 7 insertions, 43 deletions
@@ -3614,7 +3614,7 @@ wrap_text_for_single_line (const char *text, size_t text_len, // And if that doesn't help, cut the longest valid block of characters while (true) { - const char *next = utf8_next (text, text_len - eaten); + const char *next = utf8_next (text, text_len - eaten, NULL); hard_assert (next); size_t char_len = next - text; @@ -5113,39 +5113,6 @@ completion_matches (struct completion *self, int word, const char *pattern) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -struct utf8_iter -{ - const char *s; ///< String iterator - size_t len; ///< How many bytes remain -}; - -static void -utf8_iter_init (struct utf8_iter *self, const char *s) -{ - self->len = strlen ((self->s = s)); -} - -// TODO: return the value of the codepoint, that will simplify things -static const char * -utf8_iter_next (struct utf8_iter *self, size_t *len) -{ - if (!self->len) - return NULL; - - const char *old = self->s; - if (!soft_assert ((self->s = utf8_next (old, self->len)))) - { - // Invalid UTF-8 - self->len = 0; - return NULL; - } - - self->len -= (*len = self->s - old); - return old; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // XXX: this isn't completely right because Unicode, but let's keep it simple. // At worst it will stop before a combining mark, or fail to compare // non-ASCII identifiers case-insensitively. @@ -5162,18 +5129,15 @@ utf8_common_prefix (const char **vector, size_t len) utf8_iter_init (&a[i], vector[i]); size_t ch_len; - const char *ch; - while ((ch = utf8_iter_next (&a[0], &ch_len))) + int32_t ch; + while ((ch = utf8_iter_next (&a[0], &ch_len)) != -1) { for (size_t i = 1; i < len; i++) { - size_t other_len; - const char *other = utf8_iter_next (&a[i], &other_len); - - // Not bothering with different length or lowercasing non-ASCII - if (!other || ch_len != other_len - || (ch_len == 1 && tolower_ascii (*ch) != tolower_ascii (*other)) - || (ch_len != 1 && memcmp (ch, other, ch_len))) + // Not bothering with lowercasing non-ASCII + int32_t other = utf8_iter_next (&a[i], NULL); + if (other < 0 || ch >= 0x80 || other >= 0x80 + || tolower_ascii (ch) != tolower_ascii (other)) return prefix; } prefix += ch_len; diff --git a/liberty b/liberty -Subproject 37005cc443d8725a0103fdd4ded0b1d38853ef4 +Subproject 99b92fdd6e181aac2bd8fd021cd2718978126f4 |