vim-patch:8.1.53 use typval_T in the caller of call_vim_function

Problem:	unreliable types for complete function arguments
Solution:	fix argument type for functions w/ unreliable type conversion(Ozaki Kiichi)
vim/vim#2993
This commit is contained in:
cangscop
2019-07-27 03:13:29 +02:00
parent 0b4123668a
commit 0364e47ccb
4 changed files with 54 additions and 71 deletions

View File

@@ -200,7 +200,7 @@ static Array cmdline_block = ARRAY_DICT_INIT;
*/
typedef void *(*user_expand_func_T)(const char_u *,
int,
const char_u * const *,
typval_T *,
bool);
static histentry_T *(history[HIST_COUNT]) = {NULL, NULL, NULL, NULL, NULL};
@@ -5051,8 +5051,8 @@ static void * call_user_expand_func(user_expand_func_T user_expand_func,
expand_T *xp, int *num_file, char_u ***file)
{
char_u keep = 0;
char_u num[50];
char_u *args[3];
typval_T args[4];
char_u *pat = NULL;
int save_current_SID = current_SID;
void *ret;
struct cmdline_info save_ccline;
@@ -5067,10 +5067,14 @@ static void * call_user_expand_func(user_expand_func_T user_expand_func,
ccline.cmdbuff[ccline.cmdlen] = 0;
}
args[0] = vim_strnsave(xp->xp_pattern, xp->xp_pattern_len);
args[1] = xp->xp_line;
sprintf((char *)num, "%d", xp->xp_col);
args[2] = num;
pat = vim_strnsave(xp->xp_pattern, xp->xp_pattern_len);
args[0].v_type = VAR_STRING;
args[1].v_type = VAR_STRING;
args[2].v_type = VAR_NUMBER;
args[3].v_type = VAR_UNKNOWN;
args[0].vval.v_string = pat;
args[1].vval.v_string = xp->xp_line;
args[2].vval.v_number = xp->xp_col;
/* Save the cmdline, we don't know what the function may do. */
save_ccline = ccline;
@@ -5080,7 +5084,7 @@ static void * call_user_expand_func(user_expand_func_T user_expand_func,
ret = user_expand_func(xp->xp_arg,
3,
(const char_u * const *)args,
args,
false);
ccline = save_ccline;
@@ -5088,7 +5092,7 @@ static void * call_user_expand_func(user_expand_func_T user_expand_func,
if (ccline.cmdbuff != NULL)
ccline.cmdbuff[ccline.cmdlen] = keep;
xfree(args[0]);
xfree(pat);
return ret;
}