screen.c: remove dead code #6609

enc_utf8, enc_dbcs, has_mbyte are always true, so the false branches are
never taken.
This commit is contained in:
Justin M. Keyes 2019-03-02 01:23:15 +01:00 committed by GitHub
parent 018e0d5a19
commit 708176aea1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2603,7 +2603,7 @@ win_line (
} }
// Highlight one character for an empty match. // Highlight one character for an empty match.
if (shl->startcol == shl->endcol) { if (shl->startcol == shl->endcol) {
if (has_mbyte && line[shl->endcol] != NUL) { if (line[shl->endcol] != NUL) {
shl->endcol += (*mb_ptr2len)(line + shl->endcol); shl->endcol += (*mb_ptr2len)(line + shl->endcol);
} else { } else {
++shl->endcol; ++shl->endcol;
@ -2949,13 +2949,8 @@ win_line (
shl->endcol = MAXCOL; shl->endcol = MAXCOL;
if (shl->startcol == shl->endcol) { if (shl->startcol == shl->endcol) {
/* highlight empty match, try again after // highlight empty match, try again after it
* it */ shl->endcol += (*mb_ptr2len)(line + shl->endcol);
if (has_mbyte)
shl->endcol += (*mb_ptr2len)(line
+ shl->endcol);
else
++shl->endcol;
} }
/* Loop to check if the match starts at the /* Loop to check if the match starts at the
@ -3055,7 +3050,7 @@ win_line (
if (c_extra != NUL || (n_extra == 1 && c_final != NUL)) { if (c_extra != NUL || (n_extra == 1 && c_final != NUL)) {
c = (n_extra == 1 && c_final != NUL) ? c_final : c_extra; c = (n_extra == 1 && c_final != NUL) ? c_final : c_extra;
mb_c = c; // doesn't handle non-utf-8 multi-byte! mb_c = c; // doesn't handle non-utf-8 multi-byte!
if (enc_utf8 && utf_char2len(c) > 1) { if (utf_char2len(c) > 1) {
mb_utf8 = true; mb_utf8 = true;
u8cc[0] = 0; u8cc[0] = 0;
c = 0xc0; c = 0xc0;
@ -3064,9 +3059,7 @@ win_line (
} }
} else { } else {
c = *p_extra; c = *p_extra;
if (has_mbyte) {
mb_c = c; mb_c = c;
if (enc_utf8) {
// If the UTF-8 character is more than one byte: // If the UTF-8 character is more than one byte:
// Decode it into "mb_c". // Decode it into "mb_c".
mb_l = utfc_ptr2len(p_extra); mb_l = utfc_ptr2len(p_extra);
@ -3078,14 +3071,12 @@ win_line (
mb_utf8 = true; mb_utf8 = true;
c = 0xc0; c = 0xc0;
} }
} if (mb_l == 0) { // at the NUL at end-of-line
if (mb_l == 0) /* at the NUL at end-of-line */
mb_l = 1; mb_l = 1;
}
/* If a double-width char doesn't fit display a '>' in the // If a double-width char doesn't fit display a '>' in the last column.
* last column. */ if ((wp->w_p_rl ? (col <= 0) : (col >= grid->Columns - 1))
if ((wp->w_p_rl ? (col <= 0) :
(col >= grid->Columns - 1))
&& (*mb_char2cells)(mb_c) == 2) { && (*mb_char2cells)(mb_c) == 2) {
c = '>'; c = '>';
mb_c = c; mb_c = c;
@ -3101,7 +3092,6 @@ win_line (
n_extra -= mb_l - 1; n_extra -= mb_l - 1;
p_extra += mb_l - 1; p_extra += mb_l - 1;
} }
}
++p_extra; ++p_extra;
} }
--n_extra; --n_extra;
@ -3115,9 +3105,7 @@ win_line (
// Get a character from the line itself. // Get a character from the line itself.
c0 = c = *ptr; c0 = c = *ptr;
if (has_mbyte) {
mb_c = c; mb_c = c;
if (enc_utf8) {
// If the UTF-8 character is more than one byte: Decode it // If the UTF-8 character is more than one byte: Decode it
// into "mb_c". // into "mb_c".
mb_l = utfc_ptr2len(ptr); mb_l = utfc_ptr2len(ptr);
@ -3131,8 +3119,8 @@ win_line (
} }
mb_utf8 = true; mb_utf8 = true;
/* At start of the line we can have a composing char. // At start of the line we can have a composing char.
* Draw it as a space with a composing char. */ // Draw it as a space with a composing char.
if (utf_iscomposing(mb_c)) { if (utf_iscomposing(mb_c)) {
int i; int i;
@ -3166,15 +3154,15 @@ win_line (
extra_attr = win_hl_attr(wp, HLF_8); extra_attr = win_hl_attr(wp, HLF_8);
saved_attr2 = char_attr; // save current attr saved_attr2 = char_attr; // save current attr
} }
} else if (mb_l == 0) /* at the NUL at end-of-line */ } else if (mb_l == 0) { // at the NUL at end-of-line
mb_l = 1; mb_l = 1;
else if (p_arshape && !p_tbidi && arabic_char(mb_c)) { } else if (p_arshape && !p_tbidi && arabic_char(mb_c)) {
/* Do Arabic shaping. */ // Do Arabic shaping.
int pc, pc1, nc; int pc, pc1, nc;
int pcc[MAX_MCO]; int pcc[MAX_MCO];
/* The idea of what is the previous and next // The idea of what is the previous and next
* character depends on 'rightleft'. */ // character depends on 'rightleft'.
if (wp->w_p_rl) { if (wp->w_p_rl) {
pc = prev_c; pc = prev_c;
pc1 = prev_c1; pc1 = prev_c1;
@ -3188,45 +3176,12 @@ win_line (
prev_c = mb_c; prev_c = mb_c;
mb_c = arabic_shape(mb_c, &c, &u8cc[0], pc, pc1, nc); mb_c = arabic_shape(mb_c, &c, &u8cc[0], pc, pc1, nc);
} else
prev_c = mb_c;
} else { /* enc_dbcs */
mb_l = MB_BYTE2LEN(c);
if (mb_l == 0) /* at the NUL at end-of-line */
mb_l = 1;
else if (mb_l > 1) {
/* We assume a second byte below 32 is illegal.
* Hopefully this is OK for all double-byte encodings!
*/
if (ptr[1] >= 32)
mb_c = (c << 8) + ptr[1];
else {
if (ptr[1] == NUL) {
/* head byte at end of line */
mb_l = 1;
transchar_nonprint(extra, c);
} else { } else {
/* illegal tail byte */ prev_c = mb_c;
mb_l = 2;
STRCPY(extra, "XX");
} }
p_extra = extra; // If a double-width char doesn't fit display a '>' in the
n_extra = (int)STRLEN(extra) - 1; // last column; the character is displayed at the start of the
c_extra = NUL; // next line.
c_final = NUL;
c = *p_extra++;
if (area_attr == 0 && search_attr == 0) {
n_attr = n_extra + 1;
extra_attr = win_hl_attr(wp, HLF_8);
saved_attr2 = char_attr; // save current attr
}
mb_c = c;
}
}
}
/* If a double-width char doesn't fit display a '>' in the
* last column; the character is displayed at the start of the
* next line. */
if ((wp->w_p_rl ? (col <= 0) : if ((wp->w_p_rl ? (col <= 0) :
(col >= grid->Columns - 1)) (col >= grid->Columns - 1))
&& (*mb_char2cells)(mb_c) == 2) { && (*mb_char2cells)(mb_c) == 2) {
@ -3242,9 +3197,8 @@ win_line (
ptr += mb_l - 1; ptr += mb_l - 1;
} }
/* If a double-width char doesn't fit at the left side display // If a double-width char doesn't fit at the left side display a '<' in
* a '<' in the first column. Don't do this for unprintable // the first column. Don't do this for unprintable characters.
* characters. */
if (n_skip > 0 && mb_l > 1 && n_extra == 0) { if (n_skip > 0 && mb_l > 1 && n_extra == 0) {
n_extra = 1; n_extra = 1;
c_extra = MB_FILLER_CHAR; c_extra = MB_FILLER_CHAR;
@ -3259,8 +3213,6 @@ win_line (
mb_utf8 = false; mb_utf8 = false;
mb_l = 1; mb_l = 1;
} }
}
ptr++; ptr++;
if (extra_check) { if (extra_check) {
@ -3317,11 +3269,8 @@ win_line (
char_u *p; char_u *p;
int len; int len;
hlf_T spell_hlf = HLF_COUNT; hlf_T spell_hlf = HLF_COUNT;
if (has_mbyte) {
prev_ptr = ptr - mb_l; prev_ptr = ptr - mb_l;
v -= mb_l - 1; v -= mb_l - 1;
} else
prev_ptr = ptr - 1;
/* Use nextline[] if possible, it has the start of the /* Use nextline[] if possible, it has the start of the
* next line concatenated. */ * next line concatenated. */
@ -3431,7 +3380,7 @@ win_line (
extra_attr = win_hl_attr(wp, HLF_0); extra_attr = win_hl_attr(wp, HLF_0);
saved_attr2 = char_attr; // save current attr saved_attr2 = char_attr; // save current attr
mb_c = c; mb_c = c;
if (enc_utf8 && utf_char2len(c) > 1) { if (utf_char2len(c) > 1) {
mb_utf8 = true; mb_utf8 = true;
u8cc[0] = 0; u8cc[0] = 0;
c = 0xc0; c = 0xc0;
@ -3446,7 +3395,7 @@ win_line (
extra_attr = win_hl_attr(wp, HLF_0); extra_attr = win_hl_attr(wp, HLF_0);
saved_attr2 = char_attr; // save current attr saved_attr2 = char_attr; // save current attr
mb_c = c; mb_c = c;
if (enc_utf8 && utf_char2len(c) > 1) { if (utf_char2len(c) > 1) {
mb_utf8 = true; mb_utf8 = true;
u8cc[0] = 0; u8cc[0] = 0;
c = 0xc0; c = 0xc0;
@ -3553,7 +3502,7 @@ win_line (
extra_attr = win_hl_attr(wp, HLF_0); extra_attr = win_hl_attr(wp, HLF_0);
saved_attr2 = char_attr; // save current attr saved_attr2 = char_attr; // save current attr
mb_c = c; mb_c = c;
if (enc_utf8 && utf_char2len(c) > 1) { if (utf_char2len(c) > 1) {
mb_utf8 = true; mb_utf8 = true;
u8cc[0] = 0; u8cc[0] = 0;
c = 0xc0; c = 0xc0;
@ -3600,7 +3549,7 @@ win_line (
extra_attr = win_hl_attr(wp, HLF_AT); extra_attr = win_hl_attr(wp, HLF_AT);
n_attr = 1; n_attr = 1;
mb_c = c; mb_c = c;
if (enc_utf8 && utf_char2len(c) > 1) { if (utf_char2len(c) > 1) {
mb_utf8 = true; mb_utf8 = true;
u8cc[0] = 0; u8cc[0] = 0;
c = 0xc0; c = 0xc0;
@ -3689,7 +3638,7 @@ win_line (
n_skip = 1; n_skip = 1;
} }
mb_c = c; mb_c = c;
if (enc_utf8 && utf_char2len(c) > 1) { if (utf_char2len(c) > 1) {
mb_utf8 = true; mb_utf8 = true;
u8cc[0] = 0; u8cc[0] = 0;
c = 0xc0; c = 0xc0;
@ -3735,9 +3684,9 @@ win_line (
&& c != NUL) { && c != NUL) {
c = wp->w_p_lcs_chars.prec; c = wp->w_p_lcs_chars.prec;
lcs_prec_todo = NUL; lcs_prec_todo = NUL;
if (has_mbyte && (*mb_char2cells)(mb_c) > 1) { if ((*mb_char2cells)(mb_c) > 1) {
/* Double-width character being overwritten by the "precedes" // Double-width character being overwritten by the "precedes"
* character, need to fill up half the character. */ // character, need to fill up half the character.
c_extra = MB_FILLER_CHAR; c_extra = MB_FILLER_CHAR;
c_final = NUL; c_final = NUL;
n_extra = 1; n_extra = 1;
@ -3745,7 +3694,7 @@ win_line (
extra_attr = win_hl_attr(wp, HLF_AT); extra_attr = win_hl_attr(wp, HLF_AT);
} }
mb_c = c; mb_c = c;
if (enc_utf8 && utf_char2len(c) > 1) { if (utf_char2len(c) > 1) {
mb_utf8 = true; mb_utf8 = true;
u8cc[0] = 0; u8cc[0] = 0;
c = 0xc0; c = 0xc0;
@ -4019,7 +3968,7 @@ win_line (
c = wp->w_p_lcs_chars.ext; c = wp->w_p_lcs_chars.ext;
char_attr = win_hl_attr(wp, HLF_AT); char_attr = win_hl_attr(wp, HLF_AT);
mb_c = c; mb_c = c;
if (enc_utf8 && utf_char2len(c) > 1) { if (utf_char2len(c) > 1) {
mb_utf8 = true; mb_utf8 = true;
u8cc[0] = 0; u8cc[0] = 0;
c = 0xc0; c = 0xc0;
@ -4060,13 +4009,13 @@ win_line (
*/ */
vcol_prev = vcol; vcol_prev = vcol;
if (draw_state < WL_LINE || n_skip <= 0) { if (draw_state < WL_LINE || n_skip <= 0) {
/* //
* Store the character. // Store the character.
*/ //
if (has_mbyte && wp->w_p_rl && (*mb_char2cells)(mb_c) > 1) { if (wp->w_p_rl && (*mb_char2cells)(mb_c) > 1) {
/* A double-wide character is: put first halve in left cell. */ // A double-wide character is: put first halve in left cell.
--off; off--;
--col; col--;
} }
if (mb_utf8) { if (mb_utf8) {
schar_from_cc(linebuf_char[off], mb_c, u8cc); schar_from_cc(linebuf_char[off], mb_c, u8cc);
@ -4080,7 +4029,7 @@ win_line (
linebuf_attr[off] = char_attr; linebuf_attr[off] = char_attr;
} }
if (has_mbyte && (*mb_char2cells)(mb_c) > 1) { if ((*mb_char2cells)(mb_c) > 1) {
// Need to fill two screen columns. // Need to fill two screen columns.
off++; off++;
col++; col++;
@ -4140,8 +4089,8 @@ win_line (
} }
if (has_mbyte && (*mb_char2cells)(mb_c) > 1) { if ((*mb_char2cells)(mb_c) > 1) {
/* Need to fill two screen columns. */ // Need to fill two screen columns.
if (wp->w_p_rl) { if (wp->w_p_rl) {
--boguscols; --boguscols;
--col; --col;
@ -4738,8 +4687,8 @@ win_redr_status_matches (
for (; *s != NUL; ++s) { for (; *s != NUL; ++s) {
s += skip_status_match_char(xp, s); s += skip_status_match_char(xp, s);
clen += ptr2cells(s); clen += ptr2cells(s);
if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1) { if ((l = (*mb_ptr2len)(s)) > 1) {
STRNCPY(buf + len, s, l); STRNCPY(buf + len, s, l); // NOLINT(runtime/printf)
s += l - 1; s += l - 1;
len += l; len += l;
} else { } else {
@ -5007,11 +4956,12 @@ get_keymap_str (
curbuf = old_curbuf; curbuf = old_curbuf;
curwin = old_curwin; curwin = old_curwin;
if (p == NULL || *p == NUL) { if (p == NULL || *p == NUL) {
if (wp->w_buffer->b_kmap_state & KEYMAP_LOADED) if (wp->w_buffer->b_kmap_state & KEYMAP_LOADED) {
p = wp->w_buffer->b_p_keymap; p = wp->w_buffer->b_p_keymap;
else } else {
p = (char_u *)"lang"; p = (char_u *)"lang";
} }
}
if (vim_snprintf((char *)buf, len, (char *)fmt, p) > len - 1) { if (vim_snprintf((char *)buf, len, (char *)fmt, p) > len - 1) {
buf[0] = NUL; buf[0] = NUL;
} }
@ -5672,12 +5622,10 @@ next_search_hl (
shl->lnum = 0; shl->lnum = 0;
break; break;
} }
if (has_mbyte)
matchcol += mb_ptr2len(ml); matchcol += mb_ptr2len(ml);
else } else {
++matchcol;
} else
matchcol = shl->rm.endpos[0].col; matchcol = shl->rm.endpos[0].col;
}
shl->lnum = lnum; shl->lnum = lnum;
if (shl->rm.regprog != NULL) { if (shl->rm.regprog != NULL) {
@ -5812,7 +5760,6 @@ void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col,
} }
for (int row = start_row; row < end_row; row++) { for (int row = start_row; row < end_row; row++) {
if (has_mbyte) {
// When drawing over the right halve of a double-wide char clear // When drawing over the right halve of a double-wide char clear
// out the left halve. When drawing over the left halve of a // out the left halve. When drawing over the left halve of a
// double wide-char clear out the right halve. Only needed in a // double wide-char clear out the right halve. Only needed in a
@ -5824,7 +5771,6 @@ void grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col,
&& grid_fix_col(grid, end_col, row) != end_col) { && grid_fix_col(grid, end_col, row) != end_col) {
grid_puts_len(grid, (char_u *)" ", 1, row, end_col, 0); grid_puts_len(grid, (char_u *)" ", 1, row, end_col, 0);
} }
}
// if grid was resized (in ext_multigrid mode), the UI has no redraw updates // if grid was resized (in ext_multigrid mode), the UI has no redraw updates
// for the newly resized grid. It is better mark everything as dirty and // for the newly resized grid. It is better mark everything as dirty and
@ -6747,15 +6693,10 @@ static void draw_tabline(void)
(void)shorten_dir(NameBuff); (void)shorten_dir(NameBuff);
len = vim_strsize(NameBuff); len = vim_strsize(NameBuff);
p = NameBuff; p = NameBuff;
if (has_mbyte)
while (len > room) { while (len > room) {
len -= ptr2cells(p); len -= ptr2cells(p);
MB_PTR_ADV(p); MB_PTR_ADV(p);
} }
else if (len > room) {
p += len - room;
len = room;
}
if (len > Columns - col - 1) { if (len > Columns - col - 1) {
len = Columns - col - 1; len = Columns - col - 1;
} }