diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-04-28 17:52:24 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-04-28 17:52:24 +0100 |
commit | a96edb736d4274fc4aea460800780e06e1510812 (patch) | |
tree | 49b65efbf351fe23cf3340d9d8c07286f8ee778c /src/ex_docmd.c | |
parent | 05c7f5d3d03440da6f69604f8c06c4e3d90d2a26 (diff) |
patch 8.2.4841: empty string considered an error for expand()v8.2.4841
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 #10307)
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r-- | src/ex_docmd.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 5c86cee45b..226435003d 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -4924,7 +4924,7 @@ expand_filename( * Try to find a match at this position. */ repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum), - errormsgp, &escaped); + errormsgp, &escaped, TRUE); if (*errormsgp != NULL) // error detected return FAIL; if (repl == NULL) // no match found @@ -9045,8 +9045,9 @@ eval_vars( int *usedlen, // characters after src that are used linenr_T *lnump, // line number for :e command, or NULL char **errormsg, // pointer to error message - int *escaped) // return value has escaped white space (can + int *escaped, // return value has escaped white space (can // be NULL) + int empty_is_error) // empty result is considered an error { int i; char_u *s; @@ -9348,7 +9349,7 @@ eval_vars( } } - 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) *errormsg = _(e_empty_file_name_for_percent_or_hash_only_works_with_ph); @@ -9389,7 +9390,7 @@ expand_sfile(char_u *arg) else { // replace "<sfile>" with the sourced file name, and do ":" stuff - repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL); + repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL, TRUE); if (errormsg != NULL) { if (*errormsg) |