mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
vim-patch:9.0.0691: lalloc(0) error in listchars test
Problem: lalloc(0) error in listchars test.
Solution: Skip generating text for tab if tab_len is zero.
2b7b4f7670
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -2103,43 +2103,45 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
tab_len += n_extra - tab_len;
|
tab_len += n_extra - tab_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If n_extra > 0, it gives the number of chars
|
if (tab_len > 0) {
|
||||||
// to use for a tab, else we need to calculate the width
|
// If n_extra > 0, it gives the number of chars
|
||||||
// for a tab.
|
// to use for a tab, else we need to calculate the
|
||||||
int tab2_len = utf_char2len(wp->w_p_lcs_chars.tab2);
|
// width for a tab.
|
||||||
int len = tab_len * tab2_len;
|
int tab2_len = utf_char2len(wp->w_p_lcs_chars.tab2);
|
||||||
if (wp->w_p_lcs_chars.tab3) {
|
int len = tab_len * tab2_len;
|
||||||
len += utf_char2len(wp->w_p_lcs_chars.tab3) - tab2_len;
|
if (wp->w_p_lcs_chars.tab3) {
|
||||||
}
|
len += utf_char2len(wp->w_p_lcs_chars.tab3) - tab2_len;
|
||||||
if (n_extra > 0) {
|
|
||||||
len += n_extra - tab_len;
|
|
||||||
}
|
|
||||||
c = wp->w_p_lcs_chars.tab1;
|
|
||||||
p = xmalloc((size_t)len + 1);
|
|
||||||
memset(p, ' ', (size_t)len);
|
|
||||||
p[len] = NUL;
|
|
||||||
xfree(p_extra_free);
|
|
||||||
p_extra_free = p;
|
|
||||||
for (int i = 0; i < tab_len; i++) {
|
|
||||||
if (*p == NUL) {
|
|
||||||
tab_len = i;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
int lcs = wp->w_p_lcs_chars.tab2;
|
if (n_extra > 0) {
|
||||||
|
len += n_extra - tab_len;
|
||||||
// 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);
|
c = wp->w_p_lcs_chars.tab1;
|
||||||
n_extra += utf_char2len(lcs) - (saved_nextra > 0 ? 1 : 0);
|
p = xmalloc((size_t)len + 1);
|
||||||
}
|
memset(p, ' ', (size_t)len);
|
||||||
p_extra = p_extra_free;
|
p[len] = NUL;
|
||||||
|
xfree(p_extra_free);
|
||||||
|
p_extra_free = p;
|
||||||
|
for (int i = 0; i < tab_len; i++) {
|
||||||
|
if (*p == NUL) {
|
||||||
|
tab_len = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
int lcs = wp->w_p_lcs_chars.tab2;
|
||||||
|
|
||||||
// n_extra will be increased by FIX_FOX_BOGUSCOLS
|
// if tab3 is given, use it for the last char
|
||||||
// macro below, so need to adjust for that here
|
if (wp->w_p_lcs_chars.tab3 && i == tab_len - 1) {
|
||||||
if (vcol_off > 0) {
|
lcs = wp->w_p_lcs_chars.tab3;
|
||||||
n_extra -= vcol_off;
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user