From 7224c889e0d5d70b99ae377036baa6377c33a568 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 10:25:24 +0100 Subject: build: enable MSVC level 3 warnings (#21934) MSVC has 4 different warning levels: 1 (severe), 2 (significant), 3 (production quality) and 4 (informational). Enabling level 3 warnings mostly revealed conversion problems, similar to GCC/clang -Wconversion flag. --- src/nvim/eval/window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/eval/window.c') diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index f58a0c488a..c1d2e5b38f 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -192,9 +192,9 @@ win_T *find_tabwin(typval_T *wvp, typval_T *tvp) if (wvp->v_type != VAR_UNKNOWN) { if (tvp->v_type != VAR_UNKNOWN) { - long n = tv_get_number(tvp); + int n = (int)tv_get_number(tvp); if (n >= 0) { - tp = find_tabpage((int)n); + tp = find_tabpage(n); } } else { tp = curtab; -- cgit From 371823d407d7d7519735131bcad4670c62a731a7 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Wed, 5 Apr 2023 21:13:53 +0200 Subject: refactor: make error message definitions const message.c functions now take const char * as a format. Error message definitions can be made const. --- src/nvim/eval/window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/eval/window.c') diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index c1d2e5b38f..cf5727fa59 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -36,8 +36,8 @@ # include "eval/window.c.generated.h" #endif -static char *e_invalwindow = N_("E957: Invalid window number"); -static char e_cannot_resize_window_in_another_tab_page[] +static const char *e_invalwindow = N_("E957: Invalid window number"); +static const char e_cannot_resize_window_in_another_tab_page[] = N_("E1308: Cannot resize a window in another tab page"); static int win_getid(typval_T *argvars) -- cgit From 2d78e656b715119ca11d131a1a932f22f1b4ad36 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 21:43:00 +0200 Subject: refactor: remove redundant casts --- src/nvim/eval/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval/window.c') diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index cf5727fa59..25de236d90 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -265,7 +265,7 @@ static int get_winnr(tabpage_T *tp, typval_T *argvar) } else { // Extract the window count (if specified). e.g. winnr('3j') char *endp; - long count = strtol((char *)arg, &endp, 10); + long count = strtol(arg, &endp, 10); if (count <= 0) { // if count is not specified, default to 1 count = 1; -- cgit From 43c49746d9cf82dba0d56b07d39722f9ebeecf90 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 25 Apr 2023 21:32:12 +0800 Subject: vim-patch:9.0.0335: checks for Dictionary argument often give a vague error (#23309) Problem: Checks for Dictionary argument often give a vague error message. Solution: Give a useful error message. (Yegappan Lakshmanan, closes vim/vim#11009) https://github.com/vim/vim/commit/04c4c5746e15884768d2cb41370c3276a196cd4c Cherry-pick removal of E922 from docs from patch 9.0.1403. Co-authored-by: Yegappan Lakshmanan --- src/nvim/eval/window.c | 84 ++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 43 deletions(-) (limited to 'src/nvim/eval/window.c') diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index 25de236d90..9976c56879 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -651,8 +651,7 @@ void f_win_splitmove(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) dict_T *d; dictitem_T *di; - if (argvars[2].v_type != VAR_DICT || argvars[2].vval.v_dict == NULL) { - emsg(_(e_invarg)); + if (tv_check_for_nonnull_dict_arg(argvars, 2) == FAIL) { return; } @@ -796,51 +795,50 @@ void f_winrestcmd(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) /// "winrestview()" function void f_winrestview(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { - dict_T *dict = argvars[0].vval.v_dict; + if (tv_check_for_nonnull_dict_arg(argvars, 0) == FAIL) { + return; + } - if (argvars[0].v_type != VAR_DICT || dict == NULL) { - emsg(_(e_invarg)); - } else { - dictitem_T *di; - if ((di = tv_dict_find(dict, S_LEN("lnum"))) != NULL) { - curwin->w_cursor.lnum = (linenr_T)tv_get_number(&di->di_tv); - } - if ((di = tv_dict_find(dict, S_LEN("col"))) != NULL) { - curwin->w_cursor.col = (colnr_T)tv_get_number(&di->di_tv); - } - if ((di = tv_dict_find(dict, S_LEN("coladd"))) != NULL) { - curwin->w_cursor.coladd = (colnr_T)tv_get_number(&di->di_tv); - } - if ((di = tv_dict_find(dict, S_LEN("curswant"))) != NULL) { - curwin->w_curswant = (colnr_T)tv_get_number(&di->di_tv); - curwin->w_set_curswant = false; - } - if ((di = tv_dict_find(dict, S_LEN("topline"))) != NULL) { - set_topline(curwin, (linenr_T)tv_get_number(&di->di_tv)); - } - if ((di = tv_dict_find(dict, S_LEN("topfill"))) != NULL) { - curwin->w_topfill = (int)tv_get_number(&di->di_tv); - } - if ((di = tv_dict_find(dict, S_LEN("leftcol"))) != NULL) { - curwin->w_leftcol = (colnr_T)tv_get_number(&di->di_tv); - } - if ((di = tv_dict_find(dict, S_LEN("skipcol"))) != NULL) { - curwin->w_skipcol = (colnr_T)tv_get_number(&di->di_tv); - } + dict_T *dict = argvars[0].vval.v_dict; + dictitem_T *di; + if ((di = tv_dict_find(dict, S_LEN("lnum"))) != NULL) { + curwin->w_cursor.lnum = (linenr_T)tv_get_number(&di->di_tv); + } + if ((di = tv_dict_find(dict, S_LEN("col"))) != NULL) { + curwin->w_cursor.col = (colnr_T)tv_get_number(&di->di_tv); + } + if ((di = tv_dict_find(dict, S_LEN("coladd"))) != NULL) { + curwin->w_cursor.coladd = (colnr_T)tv_get_number(&di->di_tv); + } + if ((di = tv_dict_find(dict, S_LEN("curswant"))) != NULL) { + curwin->w_curswant = (colnr_T)tv_get_number(&di->di_tv); + curwin->w_set_curswant = false; + } + if ((di = tv_dict_find(dict, S_LEN("topline"))) != NULL) { + set_topline(curwin, (linenr_T)tv_get_number(&di->di_tv)); + } + if ((di = tv_dict_find(dict, S_LEN("topfill"))) != NULL) { + curwin->w_topfill = (int)tv_get_number(&di->di_tv); + } + if ((di = tv_dict_find(dict, S_LEN("leftcol"))) != NULL) { + curwin->w_leftcol = (colnr_T)tv_get_number(&di->di_tv); + } + if ((di = tv_dict_find(dict, S_LEN("skipcol"))) != NULL) { + curwin->w_skipcol = (colnr_T)tv_get_number(&di->di_tv); + } - check_cursor(); - win_new_height(curwin, curwin->w_height); - win_new_width(curwin, curwin->w_width); - changed_window_setting(); + check_cursor(); + win_new_height(curwin, curwin->w_height); + win_new_width(curwin, curwin->w_width); + changed_window_setting(); - if (curwin->w_topline <= 0) { - curwin->w_topline = 1; - } - if (curwin->w_topline > curbuf->b_ml.ml_line_count) { - curwin->w_topline = curbuf->b_ml.ml_line_count; - } - check_topfill(curwin, true); + if (curwin->w_topline <= 0) { + curwin->w_topline = 1; + } + if (curwin->w_topline > curbuf->b_ml.ml_line_count) { + curwin->w_topline = curbuf->b_ml.ml_line_count; } + check_topfill(curwin, true); } /// "winsaveview()" function -- cgit From e8661133c533345e8d83a38b077e45922988fa90 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 6 May 2023 09:34:29 +0800 Subject: vim-patch:9.0.0904: various comment and indent flaws (#23498) Problem: Various comment and indent flaws. Solution: Improve comments and indenting. https://github.com/vim/vim/commit/88456cd3c49a3dd1fda17cf350daa9b8216b1aa6 Omit test_function_lists.vim change as that file is likely not applicable to Nvim due to the existence of Nvim-only functions. Co-authored-by: Bram Moolenaar --- src/nvim/eval/window.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/eval/window.c') diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index 9976c56879..30c295de46 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -98,6 +98,7 @@ win_T *win_id2wp(int id) } /// Return the window and tab pointer of window "id". +/// Returns NULL when not found. win_T *win_id2wp_tp(int id, tabpage_T **tpp) { FOR_ALL_TAB_WINDOWS(tp, wp) { -- cgit From fcf3519c65a2d6736de437f686e788684a6c8564 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 17 Apr 2023 22:18:58 +0200 Subject: refactor: remove long long is 32-bits even on 64-bit windows which makes the type suboptimal for a codebase meant to be cross-platform. --- src/nvim/eval/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval/window.c') diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index 30c295de46..26f5414565 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -266,7 +266,7 @@ static int get_winnr(tabpage_T *tp, typval_T *argvar) } else { // Extract the window count (if specified). e.g. winnr('3j') char *endp; - long count = strtol(arg, &endp, 10); + int count = (int)strtol(arg, &endp, 10); if (count <= 0) { // if count is not specified, default to 1 count = 1; -- cgit From cf8b2c0e74fd5e723b0c15c2ce84e6900fd322d3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 12:05:28 +0800 Subject: build(iwyu): add a few more _defs.h mappings (#25435) --- src/nvim/eval/window.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/eval/window.c') diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index 26f5414565..6364128cfc 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -22,7 +22,6 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/macros.h" -#include "nvim/memline_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/move.h" -- cgit From dc6d0d2daf69e2fdadda81feb97906dbc962a239 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 14:41:34 +0800 Subject: refactor: reorganize option header files (#25437) - Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other --- src/nvim/eval/window.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/eval/window.c') diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index 6364128cfc..f64809f2ef 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -25,7 +25,6 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/move.h" -#include "nvim/option_defs.h" #include "nvim/pos.h" #include "nvim/types.h" #include "nvim/vim.h" -- cgit From 353a4be7e84fdc101318215bdcc8a7e780d737fe Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 12 Nov 2023 13:13:58 +0100 Subject: build: remove PVS We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable. --- src/nvim/eval/window.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/nvim/eval/window.c') diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index f64809f2ef..c0607a4a34 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // eval/window.c: Window related builtin functions #include -- cgit From 326d46f690b383846f136f2a25523cffe2882f27 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 16 Nov 2023 09:54:47 +0800 Subject: refactor: move some functions to winfloat.c (#26020) --- src/nvim/eval/window.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/eval/window.c') diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index c0607a4a34..bcc29dfeed 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -26,6 +26,7 @@ #include "nvim/types.h" #include "nvim/vim.h" #include "nvim/window.h" +#include "nvim/winfloat.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "eval/window.c.generated.h" @@ -635,7 +636,7 @@ void f_win_splitmove(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) if (wp == NULL || targetwin == NULL || wp == targetwin || !win_valid(wp) || !win_valid(targetwin) - || win_valid_floating(wp) || win_valid_floating(targetwin)) { + || win_float_valid(wp) || win_float_valid(targetwin)) { emsg(_(e_invalwindow)); rettv->vval.v_number = -1; return; -- cgit From f4aedbae4cb1f206f5b7c6142697b71dd473059b Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 18:39:38 +0100 Subject: build(IWYU): fix includes for undo_defs.h --- src/nvim/eval/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval/window.c') diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index bcc29dfeed..db19d0c25f 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -22,7 +22,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/move.h" -#include "nvim/pos.h" +#include "nvim/pos_defs.h" #include "nvim/types.h" #include "nvim/vim.h" #include "nvim/window.h" -- cgit From 6c14ae6bfaf51415b555e9a6b85d1d280976358d Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 20:27:32 +0100 Subject: refactor: rename types.h to types_defs.h --- src/nvim/eval/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval/window.c') diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index db19d0c25f..387f524cbb 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -23,7 +23,7 @@ #include "nvim/message.h" #include "nvim/move.h" #include "nvim/pos_defs.h" -#include "nvim/types.h" +#include "nvim/types_defs.h" #include "nvim/vim.h" #include "nvim/window.h" #include "nvim/winfloat.h" -- cgit From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/nvim/eval/window.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/eval/window.c') diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index 387f524cbb..e0abbad477 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -6,7 +6,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" @@ -18,13 +18,13 @@ #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/move.h" #include "nvim/pos_defs.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #include "nvim/winfloat.h" -- cgit