Patch 7.4.1644
Problem: Using string() on a partial that exists in the dictionary it binds
results in an error. (Nikolai Pavlov)
Solution: Make string() not fail on a recursively nested structure. (Ken
Takta)
Files: src/eval.c, src/testdir/test_partial.vim
*** ../vim-7.4.1643/src/eval.c 2016-03-24 19:14:31.821092318 +0100
--- src/eval.c 2016-03-24 21:11:33.132945779 +0100
***************
*** 7851,7860 ****
break;
case VAR_PARTIAL:
! *tofree = NULL;
! /* TODO: arguments */
! r = tv->vval.v_partial == NULL ? NULL : tv->vval.v_partial->pt_name;
! break;
case VAR_LIST:
if (tv->vval.v_list == NULL)
--- 7851,7900 ----
break;
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;
! r = *tofree;
! break;
! }
case VAR_LIST:
if (tv->vval.v_list == NULL)
***************
*** 7941,7990 ****
case VAR_FUNC:
*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;
--- 7981,7986 ----
***************
*** 7997,8002 ****
--- 7993,7999 ----
case VAR_NUMBER:
case VAR_LIST:
case VAR_DICT:
+ case VAR_PARTIAL:
case VAR_SPECIAL:
case VAR_JOB:
case VAR_CHANNEL:
***************
*** 19258,19264 ****
char_u numbuf[NUMBUFLEN];
rettv->v_type = VAR_STRING;
! rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf, 0);
/* Make a copy if we have a value but it's not in allocated memory. */
if (rettv->vval.v_string != NULL && tofree == NULL)
rettv->vval.v_string = vim_strsave(rettv->vval.v_string);
--- 19255,19262 ----
char_u numbuf[NUMBUFLEN];
rettv->v_type = VAR_STRING;
! rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf,
! get_copyID());
/* Make a copy if we have a value but it's not in allocated memory. */
if (rettv->vval.v_string != NULL && tofree == NULL)
rettv->vval.v_string = vim_strsave(rettv->vval.v_string);
*** ../vim-7.4.1643/src/testdir/test_partial.vim 2016-03-22
21:00:06.052953785 +0100
--- src/testdir/test_partial.vim 2016-03-24 21:00:17.387881966 +0100
***************
*** 180,182 ****
--- 180,195 ----
unlet obj
call assert_false(exists('*{' . funcnumber . '}'))
endfunc
+
+ func Test_tostring()
+ let d = {}
+ let d.d = d
+ function d.test3()
+ echo 42
+ endfunction
+ try
+ call string(d.test3)
+ catch
+ call assert_true(v:false, v:exception)
+ endtry
+ endfunc
*** ../vim-7.4.1643/src/version.c 2016-03-24 19:14:31.821092318 +0100
--- src/version.c 2016-03-24 21:13:06.575986895 +0100
***************
*** 750,751 ****
--- 750,753 ----
{ /* Add new patch number below this line */
+ /**/
+ 1644,
/**/
--
FIXME and XXX are two common keywords used to mark broken or incomplete code
not only since XXX as a sex reference would grab everybody's attention but
simply due to the fact that Vim would highlight these words.
-- Hendrik Scholz
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.