diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/hardcopy.c | 8 | ||||
-rw-r--r-- | src/nvim/message.c | 37 | ||||
-rw-r--r-- | src/nvim/misc1.c | 6 | ||||
-rw-r--r-- | src/nvim/screen.c | 25 | ||||
-rw-r--r-- | src/nvim/strings.c | 1 |
5 files changed, 26 insertions, 51 deletions
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index c2dc6231f1..19d97ecfef 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -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) diff --git a/src/nvim/message.c b/src/nvim/message.c index 5427ae7793..699f4b87b9 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -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); - } - } 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; + // 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 { - for (i = (int)STRLEN(s); len + (n = ptr2cells(s + i - 1)) <= room; --i) - len += n; + len += n; + i = half; } if (i <= e + 3) { diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 36087ac59c..d49d1d8a21 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -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)) { diff --git a/src/nvim/screen.c b/src/nvim/screen.c index f981fcb875..b98e59ed06 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -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; diff --git a/src/nvim/strings.c b/src/nvim/strings.c index f7218cc267..5b6fbf75a9 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -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; |