diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-06-12 22:05:14 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-06-12 22:05:14 +0200 |
commit | ffa9684150f5441e84d492e7184ef73587bd6c6c (patch) | |
tree | e73aa4b5e0d37ef4d113fcb07f9e1efa5c01d133 /src/ex_getln.c | |
parent | 83f4cbd973731872b633d6ba0caf850fb708d70c (diff) | |
download | vim-git-ffa9684150f5441e84d492e7184ef73587bd6c6c.tar.gz |
patch 8.1.0053: first argument of 'completefunc' has inconsistent typev8.1.0053
Problem: The first argument given to 'completefunc' can be Number or
String, depending on the value.
Solution: Avoid guessing the type of an argument, use typval_T in the
callers of call_vim_function(). (Ozaki Kiichi, closes #2993)
Diffstat (limited to 'src/ex_getln.c')
-rw-r--r-- | src/ex_getln.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c index c4b9acd75..063900a38 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -5266,7 +5266,7 @@ expand_shellcmd( # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) -static void * call_user_expand_func(void *(*user_expand_func)(char_u *, int, char_u **, int), expand_T *xp, int *num_file, char_u ***file); +static void * call_user_expand_func(void *(*user_expand_func)(char_u *, int, typval_T *, int), expand_T *xp, int *num_file, char_u ***file); /* * Call "user_expand_func()" to invoke a user defined Vim script function and @@ -5274,15 +5274,15 @@ static void * call_user_expand_func(void *(*user_expand_func)(char_u *, int, cha */ static void * call_user_expand_func( - void *(*user_expand_func)(char_u *, int, char_u **, int), + void *(*user_expand_func)(char_u *, int, typval_T *, int), expand_T *xp, int *num_file, char_u ***file) { int keep = 0; - char_u num[50]; - char_u *args[3]; + typval_T args[4]; int save_current_SID = current_SID; + char_u *pat = NULL; void *ret; struct cmdline_info save_ccline; @@ -5297,10 +5297,15 @@ call_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[0].vval.v_string = pat; + args[1].v_type = VAR_STRING; + args[1].vval.v_string = xp->xp_line; + args[2].v_type = VAR_NUMBER; + args[2].vval.v_number = xp->xp_col; + args[3].v_type = VAR_UNKNOWN; /* Save the cmdline, we don't know what the function may do. */ save_ccline = ccline; @@ -5315,7 +5320,7 @@ call_user_expand_func( if (ccline.cmdbuff != NULL) ccline.cmdbuff[ccline.cmdlen] = keep; - vim_free(args[0]); + vim_free(pat); return ret; } |