Bump liberty

This commit is contained in:
Přemysl Eric Janouch 2015-05-07 08:36:22 +02:00
parent ae91f9047d
commit 772e0d0870
2 changed files with 8 additions and 44 deletions

View File

@ -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 // And if that doesn't help, cut the longest valid block of characters
while (true) while (true)
{ {
const char *next = utf8_next (text, text_len - eaten); const char *next = utf8_next (text, text_len - eaten, NULL);
hard_assert (next); hard_assert (next);
size_t char_len = next - text; 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. // 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 // At worst it will stop before a combining mark, or fail to compare
// non-ASCII identifiers case-insensitively. // 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]); utf8_iter_init (&a[i], vector[i]);
size_t ch_len; size_t ch_len;
const char *ch; int32_t ch;
while ((ch = utf8_iter_next (&a[0], &ch_len))) while ((ch = utf8_iter_next (&a[0], &ch_len)) != -1)
{ {
for (size_t i = 1; i < len; i++) for (size_t i = 1; i < len; i++)
{ {
size_t other_len; // Not bothering with lowercasing non-ASCII
const char *other = utf8_iter_next (&a[i], &other_len); int32_t other = utf8_iter_next (&a[i], NULL);
if (other < 0 || ch >= 0x80 || other >= 0x80
// Not bothering with different length or lowercasing non-ASCII || tolower_ascii (ch) != tolower_ascii (other))
if (!other || ch_len != other_len
|| (ch_len == 1 && tolower_ascii (*ch) != tolower_ascii (*other))
|| (ch_len != 1 && memcmp (ch, other, ch_len)))
return prefix; return prefix;
} }
prefix += ch_len; prefix += ch_len;

@ -1 +1 @@
Subproject commit 37005cc443d8725a0103fdd4ded0b1d38853ef42 Subproject commit 99b92fdd6e181aac2bd8fd021cd2718978126f49