mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 15:28:17 +00:00
eval.c: rename capture() to execute() (#5132)
This commit is contained in:
@@ -6727,7 +6727,6 @@ static struct fst {
|
||||
{ "byteidx", 2, 2, f_byteidx },
|
||||
{ "byteidxcomp", 2, 2, f_byteidxcomp },
|
||||
{ "call", 2, 3, f_call },
|
||||
{ "capture", 1, 1, f_capture },
|
||||
{ "ceil", 1, 1, f_ceil },
|
||||
{ "changenr", 0, 0, f_changenr },
|
||||
{ "char2nr", 1, 2, f_char2nr },
|
||||
@@ -6756,6 +6755,7 @@ static struct fst {
|
||||
{ "eval", 1, 1, f_eval },
|
||||
{ "eventhandler", 0, 0, f_eventhandler },
|
||||
{ "executable", 1, 1, f_executable },
|
||||
{ "execute", 1, 1, f_execute },
|
||||
{ "exepath", 1, 1, f_exepath },
|
||||
{ "exists", 1, 1, f_exists },
|
||||
{ "exp", 1, 1, f_exp },
|
||||
@@ -8153,38 +8153,6 @@ static void f_call(typval_T *argvars, typval_T *rettv)
|
||||
(void)func_call(func, &argvars[1], selfdict, rettv);
|
||||
}
|
||||
|
||||
// "capture(command)" function
|
||||
static void f_capture(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
int save_msg_silent = msg_silent;
|
||||
garray_T *save_capture_ga = capture_ga;
|
||||
|
||||
if (check_secure()) {
|
||||
return;
|
||||
}
|
||||
|
||||
garray_T capture_local;
|
||||
capture_ga = &capture_local;
|
||||
ga_init(capture_ga, (int)sizeof(char), 80);
|
||||
|
||||
msg_silent++;
|
||||
if (argvars[0].v_type != VAR_LIST) {
|
||||
do_cmdline_cmd((char *)get_tv_string(&argvars[0]));
|
||||
} else if (argvars[0].vval.v_list != NULL) {
|
||||
for (listitem_T *li = argvars[0].vval.v_list->lv_first;
|
||||
li != NULL; li = li->li_next) {
|
||||
do_cmdline_cmd((char *)get_tv_string(&li->li_tv));
|
||||
}
|
||||
}
|
||||
msg_silent = save_msg_silent;
|
||||
|
||||
ga_append(capture_ga, NUL);
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = capture_ga->ga_data;
|
||||
|
||||
capture_ga = save_capture_ga;
|
||||
}
|
||||
|
||||
/*
|
||||
* "ceil({float})" function
|
||||
*/
|
||||
@@ -8869,6 +8837,38 @@ static void f_executable(typval_T *argvars, typval_T *rettv)
|
||||
|| (gettail_dir(name) != name && os_can_exe(name, NULL, false));
|
||||
}
|
||||
|
||||
// "execute(command)" function
|
||||
static void f_execute(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
int save_msg_silent = msg_silent;
|
||||
garray_T *save_capture_ga = capture_ga;
|
||||
|
||||
if (check_secure()) {
|
||||
return;
|
||||
}
|
||||
|
||||
garray_T capture_local;
|
||||
capture_ga = &capture_local;
|
||||
ga_init(capture_ga, (int)sizeof(char), 80);
|
||||
|
||||
msg_silent++;
|
||||
if (argvars[0].v_type != VAR_LIST) {
|
||||
do_cmdline_cmd((char *)get_tv_string(&argvars[0]));
|
||||
} else if (argvars[0].vval.v_list != NULL) {
|
||||
for (listitem_T *li = argvars[0].vval.v_list->lv_first;
|
||||
li != NULL; li = li->li_next) {
|
||||
do_cmdline_cmd((char *)get_tv_string(&li->li_tv));
|
||||
}
|
||||
}
|
||||
msg_silent = save_msg_silent;
|
||||
|
||||
ga_append(capture_ga, NUL);
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = capture_ga->ga_data;
|
||||
|
||||
capture_ga = save_capture_ga;
|
||||
}
|
||||
|
||||
/// "exepath()" function
|
||||
static void f_exepath(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
|
Reference in New Issue
Block a user