Patch 9.0.0284
Problem:    Using static buffer for multiple completion functions.
Solution:   Use one buffer in expand_T.
Files:      src/structs.h, src/misc1.c, src/syntax.c, src/cmdhist.c


*** ../vim-9.0.0283/src/structs.h       2022-08-25 16:02:09.681816465 +0100
--- src/structs.h       2022-08-26 22:22:24.173051208 +0100
***************
*** 598,603 ****
--- 598,605 ----
      int               xp_col;                 // cursor position in line
      char_u    **xp_files;             // list of files
      char_u    *xp_line;               // text being completed
+ #define EXPAND_BUF_LEN 256
+     char_u    xp_buf[EXPAND_BUF_LEN]; // buffer for returned match
  } expand_T;
  
  /*
*** ../vim-9.0.0283/src/misc1.c 2022-08-22 15:19:12.732328943 +0100
--- src/misc1.c 2022-08-26 22:23:37.389006745 +0100
***************
*** 2016,2033 ****
      expand_T  *xp UNUSED,
      int               idx)
  {
! # if defined(AMIGA)
!     /*
!      * No environ[] on the Amiga.
!      */
      return NULL;
! # else
  # ifndef __WIN32__
      // Borland C++ 5.2 has this in a header file.
      extern char               **environ;
  # endif
- # define ENVNAMELEN 100
-     static char_u     name[ENVNAMELEN];
      char_u            *str;
      int                       n;
  
--- 2016,2029 ----
      expand_T  *xp UNUSED,
      int               idx)
  {
! #if defined(AMIGA)
!     // No environ[] on the Amiga.
      return NULL;
! #else
  # ifndef __WIN32__
      // Borland C++ 5.2 has this in a header file.
      extern char               **environ;
  # endif
      char_u            *str;
      int                       n;
  
***************
*** 2035,2049 ****
      if (str == NULL)
        return NULL;
  
!     for (n = 0; n < ENVNAMELEN - 1; ++n)
      {
        if (str[n] == '=' || str[n] == NUL)
            break;
!       name[n] = str[n];
      }
!     name[n] = NUL;
!     return name;
! # endif
  }
  
  /*
--- 2031,2045 ----
      if (str == NULL)
        return NULL;
  
!     for (n = 0; n < EXPAND_BUF_LEN - 1; ++n)
      {
        if (str[n] == '=' || str[n] == NUL)
            break;
!       xp->xp_buf[n] = str[n];
      }
!     xp->xp_buf[n] = NUL;
!     return xp->xp_buf;
! #endif
  }
  
  /*
*** ../vim-9.0.0283/src/syntax.c        2022-08-26 21:58:26.089218709 +0100
--- src/syntax.c        2022-08-26 22:24:27.748975032 +0100
***************
*** 6420,6430 ****
   * expansion.
   */
      char_u *
! get_syntax_name(expand_T *xp UNUSED, int idx)
  {
- #define CBUFFER_LEN 256
-     static char_u     cbuffer[CBUFFER_LEN]; // TODO: better solution
- 
      switch (expand_what)
      {
        case EXP_SUBCMD:
--- 6420,6427 ----
   * expansion.
   */
      char_u *
! get_syntax_name(expand_T *xp, int idx)
  {
      switch (expand_what)
      {
        case EXP_SUBCMD:
***************
*** 6452,6460 ****
        {
            if (idx < curwin->w_s->b_syn_clusters.ga_len)
            {
!               vim_snprintf((char *)cbuffer, CBUFFER_LEN, "@%s",
                                         SYN_CLSTR(curwin->w_s)[idx].scl_name);
!               return cbuffer;
            }
            else
                return NULL;
--- 6449,6457 ----
        {
            if (idx < curwin->w_s->b_syn_clusters.ga_len)
            {
!               vim_snprintf((char *)xp->xp_buf, EXPAND_BUF_LEN, "@%s",
                                         SYN_CLSTR(curwin->w_s)[idx].scl_name);
!               return xp->xp_buf;
            }
            else
                return NULL;
*** ../vim-9.0.0283/src/cmdhist.c       2022-01-08 12:29:45.000000000 +0000
--- src/cmdhist.c       2022-08-26 22:26:36.128890793 +0100
***************
*** 99,113 ****
      char_u *
  get_history_arg(expand_T *xp UNUSED, int idx)
  {
!     static char_u compl[2] = { NUL, NUL };
!     char *short_names = ":=@>?/";
!     int short_names_count = (int)STRLEN(short_names);
!     int history_name_count = ARRAY_LENGTH(history_names) - 1;
  
      if (idx < short_names_count)
      {
!       compl[0] = (char_u)short_names[idx];
!       return compl;
      }
      if (idx < short_names_count + history_name_count)
        return (char_u *)history_names[idx - short_names_count];
--- 99,113 ----
      char_u *
  get_history_arg(expand_T *xp UNUSED, int idx)
  {
!     char    *short_names = ":=@>?/";
!     int           short_names_count = (int)STRLEN(short_names);
!     int           history_name_count = ARRAY_LENGTH(history_names) - 1;
  
      if (idx < short_names_count)
      {
!       xp->xp_buf[0] = (char_u)short_names[idx];
!       xp->xp_buf[1] = NUL;
!       return xp->xp_buf;
      }
      if (idx < short_names_count + history_name_count)
        return (char_u *)history_names[idx - short_names_count];
*** ../vim-9.0.0283/src/version.c       2022-08-26 21:58:26.089218709 +0100
--- src/version.c       2022-08-26 22:34:10.704564878 +0100
***************
*** 709,710 ****
--- 709,712 ----
  {   /* Add new patch number below this line */
+ /**/
+     284,
  /**/

-- 
No man may purchase alcohol without written consent from his wife.
                [real standing law in Pennsylvania, United States of America]

 /// 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/20220826213724.63F851C066C%40moolenaar.net.

Raspunde prin e-mail lui