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. * 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) { for (col = ppos->column; line[col] != NUL && !need_break; col += outputlen) {
outputlen = 1; if ((outputlen = (*mb_ptr2len)(line + col)) < 1) {
if (has_mbyte && (outputlen = (*mb_ptr2len)(line + col)) < 1)
outputlen = 1; outputlen = 1;
/* }
* syntax highlighting stuff. // syntax highlighting stuff.
*/
if (psettings->do_syntax) { if (psettings->do_syntax) {
id = syn_get_id(curwin, ppos->file_line, col, 1, NULL, FALSE); id = syn_get_id(curwin, ppos->file_line, col, 1, NULL, FALSE);
if (id > 0) 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. */ // Last part: End of the string.
i = e; half = i = (int)STRLEN(s);
if (enc_dbcs != 0) { for (;;) {
/* For DBCS going backwards in a string is slow, but do {
* computing the cell width isn't too slow: go forward half = half - (*mb_head_off)(s, s + half - 1) - 1;
* until the rest fits. */ } while (utf_iscomposing(utf_ptr2char(s + half)) && half > 0);
n = vim_strsize(s + i); n = ptr2cells(s + half);
while (len + n > room) { if (len + n > room) {
n -= ptr2cells(s + i); break;
i += (*mb_ptr2len)(s + i);
} }
} else if (enc_utf8) { len += n;
/* For UTF-8 we can go backwards easily. */ i = half;
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;
} }
if (i <= e + 3) { if (i <= e + 3) {

View File

@ -1406,7 +1406,6 @@ void ins_char_bytes(char_u *buf, size_t charlen)
coladvance_force(getviscol()); coladvance_force(getviscol());
} }
int c = buf[0];
size_t col = (size_t)curwin->w_cursor.col; size_t col = (size_t)curwin->w_cursor.col;
linenr_T lnum = curwin->w_cursor.lnum; linenr_T lnum = curwin->w_cursor.lnum;
char_u *oldp = ml_get(lnum); char_u *oldp = ml_get(lnum);
@ -1499,10 +1498,7 @@ void ins_char_bytes(char_u *buf, size_t charlen)
&& msg_silent == 0 && msg_silent == 0
&& !ins_compl_active() && !ins_compl_active()
) { ) {
if (has_mbyte) showmatch(mb_ptr2char(buf));
showmatch(mb_ptr2char(buf));
else
showmatch(c);
} }
if (!p_ri || (State & REPLACE_FLAG)) { 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) { if (wp->w_buffer->b_p_ro) {
STRCPY(p + len, _("[RO]")); STRCPY(p + len, _("[RO]"));
len += 4; len += (int)STRLEN(p + len);
} }
this_ru_col = ru_col - (Columns - wp->w_width); 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; this_ru_col = (wp->w_width + 1) / 2;
}
if (this_ru_col <= 1) { if (this_ru_col <= 1) {
p = (char_u *)"<"; /* No room for file name! */ p = (char_u *)"<"; // No room for file name!
len = 1; len = 1;
} else if (has_mbyte) { } else {
int clen = 0, i; int clen = 0, i;
/* Count total number of display cells. */ // Count total number of display cells.
clen = (int) mb_string2cells(p); clen = (int)mb_string2cells(p);
/* Find first character that will fit. // Find first character that will fit.
* Going from start to end is much faster for DBCS. */ // Going from start to end is much faster for DBCS.
for (i = 0; p[i] != NUL && clen >= this_ru_col - 1; 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); clen -= (*mb_ptr2cells)(p + i);
}
len = clen; len = clen;
if (i > 0) { if (i > 0) {
p = p + i - 1; p = p + i - 1;
*p = '<'; *p = '<';
++len; ++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; 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; const void *ptr_arg = NULL;
if (fmt_spec == 'p') { if (fmt_spec == 'p') {
length_modifier = '\0';
ptr_arg = tvs ? tv_ptr(tvs, &arg_idx) : va_arg(ap, void *); ptr_arg = tvs ? tv_ptr(tvs, &arg_idx) : va_arg(ap, void *);
if (ptr_arg) { if (ptr_arg) {
arg_sign = 1; arg_sign = 1;