diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-08-26 22:36:41 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-08-26 22:36:41 +0100 |
commit | 5ff595d9db2d9a33aa10cc9f18f256826226862f (patch) | |
tree | 1abcab2fb32d1084c7d0667490679d5c5941a04b /src | |
parent | af9a6002e0761012cb7108cbfa179a880d3cb49b (diff) |
patch 9.0.0284: using static buffer for multiple completion functionsv9.0.0284
Problem: Using static buffer for multiple completion functions.
Solution: Use one buffer in expand_T.
Diffstat (limited to 'src')
-rw-r--r-- | src/cmdhist.c | 12 | ||||
-rw-r--r-- | src/misc1.c | 20 | ||||
-rw-r--r-- | src/structs.h | 2 | ||||
-rw-r--r-- | src/syntax.c | 9 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 21 insertions, 24 deletions
diff --git a/src/cmdhist.c b/src/cmdhist.c index 6256fd91b0..0619e82775 100644 --- a/src/cmdhist.c +++ b/src/cmdhist.c @@ -99,15 +99,15 @@ static char *(history_names[]) = 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; + 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; + 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]; diff --git a/src/misc1.c b/src/misc1.c index 6383922521..e8216a08ae 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -2016,18 +2016,14 @@ get_env_name( expand_T *xp UNUSED, int idx) { -# if defined(AMIGA) - /* - * No environ[] on the Amiga. - */ +#if defined(AMIGA) + // No environ[] on the Amiga. return NULL; -# else +#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; @@ -2035,15 +2031,15 @@ get_env_name( if (str == NULL) return NULL; - for (n = 0; n < ENVNAMELEN - 1; ++n) + for (n = 0; n < EXPAND_BUF_LEN - 1; ++n) { if (str[n] == '=' || str[n] == NUL) break; - name[n] = str[n]; + xp->xp_buf[n] = str[n]; } - name[n] = NUL; - return name; -# endif + xp->xp_buf[n] = NUL; + return xp->xp_buf; +#endif } /* diff --git a/src/structs.h b/src/structs.h index 28cfa00ffc..fc44d23a64 100644 --- a/src/structs.h +++ b/src/structs.h @@ -598,6 +598,8 @@ typedef struct expand 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; /* diff --git a/src/syntax.c b/src/syntax.c index 1fc205414e..c68e001be9 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -6420,11 +6420,8 @@ set_context_in_syntax_cmd(expand_T *xp, char_u *arg) * expansion. */ char_u * -get_syntax_name(expand_T *xp UNUSED, int idx) +get_syntax_name(expand_T *xp, int idx) { -#define CBUFFER_LEN 256 - static char_u cbuffer[CBUFFER_LEN]; // TODO: better solution - switch (expand_what) { case EXP_SUBCMD: @@ -6452,9 +6449,9 @@ get_syntax_name(expand_T *xp UNUSED, int idx) { if (idx < curwin->w_s->b_syn_clusters.ga_len) { - vim_snprintf((char *)cbuffer, CBUFFER_LEN, "@%s", + vim_snprintf((char *)xp->xp_buf, EXPAND_BUF_LEN, "@%s", SYN_CLSTR(curwin->w_s)[idx].scl_name); - return cbuffer; + return xp->xp_buf; } else return NULL; diff --git a/src/version.c b/src/version.c index c3fbe5f591..2e48687447 100644 --- a/src/version.c +++ b/src/version.c @@ -708,6 +708,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 284, +/**/ 283, /**/ 282, |