Patch 9.0.0090

5 views
Skip to first unread message

Bram Moolenaar

unread,
Jul 27, 2022, 7:31:00 AM7/27/22
to vim...@googlegroups.com

Patch 9.0.0090
Problem: No error when assigning bool to a string option with setwinvar().
Solution: Give an error (closes #10766)
Files: src/option.c, src/proto/option.pro, src/evalvars.c,
src/testdir/test_vim9_builtin.vim


*** ../vim-9.0.0089/src/option.c 2022-07-04 21:03:33.107829279 +0100
--- src/option.c 2022-07-27 12:13:04.323549427 +0100
***************
*** 4478,4483 ****
--- 4478,4497 ----
}
#endif

+ #if defined(FEAT_EVAL) || defined(PROTO)
+ /*
+ * Return TRUE if "name" is a string option.
+ * Returns FALSE if option "name" does not exist.
+ */
+ int
+ is_string_option(char_u *name)
+ {
+ int idx = findoption(name);
+
+ return idx >= 0 && (options[idx].flags & P_STRING);
+ }
+ #endif
+
/*
* Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
* When "has_lt" is true there is a '<' before "*arg_arg".
*** ../vim-9.0.0089/src/proto/option.pro 2022-06-27 23:15:18.000000000 +0100
--- src/proto/option.pro 2022-07-27 12:11:24.699756165 +0100
***************
*** 43,48 ****
--- 43,49 ----
char_u *get_highlight_default(void);
char_u *get_encoding_default(void);
int is_option_allocated(char *name);
+ int is_string_option(char_u *name);
int makeset(FILE *fd, int opt_flags, int local_only);
int makefoldset(FILE *fd);
void clear_termoptions(void);
*** ../vim-9.0.0089/src/evalvars.c 2022-07-25 12:28:05.844483996 +0100
--- src/evalvars.c 2022-07-27 12:12:53.751571740 +0100
***************
*** 4223,4228 ****
--- 4223,4233 ----

if (varp->v_type == VAR_BOOL)
{
+ if (is_string_option(varname))
+ {
+ emsg(_(e_string_required));
+ return;
+ }
numval = (long)varp->vval.v_number;
strval = (char_u *)"0"; // avoid using "false"
}
*** ../vim-9.0.0089/src/testdir/test_vim9_builtin.vim 2022-06-29 12:54:48.068572061 +0100
--- src/testdir/test_vim9_builtin.vim 2022-07-27 12:16:15.199134024 +0100
***************
*** 3719,3724 ****
--- 3719,3725 ----
v9.CheckDefAndScriptFailure(['setwinvar("a", "b", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
v9.CheckDefAndScriptFailure(['setwinvar(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
assert_fails('setwinvar(1, "", 10)', 'E461: Illegal variable name')
+ assert_fails('setwinvar(0, "&rulerformat", true)', 'E928:')
enddef

def Test_sha256()
*** ../vim-9.0.0089/src/version.c 2022-07-26 22:01:32.377972135 +0100
--- src/version.c 2022-07-27 12:08:48.884061105 +0100
***************
*** 737,738 ****
--- 737,740 ----
{ /* Add new patch number below this line */
+ /**/
+ 90,
/**/

--
hundred-and-one symptoms of being an internet addict:
148. You find it easier to dial-up the National Weather Service
Weather/your_town/now.html than to simply look out the window.

/// 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