mirror of
https://github.com/neovim/neovim.git
synced 2025-10-11 12:26:37 +00:00
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.bade44e5ca
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.d70840ed68
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -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_listblobarg = N_("E899: Argument of %s must be a List or Blob");
|
||||||
static char *e_invalwindow = N_("E957: Invalid window number");
|
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_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[]
|
static char e_cannot_resize_window_in_another_tab_page[]
|
||||||
= N_("E1308: Cannot resize a 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);
|
noref = (int)tv_get_number_chk(&argvars[1], NULL);
|
||||||
}
|
}
|
||||||
if (noref < 0 || noref > 1) {
|
if (noref < 0 || noref > 1) {
|
||||||
emsg(_(e_invarg));
|
semsg(_(e_using_number_as_bool_nr), noref);
|
||||||
} else {
|
} else {
|
||||||
var_item_copy(NULL, &argvars[0], rettv, true, (noref == 0
|
var_item_copy(NULL, &argvars[0], rettv, true, (noref == 0
|
||||||
? get_copyID()
|
? 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);
|
skipcc = (int)tv_get_number_chk(&argvars[1], NULL);
|
||||||
}
|
}
|
||||||
if (skipcc < 0 || skipcc > 1) {
|
if (skipcc < 0 || skipcc > 1) {
|
||||||
emsg(_(e_invarg));
|
semsg(_(e_using_number_as_bool_nr), skipcc);
|
||||||
} else {
|
} else {
|
||||||
func_mb_ptr2char_adv = skipcc ? mb_ptr2char_adv : mb_cptr2char_adv;
|
func_mb_ptr2char_adv = skipcc ? mb_ptr2char_adv : mb_cptr2char_adv;
|
||||||
while (*s != NUL) {
|
while (*s != NUL) {
|
||||||
|
@@ -559,4 +559,9 @@ EXTERN const size_t kTVTranslate INIT(= TV_TRANSLATE);
|
|||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "eval/typval.h.generated.h"
|
# include "eval/typval.h.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define tv_get_bool tv_get_number
|
||||||
|
#define tv_get_bool_chk tv_get_number_chk
|
||||||
|
#define tv_dict_get_bool tv_dict_get_number_def
|
||||||
|
|
||||||
#endif // NVIM_EVAL_TYPVAL_H
|
#endif // NVIM_EVAL_TYPVAL_H
|
||||||
|
@@ -294,6 +294,9 @@ func Test_searchpair()
|
|||||||
new
|
new
|
||||||
call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]'])
|
call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]'])
|
||||||
|
|
||||||
|
" should not give an error for using "42"
|
||||||
|
call assert_equal(0, searchpair('a', 'b', 'c', '', 42))
|
||||||
|
|
||||||
4
|
4
|
||||||
call assert_equal(3, searchpair('\[', '', ']', 'bW'))
|
call assert_equal(3, searchpair('\[', '', ']', 'bW'))
|
||||||
call assert_equal([0, 3, 2, 0], getpos('.'))
|
call assert_equal([0, 3, 2, 0], getpos('.'))
|
||||||
|
Reference in New Issue
Block a user