To: vim_dev@googlegroups.com Subject: Patch 7.4.1586 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1586 Problem: Nesting partials doesn't work. Solution: Append arguments. (Ken Takata) Files: src/eval.c, src/testdir/test_partial.vim *** ../vim-7.4.1585/src/eval.c 2016-03-17 20:50:44.110148894 +0100 --- src/eval.c 2016-03-17 21:05:49.760487082 +0100 *************** *** 11814,11819 **** --- 11814,11820 ---- char_u *s; char_u *name; int use_string = FALSE; + partial_T *arg_pt = NULL; if (argvars[0].v_type == VAR_FUNC) { *************** *** 11822,11829 **** } else if (argvars[0].v_type == VAR_PARTIAL && argvars[0].vval.v_partial != NULL) /* function(dict.MyFunc, [arg]) */ ! s = argvars[0].vval.v_partial->pt_name; else { /* function('MyFunc', [arg], dict) */ --- 11823,11833 ---- } else if (argvars[0].v_type == VAR_PARTIAL && argvars[0].vval.v_partial != NULL) + { /* function(dict.MyFunc, [arg]) */ ! arg_pt = argvars[0].vval.v_partial; ! s = arg_pt->pt_name; ! } else { /* function('MyFunc', [arg], dict) */ *************** *** 11901,11919 **** arg_idx = 0; } } ! if (dict_idx > 0 || arg_idx > 0) { partial_T *pt = (partial_T *)alloc_clear(sizeof(partial_T)); if (pt != NULL) { ! if (arg_idx > 0) { listitem_T *li; int i = 0; pt->pt_argv = (typval_T *)alloc( ! sizeof(typval_T) * list->lv_len); if (pt->pt_argv == NULL) { vim_free(pt); --- 11905,11931 ---- arg_idx = 0; } } ! if (dict_idx > 0 || arg_idx > 0 || arg_pt != NULL) { partial_T *pt = (partial_T *)alloc_clear(sizeof(partial_T)); + /* result is a VAR_PARTIAL */ if (pt != NULL) { ! if (arg_idx > 0 || (arg_pt != NULL && arg_pt->pt_argc > 0)) { listitem_T *li; int i = 0; + int arg_len = 0; + int lv_len = 0; + if (arg_pt != NULL) + arg_len = arg_pt->pt_argc; + if (list != NULL) + lv_len = list->lv_len; + pt->pt_argc = arg_len + lv_len; pt->pt_argv = (typval_T *)alloc( ! sizeof(typval_T) * pt->pt_argc); if (pt->pt_argv == NULL) { vim_free(pt); *************** *** 11922,11930 **** } else { ! pt->pt_argc = list->lv_len; ! for (li = list->lv_first; li != NULL; li = li->li_next) ! copy_tv(&li->li_tv, &pt->pt_argv[i++]); } } --- 11934,11945 ---- } 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++]); } } *************** *** 11935,11944 **** pt->pt_dict = argvars[dict_idx].vval.v_dict; ++pt->pt_dict->dv_refcount; } ! else if (argvars[0].v_type == VAR_PARTIAL) { ! pt->pt_dict = argvars[0].vval.v_partial->pt_dict; ! ++pt->pt_dict->dv_refcount; } pt->pt_refcount = 1; --- 11950,11960 ---- pt->pt_dict = argvars[dict_idx].vval.v_dict; ++pt->pt_dict->dv_refcount; } ! else if (arg_pt != NULL) { ! pt->pt_dict = arg_pt->pt_dict; ! if (pt->pt_dict != NULL) ! ++pt->pt_dict->dv_refcount; } pt->pt_refcount = 1; *************** *** 11950,11955 **** --- 11966,11972 ---- } else { + /* result is a VAR_FUNC */ rettv->v_type = VAR_FUNC; rettv->vval.v_string = name; func_ref(name); *** ../vim-7.4.1585/src/testdir/test_partial.vim 2016-03-17 20:50:44.110148894 +0100 --- src/testdir/test_partial.vim 2016-03-17 20:55:45.218953384 +0100 *************** *** 20,28 **** --- 20,36 ---- call Cb("zzz") call assert_equal("foo/bar/xxx", Cb("xxx")) call assert_equal("foo/bar/yyy", call(Cb, ["yyy"])) + let Cb2 = function(Cb) + call assert_equal("foo/bar/zzz", Cb2("zzz")) + let Cb3 = function(Cb, ["www"]) + call assert_equal("foo/bar/www", Cb3()) let Cb = function('MyFunc', []) call assert_equal("a/b/c", Cb("a", "b", "c")) + let Cb2 = function(Cb, []) + call assert_equal("a/b/d", Cb2("a", "b", "d")) + let Cb3 = function(Cb, ["a", "b"]) + call assert_equal("a/b/e", Cb3("e")) let Sort = function('MySort', [1]) call assert_equal([1, 2, 3], sort([3, 1, 2], Sort)) *** ../vim-7.4.1585/src/version.c 2016-03-17 20:50:44.110148894 +0100 --- src/version.c 2016-03-17 20:55:16.307263016 +0100 *************** *** 750,751 **** --- 750,753 ---- { /* Add new patch number below this line */ + /**/ + 1586, /**/ -- hundred-and-one symptoms of being an internet addict: 66. You create a homepage with the impression to cure the afflicted...but your hidden agenda is to receive more e-mail. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///