diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-01-27 14:25:47 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-01-27 14:25:47 +0100 |
commit | 770350f41ceadd17b3b982627ed67a74a87603f4 (patch) | |
tree | d49263489849e04c14c268dd56a04f1f9aeea235 /src/basic/string-util.c | |
parent | fdb4ee00f022863ceee923b196f9c6dd536db9e2 (diff) | |
parent | c932fb71cc90461b88ecdffe47c071d001d78fb4 (diff) |
Merge pull request #2451 from zonque/pr-2162-rebased
utf8.[ch] et al: use char32_t and char16_t instead of int, int32_t, i…
Diffstat (limited to 'src/basic/string-util.c')
-rw-r--r-- | src/basic/string-util.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/basic/string-util.c b/src/basic/string-util.c index 1f95a9abba..cb75b09c74 100644 --- a/src/basic/string-util.c +++ b/src/basic/string-util.c @@ -450,6 +450,7 @@ char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigne char *e; const char *i, *j; unsigned k, len, len2; + int r; assert(s); assert(percent <= 100); @@ -469,10 +470,10 @@ char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigne k = 0; for (i = s; k < x && i < s + old_length; i = utf8_next_char(i)) { - int c; + char32_t c; - c = utf8_encoded_to_unichar(i); - if (c < 0) + r = utf8_encoded_to_unichar(i, &c); + if (r < 0) return NULL; k += unichar_iswide(c) ? 2 : 1; } @@ -481,11 +482,11 @@ char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigne x ++; for (j = s + old_length; k < new_length && j > i; ) { - int c; + char32_t c; j = utf8_prev_char(j); - c = utf8_encoded_to_unichar(j); - if (c < 0) + r = utf8_encoded_to_unichar(j, &c); + if (r < 0) return NULL; k += unichar_iswide(c) ? 2 : 1; } |