@@ -575,17 +575,16 @@ skip_expr_concatenate(
575575
576576/*
577577 * Convert "tv" to a string.
578- * When "convert" is TRUE convert a List into a sequence of lines and a Dict
579- * into a textual representation of the Dict.
578+ * When "join_list" is TRUE convert a List into a sequence of lines.
580579 * Returns an allocated string (NULL when out of memory).
581580 */
582581 char_u *
583- typval2string (typval_T * tv , int convert )
582+ typval2string (typval_T * tv , int join_list )
584583{
585584 garray_T ga ;
586585 char_u * retval ;
587586
588- if (convert && tv -> v_type == VAR_LIST )
587+ if (join_list && tv -> v_type == VAR_LIST )
589588 {
590589 ga_init2 (& ga , sizeof (char ), 80 );
591590 if (tv -> vval .v_list != NULL )
@@ -597,8 +596,16 @@ typval2string(typval_T *tv, int convert)
597596 ga_append (& ga , NUL );
598597 retval = (char_u * )ga .ga_data ;
599598 }
600- else if (convert && tv -> v_type == VAR_DICT )
601- retval = dict2string (tv , get_copyID (), FALSE);
599+ else if (tv -> v_type == VAR_LIST || tv -> v_type == VAR_DICT )
600+ {
601+ char_u * tofree ;
602+ char_u numbuf [NUMBUFLEN ];
603+
604+ retval = tv2string (tv , & tofree , numbuf , 0 );
605+ // Make a copy if we have a value but it's not in allocated memory.
606+ if (retval != NULL && tofree == NULL )
607+ retval = vim_strsave (retval );
608+ }
602609 else
603610 retval = vim_strsave (tv_get_string (tv ));
604611 return retval ;
@@ -607,13 +614,13 @@ typval2string(typval_T *tv, int convert)
607614/*
608615 * Top level evaluation function, returning a string. Does not handle line
609616 * breaks.
610- * When "convert " is TRUE convert a List into a sequence of lines.
617+ * When "join_list " is TRUE convert a List into a sequence of lines.
611618 * Return pointer to allocated memory, or NULL for failure.
612619 */
613620 char_u *
614621eval_to_string_eap (
615622 char_u * arg ,
616- int convert ,
623+ int join_list ,
617624 exarg_T * eap ,
618625 int use_simple_function )
619626{
@@ -631,7 +638,7 @@ eval_to_string_eap(
631638 retval = NULL ;
632639 else
633640 {
634- retval = typval2string (& tv , convert );
641+ retval = typval2string (& tv , join_list );
635642 clear_tv (& tv );
636643 }
637644 clear_evalarg (& evalarg , NULL );
@@ -642,10 +649,10 @@ eval_to_string_eap(
642649 char_u *
643650eval_to_string (
644651 char_u * arg ,
645- int convert ,
652+ int join_list ,
646653 int use_simple_function )
647654{
648- return eval_to_string_eap (arg , convert , NULL , use_simple_function );
655+ return eval_to_string_eap (arg , join_list , NULL , use_simple_function );
649656}
650657
651658/*
0 commit comments