aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-02-09 15:52:00 +0800
committerGitHub <noreply@github.com>2022-02-09 15:52:00 +0800
commit01b748f28f0412c13ae9c5365dbd362fca0d93f6 (patch)
tree210b2a307b3f8ff9870f4ad4b987620c3ae53196
parent07c97fa02d2f5be0e643f78428d56413895096cd (diff)
parenta2a37effc2144860174310b354ba289297cc482f (diff)
downloadrneovim-01b748f28f0412c13ae9c5365dbd362fca0d93f6.tar.gz
rneovim-01b748f28f0412c13ae9c5365dbd362fca0d93f6.tar.bz2
rneovim-01b748f28f0412c13ae9c5365dbd362fca0d93f6.zip
Merge pull request #17347 from zeertzjq/screen-pvs
refactor(PVS/V547): p == NULL is always false
-rw-r--r--src/nvim/screen.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 6b2a2afa41..0644a08210 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -3753,34 +3753,30 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
}
c = wp->w_p_lcs_chars.tab1;
p = xmalloc(len + 1);
- if (p == NULL) {
- n_extra = 0;
- } else {
- memset(p, ' ', len);
- p[len] = NUL;
- xfree(p_extra_free);
- p_extra_free = p;
- for (i = 0; i < tab_len; i++) {
- if (*p == NUL) {
- tab_len = i;
- break;
- }
- int lcs = wp->w_p_lcs_chars.tab2;
-
- // if tab3 is given, use it for the last char
- if (wp->w_p_lcs_chars.tab3 && i == tab_len - 1) {
- lcs = wp->w_p_lcs_chars.tab3;
- }
- p += utf_char2bytes(lcs, p);
- n_extra += utf_char2len(lcs) - (saved_nextra > 0 ? 1 : 0);
+ memset(p, ' ', len);
+ p[len] = NUL;
+ xfree(p_extra_free);
+ p_extra_free = p;
+ for (i = 0; i < tab_len; i++) {
+ if (*p == NUL) {
+ tab_len = i;
+ break;
}
- p_extra = p_extra_free;
+ int lcs = wp->w_p_lcs_chars.tab2;
- // n_extra will be increased by FIX_FOX_BOGUSCOLS
- // macro below, so need to adjust for that here
- if (vcol_off > 0) {
- n_extra -= vcol_off;
+ // if tab3 is given, use it for the last char
+ if (wp->w_p_lcs_chars.tab3 && i == tab_len - 1) {
+ lcs = wp->w_p_lcs_chars.tab3;
}
+ p += utf_char2bytes(lcs, p);
+ n_extra += utf_char2len(lcs) - (saved_nextra > 0 ? 1 : 0);
+ }
+ p_extra = p_extra_free;
+
+ // n_extra will be increased by FIX_FOX_BOGUSCOLS
+ // macro below, so need to adjust for that here
+ if (vcol_off > 0) {
+ n_extra -= vcol_off;
}
}