diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-23 13:24:40 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-08-23 17:48:12 +0800 |
commit | f1b8683b8c2f4a48d501c9dedef664f17761b8ac (patch) | |
tree | 83f5692a8a4f400c0828d28794067875071fbe05 /src/nvim/ex_docmd.c | |
parent | d0b9fe2d5a95def67acc83f713b932f3f12dea08 (diff) | |
download | rneovim-f1b8683b8c2f4a48d501c9dedef664f17761b8ac.tar.gz rneovim-f1b8683b8c2f4a48d501c9dedef664f17761b8ac.tar.bz2 rneovim-f1b8683b8c2f4a48d501c9dedef664f17761b8ac.zip |
vim-patch:8.2.4841: empty string considered an error for expand()
Problem: Empty string considered an error for expand() when 'verbose' is
set. (Christian Brabandt)
Solution: Do not give an error for an empty result. (closes vim/vim#10307)
https://github.com/vim/vim/commit/a96edb736d4274fc4aea460800780e06e1510812
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 7ed28e823e..f9055a0e8b 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3705,7 +3705,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, char **errormsgp) size_t srclen; int escaped; char *repl = (char *)eval_vars((char_u *)p, (char_u *)eap->arg, &srclen, &(eap->do_ecmd_lnum), - errormsgp, &escaped); + errormsgp, &escaped, true); if (*errormsgp != NULL) { // error detected return FAIL; } @@ -6634,18 +6634,19 @@ ssize_t find_cmdline_var(const char_u *src, size_t *usedlen) /// When an error is detected, "errormsg" is set to a non-NULL pointer (may be /// "" for error without a message) and NULL is returned. /// -/// @param src pointer into commandline -/// @param srcstart beginning of valid memory for src -/// @param usedlen characters after src that are used -/// @param lnump line number for :e command, or NULL -/// @param errormsg pointer to error message -/// @param escaped return value has escaped white space (can be NULL) +/// @param src pointer into commandline +/// @param srcstart beginning of valid memory for src +/// @param usedlen characters after src that are used +/// @param lnump line number for :e command, or NULL +/// @param errormsg pointer to error message +/// @param escaped return value has escaped white space (can be NULL) +/// @param empty_is_error empty result is considered an error /// /// @return an allocated string if a valid match was found. /// Returns NULL if no match was found. "usedlen" then still contains the /// number of characters to skip. char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnump, char **errormsg, - int *escaped) + int *escaped, bool empty_is_error) { char *result; char *resultbuf = NULL; @@ -6890,7 +6891,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum } } - if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH) { + if (empty_is_error && (resultlen == 0 || valid != VALID_HEAD + VALID_PATH)) { if (valid != VALID_HEAD + VALID_PATH) { // xgettext:no-c-format *errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\""); @@ -6919,7 +6920,8 @@ char *expand_sfile(char *arg) // replace "<sfile>" with the sourced file name, and do ":" stuff size_t srclen; char *errormsg; - char *repl = (char *)eval_vars((char_u *)p, (char_u *)result, &srclen, NULL, &errormsg, NULL); + char *repl = (char *)eval_vars((char_u *)p, (char_u *)result, &srclen, NULL, &errormsg, NULL, + true); if (errormsg != NULL) { if (*errormsg) { emsg(errormsg); |