mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -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:
@@ -1374,6 +1374,33 @@ compile_get_env(char_u **arg, cctx_T *cctx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compile "$"string"" or "$'string'".
|
||||
*/
|
||||
static int
|
||||
compile_interp_string(char_u **arg, cctx_T *cctx)
|
||||
{
|
||||
typval_T tv;
|
||||
int ret;
|
||||
int evaluate = cctx->ctx_skip != SKIP_YES;
|
||||
|
||||
// *arg is on the '$' character.
|
||||
(*arg)++;
|
||||
|
||||
if (**arg == '"')
|
||||
ret = eval_string(arg, &tv, evaluate);
|
||||
else
|
||||
ret = eval_lit_string(arg, &tv, evaluate);
|
||||
|
||||
if (ret == FAIL || !evaluate)
|
||||
return ret;
|
||||
|
||||
ret = compile_all_expr_in_str(tv.vval.v_string, TRUE, cctx);
|
||||
clear_tv(&tv);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compile "@r".
|
||||
*/
|
||||
@@ -2226,10 +2253,14 @@ compile_expr8(
|
||||
|
||||
/*
|
||||
* Environment variable: $VAR.
|
||||
* Interpolated string: $"string" or $'string'.
|
||||
*/
|
||||
case '$': if (generate_ppconst(cctx, ppconst) == FAIL)
|
||||
return FAIL;
|
||||
ret = compile_get_env(arg, cctx);
|
||||
if ((*arg)[1] == '"' || (*arg)[1] == '\'')
|
||||
ret = compile_interp_string(arg, cctx);
|
||||
else
|
||||
ret = compile_get_env(arg, cctx);
|
||||
break;
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user