typval.h: Allow non-var expressions in TV_DICT_ITER first argument

This commit is contained in:
ZyX 2016-09-04 17:56:24 +03:00
parent 6cc3d59ec8
commit c4fe656fef

View File

@ -11248,26 +11248,26 @@ static void f_islocked(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} }
/* /// Turn a dictionary into a list
* Turn a dict into a list: ///
* "what" == 0: list of keys /// @param[in] tv Dictionary to convert. Is checked for actually being
* "what" == 1: list of values /// a dictionary, will give an error if not.
* "what" == 2: list of items /// @param[out] rettv Location where result will be saved.
*/ /// @param[in] what What to save in rettv.
static void dict_list(typval_T *argvars, typval_T *rettv, int what) static void dict_list(typval_T *const tv, typval_T *const rettv,
const DictListType what)
{ {
if (argvars[0].v_type != VAR_DICT) { if (tv->v_type != VAR_DICT) {
EMSG(_(e_dictreq)); emsgf(_(e_dictreq));
return; return;
} }
dict_T *const d = argvars[0].vval.v_dict; if (tv->vval.v_dict == NULL) {
if (d == NULL) {
return; return;
} }
tv_list_alloc_ret(rettv); tv_list_alloc_ret(rettv);
TV_DICT_ITER(d, di, { TV_DICT_ITER(tv->vval.v_dict, di, {
listitem_T *const li = tv_list_item_alloc(); listitem_T *const li = tv_list_item_alloc();
tv_list_append(rettv->vval.v_list, li); tv_list_append(rettv->vval.v_list, li);