mirror of
https://github.com/vim/vim.git
synced 2025-11-16 23:24:03 -05:00
patch 8.1.1319: computing function length name in many places
Problem: Computing function length name in many places. Solution: compute name length in call_func().
This commit is contained in:
@@ -1650,7 +1650,7 @@ invoke_callback(channel_T *channel, char_u *callback, partial_T *partial,
|
|||||||
argv[0].v_type = VAR_CHANNEL;
|
argv[0].v_type = VAR_CHANNEL;
|
||||||
argv[0].vval.v_channel = channel;
|
argv[0].vval.v_channel = channel;
|
||||||
|
|
||||||
call_func(callback, (int)STRLEN(callback), &rettv, 2, argv, NULL,
|
call_func(callback, -1, &rettv, 2, argv, NULL,
|
||||||
0L, 0L, &dummy, TRUE, partial, NULL);
|
0L, 0L, &dummy, TRUE, partial, NULL);
|
||||||
clear_tv(&rettv);
|
clear_tv(&rettv);
|
||||||
channel_need_redraw = TRUE;
|
channel_need_redraw = TRUE;
|
||||||
@@ -2989,7 +2989,7 @@ channel_close(channel_T *channel, int invoke_close_cb)
|
|||||||
(char *)channel->ch_close_cb);
|
(char *)channel->ch_close_cb);
|
||||||
argv[0].v_type = VAR_CHANNEL;
|
argv[0].v_type = VAR_CHANNEL;
|
||||||
argv[0].vval.v_channel = channel;
|
argv[0].vval.v_channel = channel;
|
||||||
call_func(channel->ch_close_cb, (int)STRLEN(channel->ch_close_cb),
|
call_func(channel->ch_close_cb, -1,
|
||||||
&rettv, 1, argv, NULL, 0L, 0L, &dummy, TRUE,
|
&rettv, 1, argv, NULL, 0L, 0L, &dummy, TRUE,
|
||||||
channel->ch_close_partial, NULL);
|
channel->ch_close_partial, NULL);
|
||||||
clear_tv(&rettv);
|
clear_tv(&rettv);
|
||||||
@@ -5478,7 +5478,7 @@ job_cleanup(job_T *job)
|
|||||||
argv[0].vval.v_job = job;
|
argv[0].vval.v_job = job;
|
||||||
argv[1].v_type = VAR_NUMBER;
|
argv[1].v_type = VAR_NUMBER;
|
||||||
argv[1].vval.v_number = job->jv_exitval;
|
argv[1].vval.v_number = job->jv_exitval;
|
||||||
call_func(job->jv_exit_cb, (int)STRLEN(job->jv_exit_cb),
|
call_func(job->jv_exit_cb, -1,
|
||||||
&rettv, 2, argv, NULL, 0L, 0L, &dummy, TRUE,
|
&rettv, 2, argv, NULL, 0L, 0L, &dummy, TRUE,
|
||||||
job->jv_exit_partial, NULL);
|
job->jv_exit_partial, NULL);
|
||||||
clear_tv(&rettv);
|
clear_tv(&rettv);
|
||||||
@@ -6069,8 +6069,7 @@ invoke_prompt_callback(void)
|
|||||||
argv[0].vval.v_string = vim_strsave(text);
|
argv[0].vval.v_string = vim_strsave(text);
|
||||||
argv[1].v_type = VAR_UNKNOWN;
|
argv[1].v_type = VAR_UNKNOWN;
|
||||||
|
|
||||||
call_func(curbuf->b_prompt_callback,
|
call_func(curbuf->b_prompt_callback, -1,
|
||||||
(int)STRLEN(curbuf->b_prompt_callback),
|
|
||||||
&rettv, 1, argv, NULL, 0L, 0L, &dummy, TRUE,
|
&rettv, 1, argv, NULL, 0L, 0L, &dummy, TRUE,
|
||||||
curbuf->b_prompt_partial, NULL);
|
curbuf->b_prompt_partial, NULL);
|
||||||
clear_tv(&argv[0]);
|
clear_tv(&argv[0]);
|
||||||
@@ -6093,8 +6092,7 @@ invoke_prompt_interrupt(void)
|
|||||||
argv[0].v_type = VAR_UNKNOWN;
|
argv[0].v_type = VAR_UNKNOWN;
|
||||||
|
|
||||||
got_int = FALSE; // don't skip executing commands
|
got_int = FALSE; // don't skip executing commands
|
||||||
call_func(curbuf->b_prompt_interrupt,
|
call_func(curbuf->b_prompt_interrupt, -1,
|
||||||
(int)STRLEN(curbuf->b_prompt_interrupt),
|
|
||||||
&rettv, 0, argv, NULL, 0L, 0L, &dummy, TRUE,
|
&rettv, 0, argv, NULL, 0L, 0L, &dummy, TRUE,
|
||||||
curbuf->b_prompt_int_partial, NULL);
|
curbuf->b_prompt_int_partial, NULL);
|
||||||
clear_tv(&rettv);
|
clear_tv(&rettv);
|
||||||
|
|||||||
@@ -765,7 +765,7 @@ eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T *rettv)
|
|||||||
s = expr->vval.v_string;
|
s = expr->vval.v_string;
|
||||||
if (s == NULL || *s == NUL)
|
if (s == NULL || *s == NUL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
if (call_func(s, (int)STRLEN(s), rettv, argc, argv, NULL,
|
if (call_func(s, -1, rettv, argc, argv, NULL,
|
||||||
0L, 0L, &dummy, TRUE, NULL, NULL) == FAIL)
|
0L, 0L, &dummy, TRUE, NULL, NULL) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@@ -776,7 +776,7 @@ eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T *rettv)
|
|||||||
s = partial_name(partial);
|
s = partial_name(partial);
|
||||||
if (s == NULL || *s == NUL)
|
if (s == NULL || *s == NUL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
if (call_func(s, (int)STRLEN(s), rettv, argc, argv, NULL,
|
if (call_func(s, -1, rettv, argc, argv, NULL,
|
||||||
0L, 0L, &dummy, TRUE, partial, NULL) == FAIL)
|
0L, 0L, &dummy, TRUE, partial, NULL) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@@ -1088,7 +1088,7 @@ call_vim_function(
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
rettv->v_type = VAR_UNKNOWN; /* clear_tv() uses this */
|
rettv->v_type = VAR_UNKNOWN; /* clear_tv() uses this */
|
||||||
ret = call_func(func, (int)STRLEN(func), rettv, argc, argv, NULL,
|
ret = call_func(func, -1, rettv, argc, argv, NULL,
|
||||||
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
|
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
|
||||||
&doesrange, TRUE, NULL, NULL);
|
&doesrange, TRUE, NULL, NULL);
|
||||||
if (ret == FAIL)
|
if (ret == FAIL)
|
||||||
@@ -7109,7 +7109,7 @@ handle_subscript(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
s = (char_u *)"";
|
s = (char_u *)"";
|
||||||
ret = get_func_tv(s, (int)STRLEN(s), rettv, arg,
|
ret = get_func_tv(s, -1, rettv, arg,
|
||||||
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
|
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
|
||||||
&len, evaluate, pt, selfdict);
|
&len, evaluate, pt, selfdict);
|
||||||
|
|
||||||
|
|||||||
@@ -767,6 +767,8 @@ static struct fst
|
|||||||
{"line2byte", 1, 1, f_line2byte},
|
{"line2byte", 1, 1, f_line2byte},
|
||||||
{"lispindent", 1, 1, f_lispindent},
|
{"lispindent", 1, 1, f_lispindent},
|
||||||
{"list2str", 1, 2, f_list2str},
|
{"list2str", 1, 2, f_list2str},
|
||||||
|
{"listener_add", 1, 2, f_listener_add},
|
||||||
|
{"listener_remove", 1, 1, f_listener_remove},
|
||||||
{"localtime", 0, 0, f_localtime},
|
{"localtime", 0, 0, f_localtime},
|
||||||
#ifdef FEAT_FLOAT
|
#ifdef FEAT_FLOAT
|
||||||
{"log", 1, 1, f_log},
|
{"log", 1, 1, f_log},
|
||||||
@@ -9746,9 +9748,9 @@ f_readfile(typval_T *argvars, typval_T *rettv)
|
|||||||
|
|
||||||
if (failed)
|
if (failed)
|
||||||
{
|
{
|
||||||
|
// an empty list is returned on error
|
||||||
list_free(rettv->vval.v_list);
|
list_free(rettv->vval.v_list);
|
||||||
/* readfile doc says an empty list is returned on error */
|
rettv_list_alloc(rettv);
|
||||||
rettv->vval.v_list = list_alloc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vim_free(prev);
|
vim_free(prev);
|
||||||
@@ -12644,8 +12646,7 @@ item_compare2(const void *s1, const void *s2)
|
|||||||
copy_tv(&si2->item->li_tv, &argv[1]);
|
copy_tv(&si2->item->li_tv, &argv[1]);
|
||||||
|
|
||||||
rettv.v_type = VAR_UNKNOWN; /* clear_tv() uses this */
|
rettv.v_type = VAR_UNKNOWN; /* clear_tv() uses this */
|
||||||
res = call_func(func_name, (int)STRLEN(func_name),
|
res = call_func(func_name, -1, &rettv, 2, argv, NULL, 0L, 0L, &dummy, TRUE,
|
||||||
&rettv, 2, argv, NULL, 0L, 0L, &dummy, TRUE,
|
|
||||||
partial, sortinfo->item_compare_selfdict);
|
partial, sortinfo->item_compare_selfdict);
|
||||||
clear_tv(&argv[0]);
|
clear_tv(&argv[0]);
|
||||||
clear_tv(&argv[1]);
|
clear_tv(&argv[1]);
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ timer_callback(timer_T *timer)
|
|||||||
argv[0].vval.v_number = (varnumber_T)timer->tr_id;
|
argv[0].vval.v_number = (varnumber_T)timer->tr_id;
|
||||||
argv[1].v_type = VAR_UNKNOWN;
|
argv[1].v_type = VAR_UNKNOWN;
|
||||||
|
|
||||||
call_func(timer->tr_callback, (int)STRLEN(timer->tr_callback),
|
call_func(timer->tr_callback, -1,
|
||||||
&rettv, 1, argv, NULL, 0L, 0L, &dummy, TRUE,
|
&rettv, 1, argv, NULL, 0L, 0L, &dummy, TRUE,
|
||||||
timer->tr_partial, NULL);
|
timer->tr_partial, NULL);
|
||||||
clear_tv(&rettv);
|
clear_tv(&rettv);
|
||||||
|
|||||||
@@ -7423,7 +7423,7 @@ vim_regsub_both(
|
|||||||
if (expr->v_type == VAR_FUNC)
|
if (expr->v_type == VAR_FUNC)
|
||||||
{
|
{
|
||||||
s = expr->vval.v_string;
|
s = expr->vval.v_string;
|
||||||
call_func(s, (int)STRLEN(s), &rettv,
|
call_func(s, -1, &rettv,
|
||||||
1, argv, fill_submatch_list,
|
1, argv, fill_submatch_list,
|
||||||
0L, 0L, &dummy, TRUE, NULL, NULL);
|
0L, 0L, &dummy, TRUE, NULL, NULL);
|
||||||
}
|
}
|
||||||
@@ -7432,7 +7432,7 @@ vim_regsub_both(
|
|||||||
partial_T *partial = expr->vval.v_partial;
|
partial_T *partial = expr->vval.v_partial;
|
||||||
|
|
||||||
s = partial_name(partial);
|
s = partial_name(partial);
|
||||||
call_func(s, (int)STRLEN(s), &rettv,
|
call_func(s, -1, &rettv,
|
||||||
1, argv, fill_submatch_list,
|
1, argv, fill_submatch_list,
|
||||||
0L, 0L, &dummy, TRUE, partial, NULL);
|
0L, 0L, &dummy, TRUE, partial, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3779,7 +3779,7 @@ handle_call_command(term_T *term, channel_T *channel, listitem_T *item)
|
|||||||
argvars[0].v_type = VAR_NUMBER;
|
argvars[0].v_type = VAR_NUMBER;
|
||||||
argvars[0].vval.v_number = term->tl_buffer->b_fnum;
|
argvars[0].vval.v_number = term->tl_buffer->b_fnum;
|
||||||
argvars[1] = item->li_next->li_tv;
|
argvars[1] = item->li_next->li_tv;
|
||||||
if (call_func(func, (int)STRLEN(func), &rettv,
|
if (call_func(func, -1, &rettv,
|
||||||
2, argvars, /* argv_func */ NULL,
|
2, argvars, /* argv_func */ NULL,
|
||||||
/* firstline */ 1, /* lastline */ 1,
|
/* firstline */ 1, /* lastline */ 1,
|
||||||
&doesrange, /* evaluate */ TRUE,
|
&doesrange, /* evaluate */ TRUE,
|
||||||
|
|||||||
@@ -432,16 +432,16 @@ emsg_funcname(char *ermsg, char_u *name)
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_func_tv(
|
get_func_tv(
|
||||||
char_u *name, /* name of the function */
|
char_u *name, // name of the function
|
||||||
int len, /* length of "name" */
|
int len, // length of "name" or -1 to use strlen()
|
||||||
typval_T *rettv,
|
typval_T *rettv,
|
||||||
char_u **arg, /* argument, pointing to the '(' */
|
char_u **arg, // argument, pointing to the '('
|
||||||
linenr_T firstline, /* first line of range */
|
linenr_T firstline, // first line of range
|
||||||
linenr_T lastline, /* last line of range */
|
linenr_T lastline, // last line of range
|
||||||
int *doesrange, /* return: function handled range */
|
int *doesrange, // return: function handled range
|
||||||
int evaluate,
|
int evaluate,
|
||||||
partial_T *partial, /* for extra arguments */
|
partial_T *partial, // for extra arguments
|
||||||
dict_T *selfdict) /* Dictionary for "self" */
|
dict_T *selfdict) // Dictionary for "self"
|
||||||
{
|
{
|
||||||
char_u *argp;
|
char_u *argp;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
@@ -1435,7 +1435,7 @@ func_call(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
r = call_func(name, (int)STRLEN(name), rettv, argc, argv, NULL,
|
r = call_func(name, -1, rettv, argc, argv, NULL,
|
||||||
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
|
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
|
||||||
&dummy, TRUE, partial, selfdict);
|
&dummy, TRUE, partial, selfdict);
|
||||||
|
|
||||||
@@ -1458,20 +1458,20 @@ func_call(
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
call_func(
|
call_func(
|
||||||
char_u *funcname, /* name of the function */
|
char_u *funcname, // name of the function
|
||||||
int len, /* length of "name" */
|
int len, // length of "name" or -1 to use strlen()
|
||||||
typval_T *rettv, /* return value goes here */
|
typval_T *rettv, // return value goes here
|
||||||
int argcount_in, /* number of "argvars" */
|
int argcount_in, // number of "argvars"
|
||||||
typval_T *argvars_in, /* vars for arguments, must have "argcount"
|
typval_T *argvars_in, // vars for arguments, must have "argcount"
|
||||||
PLUS ONE elements! */
|
// PLUS ONE elements!
|
||||||
int (* argv_func)(int, typval_T *, int),
|
int (* argv_func)(int, typval_T *, int),
|
||||||
/* function to fill in argvars */
|
// function to fill in argvars
|
||||||
linenr_T firstline, /* first line of range */
|
linenr_T firstline, // first line of range
|
||||||
linenr_T lastline, /* last line of range */
|
linenr_T lastline, // last line of range
|
||||||
int *doesrange, /* return: function handled range */
|
int *doesrange, // return: function handled range
|
||||||
int evaluate,
|
int evaluate,
|
||||||
partial_T *partial, /* optional, can be NULL */
|
partial_T *partial, // optional, can be NULL
|
||||||
dict_T *selfdict_in) /* Dictionary for "self" */
|
dict_T *selfdict_in) // Dictionary for "self"
|
||||||
{
|
{
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
int error = ERROR_NONE;
|
int error = ERROR_NONE;
|
||||||
@@ -1487,9 +1487,9 @@ call_func(
|
|||||||
typval_T argv[MAX_FUNC_ARGS + 1]; /* used when "partial" is not NULL */
|
typval_T argv[MAX_FUNC_ARGS + 1]; /* used when "partial" is not NULL */
|
||||||
int argv_clear = 0;
|
int argv_clear = 0;
|
||||||
|
|
||||||
/* Make a copy of the name, if it comes from a funcref variable it could
|
// Make a copy of the name, if it comes from a funcref variable it could
|
||||||
* be changed or deleted in the called function. */
|
// be changed or deleted in the called function.
|
||||||
name = vim_strnsave(funcname, len);
|
name = len > 0 ? vim_strnsave(funcname, len) : vim_strsave(funcname);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -3285,7 +3285,7 @@ ex_call(exarg_T *eap)
|
|||||||
curwin->w_cursor.coladd = 0;
|
curwin->w_cursor.coladd = 0;
|
||||||
}
|
}
|
||||||
arg = startarg;
|
arg = startarg;
|
||||||
if (get_func_tv(name, (int)STRLEN(name), &rettv, &arg,
|
if (get_func_tv(name, -1, &rettv, &arg,
|
||||||
eap->line1, eap->line2, &doesrange,
|
eap->line1, eap->line2, &doesrange,
|
||||||
!eap->skip, partial, fudi.fd_dict) == FAIL)
|
!eap->skip, partial, fudi.fd_dict) == FAIL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -767,6 +767,10 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1319,
|
||||||
|
/**/
|
||||||
|
1318,
|
||||||
/**/
|
/**/
|
||||||
1317,
|
1317,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user