Merge #6148 from delftswa2017/clang-scan-fix-dead-stores

vim-patch:8.0.0353
This commit is contained in:
Justin M. Keyes 2017-02-28 00:46:09 +01:00 committed by GitHub
commit 28a6d4393d
5 changed files with 26 additions and 51 deletions

View File

@ -845,12 +845,10 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T
* Loop over the columns until the end of the file line or right margin.
*/
for (col = ppos->column; line[col] != NUL && !need_break; col += outputlen) {
outputlen = 1;
if (has_mbyte && (outputlen = (*mb_ptr2len)(line + col)) < 1)
if ((outputlen = (*mb_ptr2len)(line + col)) < 1) {
outputlen = 1;
/*
* syntax highlighting stuff.
*/
}
// syntax highlighting stuff.
if (psettings->do_syntax) {
id = syn_get_id(curwin, ppos->file_line, col, 1, NULL, FALSE);
if (id > 0)

View File

@ -269,33 +269,18 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen)
}
}
/* 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);
// Last part: End of the string.
half = i = (int)STRLEN(s);
for (;;) {
do {
half = half - (*mb_head_off)(s, s + half - 1) - 1;
} while (utf_iscomposing(utf_ptr2char(s + half)) && half > 0);
n = ptr2cells(s + half);
if (len + n > room) {
break;
}
} else if (enc_utf8) {
/* For UTF-8 we can go backwards easily. */
half = i = (int)STRLEN(s);
for (;; ) {
do
half = half - (*mb_head_off)(s, s + half - 1) - 1;
while (utf_iscomposing(utf_ptr2char(s + half)) && half > 0);
n = ptr2cells(s + half);
if (len + n > room)
break;
len += n;
i = half;
}
} else {
for (i = (int)STRLEN(s); len + (n = ptr2cells(s + i - 1)) <= room; --i)
len += n;
len += n;
i = half;
}
if (i <= e + 3) {

View File

@ -1406,7 +1406,6 @@ void ins_char_bytes(char_u *buf, size_t charlen)
coladvance_force(getviscol());
}
int c = buf[0];
size_t col = (size_t)curwin->w_cursor.col;
linenr_T lnum = curwin->w_cursor.lnum;
char_u *oldp = ml_get(lnum);
@ -1499,10 +1498,7 @@ void ins_char_bytes(char_u *buf, size_t charlen)
&& msg_silent == 0
&& !ins_compl_active()
) {
if (has_mbyte)
showmatch(mb_ptr2char(buf));
else
showmatch(c);
showmatch(mb_ptr2char(buf));
}
if (!p_ri || (State & REPLACE_FLAG)) {

View File

@ -4876,37 +4876,34 @@ void win_redr_status(win_T *wp)
}
if (wp->w_buffer->b_p_ro) {
STRCPY(p + len, _("[RO]"));
len += 4;
len += (int)STRLEN(p + len);
}
this_ru_col = ru_col - (Columns - wp->w_width);
if (this_ru_col < (wp->w_width + 1) / 2)
if (this_ru_col < (wp->w_width + 1) / 2) {
this_ru_col = (wp->w_width + 1) / 2;
}
if (this_ru_col <= 1) {
p = (char_u *)"<"; /* No room for file name! */
p = (char_u *)"<"; // No room for file name!
len = 1;
} else if (has_mbyte) {
} else {
int clen = 0, i;
/* Count total number of display cells. */
clen = (int) mb_string2cells(p);
// Count total number of display cells.
clen = (int)mb_string2cells(p);
/* Find first character that will fit.
* Going from start to end is much faster for DBCS. */
// Find first character that will fit.
// Going from start to end is much faster for DBCS.
for (i = 0; p[i] != NUL && clen >= this_ru_col - 1;
i += (*mb_ptr2len)(p + i))
i += (*mb_ptr2len)(p + i)) {
clen -= (*mb_ptr2cells)(p + i);
}
len = clen;
if (i > 0) {
p = p + i - 1;
*p = '<';
++len;
}
} else if (len > this_ru_col - 1) {
p += len - (this_ru_col - 1);
*p = '<';
len = this_ru_col - 1;
}
row = wp->w_winrow + wp->w_height;

View File

@ -980,7 +980,6 @@ int vim_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap,
const void *ptr_arg = NULL;
if (fmt_spec == 'p') {
length_modifier = '\0';
ptr_arg = tvs ? tv_ptr(tvs, &arg_idx) : va_arg(ap, void *);
if (ptr_arg) {
arg_sign = 1;