Patch 8.2.4841

5 views
Skip to first unread message

Bram Moolenaar

unread,
Apr 28, 2022, 12:53:10 PM4/28/22
to vim...@googlegroups.com

Patch 8.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)
Files: src/evalfunc.c, src/ex_docmd.c, src/proto/ex_docmd.pro,
src/filepath.c, src/testdir/test_expand_func.vim


*** ../vim-8.2.4840/src/evalfunc.c 2022-04-28 15:26:29.214947839 +0100
--- src/evalfunc.c 2022-04-28 17:50:35.376240975 +0100
***************
*** 4105,4111 ****

if (p_verbose == 0)
++emsg_off;
! result = eval_vars(s, s, &len, NULL, &errormsg, NULL);
if (p_verbose == 0)
--emsg_off;
else if (errormsg != NULL)
--- 4105,4111 ----

if (p_verbose == 0)
++emsg_off;
! result = eval_vars(s, s, &len, NULL, &errormsg, NULL, FALSE);
if (p_verbose == 0)
--emsg_off;
else if (errormsg != NULL)
*** ../vim-8.2.4840/src/ex_docmd.c 2022-04-19 11:38:01.484066480 +0100
--- src/ex_docmd.c 2022-04-28 17:18:36.458660746 +0100
***************
*** 4924,4930 ****
* Try to find a match at this position.
*/
repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum),
! errormsgp, &escaped);
if (*errormsgp != NULL) // error detected
return FAIL;
if (repl == NULL) // no match found
--- 4924,4930 ----
* Try to find a match at this position.
*/
repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum),
! errormsgp, &escaped, TRUE);
if (*errormsgp != NULL) // error detected
return FAIL;
if (repl == NULL) // no match found
***************
*** 9045,9052 ****
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
// be NULL)
{
int i;
char_u *s;
--- 9045,9053 ----
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
// be NULL)
+ int empty_is_error) // empty result is considered an error
{
int i;
char_u *s;
***************
*** 9348,9354 ****
}
}

! if (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);
--- 9349,9355 ----
}
}

! 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,9395 ****
else
{
// replace "<sfile>" with the sourced file name, and do ":" stuff
! repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL);
if (errormsg != NULL)
{
if (*errormsg)
--- 9390,9396 ----
else
{
// replace "<sfile>" with the sourced file name, and do ":" stuff
! repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL, TRUE);
if (errormsg != NULL)
{
if (*errormsg)
*** ../vim-8.2.4840/src/proto/ex_docmd.pro 2022-03-23 19:44:56.098161437 +0000
--- src/proto/ex_docmd.pro 2022-04-28 17:18:24.446671237 +0100
***************
*** 63,69 ****
void exec_normal_cmd(char_u *cmd, int remap, int silent);
void exec_normal(int was_typed, int use_vpeekc, int may_use_terminal_loop);
int find_cmdline_var(char_u *src, int *usedlen);
! char_u *eval_vars(char_u *src, char_u *srcstart, int *usedlen, linenr_T *lnump, char **errormsg, int *escaped);
char_u *expand_sfile(char_u *arg);
void dialog_msg(char_u *buff, char *format, char_u *fname);
void set_no_hlsearch(int flag);
--- 63,69 ----
void exec_normal_cmd(char_u *cmd, int remap, int silent);
void exec_normal(int was_typed, int use_vpeekc, int may_use_terminal_loop);
int find_cmdline_var(char_u *src, int *usedlen);
! char_u *eval_vars(char_u *src, char_u *srcstart, int *usedlen, linenr_T *lnump, char **errormsg, int *escaped, int empty_is_error);
char_u *expand_sfile(char_u *arg);
void dialog_msg(char_u *buff, char *format, char_u *fname);
void set_no_hlsearch(int flag);
*** ../vim-8.2.4840/src/filepath.c 2022-04-28 15:26:29.214947839 +0100
--- src/filepath.c 2022-04-28 17:18:42.958655082 +0100
***************
*** 3097,3103 ****
{
++emsg_off;
eval_pat = eval_vars(exp_pat, exp_pat, &usedlen,
! NULL, &ignored_msg, NULL);
--emsg_off;
if (eval_pat != NULL)
exp_pat = concat_str(eval_pat, exp_pat + usedlen);
--- 3097,3103 ----
{
++emsg_off;
eval_pat = eval_vars(exp_pat, exp_pat, &usedlen,
! NULL, &ignored_msg, NULL, TRUE);
--emsg_off;
if (eval_pat != NULL)
exp_pat = concat_str(eval_pat, exp_pat + usedlen);
*** ../vim-8.2.4840/src/testdir/test_expand_func.vim 2020-09-11 16:59:19.032235034 +0100
--- src/testdir/test_expand_func.vim 2022-04-28 17:50:04.036274658 +0100
***************
*** 82,91 ****

func Test_expand()
new
! call assert_equal("", expand('%:S'))
call assert_equal('3', '<slnum>'->expand())
call assert_equal(['4'], expand('<slnum>', v:false, v:true))
" Don't add any line above this, otherwise <slnum> will change.
quit
endfunc

--- 82,95 ----

func Test_expand()
new
! call assert_equal("''", expand('%:S'))
call assert_equal('3', '<slnum>'->expand())
call assert_equal(['4'], expand('<slnum>', v:false, v:true))
" Don't add any line above this, otherwise <slnum> will change.
+ call assert_equal("", expand('%'))
+ set verbose=1
+ call assert_equal("", expand('%'))
+ set verbose=0
quit
endfunc

*** ../vim-8.2.4840/src/version.c 2022-04-28 16:51:37.512460217 +0100
--- src/version.c 2022-04-28 17:51:02.024212481 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4841,
/**/

--
hundred-and-one symptoms of being an internet addict:
90. Instead of calling you to dinner, your spouse sends e-mail.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages