aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/userfunc.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-02-03 12:49:33 +0800
committerGitHub <noreply@github.com>2025-02-03 12:49:33 +0800
commit0c8890e7a771ca26c75a767b9851aaf7bf2c0f90 (patch)
treed17360af89c478816aa8f8545755f1c249e5afcb /src/nvim/eval/userfunc.c
parentefa3677f28ab0d47057f68b66e49cfa9cf491197 (diff)
downloadrneovim-0c8890e7a771ca26c75a767b9851aaf7bf2c0f90.tar.gz
rneovim-0c8890e7a771ca26c75a767b9851aaf7bf2c0f90.tar.bz2
rneovim-0c8890e7a771ca26c75a767b9851aaf7bf2c0f90.zip
vim-patch:8.2.4948: cannot use Perl heredoc in nested :def function (#32311)
Problem: Cannot use Perl heredoc in nested :def function. (Virginia Senioria) Solution: Only concatenate heredoc lines when not in a nested function. (closes vim/vim#10415) https://github.com/vim/vim/commit/d881d1598467d88808bafd2fa86982ebbca7dcc1 Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/eval/userfunc.c')
-rw-r--r--src/nvim/eval/userfunc.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 8022b37f6b..225880d731 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -2471,36 +2471,38 @@ static int get_function_body(exarg_T *eap, garray_T *newlines, char *line_arg_in
is_heredoc = true;
}
- // Check for ":let v =<< [trim] EOF"
- // and ":let [a, b] =<< [trim] EOF"
- arg = p;
- if (checkforcmd(&arg, "let", 2)) {
- int var_count = 0;
- int semicolon = 0;
- arg = (char *)skip_var_list(arg, &var_count, &semicolon, true);
- if (arg != NULL) {
- arg = skipwhite(arg);
- }
- if (arg != NULL && strncmp(arg, "=<<", 3) == 0) {
- p = skipwhite(arg + 3);
- while (true) {
- if (strncmp(p, "trim", 4) == 0) {
- // Ignore leading white space.
- p = skipwhite(p + 4);
- heredoc_trimmedlen = (size_t)(skipwhite(theline) - theline);
- heredoc_trimmed = xmemdupz(theline, heredoc_trimmedlen);
- continue;
- }
- if (strncmp(p, "eval", 4) == 0) {
- // Ignore leading white space.
- p = skipwhite(p + 4);
- continue;
+ if (!is_heredoc) {
+ // Check for ":let v =<< [trim] EOF"
+ // and ":let [a, b] =<< [trim] EOF"
+ arg = p;
+ if (checkforcmd(&arg, "let", 2)) {
+ int var_count = 0;
+ int semicolon = 0;
+ arg = (char *)skip_var_list(arg, &var_count, &semicolon, true);
+ if (arg != NULL) {
+ arg = skipwhite(arg);
+ }
+ if (arg != NULL && strncmp(arg, "=<<", 3) == 0) {
+ p = skipwhite(arg + 3);
+ while (true) {
+ if (strncmp(p, "trim", 4) == 0) {
+ // Ignore leading white space.
+ p = skipwhite(p + 4);
+ heredoc_trimmedlen = (size_t)(skipwhite(theline) - theline);
+ heredoc_trimmed = xmemdupz(theline, heredoc_trimmedlen);
+ continue;
+ }
+ if (strncmp(p, "eval", 4) == 0) {
+ // Ignore leading white space.
+ p = skipwhite(p + 4);
+ continue;
+ }
+ break;
}
- break;
+ skip_until = xmemdupz(p, (size_t)(skiptowhite(p) - p));
+ do_concat = false;
+ is_heredoc = true;
}
- skip_until = xmemdupz(p, (size_t)(skiptowhite(p) - p));
- do_concat = false;
- is_heredoc = true;
}
}
}