From 772e0d0870d912b9b765caf3991bf421d538b0e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Thu, 7 May 2015 08:36:22 +0200 Subject: [PATCH] Bump liberty --- degesch.c | 50 +++++++------------------------------------------- liberty | 2 +- 2 files changed, 8 insertions(+), 44 deletions(-) diff --git a/degesch.c b/degesch.c index f6f303b..ea93fdf 100644 --- a/degesch.c +++ b/degesch.c @@ -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 index 37005cc..99b92fd 160000 --- a/liberty +++ b/liberty @@ -1 +1 @@ -Subproject commit 37005cc443d8725a0103fdd4ded0b1d38853ef42 +Subproject commit 99b92fdd6e181aac2bd8fd021cd2718978126f49