mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 05:28:33 +00:00
message.c: fix dead assignment by removing dead code
`enc_dbcs` and `enc_utf8` are deprecated (globals.h), so the second branch is always taken.
This commit is contained in:
@@ -269,34 +269,19 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Last part: End of the string. */
|
// Last part: End of the string.
|
||||||
i = e;
|
|
||||||
if (enc_dbcs != 0) {
|
|
||||||
/* For DBCS going backwards in a string is slow, but
|
|
||||||
* computing the cell width isn't too slow: go forward
|
|
||||||
* until the rest fits. */
|
|
||||||
n = vim_strsize(s + i);
|
|
||||||
while (len + n > room) {
|
|
||||||
n -= ptr2cells(s + i);
|
|
||||||
i += (*mb_ptr2len)(s + i);
|
|
||||||
}
|
|
||||||
} else if (enc_utf8) {
|
|
||||||
/* For UTF-8 we can go backwards easily. */
|
|
||||||
half = i = (int)STRLEN(s);
|
half = i = (int)STRLEN(s);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
do
|
do {
|
||||||
half = half - (*mb_head_off)(s, s + half - 1) - 1;
|
half = half - (*mb_head_off)(s, s + half - 1) - 1;
|
||||||
while (utf_iscomposing(utf_ptr2char(s + half)) && half > 0);
|
} while (utf_iscomposing(utf_ptr2char(s + half)) && half > 0);
|
||||||
n = ptr2cells(s + half);
|
n = ptr2cells(s + half);
|
||||||
if (len + n > room)
|
if (len + n > room) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
len += n;
|
len += n;
|
||||||
i = half;
|
i = half;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
for (i = (int)STRLEN(s); len + (n = ptr2cells(s + i - 1)) <= room; --i)
|
|
||||||
len += n;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i <= e + 3) {
|
if (i <= e + 3) {
|
||||||
// text fits without truncating
|
// text fits without truncating
|
||||||
|
Reference in New Issue
Block a user