aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2017-03-07 09:03:52 -0500
committerGitHub <noreply@github.com>2017-03-07 09:03:52 -0500
commitf613dd016a75073d2fb251dc54315967b9bd6b93 (patch)
treeeca09d83d72adb3bdfdc8409f5c8d1973189e667 /src
parent70bbd5a7ef617d5048406cd737882c82253e5cfa (diff)
parent532197b4f95596e202fb230523ceb0c9e6233dae (diff)
downloadrneovim-f613dd016a75073d2fb251dc54315967b9bd6b93.tar.gz
rneovim-f613dd016a75073d2fb251dc54315967b9bd6b93.tar.bz2
rneovim-f613dd016a75073d2fb251dc54315967b9bd6b93.zip
Merge pull request #6225 from jamessan/vim-7.4.2051
vim-patch:7.4.2051,7.4.2068,7.4.2097
Diffstat (limited to 'src')
-rw-r--r--src/nvim/message.c26
-rw-r--r--src/nvim/version.c6
2 files changed, 18 insertions, 14 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 699f4b87b9..4cd0db21e8 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -237,17 +237,19 @@ msg_strtrunc (
* Truncate a string "s" to "buf" with cell width "room".
* "s" and "buf" may be equal.
*/
-void trunc_string(char_u *s, char_u *buf, int room, int buflen)
+void trunc_string(char_u *s, char_u *buf, int room_in, int buflen)
{
- int half;
- int len;
+ size_t room = room_in - 3; // "..." takes 3 chars
+ size_t half;
+ size_t len = 0;
int e;
int i;
int n;
- room -= 3;
+ if (room_in < 3) {
+ room = 0;
+ }
half = room / 2;
- len = 0;
/* First part: Start of the string. */
for (e = 0; len < half && e < buflen; ++e) {
@@ -257,8 +259,9 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen)
return;
}
n = ptr2cells(s + e);
- if (len + n >= half)
+ if (len + n > half) {
break;
+ }
len += n;
buf[e] = s[e];
if (has_mbyte)
@@ -274,9 +277,9 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen)
for (;;) {
do {
half = half - (*mb_head_off)(s, s + half - 1) - 1;
- } while (utf_iscomposing(utf_ptr2char(s + half)) && half > 0);
+ } while (half > 0 && utf_iscomposing(utf_ptr2char(s + half)));
n = ptr2cells(s + half);
- if (len + n > room) {
+ if (len + n > room || half == 0) {
break;
}
len += n;
@@ -287,7 +290,7 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen)
// text fits without truncating
if (s != buf) {
len = STRLEN(s);
- if (len >= buflen) {
+ if (len >= (size_t)buflen) {
len = buflen - 1;
}
len = len - e + 1;
@@ -300,9 +303,10 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen)
} else if (e + 3 < buflen) {
// set the middle and copy the last part
memmove(buf + e, "...", (size_t)3);
- len = (int)STRLEN(s + i) + 1;
- if (len >= buflen - e - 3)
+ len = STRLEN(s + i) + 1;
+ if (len >= (size_t)buflen - e - 3) {
len = buflen - e - 3 - 1;
+ }
memmove(buf + e + 3, s + i, len);
buf[e + 3 + len - 1] = NUL;
} else {
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 9c816457c1..eae0da98f4 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -343,7 +343,7 @@ static int included_patches[] = {
2100,
2099,
2098,
- // 2097,
+ 2097,
2096,
2095,
// 2094 NA
@@ -372,7 +372,7 @@ static int included_patches[] = {
2071,
// 2070 NA
// 2069,
- // 2068,
+ 2068,
2067,
2066,
2065,
@@ -389,7 +389,7 @@ static int included_patches[] = {
// 2054 NA
// 2053 NA
// 2052 NA
- // 2051,
+ 2051,
2050,
2049,
// 2048 NA