diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-11-05 14:59:45 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-11-05 18:06:00 +0800 |
commit | e25193143bca3a48920322634120a442854bb891 (patch) | |
tree | bf6bf2b029cb90e508298c415ea86210a55f2ad7 /src/nvim/eval/funcs.c | |
parent | 562d572926e0c11329c13c9df45be7170888e7f6 (diff) | |
download | rneovim-e25193143bca3a48920322634120a442854bb891.tar.gz rneovim-e25193143bca3a48920322634120a442854bb891.tar.bz2 rneovim-e25193143bca3a48920322634120a442854bb891.zip |
vim-patch:8.2.1751: using 2 where bool is expected may throw an error
Problem: Using 2 where bool is expected may throw an error.
Solution: Make this backwards compatible.
https://github.com/vim/vim/commit/bade44e5cad1b08c85d4a8ba08d94a30458dddfb
In legacy Vim script get_bool functions do the same thing as get_number
functions, so just add aliases using #define.
N/A patches for version.c:
vim-patch:8.2.1506: Vim9: no error when using a number other than 0 or 1 as bool
Problem: Vim9: no error when using a number other than 0 or 1 as bool.
Solution: Check the number is 0 or 1.
https://github.com/vim/vim/commit/d70840ed68296c1144d743e6335003c81c558c24
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r-- | src/nvim/eval/funcs.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index cf924b1c49..1661a7079e 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -112,6 +112,8 @@ PRAGMA_DIAG_POP static char *e_listblobarg = N_("E899: Argument of %s must be a List or Blob"); static char *e_invalwindow = N_("E957: Invalid window number"); static char *e_reduceempty = N_("E998: Reduce of an empty %s with no initial value"); +static char e_using_number_as_bool_nr[] + = N_("E1023: Using a Number as a Bool: %d"); static char e_cannot_resize_window_in_another_tab_page[] = N_("E1308: Cannot resize a window in another tab page"); @@ -1361,7 +1363,7 @@ static void f_deepcopy(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) noref = (int)tv_get_number_chk(&argvars[1], NULL); } if (noref < 0 || noref > 1) { - emsg(_(e_invarg)); + semsg(_(e_using_number_as_bool_nr), noref); } else { var_item_copy(NULL, &argvars[0], rettv, true, (noref == 0 ? get_copyID() @@ -8457,7 +8459,7 @@ static void f_strchars(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) skipcc = (int)tv_get_number_chk(&argvars[1], NULL); } if (skipcc < 0 || skipcc > 1) { - emsg(_(e_invarg)); + semsg(_(e_using_number_as_bool_nr), skipcc); } else { func_mb_ptr2char_adv = skipcc ? mb_ptr2char_adv : mb_cptr2char_adv; while (*s != NUL) { |