mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 8.2.4930: interpolated string expression requires escaping
Problem: Interpolated string expression requires escaping. Solution: Do not require escaping in the expression.
This commit is contained in:
@@ -968,6 +968,36 @@ theend:
|
||||
return r == FAIL ? NULL : (char_u *)"";
|
||||
}
|
||||
|
||||
/*
|
||||
* Compile one Vim expression {expr} in string "p".
|
||||
* "p" points to the opening "{".
|
||||
* Return a pointer to the character after "}", NULL for an error.
|
||||
*/
|
||||
char_u *
|
||||
compile_one_expr_in_str(char_u *p, cctx_T *cctx)
|
||||
{
|
||||
char_u *block_start;
|
||||
char_u *block_end;
|
||||
|
||||
// Skip the opening {.
|
||||
block_start = skipwhite(p + 1);
|
||||
block_end = block_start;
|
||||
if (*block_start != NUL && skip_expr(&block_end, NULL) == FAIL)
|
||||
return NULL;
|
||||
block_end = skipwhite(block_end);
|
||||
// The block must be closed by a }.
|
||||
if (*block_end != '}')
|
||||
{
|
||||
semsg(_(e_missing_close_curly_str), p);
|
||||
return NULL;
|
||||
}
|
||||
if (compile_expr0(&block_start, cctx) == FAIL)
|
||||
return NULL;
|
||||
may_generate_2STRING(-1, TRUE, cctx);
|
||||
|
||||
return block_end + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compile a string "str" (either containing a literal string or a mix of
|
||||
* literal strings and Vim expressions of the form `{expr}`). This is used
|
||||
@@ -997,8 +1027,6 @@ compile_all_expr_in_str(char_u *str, int evalstr, cctx_T *cctx)
|
||||
while (*p != NUL)
|
||||
{
|
||||
char_u *lit_start;
|
||||
char_u *block_start;
|
||||
char_u *block_end;
|
||||
int escaped_brace = FALSE;
|
||||
|
||||
// Look for a block start.
|
||||
@@ -1038,28 +1066,14 @@ compile_all_expr_in_str(char_u *str, int evalstr, cctx_T *cctx)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip the opening {.
|
||||
block_start = skipwhite(p + 1);
|
||||
block_end = block_start;
|
||||
if (*block_start != NUL && skip_expr(&block_end, NULL) == FAIL)
|
||||
p = compile_one_expr_in_str(p, cctx);
|
||||
if (p == NULL)
|
||||
return FAIL;
|
||||
block_end = skipwhite(block_end);
|
||||
// The block must be closed by a }.
|
||||
if (*block_end != '}')
|
||||
{
|
||||
semsg(_(e_missing_close_curly_str), str);
|
||||
return FAIL;
|
||||
}
|
||||
if (compile_expr0(&block_start, cctx) == FAIL)
|
||||
return FAIL;
|
||||
may_generate_2STRING(-1, TRUE, cctx);
|
||||
++count;
|
||||
|
||||
p = block_end + 1;
|
||||
}
|
||||
|
||||
// Small optimization, if there's only a single piece skip the ISN_CONCAT.
|
||||
if (count != 1)
|
||||
if (count > 1)
|
||||
return generate_CONCAT(cctx, count);
|
||||
|
||||
return OK;
|
||||
|
Reference in New Issue
Block a user