Problem: Using static buffer for multiple completion functions.
Solution: Use one buffer in expand_T.
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];
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;
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
}
/*
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;
/*
* 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:
{
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;
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 284,
/**/
283,
/**/