To: vim_dev@googlegroups.com Subject: Patch 8.0.0867 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0867 Problem: When using a job or channel value as a dict value, when turning it into a string the quotes are missing. Solution: Add quotes to the job and channel values. (Yasuhiro Matsumoto, closes #1930) Files: src/list.c, src/eval.c, src/testdir/test_terminal.vim *** ../vim-8.0.0866/src/list.c 2017-04-30 20:12:53.378810666 +0200 --- src/list.c 2017-08-05 16:02:34.836783879 +0200 *************** *** 740,746 **** for (item = l->lv_first; item != NULL && !got_int; item = item->li_next) { s = echo_string_core(&item->li_tv, &tofree, numbuf, copyID, ! echo_style, restore_copyID, FALSE); if (s == NULL) return FAIL; --- 740,746 ---- for (item = l->lv_first; item != NULL && !got_int; item = item->li_next) { s = echo_string_core(&item->li_tv, &tofree, numbuf, copyID, ! echo_style, restore_copyID, !echo_style); if (s == NULL) return FAIL; *** ../vim-8.0.0866/src/eval.c 2017-07-29 20:11:34.726999121 +0200 --- src/eval.c 2017-08-05 16:10:13.645376430 +0200 *************** *** 5683,5691 **** * If the memory is allocated "tofree" is set to it, otherwise NULL. * "numbuf" is used for a number. * When "copyID" is not NULL replace recursive lists and dicts with "...". ! * When both "echo_style" and "dict_val" are FALSE, put quotes around stings as ! * "string()", otherwise does not put quotes around strings, as ":echo" ! * displays values. * When "restore_copyID" is FALSE, repeated items in dictionaries and lists * are replaced with "...". * May return NULL. --- 5683,5691 ---- * If the memory is allocated "tofree" is set to it, otherwise NULL. * "numbuf" is used for a number. * When "copyID" is not NULL replace recursive lists and dicts with "...". ! * When both "echo_style" and "composite_val" are FALSE, put quotes around ! * stings as "string()", otherwise does not put quotes around strings, as ! * ":echo" displays values. * When "restore_copyID" is FALSE, repeated items in dictionaries and lists * are replaced with "...". * May return NULL. *************** *** 5698,5704 **** int copyID, int echo_style, int restore_copyID, ! int dict_val) { static int recurse = 0; char_u *r = NULL; --- 5698,5704 ---- int copyID, int echo_style, int restore_copyID, ! int composite_val) { static int recurse = 0; char_u *r = NULL; *************** *** 5721,5730 **** switch (tv->v_type) { case VAR_STRING: ! if (echo_style && !dict_val) { *tofree = NULL; ! r = get_tv_string_buf(tv, numbuf); } else { --- 5721,5732 ---- switch (tv->v_type) { case VAR_STRING: ! if (echo_style && !composite_val) { *tofree = NULL; ! r = tv->vval.v_string; ! if (r == NULL) ! r = (char_u *)""; } else { *************** *** 5841,5850 **** --- 5843,5861 ---- case VAR_NUMBER: case VAR_UNKNOWN: + *tofree = NULL; + r = get_tv_string_buf(tv, numbuf); + break; + case VAR_JOB: case VAR_CHANNEL: *tofree = NULL; r = get_tv_string_buf(tv, numbuf); + if (composite_val) + { + *tofree = string_quote(r, FALSE); + r = *tofree; + } break; case VAR_FLOAT: *** ../vim-8.0.0866/src/testdir/test_terminal.vim 2017-08-03 22:44:51.046797665 +0200 --- src/testdir/test_terminal.vim 2017-08-05 16:16:14.190701327 +0200 *************** *** 18,23 **** --- 18,26 ---- let g:job = term_getjob(buf) call assert_equal(v:t_job, type(g:job)) + let string = string({'job': term_getjob(buf)}) + call assert_match("{'job': 'process \\d\\+ run'}", string) + return buf endfunc *** ../vim-8.0.0866/src/version.c 2017-08-05 15:16:28.169244309 +0200 --- src/version.c 2017-08-05 16:31:30.139834390 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 867, /**/ -- There can't be a crisis today, my schedule is already full. /// 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 ///