changeset 30713:cb8094ff4f36 v9.0.0691

patch 9.0.0691: lalloc(0) error in listchars test Commit: https://github.com/vim/vim/commit/2b7b4f7670f607704307f7715ce56752757c22e3 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 8 11:46:02 2022 +0100 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.
author Bram Moolenaar <Bram@vim.org>
date Sat, 08 Oct 2022 13:00:06 +0200
parents 4a393ae6ebce
children c9a2729e2ee3
files src/drawline.c src/version.c
diffstat 2 files changed, 46 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -2802,49 +2802,56 @@ win_line(
 						      && wlv.n_extra > tab_len)
 			    tab_len += wlv.n_extra - tab_len;
 # endif
-			// If wlv.n_extra > 0, it gives the number of chars, to
-			// use for a tab, else we need to calculate the width
-			// for a tab.
-			int tab2_len = mb_char2len(wp->w_lcs_chars.tab2);
-			len = tab_len * tab2_len;
-			if (wp->w_lcs_chars.tab3)
-			    len += mb_char2len(wp->w_lcs_chars.tab3) - tab2_len;
-			if (wlv.n_extra > 0)
-			    len += wlv.n_extra - tab_len;
-			c = wp->w_lcs_chars.tab1;
-			p = alloc(len + 1);
-			if (p == NULL)
-			    wlv.n_extra = 0;
-			else
+			if (tab_len > 0)
 			{
-			    vim_memset(p, ' ', len);
-			    p[len] = NUL;
-			    vim_free(wlv.p_extra_free);
-			    wlv.p_extra_free = p;
-			    for (i = 0; i < tab_len; i++)
+			    // If wlv.n_extra > 0, it gives the number of
+			    // chars, to use for a tab, else we need to
+			    // calculate the width for a tab.
+			    int tab2_len = mb_char2len(wp->w_lcs_chars.tab2);
+			    len = tab_len * tab2_len;
+			    if (wp->w_lcs_chars.tab3)
+				len += mb_char2len(wp->w_lcs_chars.tab3)
+								    - tab2_len;
+			    if (wlv.n_extra > 0)
+				len += wlv.n_extra - tab_len;
+			    c = wp->w_lcs_chars.tab1;
+			    p = alloc(len + 1);
+			    if (p == NULL)
+				wlv.n_extra = 0;
+			    else
 			    {
-				int lcs = wp->w_lcs_chars.tab2;
-
-				if (*p == NUL)
+				vim_memset(p, ' ', len);
+				p[len] = NUL;
+				vim_free(wlv.p_extra_free);
+				wlv.p_extra_free = p;
+				for (i = 0; i < tab_len; i++)
 				{
-				    tab_len = i;
-				    break;
-				}
+				    int lcs = wp->w_lcs_chars.tab2;
+
+				    if (*p == NUL)
+				    {
+					tab_len = i;
+					break;
+				    }
 
-				// if tab3 is given, use it for the last char
-				if (wp->w_lcs_chars.tab3 && i == tab_len - 1)
-				    lcs = wp->w_lcs_chars.tab3;
-				p += mb_char2bytes(lcs, p);
-				wlv.n_extra += mb_char2len(lcs)
+				    // if tab3 is given, use it for the last
+				    // char
+				    if (wp->w_lcs_chars.tab3
+							   && i == tab_len - 1)
+					lcs = wp->w_lcs_chars.tab3;
+				    p += mb_char2bytes(lcs, p);
+				    wlv.n_extra += mb_char2len(lcs)
 						  - (saved_nextra > 0 ? 1 : 0);
+				}
+				wlv.p_extra = wlv.p_extra_free;
+# ifdef FEAT_CONCEAL
+				// n_extra will be increased by
+				// FIX_FOX_BOGUSCOLS macro below, so need to
+				// adjust for that here
+				if (wlv.vcol_off > 0)
+				    wlv.n_extra -= wlv.vcol_off;
+# endif
 			    }
-			    wlv.p_extra = wlv.p_extra_free;
-# ifdef FEAT_CONCEAL
-			    // n_extra will be increased by FIX_FOX_BOGUSCOLS
-			    // macro below, so need to adjust for that here
-			    if (wlv.vcol_off > 0)
-				wlv.n_extra -= wlv.vcol_off;
-# endif
 			}
 		    }
 #endif
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    691,
+/**/
     690,
 /**/
     689,