diff options
author | ZyX <kp-pav@yandex.ru> | 2016-09-18 01:59:07 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-03-29 10:08:06 +0300 |
commit | f80a00469fdba8a3dec0edae30c911d050485055 (patch) | |
tree | f42ea5ec669479c0b34d6923b34a553fa49a7edf /src | |
parent | 82e6cac5f9d437da5aeb8c4cf51945cfeb5922ff (diff) | |
download | rneovim-f80a00469fdba8a3dec0edae30c911d050485055.tar.gz rneovim-f80a00469fdba8a3dec0edae30c911d050485055.tar.bz2 rneovim-f80a00469fdba8a3dec0edae30c911d050485055.zip |
eval/typval: Make tv_list_concat handle NULL lists correctly
Fixes some FIXMEs in eval/null_spec.lua.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval/typval.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index ae4199697f..9dd1b62d7d 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -498,20 +498,25 @@ void tv_list_extend(list_T *const l1, list_T *const l2, int tv_list_concat(list_T *const l1, list_T *const l2, typval_T *const tv) FUNC_ATTR_WARN_UNUSED_RESULT { - if (l1 == NULL || l2 == NULL) { - return FAIL; - } + list_T *l; - // make a copy of the first list. - list_T *const l = tv_list_copy(NULL, l1, false, 0); - if (l == NULL) { + tv->v_type = VAR_LIST; + + if (l1 == NULL && l2 == NULL) { + l = NULL; + } else if (l1 == NULL) { + l = tv_list_copy(NULL, l2, false, 0); + } else { + l = tv_list_copy(NULL, l1, false, 0); + if (l != NULL && l2 != NULL) { + tv_list_extend(l, l2, NULL); + } + } + if (l == NULL && !(l1 == NULL && l2 == NULL)) { return FAIL; } - tv->v_type = VAR_LIST; - tv->vval.v_list = l; - // append all items from the second list - tv_list_extend(l, l2, NULL); + tv->vval.v_list = l; return OK; } |