mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
commit
d4b931deac
@ -9748,60 +9748,54 @@ static void f_function(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dict_idx > 0 || arg_idx > 0 || arg_pt != NULL) {
|
if (dict_idx > 0 || arg_idx > 0 || arg_pt != NULL) {
|
||||||
partial_T *pt = (partial_T *)xcalloc(1, sizeof(partial_T));
|
partial_T *const pt = xcalloc(1, sizeof(*pt));
|
||||||
|
|
||||||
// result is a VAR_PARTIAL
|
// result is a VAR_PARTIAL
|
||||||
if (pt != NULL) {
|
if (arg_idx > 0 || (arg_pt != NULL && arg_pt->pt_argc > 0)) {
|
||||||
if (arg_idx > 0 || (arg_pt != NULL && arg_pt->pt_argc > 0)) {
|
const int arg_len = (arg_pt == NULL ? 0 : arg_pt->pt_argc);
|
||||||
listitem_T *li;
|
const int lv_len = (list == NULL ? 0 : list->lv_len);
|
||||||
|
|
||||||
|
pt->pt_argc = arg_len + lv_len;
|
||||||
|
pt->pt_argv = xmalloc(sizeof(pt->pt_argv[0]) * pt->pt_argc);
|
||||||
|
if (pt->pt_argv == NULL) {
|
||||||
|
xfree(pt);
|
||||||
|
xfree(name);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int arg_len = 0;
|
for (; i < arg_len; i++) {
|
||||||
int lv_len = 0;
|
copy_tv(&arg_pt->pt_argv[i], &pt->pt_argv[i]);
|
||||||
|
|
||||||
if (arg_pt != NULL) {
|
|
||||||
arg_len = arg_pt->pt_argc;
|
|
||||||
}
|
}
|
||||||
if (list != NULL) {
|
if (lv_len > 0) {
|
||||||
lv_len = list->lv_len;
|
for (listitem_T *li = list->lv_first;
|
||||||
}
|
li != NULL;
|
||||||
pt->pt_argc = arg_len + lv_len;
|
li = li->li_next) {
|
||||||
pt->pt_argv = (typval_T *)xmalloc(sizeof(typval_T) * pt->pt_argc);
|
copy_tv(&li->li_tv, &pt->pt_argv[i++]);
|
||||||
if (pt->pt_argv == NULL) {
|
|
||||||
xfree(pt);
|
|
||||||
xfree(name);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < arg_len; i++) {
|
|
||||||
copy_tv(&arg_pt->pt_argv[i], &pt->pt_argv[i]);
|
|
||||||
}
|
|
||||||
if (lv_len > 0) {
|
|
||||||
for (li = list->lv_first; li != NULL; li = li->li_next) {
|
|
||||||
copy_tv(&li->li_tv, &pt->pt_argv[i++]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For "function(dict.func, [], dict)" and "func" is a partial
|
|
||||||
// use "dict". That is backwards compatible.
|
|
||||||
if (dict_idx > 0) {
|
|
||||||
// The dict is bound explicitly, pt_auto is false
|
|
||||||
pt->pt_dict = argvars[dict_idx].vval.v_dict;
|
|
||||||
(pt->pt_dict->dv_refcount)++;
|
|
||||||
} else if (arg_pt != NULL) {
|
|
||||||
// If the dict was bound automatically the result is also
|
|
||||||
// bound automatically.
|
|
||||||
pt->pt_dict = arg_pt->pt_dict;
|
|
||||||
pt->pt_auto = arg_pt->pt_auto;
|
|
||||||
if (pt->pt_dict != NULL) {
|
|
||||||
(pt->pt_dict->dv_refcount)++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pt->pt_refcount = 1;
|
|
||||||
pt->pt_name = name;
|
|
||||||
func_ref(pt->pt_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For "function(dict.func, [], dict)" and "func" is a partial
|
||||||
|
// use "dict". That is backwards compatible.
|
||||||
|
if (dict_idx > 0) {
|
||||||
|
// The dict is bound explicitly, pt_auto is false
|
||||||
|
pt->pt_dict = argvars[dict_idx].vval.v_dict;
|
||||||
|
(pt->pt_dict->dv_refcount)++;
|
||||||
|
} else if (arg_pt != NULL) {
|
||||||
|
// If the dict was bound automatically the result is also
|
||||||
|
// bound automatically.
|
||||||
|
pt->pt_dict = arg_pt->pt_dict;
|
||||||
|
pt->pt_auto = arg_pt->pt_auto;
|
||||||
|
if (pt->pt_dict != NULL) {
|
||||||
|
(pt->pt_dict->dv_refcount)++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pt->pt_refcount = 1;
|
||||||
|
pt->pt_name = name;
|
||||||
|
func_ref(pt->pt_name);
|
||||||
|
|
||||||
rettv->v_type = VAR_PARTIAL;
|
rettv->v_type = VAR_PARTIAL;
|
||||||
rettv->vval.v_partial = pt;
|
rettv->vval.v_partial = pt;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1408,32 +1408,30 @@ char_u *make_filter_cmd(char_u *cmd, char_u *itmp, char_u *otmp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (itmp != NULL) {
|
if (itmp != NULL) {
|
||||||
strncat(buf, " < ", len);
|
strncat(buf, " < ", len - 1);
|
||||||
strncat(buf, (char *) itmp, len);
|
strncat(buf, (const char *)itmp, len - 1);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// For shells that don't understand braces around commands, at least allow
|
// For shells that don't understand braces around commands, at least allow
|
||||||
// the use of commands in a pipe.
|
// the use of commands in a pipe.
|
||||||
strncpy(buf, cmd, len);
|
strncpy(buf, cmd, len);
|
||||||
if (itmp != NULL) {
|
if (itmp != NULL) {
|
||||||
char_u *p;
|
|
||||||
|
|
||||||
// If there is a pipe, we have to put the '<' in front of it.
|
// If there is a pipe, we have to put the '<' in front of it.
|
||||||
// Don't do this when 'shellquote' is not empty, otherwise the
|
// Don't do this when 'shellquote' is not empty, otherwise the
|
||||||
// redirection would be inside the quotes.
|
// redirection would be inside the quotes.
|
||||||
if (*p_shq == NUL) {
|
if (*p_shq == NUL) {
|
||||||
p = strchr(buf, '|');
|
char *const p = strchr(buf, '|');
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
*p = NUL;
|
*p = NUL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strncat(buf, " < ", len);
|
strncat(buf, " < ", len);
|
||||||
strncat(buf, (char *) itmp, len);
|
strncat(buf, (const char *)itmp, len);
|
||||||
if (*p_shq == NUL) {
|
if (*p_shq == NUL) {
|
||||||
p = strchr(cmd, '|');
|
const char *const p = strchr((const char *)cmd, '|');
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
strncat(buf, " ", len); // Insert a space before the '|' for DOS
|
strncat(buf, " ", len - 1); // Insert a space before the '|' for DOS
|
||||||
strncat(buf, p, len);
|
strncat(buf, p, len - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4982,8 +4982,8 @@ buf_check_timestamp (
|
|||||||
set_vim_var_string(VV_WARNINGMSG, tbuf, -1);
|
set_vim_var_string(VV_WARNINGMSG, tbuf, -1);
|
||||||
if (can_reload) {
|
if (can_reload) {
|
||||||
if (*mesg2 != NUL) {
|
if (*mesg2 != NUL) {
|
||||||
strncat(tbuf, "\n", tbuf_len);
|
strncat(tbuf, "\n", tbuf_len - 1);
|
||||||
strncat(tbuf, mesg2, tbuf_len);
|
strncat(tbuf, mesg2, tbuf_len - 1);
|
||||||
}
|
}
|
||||||
if (do_dialog(VIM_WARNING, (char_u *) _("Warning"), (char_u *) tbuf,
|
if (do_dialog(VIM_WARNING, (char_u *) _("Warning"), (char_u *) tbuf,
|
||||||
(char_u *) _("&OK\n&Load File"), 1, NULL, true) == 2) {
|
(char_u *) _("&OK\n&Load File"), 1, NULL, true) == 2) {
|
||||||
|
@ -1986,7 +1986,7 @@ static ShaDaWriteResult shada_pack_encoded_entry(msgpack_packer *const packer,
|
|||||||
entry.data.data.reg.contents =
|
entry.data.data.reg.contents =
|
||||||
xmemdup(entry.data.data.reg.contents,
|
xmemdup(entry.data.data.reg.contents,
|
||||||
(entry.data.data.reg.contents_size
|
(entry.data.data.reg.contents_size
|
||||||
* sizeof(entry.data.data.reg.contents)));
|
* sizeof(entry.data.data.reg.contents[0])));
|
||||||
for (size_t i = 0; i < entry.data.data.reg.contents_size; i++) {
|
for (size_t i = 0; i < entry.data.data.reg.contents_size; i++) {
|
||||||
if (i >= first_non_ascii) {
|
if (i >= first_non_ascii) {
|
||||||
entry.data.data.reg.contents[i] = get_converted_string(
|
entry.data.data.reg.contents[i] = get_converted_string(
|
||||||
|
Loading…
Reference in New Issue
Block a user