From 04fb65fd76af2fda4302fd79b81f59085d2d5fbe Mon Sep 17 00:00:00 2001 From: Jente Hidskes Date: Fri, 17 Feb 2017 23:29:42 +0100 Subject: screen.c: account for translated string length `[RO]` is appended to the status line and `len` is increased with the length of this string (4). However, the string is marked for translation and may thus well be larger (or smaller) than 4. Therefore, we check the length at runtime. The resulting len is never actually used, and thus could be removed. However, by keeping this line, the body of this if-statement is kept consistent with surrounding code, and future changes can not forget to add this line when additional strings are added to p. --- src/nvim/screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/screen.c') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 6df443754b..fd3489c503 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -4876,7 +4876,7 @@ 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); -- cgit From 83666f3ce21d748c9e0b8caa307e855a9dcc3626 Mon Sep 17 00:00:00 2001 From: Sander Bosma Date: Sun, 19 Feb 2017 18:31:46 +0100 Subject: screen.c: remove dead code As stated in globals.h, mbyte flags are deprecated, and code using it can be refractored to remove dead code. Since has_mbyte is defined to true, this refractoring correct. --- src/nvim/screen.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/nvim/screen.c') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index fd3489c503..bb1f4b9a14 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -4880,33 +4880,30 @@ void win_redr_status(win_T *wp) } 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; -- cgit