diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-06-21 23:56:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-21 23:56:00 +0200 |
commit | 144f584948a0183382411dd583df9b18cd95b473 (patch) | |
tree | 0ea38fa17b41f5e2871cf0259944f67310f6479d /src/nvim/eval.c | |
parent | cb8e47c4f88f12e2a107698a250410561807395a (diff) | |
parent | 476c28f433ebd7e3c8dfc2d31c59b3fc4c1c02e5 (diff) | |
download | rneovim-144f584948a0183382411dd583df9b18cd95b473.tar.gz rneovim-144f584948a0183382411dd583df9b18cd95b473.tar.bz2 rneovim-144f584948a0183382411dd583df9b18cd95b473.zip |
Merge #6914 from ZyX-I/func-def-trailing-error
Allow multiple function definitions in one :execute
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index baa61a26bc..18aa5bf763 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -19765,10 +19765,12 @@ void ex_function(exarg_T *eap) /* When there is a line break use what follows for the function body. * Makes 'exe "func Test()\n...\nendfunc"' work. */ - if (*p == '\n') + const char *const end = (const char *)p + STRLEN(p); + if (*p == '\n') { line_arg = p + 1; - else if (*p != NUL && *p != '"' && !eap->skip && !did_emsg) - EMSG(_(e_trailing)); + } else if (*p != NUL && *p != '"' && !eap->skip && !did_emsg) { + emsgf(_(e_trailing)); + } /* * Read the body of the function, until ":endfunction" is found. @@ -19842,8 +19844,30 @@ void ex_function(exarg_T *eap) /* Check for "endfunction". */ if (checkforcmd(&p, "endfunction", 4) && nesting-- == 0) { - if (line_arg == NULL) + if (*p == '!') { + p++; + } + const char *const comment_start = strchr((const char *)p, '"'); + const char *const endfunc_end = (comment_start + ? strchr(comment_start, '\n') + : strpbrk((const char *)p, "\n|")); + p = (endfunc_end + ? (char_u *)endfunc_end + : p + STRLEN(p)); + if (*p == '|') { + emsgf(_(e_trailing2), p); + if (line_arg == NULL) { + xfree(theline); + } + goto erret; + } + if (line_arg == NULL) { xfree(theline); + } else { + if ((const char *)p < end) { + eap->nextcmd = p + 1; + } + } break; } |