0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.4883: string interpolation only works in heredoc

Problem:    String interpolation only works in heredoc.
Solution:   Support interpolated strings.  Use syntax for heredoc consistent
            with strings, similar to C#. (closes #10327)
This commit is contained in:
LemonBoy
2022-05-06 13:14:50 +01:00
committed by Bram Moolenaar
parent e7d6dbc572
commit 2eaef106e4
16 changed files with 364 additions and 137 deletions

View File

@@ -2266,6 +2266,32 @@ eval_lit_string(char_u **arg, typval_T *rettv, int evaluate)
return OK;
}
int
eval_interp_string(char_u **arg, typval_T *rettv, int evaluate)
{
typval_T tv;
int ret;
// *arg is on the '$' character.
(*arg)++;
rettv->v_type = VAR_STRING;
if (**arg == '"')
ret = eval_string(arg, &tv, evaluate);
else
ret = eval_lit_string(arg, &tv, evaluate);
if (ret == FAIL || !evaluate)
return ret;
rettv->vval.v_string = eval_all_expr_in_str(tv.vval.v_string);
clear_tv(&tv);
return rettv->vval.v_string != NULL ? OK : FAIL;
}
/*
* Return a string with the string representation of a variable.
* If the memory is allocated "tofree" is set to it, otherwise NULL.