Patch 9.0.0691
Problem:    lalloc(0) error in listchars test.
Solution:   Skip generating text for tab if tab_len is zero.
Files:      src/drawline.c


*** ../vim-9.0.0690/src/drawline.c      2022-10-08 11:15:57.640625030 +0100
--- src/drawline.c      2022-10-08 11:43:21.572470416 +0100
***************
*** 2802,2850 ****
                                                      && 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
                        {
!                           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++)
                            {
!                               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)
                                                  - (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
                        }
                    }
  #endif
--- 2802,2857 ----
                                                      && wlv.n_extra > tab_len)
                            tab_len += wlv.n_extra - tab_len;
  # endif
!                       if (tab_len > 0)
                        {
!                           // 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
                            {
!                               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++)
                                {
!                                   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)
                                                  - (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
+                           }
                        }
                    }
  #endif
*** ../vim-9.0.0690/src/version.c       2022-10-08 11:15:57.640625030 +0100
--- src/version.c       2022-10-08 11:45:08.524429462 +0100
***************
*** 701,702 ****
--- 701,704 ----
  {   /* Add new patch number below this line */
+ /**/
+     691,
  /**/

-- 
Yah, well, we had to carve our electrons out of driftwood we'd
find.  In the winter.  Uphill.  Both ways.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221008104634.E925D1C0CD2%40moolenaar.net.

Raspunde prin e-mail lui