Mercurial > vim
comparison src/edit.c @ 14071:c1fcfafa8d1a v8.1.0053
patch 8.1.0053: first argument of 'completefunc' has inconsistent type
commit https://github.com/vim/vim/commit/ffa9684150f5441e84d492e7184ef73587bd6c6c
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jun 12 22:05:14 2018 +0200
patch 8.1.0053: first argument of 'completefunc' has inconsistent type
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 12 Jun 2018 22:15:06 +0200 |
parents | e182079c3374 |
children | b5e43a048878 |
comparison
equal
deleted
inserted
replaced
14070:e5b1d05b7b77 | 14071:c1fcfafa8d1a |
---|---|
4199 int type, /* CTRL_X_OMNI or CTRL_X_FUNCTION */ | 4199 int type, /* CTRL_X_OMNI or CTRL_X_FUNCTION */ |
4200 char_u *base) | 4200 char_u *base) |
4201 { | 4201 { |
4202 list_T *matchlist = NULL; | 4202 list_T *matchlist = NULL; |
4203 dict_T *matchdict = NULL; | 4203 dict_T *matchdict = NULL; |
4204 char_u *args[2]; | 4204 typval_T args[3]; |
4205 char_u *funcname; | 4205 char_u *funcname; |
4206 pos_T pos; | 4206 pos_T pos; |
4207 win_T *curwin_save; | 4207 win_T *curwin_save; |
4208 buf_T *curbuf_save; | 4208 buf_T *curbuf_save; |
4209 typval_T rettv; | 4209 typval_T rettv; |
4211 funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu; | 4211 funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu; |
4212 if (*funcname == NUL) | 4212 if (*funcname == NUL) |
4213 return; | 4213 return; |
4214 | 4214 |
4215 /* Call 'completefunc' to obtain the list of matches. */ | 4215 /* Call 'completefunc' to obtain the list of matches. */ |
4216 args[0] = (char_u *)"0"; | 4216 args[0].v_type = VAR_NUMBER; |
4217 args[1] = base; | 4217 args[0].vval.v_number = 0; |
4218 args[1].v_type = VAR_STRING; | |
4219 args[1].vval.v_string = base != NULL ? base : (char_u *)""; | |
4220 args[2].v_type = VAR_UNKNOWN; | |
4218 | 4221 |
4219 pos = curwin->w_cursor; | 4222 pos = curwin->w_cursor; |
4220 curwin_save = curwin; | 4223 curwin_save = curwin; |
4221 curbuf_save = curbuf; | 4224 curbuf_save = curbuf; |
4222 | 4225 |
4223 /* Call a function, which returns a list or dict. */ | 4226 /* Call a function, which returns a list or dict. */ |
4224 if (call_vim_function(funcname, 2, args, FALSE, FALSE, &rettv) == OK) | 4227 if (call_vim_function(funcname, 2, args, &rettv, FALSE) == OK) |
4225 { | 4228 { |
4226 switch (rettv.v_type) | 4229 switch (rettv.v_type) |
4227 { | 4230 { |
4228 case VAR_LIST: | 4231 case VAR_LIST: |
4229 matchlist = rettv.vval.v_list; | 4232 matchlist = rettv.vval.v_list; |
5526 #ifdef FEAT_COMPL_FUNC | 5529 #ifdef FEAT_COMPL_FUNC |
5527 /* | 5530 /* |
5528 * Call user defined function 'completefunc' with "a:findstart" | 5531 * Call user defined function 'completefunc' with "a:findstart" |
5529 * set to 1 to obtain the length of text to use for completion. | 5532 * set to 1 to obtain the length of text to use for completion. |
5530 */ | 5533 */ |
5531 char_u *args[2]; | 5534 typval_T args[3]; |
5532 int col; | 5535 int col; |
5533 char_u *funcname; | 5536 char_u *funcname; |
5534 pos_T pos; | 5537 pos_T pos; |
5535 win_T *curwin_save; | 5538 win_T *curwin_save; |
5536 buf_T *curbuf_save; | 5539 buf_T *curbuf_save; |
5546 /* restore did_ai, so that adding comment leader works */ | 5549 /* restore did_ai, so that adding comment leader works */ |
5547 did_ai = save_did_ai; | 5550 did_ai = save_did_ai; |
5548 return FAIL; | 5551 return FAIL; |
5549 } | 5552 } |
5550 | 5553 |
5551 args[0] = (char_u *)"1"; | 5554 args[0].v_type = VAR_NUMBER; |
5552 args[1] = NULL; | 5555 args[0].vval.v_number = 1; |
5556 args[1].v_type = VAR_STRING; | |
5557 args[1].vval.v_string = (char_u *)""; | |
5558 args[2].v_type = VAR_UNKNOWN; | |
5553 pos = curwin->w_cursor; | 5559 pos = curwin->w_cursor; |
5554 curwin_save = curwin; | 5560 curwin_save = curwin; |
5555 curbuf_save = curbuf; | 5561 curbuf_save = curbuf; |
5556 col = call_func_retnr(funcname, 2, args, FALSE); | 5562 col = call_func_retnr(funcname, 2, args, FALSE); |
5557 if (curwin_save != curwin || curbuf_save != curbuf) | 5563 if (curwin_save != curwin || curbuf_save != curbuf) |