Mercurial > vim
changeset 9640:bc0a6d9a9a07 v7.4.2097
commit https://github.com/vim/vim/commit/d4f31dc45482e8db527ca044b9c3436b1e750006
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 23 17:28:22 2016 +0200
patch 7.4.2097
Problem: Warning from 64 bit compiler.
Solution: use size_t instead of int. (Mike Williams)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 23 Jul 2016 17:30:06 +0200 |
parents | 119fa0edfdd7 |
children | 5c80d18b914a |
files | src/message.c src/version.c |
diffstat | 2 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/message.c +++ b/src/message.c @@ -237,18 +237,19 @@ msg_strtrunc( trunc_string( char_u *s, char_u *buf, - int room, + 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) @@ -320,7 +321,7 @@ trunc_string( if (s != buf) { len = STRLEN(s); - if (len >= buflen) + if (len >= (size_t)buflen) len = buflen - 1; len = len - e + 1; if (len < 1) @@ -333,8 +334,8 @@ trunc_string( { /* set the middle and copy the last part */ mch_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; mch_memmove(buf + e + 3, s + i, len); buf[e + 3 + len - 1] = NUL;