diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-04-14 20:15:49 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-04-14 20:15:49 +0200 |
commit | 6c2b7b8055b96463f78abb70f58c4c6d6d4b9d55 (patch) | |
tree | 597e3992bed8691b13c5a2c4a459d2541b9acc18 /src/ex_getln.c | |
parent | 7a1637f4c00ac3d0cbf894803ada1586a1717470 (diff) | |
download | vim-git-6c2b7b8055b96463f78abb70f58c4c6d6d4b9d55.tar.gz |
patch 8.2.0578: heredoc for interfaces does not support "trim"v8.2.0578
Problem: Heredoc for interfaces does not support "trim".
Solution: Update the script heredoc support to be same as the :let command.
(Yegappan Lakshmanan, closes #5916)
Diffstat (limited to 'src/ex_getln.c')
-rw-r--r-- | src/ex_getln.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c index accedb540..9b959fbad 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -4408,44 +4408,37 @@ open_cmdwin(void) * Returns a pointer to allocated memory with {script} or NULL. */ char_u * -script_get(exarg_T *eap, char_u *cmd) +script_get(exarg_T *eap UNUSED, char_u *cmd UNUSED) { - char_u *theline; - char *end_pattern = NULL; - char dot[] = "."; +#ifdef FEAT_EVAL + list_T *l; + listitem_T *li; + char_u *s; garray_T ga; if (cmd[0] != '<' || cmd[1] != '<' || eap->getline == NULL) return NULL; + cmd += 2; - ga_init2(&ga, 1, 0x400); + l = heredoc_get(eap, cmd, TRUE); + if (l == NULL) + return NULL; - if (cmd[2] != NUL) - end_pattern = (char *)skipwhite(cmd + 2); - else - end_pattern = dot; + ga_init2(&ga, 1, 0x400); - for (;;) + FOR_ALL_LIST_ITEMS(l, li) { - theline = eap->getline( -#ifdef FEAT_EVAL - eap->cstack->cs_looplevel > 0 ? -1 : -#endif - NUL, eap->cookie, 0, TRUE); - - if (theline == NULL || STRCMP(end_pattern, theline) == 0) - { - vim_free(theline); - break; - } - - ga_concat(&ga, theline); + s = tv_get_string(&li->li_tv); + ga_concat(&ga, s); ga_append(&ga, '\n'); - vim_free(theline); } ga_append(&ga, NUL); + list_free(l); return (char_u *)ga.ga_data; +#else + return NULL; +#endif } #if defined(FEAT_EVAL) || defined(PROTO) |