To: vim_dev@googlegroups.com Subject: Patch 7.4.1608 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1608 Problem: string() doesn't handle a partial. Solution: Make a string from a partial. Files: src/eval.c, src/testdir/test_partial.vim *** ../vim-7.4.1607/src/eval.c 2016-03-19 19:37:56.069824594 +0100 --- src/eval.c 2016-03-19 19:55:07.827003338 +0100 *************** *** 7897,7905 **** *tofree = string_quote(tv->vval.v_string, TRUE); return *tofree; case VAR_PARTIAL: ! *tofree = string_quote(tv->vval.v_partial == NULL ? NULL ! : tv->vval.v_partial->pt_name, TRUE); ! return *tofree; case VAR_STRING: *tofree = string_quote(tv->vval.v_string, FALSE); return *tofree; --- 7897,7945 ---- *tofree = string_quote(tv->vval.v_string, TRUE); return *tofree; case VAR_PARTIAL: ! { ! partial_T *pt = tv->vval.v_partial; ! char_u *fname = string_quote(pt == NULL ? NULL ! : pt->pt_name, FALSE); ! garray_T ga; ! int i; ! char_u *tf; ! ! ga_init2(&ga, 1, 100); ! ga_concat(&ga, (char_u *)"function("); ! if (fname != NULL) ! { ! ga_concat(&ga, fname); ! vim_free(fname); ! } ! if (pt != NULL && pt->pt_argc > 0) ! { ! ga_concat(&ga, (char_u *)", ["); ! for (i = 0; i < pt->pt_argc; ++i) ! { ! if (i > 0) ! ga_concat(&ga, (char_u *)", "); ! ga_concat(&ga, ! tv2string(&pt->pt_argv[i], &tf, numbuf, copyID)); ! vim_free(tf); ! } ! ga_concat(&ga, (char_u *)"]"); ! } ! if (pt != NULL && pt->pt_dict != NULL) ! { ! typval_T dtv; ! ! ga_concat(&ga, (char_u *)", "); ! dtv.v_type = VAR_DICT; ! dtv.vval.v_dict = pt->pt_dict; ! ga_concat(&ga, tv2string(&dtv, &tf, numbuf, copyID)); ! vim_free(tf); ! } ! ga_concat(&ga, (char_u *)")"); ! ! *tofree = ga.ga_data; ! return *tofree; ! } case VAR_STRING: *tofree = string_quote(tv->vval.v_string, FALSE); return *tofree; *** ../vim-7.4.1607/src/testdir/test_partial.vim 2016-03-17 23:13:24.174681447 +0100 --- src/testdir/test_partial.vim 2016-03-19 19:58:32.988852642 +0100 *************** *** 156,158 **** --- 156,172 ---- let lF = [F] call assert_true(exists('*lF[0]')) endfunc + + func Test_partial_string() + let F = function('MyFunc') + call assert_equal("function('MyFunc')", string(F)) + let F = function('MyFunc', ['foo']) + call assert_equal("function('MyFunc', ['foo'])", string(F)) + let F = function('MyFunc', ['foo', 'bar']) + call assert_equal("function('MyFunc', ['foo', 'bar'])", string(F)) + let d = {'one': 1} + let F = function('MyFunc', d) + call assert_equal("function('MyFunc', {'one': 1})", string(F)) + let F = function('MyFunc', ['foo'], d) + call assert_equal("function('MyFunc', ['foo'], {'one': 1})", string(F)) + endfunc *** ../vim-7.4.1607/src/version.c 2016-03-19 19:37:56.069824594 +0100 --- src/version.c 2016-03-19 19:56:24.814196296 +0100 *************** *** 750,751 **** --- 750,753 ---- { /* Add new patch number below this line */ + /**/ + 1608, /**/ -- From "know your smileys": :-H Is missing teeth /// 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 ///