aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/release.yml18
-rw-r--r--cmake.deps/CMakeLists.txt4
-rw-r--r--runtime/doc/autocmd.txt4
-rw-r--r--runtime/doc/builtin.txt53
-rw-r--r--runtime/doc/cmdline.txt2
-rw-r--r--runtime/doc/options.txt11
-rw-r--r--runtime/doc/syntax.txt2
-rw-r--r--runtime/doc/usr_41.txt3
-rw-r--r--runtime/doc/windows.txt2
-rw-r--r--runtime/filetype.vim3
-rw-r--r--runtime/lua/vim/filetype.lua1
-rw-r--r--src/mpack/mpack_core.h1
-rw-r--r--src/nvim/api/command.c11
-rw-r--r--src/nvim/api/ui.c2
-rw-r--r--src/nvim/buffer.c4
-rw-r--r--src/nvim/charset.c2
-rw-r--r--src/nvim/cmdhist.c4
-rw-r--r--src/nvim/decoration.c2
-rw-r--r--src/nvim/diff.c10
-rw-r--r--src/nvim/eval.c2
-rw-r--r--src/nvim/eval/funcs.c20
-rw-r--r--src/nvim/eval/typval.c4
-rw-r--r--src/nvim/eval/userfunc.c2
-rw-r--r--src/nvim/ex_docmd.c38
-rw-r--r--src/nvim/ex_getln.c26
-rw-r--r--src/nvim/fileio.c2
-rw-r--r--src/nvim/hardcopy.c8
-rw-r--r--src/nvim/hashtab.c10
-rw-r--r--src/nvim/highlight_group.c6
-rw-r--r--src/nvim/insexpand.c2
-rw-r--r--src/nvim/lua/converter.c2
-rw-r--r--src/nvim/lua/executor.c2
-rw-r--r--src/nvim/lua/xdiff.c6
-rw-r--r--src/nvim/main.c2
-rw-r--r--src/nvim/mapping.c2
-rw-r--r--src/nvim/mark.c4
-rw-r--r--src/nvim/memfile.c4
-rw-r--r--src/nvim/normal.c6
-rw-r--r--src/nvim/ops.c2
-rw-r--r--src/nvim/option.c2
-rw-r--r--src/nvim/os/fs.c6
-rw-r--r--src/nvim/popupmnu.c2
-rw-r--r--src/nvim/quickfix.c4
-rw-r--r--src/nvim/regexp_bt.c2
-rw-r--r--src/nvim/regexp_nfa.c4
-rw-r--r--src/nvim/screen.c2
-rw-r--r--src/nvim/search.c10
-rw-r--r--src/nvim/shada.c6
-rw-r--r--src/nvim/sign.c2
-rw-r--r--src/nvim/spell.c14
-rw-r--r--src/nvim/spellfile.c6
-rw-r--r--src/nvim/syntax.c9
-rw-r--r--src/nvim/tag.c6
-rw-r--r--src/nvim/testdir/test_filetype.vim1
-rw-r--r--src/nvim/tui/tui.c2
-rw-r--r--src/nvim/undo.c24
-rw-r--r--src/nvim/vim.h1
-rw-r--r--src/nvim/window.c6
-rw-r--r--test/functional/api/vim_spec.lua7
59 files changed, 213 insertions, 192 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index cab57add52..3b5c992fc7 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -13,10 +13,10 @@ on:
- v[0-9]+.[0-9]+.[0-9]+
# Build on the oldest supported images, so we have broader compatibility
-# Upgrade to gcc-11 to prevent it from using its builtins (#14150)
+# Build with gcc-10 to prevent triggering #14150 (default is still gcc-9 on 20.04)
jobs:
linux:
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-20.04
outputs:
version: ${{ steps.build.outputs.version }}
release: ${{ steps.build.outputs.release }}
@@ -27,7 +27,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
- sudo apt-get install -y autoconf automake build-essential cmake gcc-11 gettext libtool-bin locales ninja-build pkg-config unzip
+ sudo apt-get install -y autoconf automake build-essential cmake gettext libtool-bin locales ninja-build pkg-config unzip
- if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != 'nightly')
run: printf 'NVIM_BUILD_TYPE=Release\n' >> $GITHUB_ENV
- if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name == 'nightly')
@@ -35,7 +35,7 @@ jobs:
- name: Build release
id: build
run: |
- CC=gcc-11 make CMAKE_BUILD_TYPE=${NVIM_BUILD_TYPE} CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX:PATH="
+ CC=gcc-10 make CMAKE_BUILD_TYPE=${NVIM_BUILD_TYPE} CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX:PATH="
printf '::set-output name=version::%s\n' "$(./build/bin/nvim --version | head -n 3 | sed -z 's/\n/%0A/g')"
printf '::set-output name=release::%s\n' "$(./build/bin/nvim --version | head -n 1)"
make DESTDIR="$GITHUB_WORKSPACE/build/release/nvim-linux64" install
@@ -50,7 +50,7 @@ jobs:
retention-days: 1
appimage:
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
@@ -58,11 +58,11 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
- sudo apt-get install -y autoconf automake build-essential cmake gcc-11 gettext libtool-bin locales ninja-build pkg-config unzip
+ sudo apt-get install -y autoconf automake build-essential cmake gettext libtool-bin locales ninja-build pkg-config unzip
- if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != 'nightly')
- run: CC=gcc-11 make appimage-latest
+ run: CC=gcc-10 make appimage-latest
- if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name == 'nightly')
- run: CC=gcc-11 make appimage-nightly
+ run: CC=gcc-10 make appimage-nightly
- uses: actions/upload-artifact@v3
with:
name: appimage
@@ -150,7 +150,7 @@ jobs:
publish:
needs: [linux, appimage, macOS, windows]
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-latest
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/cmake.deps/CMakeLists.txt b/cmake.deps/CMakeLists.txt
index 8724ab4916..f65111f9ff 100644
--- a/cmake.deps/CMakeLists.txt
+++ b/cmake.deps/CMakeLists.txt
@@ -159,8 +159,8 @@ set(MSGPACK_URL https://github.com/msgpack/msgpack-c/releases/download/c-4.0.0/m
set(MSGPACK_SHA256 420fe35e7572f2a168d17e660ef981a589c9cbe77faa25eb34a520e1fcc032c8)
# https://github.com/LuaJIT/LuaJIT/tree/v2.1
-set(LUAJIT_URL https://github.com/LuaJIT/LuaJIT/archive/a7d0265480c662964988f83d4e245bf139eb7cc0.tar.gz)
-set(LUAJIT_SHA256 7d7f58ca5c02b453ed4ddd2298e741053cbd6cd3d96e79460d06ec6684244c59)
+set(LUAJIT_URL https://github.com/LuaJIT/LuaJIT/archive/633f265f67f322cbe2c5fd11d3e46d968ac220f7.tar.gz)
+set(LUAJIT_SHA256 2681f0a6f624a64a8dfb70a5a377d494daf38960442c547d9c468674c1afa3c2)
set(LUA_URL https://www.lua.org/ftp/lua-5.1.5.tar.gz)
set(LUA_SHA256 2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333)
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index 59e5c078a3..63226fe701 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -441,8 +441,8 @@ CompleteChanged *CompleteChanged*
Non-recursive (event cannot trigger itself).
Cannot change the text. |textlock|
- The size and position of the popup are also
- available by calling |pum_getpos()|.
+ The size and position of the popup are also
+ available by calling |pum_getpos()|.
*CompleteDonePre*
CompleteDonePre After Insert mode completion is done. Either
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index b80bedfac5..d0b28ce875 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -119,7 +119,7 @@ dictwatcherdel({dict}, {pattern}, {callback})
did_filetype() Number |TRUE| if FileType autocommand event used
diff_filler({lnum}) Number diff filler lines about {lnum}
diff_hlID({lnum}, {col}) Number diff highlighting at {lnum}/{col}
-digraph_get({chars}) String get the digraph of {chars}
+digraph_get({chars}) String get the |digraph| of {chars}
digraph_getlist([{listall}]) List get all |digraph|s
digraph_set({chars}, {digraph}) Boolean register |digraph|
digraph_setlist({digraphlist}) Boolean register multiple |digraph|s
@@ -239,8 +239,8 @@ haslocaldir([{winnr} [, {tabnr}]])
the tab executed |:tcd|
hasmapto({what} [, {mode} [, {abbr}]])
Number |TRUE| if mapping to {what} exists
-histadd({history}, {item}) String add an item to a history
-histdel({history} [, {item}]) String remove an item from a history
+histadd({history}, {item}) Number add an item to a history
+histdel({history} [, {item}]) Number remove an item from a history
histget({history} [, {index}]) String get the item {index} from a history
histnr({history}) Number highest index of a history
hlID({name}) Number syntax ID of highlight group {name}
@@ -587,7 +587,7 @@ acos({expr}) *acos()*
{expr} must evaluate to a |Float| or a |Number| in the range
[-1, 1].
Returns NaN if {expr} is outside the range [-1, 1]. Returns
- 0.0 if {expr} is not a |Float| or a |Number|.
+ 0.0 if {expr} is not a |Float| or a |Number|.
Examples: >
:echo acos(0)
< 1.570796 >
@@ -1136,8 +1136,8 @@ cindent({lnum}) *cindent()*
GetLnum()->cindent()
clearmatches([{win}]) *clearmatches()*
- Clears all matches previously defined for the current window
- by |matchadd()| and the |:match| commands.
+ Clears all matches previously defined for the current window
+ by |matchadd()| and the |:match| commands.
If {win} is specified, use the window with this number or
window ID instead of the current window.
@@ -1989,6 +1989,7 @@ expand({string} [, {nosuf} [, {list}]]) *expand()*
<afile> autocmd file name
<abuf> autocmd buffer number (as a String!)
<amatch> autocmd matched name
+ <cexpr> C expression under the cursor
<sfile> sourced script file or function name
<slnum> sourced script line number or function
line number
@@ -2981,10 +2982,10 @@ getcurpos([{winid}])
current value of the buffer if it is not the current window.
If {winid} is invalid a list with zeroes is returned.
- This can be used to save and restore the cursor position: >
- let save_cursor = getcurpos()
- MoveTheCursorAround
- call setpos('.', save_cursor)
+ This can be used to save and restore the cursor position: >
+ let save_cursor = getcurpos()
+ MoveTheCursorAround
+ call setpos('.', save_cursor)
< Note that this only works within the window. See
|winrestview()| for restoring more state.
@@ -3119,7 +3120,7 @@ getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
{winnr} can also be a |window-ID|.
With {winnr} and {tabnr} use the window in the specified tab
page. If {winnr} or {tabnr} is invalid, an empty list is
- returned.
+ returned.
The returned list contains two entries: a list with the jump
locations and the last used jump position number in the list.
@@ -3506,7 +3507,7 @@ gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
Get the value of window-local variable {varname} in window
{winnr} in tab page {tabnr}.
The {varname} argument is a string. When {varname} is empty a
- dictionary with all window-local variables is returned.
+ dictionary with all window-local variables is returned.
When {varname} is equal to "&" get the values of all
window-local options in a |Dictionary|.
Otherwise, when {varname} starts with "&" get the value of a
@@ -4728,9 +4729,9 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
listing.
When there is no mapping for {name}, an empty String is
- returned if {dict} is FALSE, otherwise returns an empty Dict.
- When the mapping for {name} is empty, then "<Nop>" is
- returned.
+ returned if {dict} is FALSE, otherwise returns an empty Dict.
+ When the mapping for {name} is empty, then "<Nop>" is
+ returned.
The {name} can have special key names, like in the ":map"
command.
@@ -5904,7 +5905,7 @@ pum_getpos() *pum_getpos()*
size total nr of items
scrollbar |TRUE| if scrollbar is visible
- The values are the same as in |v:event| during |CompleteChanged|.
+ The values are the same as in |v:event| during |CompleteChanged|.
pumvisible() *pumvisible()*
Returns non-zero when the popup menu is visible, zero
@@ -6654,7 +6655,7 @@ searchpair({start}, {middle}, {end} [, {flags} [, {skip}
When {skip} is omitted or empty, every match is accepted.
When evaluating {skip} causes an error the search is aborted
and -1 returned.
- {skip} can be a string, a lambda, a funcref or a partial.
+ {skip} can be a string, a lambda, a funcref or a partial.
Anything else makes the function fail.
For {stopline} and {timeout} see |search()|.
@@ -7692,15 +7693,15 @@ stdpath({what}) *stdpath()* *E6100*
str2float({string} [, {quoted}]) *str2float()*
- Convert String {string} to a Float. This mostly works the
- same as when using a floating point number in an expression,
- see |floating-point-format|. But it's a bit more permissive.
- E.g., "1e40" is accepted, while in an expression you need to
- write "1.0e40". The hexadecimal form "0x123" is also
- accepted, but not others, like binary or octal.
- When {quoted} is present and non-zero then embedded single
- quotes before the dot are ignored, thus "1'000.0" is a
- thousand.
+ Convert String {string} to a Float. This mostly works the
+ same as when using a floating point number in an expression,
+ see |floating-point-format|. But it's a bit more permissive.
+ E.g., "1e40" is accepted, while in an expression you need to
+ write "1.0e40". The hexadecimal form "0x123" is also
+ accepted, but not others, like binary or octal.
+ When {quoted} is present and non-zero then embedded single
+ quotes before the dot are ignored, thus "1'000.0" is a
+ thousand.
Text after the number is silently ignored.
The decimal point is always '.', no matter what the locale is
set to. A comma ends the number: "12,345.67" is converted to
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 5d82f5985b..87f1589ea1 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -875,7 +875,7 @@ Note: these are typed literally, they are not special keys!
match with (for FileType, Syntax and SpellFileMissing
events).
When the match is with a file name, it is expanded to the
- full path.
+ full path.
*:<sfile>* *<sfile>*
<sfile> When executing a `:source` command, is replaced with the
file name of the sourced file. *E498*
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index f8e60f0d0d..614c6aec60 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -2144,7 +2144,8 @@ A jump table for the options with a short description can be found at |Q_op|.
When on all Unicode emoji characters are considered to be full width.
This excludes "text emoji" characters, which are normally displayed as
single width. Unfortunately there is no good specification for this
- and it has been determined on trial-and-error basis.
+ and it has been determined on trial-and-error basis. Use the
+ |setcellwidths()| function to change the behavior.
*'encoding'* *'enc'* *E543*
'encoding' 'enc'
@@ -4717,8 +4718,8 @@ A jump table for the options with a short description can be found at |Q_op|.
in read-only mode ("vim -R") or when the executable is called "view".
When using ":w!" the 'readonly' option is reset for the current
buffer, unless the 'Z' flag is in 'cpoptions'.
- When using the ":view" command the 'readonly' option is
- set for the newly edited buffer.
+ When using the ":view" command the 'readonly' option is set for the
+ newly edited buffer.
See 'modifiable' for disallowing changes to the buffer.
*'redrawdebug'* *'rdb'*
@@ -4839,7 +4840,7 @@ A jump table for the options with a short description can be found at |Q_op|.
search "/" and "?" commands
- This is useful for languages such as Hebrew and Arabic.
+ This is useful for languages such as Hebrew, Arabic and Farsi.
The 'rightleft' option must be set for 'rightleftcmd' to take effect.
*'ruler'* *'ru'* *'noruler'* *'noru'*
@@ -6190,7 +6191,7 @@ A jump table for the options with a short description can be found at |Q_op|.
global
This option controls the behavior when switching between buffers.
Mostly for |quickfix| commands some values are also used for other
- commands, as mentioned below.
+ commands, as mentioned below.
Possible values (comma-separated list):
useopen If included, jump to the first open window that
contains the specified buffer (if there is one).
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 9ed3c37b8c..b74611633f 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -5250,7 +5250,7 @@ TabLineSel Tab pages line, active tab page label.
Title Titles for output from ":set all", ":autocmd" etc.
*hl-Visual*
Visual Visual mode selection.
- *hl-VisualNOS*
+ *hl-VisualNOS*
VisualNOS Visual mode selection when vim is "Not Owning the Selection".
*hl-WarningMsg*
WarningMsg Warning messages.
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index af5ef0ab2d..235925c033 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -743,6 +743,7 @@ Cursor and mark position: *cursor-functions* *mark-functions*
cursor() position the cursor at a line/column
screencol() get screen column of the cursor
screenrow() get screen row of the cursor
+ screenpos() screen row and col of a text character
getcurpos() get position of the cursor
getpos() get position of cursor, mark, etc.
setpos() set position of cursor, mark, etc.
@@ -852,9 +853,9 @@ Buffers, windows and the argument list:
win_gotoid() go to window with ID
win_id2tabwin() get tab and window nr from window ID
win_id2win() get window nr from window ID
- win_splitmove() move window to a split of another window
win_move_separator() move window vertical separator
win_move_statusline() move window status line
+ win_splitmove() move window to a split of another window
getbufinfo() get a list with buffer information
gettabinfo() get a list with tab page information
getwininfo() get a list with window information
diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt
index 8062b9e28f..9d6a790a9c 100644
--- a/runtime/doc/windows.txt
+++ b/runtime/doc/windows.txt
@@ -372,7 +372,7 @@ CTRL-W o *CTRL-W_o* *E445*
CTRL-W CTRL-O *CTRL-W_CTRL-O* *:on* *:only*
Make the current window the only one on the screen. All other
windows are closed. For {count} see the `:quit` command
- above |:count_quit|.
+ above |:count_quit|.
When the 'hidden' option is set, all buffers in closed windows
become hidden.
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index fbb4b9f6aa..e32374863f 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1532,6 +1532,9 @@ au BufNewFile,BufRead *.ptl,*.pyi,SConstruct setf python
" QL
au BufRead,BufNewFile *.ql,*.qll setf ql
+" Quarto
+au BufRead,BufNewFile *.qmd setf quarto
+
" Radiance
au BufNewFile,BufRead *.rad,*.mat setf radiance
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua
index 1b209e6a9d..e9e81caec0 100644
--- a/runtime/lua/vim/filetype.lua
+++ b/runtime/lua/vim/filetype.lua
@@ -776,6 +776,7 @@ local extension = {
ptl = 'python',
ql = 'ql',
qll = 'ql',
+ qmd = 'quarto',
R = function(path, bufnr)
return require('vim.filetype.detect').r(bufnr)
end,
diff --git a/src/mpack/mpack_core.h b/src/mpack/mpack_core.h
index 1d601bc82d..336b778931 100644
--- a/src/mpack/mpack_core.h
+++ b/src/mpack/mpack_core.h
@@ -8,6 +8,7 @@
#include <assert.h>
#include <limits.h>
#include <stddef.h>
+#include <stdbool.h>
#ifdef __GNUC__
# define FPURE __attribute__((const))
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index bc766ff39c..d264237e37 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -300,10 +300,10 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
FUNC_API_SINCE(10)
{
exarg_T ea;
- memset(&ea, 0, sizeof(ea));
+ CLEAR_FIELD(ea);
CmdParseInfo cmdinfo;
- memset(&cmdinfo, 0, sizeof(cmdinfo));
+ CLEAR_FIELD(cmdinfo);
char *cmdline = NULL;
char *cmdname = NULL;
@@ -819,9 +819,12 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin
char *p = replace_makeprg(eap, eap->arg, cmdlinep);
if (p != eap->arg) {
// If replace_makeprg modified the cmdline string, correct the argument pointers.
- assert(argc == 1);
eap->arg = p;
- eap->args[0] = p;
+ // We can only know the position of the first argument because the argument list can be used
+ // multiple times in makeprg / grepprg.
+ if (argc >= 1) {
+ eap->args[0] = p;
+ }
}
}
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index 6239e414a7..9cd4c97508 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -224,7 +224,7 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height, Dictiona
ui->event = remote_ui_event;
ui->inspect = remote_ui_inspect;
- memset(ui->ui_ext, 0, sizeof(ui->ui_ext));
+ CLEAR_FIELD(ui->ui_ext);
for (size_t i = 0; i < options.size; i++) {
ui_set_option(ui, true, options.items[i].key, options.items[i].value, err);
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index f23a1caf8b..657a18e0b6 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -793,8 +793,8 @@ static void free_buffer(buf_T *buf)
if (autocmd_busy) {
// Do not free the buffer structure while autocommands are executing,
// it's still needed. Free it when autocmd_busy is reset.
- memset(&buf->b_namedm[0], 0, sizeof(buf->b_namedm));
- memset(&buf->b_changelist[0], 0, sizeof(buf->b_changelist));
+ CLEAR_FIELD(buf->b_namedm);
+ CLEAR_FIELD(buf->b_changelist);
buf->b_next = au_pending_free_buf;
au_pending_free_buf = buf;
} else {
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index a26a7f6aaf..6238d85b3a 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -126,7 +126,7 @@ int buf_init_chartab(buf_T *buf, int global)
}
// Init word char flags all to false
- memset(buf->b_chartab, 0, (size_t)32);
+ CLEAR_FIELD(buf->b_chartab);
// In lisp mode the '-' character is included in keywords.
if (buf->b_p_lisp) {
diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c
index 625bd514ad..cd494d2247 100644
--- a/src/nvim/cmdhist.c
+++ b/src/nvim/cmdhist.c
@@ -178,7 +178,7 @@ static inline void hist_free_entry(histentry_T *hisptr)
static inline void clear_hist_entry(histentry_T *hisptr)
FUNC_ATTR_NONNULL_ALL
{
- memset(hisptr, 0, sizeof(*hisptr));
+ CLEAR_POINTER(hisptr);
}
/// Check if command line 'str' is already in history.
@@ -714,7 +714,7 @@ const void *hist_iter(const void *const iter, const uint8_t history_type, const
}
*hist = *hiter;
if (zero) {
- memset(hiter, 0, sizeof(*hiter));
+ CLEAR_POINTER(hiter);
}
if (hiter == hlast) {
return NULL;
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index e7c76fe38e..6f946bb41a 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -391,7 +391,7 @@ void decor_redraw_signs(buf_T *buf, int row, int *num_signs, sign_attrs_T sattrs
sattrs[j] = sattrs[j - 1];
}
if (j < SIGN_SHOW_MAX) {
- memset(&sattrs[j], 0, sizeof(sign_attrs_T));
+ CLEAR_FIELD(sattrs[j]);
sattrs[j].sat_text = decor->sign_text;
if (decor->sign_hl_id != 0) {
sattrs[j].sat_texthl = syn_id2attr(decor->sign_hl_id);
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 849204f789..e3a6f9039d 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -956,13 +956,13 @@ void ex_diffupdate(exarg_T *eap)
// Only use the internal method if it did not fail for one of the buffers.
diffio_T diffio;
- memset(&diffio, 0, sizeof(diffio));
+ CLEAR_FIELD(diffio);
diffio.dio_internal = diff_internal() && !diff_internal_failed();
diff_try_update(&diffio, idx_orig, eap);
if (diffio.dio_internal && diff_internal_failed()) {
// Internal diff failed, use external diff instead.
- memset(&diffio, 0, sizeof(diffio));
+ CLEAR_FIELD(diffio);
diff_try_update(&diffio, idx_orig, eap);
}
@@ -1075,9 +1075,9 @@ static int diff_file_internal(diffio_T *diffio)
xdemitconf_t emit_cfg;
xdemitcb_t emit_cb;
- memset(&param, 0, sizeof(param));
- memset(&emit_cfg, 0, sizeof(emit_cfg));
- memset(&emit_cb, 0, sizeof(emit_cb));
+ CLEAR_FIELD(param);
+ CLEAR_FIELD(emit_cfg);
+ CLEAR_FIELD(emit_cb);
param.flags = (unsigned long)diff_algorithm;
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index b0a207e5ba..5abaf88e60 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1308,7 +1308,7 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const
int quiet = flags & GLV_QUIET;
// Clear everything in "lp".
- memset(lp, 0, sizeof(lval_T));
+ CLEAR_POINTER(lp);
if (skip) {
// When skipping just find the end of the name.
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 52386a67f6..4a44c08457 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -2640,7 +2640,7 @@ static void f_get(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (argvars[0].v_type == VAR_PARTIAL) {
pt = argvars[0].vval.v_partial;
} else {
- memset(&fref_pt, 0, sizeof(fref_pt));
+ CLEAR_FIELD(fref_pt);
fref_pt.pt_name = (char_u *)argvars[0].vval.v_string;
pt = &fref_pt;
}
@@ -7127,7 +7127,6 @@ static int search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
long time_limit = 0;
int options = SEARCH_KEEP;
int subpatnum;
- searchit_arg_T sia;
bool use_skip = false;
const char *const pat = tv_get_string(&argvars[0]);
@@ -7178,9 +7177,10 @@ static int search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
pos = save_cursor = curwin->w_cursor;
pos_T firstpos = { 0 };
- memset(&sia, 0, sizeof(sia));
- sia.sa_stop_lnum = (linenr_T)lnum_stop;
- sia.sa_tm = &tm;
+ searchit_arg_T sia = {
+ .sa_stop_lnum = (linenr_T)lnum_stop,
+ .sa_tm = &tm,
+ };
// Repeat until {skip} returns false.
for (;;) {
@@ -7799,10 +7799,10 @@ long do_searchpair(const char *spat, const char *mpat, const char *epat, int dir
clearpos(&foundpos);
pat = pat3;
for (;;) {
- searchit_arg_T sia;
- memset(&sia, 0, sizeof(sia));
- sia.sa_stop_lnum = lnum_stop;
- sia.sa_tm = &tm;
+ searchit_arg_T sia = {
+ .sa_stop_lnum = lnum_stop,
+ .sa_tm = &tm,
+ };
n = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L,
options, RE_SEARCH, &sia);
@@ -9500,7 +9500,7 @@ static void f_synconcealed(typval_T *argvars, typval_T *rettv, FunPtr fptr)
const linenr_T lnum = tv_get_lnum(argvars);
const colnr_T col = (colnr_T)tv_get_number(&argvars[1]) - 1;
- memset(str, NUL, sizeof(str));
+ CLEAR_FIELD(str);
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count && col >= 0
&& (size_t)col <= STRLEN(ml_get(lnum)) && curwin->w_p_cole > 0) {
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index ff1808ed91..8822bb0491 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -233,7 +233,7 @@ void tv_list_init_static10(staticList10_T *const sl)
#define SL_SIZE ARRAY_SIZE(sl->sl_items)
list_T *const l = &sl->sl_list;
- memset(sl, 0, sizeof(staticList10_T));
+ CLEAR_POINTER(sl);
l->lv_first = &sl->sl_items[0];
l->lv_last = &sl->sl_items[SL_SIZE - 1];
l->lv_refcount = DO_NOT_FREE_CNT;
@@ -261,7 +261,7 @@ void tv_list_init_static10(staticList10_T *const sl)
void tv_list_init_static(list_T *const l)
FUNC_ATTR_NONNULL_ALL
{
- memset(l, 0, sizeof(*l));
+ CLEAR_POINTER(l);
l->lv_refcount = DO_NOT_FREE_CNT;
list_log(l, NULL, NULL, "sinit");
}
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 2f4799db57..38a00099bc 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -1702,7 +1702,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
lval_T lv;
if (fdp != NULL) {
- memset(fdp, 0, sizeof(funcdict_T));
+ CLEAR_POINTER(fdp);
}
start = *pp;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 86c5489cf2..e8dc0b8e86 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -391,7 +391,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
if (flags & DOCMD_EXCRESET) {
save_dbg_stuff(&debug_saved);
} else {
- memset(&debug_saved, 0, sizeof(debug_saved));
+ CLEAR_FIELD(debug_saved);
}
initial_trylevel = trylevel;
@@ -1428,16 +1428,17 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er
char *after_modifier = NULL;
// Initialize cmdinfo
- memset(cmdinfo, 0, sizeof(*cmdinfo));
+ CLEAR_POINTER(cmdinfo);
// Initialize eap
- memset(eap, 0, sizeof(*eap));
- eap->line1 = 1;
- eap->line2 = 1;
- eap->cmd = cmdline;
- eap->cmdlinep = &cmdline;
- eap->getline = NULL;
- eap->cookie = NULL;
+ *eap = (exarg_T){
+ .line1 = 1,
+ .line2 = 1,
+ .cmd = cmdline,
+ .cmdlinep = &cmdline,
+ .getline = NULL,
+ .cookie = NULL,
+ };
const bool save_ex_pressedreturn = ex_pressedreturn;
// Parse command modifiers
@@ -1877,10 +1878,10 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
const int save_reg_executing = reg_executing;
const bool save_pending_end_reg_executing = pending_end_reg_executing;
- exarg_T ea;
- memset(&ea, 0, sizeof(ea));
- ea.line1 = 1;
- ea.line2 = 1;
+ exarg_T ea = {
+ .line1 = 1,
+ .line2 = 1,
+ };
ex_nesting_level++;
// When the last file has not been edited :q has to be typed twice.
@@ -6021,12 +6022,11 @@ theend:
/// Open a new tab page.
void tabpage_new(void)
{
- exarg_T ea;
-
- memset(&ea, 0, sizeof(ea));
- ea.cmdidx = CMD_tabnew;
- ea.cmd = "tabn";
- ea.arg = "";
+ exarg_T ea = {
+ .cmdidx = CMD_tabnew,
+ .cmd = "tabn",
+ .arg = "",
+ };
ex_splitview(&ea);
}
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 841345d625..22bbefe827 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -311,7 +311,6 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
int delim;
char *end;
char *dummy;
- exarg_T ea;
pos_T save_cursor;
bool use_last_pat;
bool retval = false;
@@ -336,11 +335,12 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
}
emsg_off++;
- memset(&ea, 0, sizeof(ea));
- ea.line1 = 1;
- ea.line2 = 1;
- ea.cmd = (char *)ccline.cmdbuff;
- ea.addr_type = ADDR_LINES;
+ exarg_T ea = {
+ .line1 = 1,
+ .line2 = 1,
+ .cmd = (char *)ccline.cmdbuff,
+ .addr_type = ADDR_LINES,
+ };
cmdmod_T dummy_cmdmod;
parse_command_modifiers(&ea, &dummy, &dummy_cmdmod, true);
@@ -453,7 +453,6 @@ static void may_do_incsearch_highlighting(int firstc, long count, incsearch_stat
{
pos_T end_pos;
proftime_T tm;
- searchit_arg_T sia;
int skiplen, patlen;
char_u next_char;
char_u use_last_pat;
@@ -516,8 +515,9 @@ static void may_do_incsearch_highlighting(int firstc, long count, incsearch_stat
search_flags += SEARCH_START;
}
ccline.cmdbuff[skiplen + patlen] = NUL;
- memset(&sia, 0, sizeof(sia));
- sia.sa_tm = &tm;
+ searchit_arg_T sia = {
+ .sa_tm = &tm,
+ };
found = do_search(NULL, firstc == ':' ? '/' : firstc, search_delim,
ccline.cmdbuff + skiplen, count,
search_flags, &sia);
@@ -731,7 +731,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init
save_cmdline(&save_ccline);
did_save_ccline = true;
} else if (init_ccline) {
- memset(&ccline, 0, sizeof(struct cmdline_info));
+ CLEAR_FIELD(ccline);
}
if (s->firstc == -1) {
@@ -2677,7 +2677,7 @@ char *getcmdline_prompt(const int firstc, const char *const prompt, const int at
save_cmdline(&save_ccline);
did_save_ccline = true;
} else {
- memset(&ccline, 0, sizeof(struct cmdline_info));
+ CLEAR_FIELD(ccline);
}
ccline.prompt_id = last_prompt_id++;
ccline.cmdprompt = (char_u *)prompt;
@@ -3640,7 +3640,7 @@ void put_on_cmdline(char_u *str, int len, int redraw)
static void save_cmdline(struct cmdline_info *ccp)
{
*ccp = ccline;
- memset(&ccline, 0, sizeof(struct cmdline_info));
+ CLEAR_FIELD(ccline);
ccline.prev_ccline = ccp;
ccline.cmdbuff = NULL; // signal that ccline is not in use
}
@@ -6029,7 +6029,7 @@ int get_list_range(char_u **str, int *num1, int *num2)
void cmdline_init(void)
{
- memset(&ccline, 0, sizeof(struct cmdline_info));
+ CLEAR_FIELD(ccline);
}
/// Open a window on the current command line and history. Allow editing in
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index b98984017b..b467f53bbd 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -5122,7 +5122,7 @@ void buf_reload(buf_T *buf, int orig_mode, bool reload_options)
// file, not reset the syntax highlighting, clear marks, diff status, etc.
// Force the fileformat and encoding to be the same.
if (reload_options) {
- memset(&ea, 0, sizeof(ea));
+ CLEAR_FIELD(ea);
} else {
prep_exarg(&ea, buf);
}
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index d7f7b8eb92..96d3bfb4d3 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -632,8 +632,8 @@ void ex_hardcopy(exarg_T *eap)
int page_line;
int jobsplit;
- memset(&settings, 0, sizeof(prt_settings_T));
- settings.has_color = TRUE;
+ CLEAR_FIELD(settings);
+ settings.has_color = true;
if (*eap->arg == '>') {
char *errormsg = NULL;
@@ -734,7 +734,7 @@ void ex_hardcopy(exarg_T *eap)
prt_pos_T page_prtpos; // print position at page start
int side;
- memset(&page_prtpos, 0, sizeof(prt_pos_T));
+ CLEAR_FIELD(page_prtpos);
page_prtpos.file_line = eap->line1;
prtpos = page_prtpos;
@@ -1718,7 +1718,7 @@ static bool prt_open_resource(struct prt_ps_resource_S *resource)
semsg(_("E624: Can't open file \"%s\""), resource->filename);
return false;
}
- memset(prt_resfile.buffer, NUL, PRT_FILE_BUFFER_LEN);
+ CLEAR_FIELD(prt_resfile.buffer);
// Parse first line to ensure valid resource file
prt_resfile.len = (int)fread((char *)prt_resfile.buffer, sizeof(char_u),
diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c
index 95ae7a152c..951e72ea52 100644
--- a/src/nvim/hashtab.c
+++ b/src/nvim/hashtab.c
@@ -45,7 +45,7 @@ char hash_removed;
void hash_init(hashtab_T *ht)
{
// This zeroes all "ht_" entries and all the "hi_key" in "ht_smallarray".
- memset(ht, 0, sizeof(hashtab_T));
+ CLEAR_POINTER(ht);
ht->ht_array = ht->ht_smallarray;
ht->ht_mask = HT_INIT_SIZE - 1;
}
@@ -342,11 +342,13 @@ static void hash_may_resize(hashtab_T *ht, size_t minitems)
hashitem_T *oldarray = keep_smallarray
? memcpy(temparray, ht->ht_smallarray, sizeof(temparray))
: ht->ht_array;
+
+ if (newarray_is_small) {
+ CLEAR_FIELD(ht->ht_smallarray);
+ }
hashitem_T *newarray = newarray_is_small
? ht->ht_smallarray
- : xmalloc(sizeof(hashitem_T) * newsize);
-
- memset(newarray, 0, sizeof(hashitem_T) * newsize);
+ : xcalloc(newsize, sizeof(hashitem_T));
// Move all the items from the old array to the new one, placing them in
// the right spot. The new array won't have any removed items, thus this
diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c
index f6ec03fb14..5afbaaf121 100644
--- a/src/nvim/highlight_group.c
+++ b/src/nvim/highlight_group.c
@@ -1765,7 +1765,7 @@ static int syn_add_group(const char *name, size_t len)
// Append another syntax_highlight entry.
HlGroup *hlgp = GA_APPEND_VIA_PTR(HlGroup, &highlight_ga);
- memset(hlgp, 0, sizeof(*hlgp));
+ CLEAR_POINTER(hlgp);
hlgp->sg_name = (char_u *)arena_memdupz(&highlight_arena, name, len);
hlgp->sg_rgb_bg = -1;
hlgp->sg_rgb_fg = -1;
@@ -1863,7 +1863,7 @@ static void combine_stl_hlt(int id, int id_S, int id_alt, int hlcnt, int i, int
HlGroup *const hlt = hl_table;
if (id_alt == 0) {
- memset(&hlt[hlcnt + i], 0, sizeof(HlGroup));
+ CLEAR_POINTER(&hlt[hlcnt + i]);
hlt[hlcnt + i].sg_cterm = highlight_attr[hlf];
hlt[hlcnt + i].sg_gui = highlight_attr[hlf];
} else {
@@ -1945,7 +1945,7 @@ void highlight_changed(void)
hlcnt = highlight_ga.ga_len;
if (id_S == -1) {
// Make sure id_S is always valid to simplify code below. Use the last entry
- memset(&hl_table[hlcnt + 9], 0, sizeof(HlGroup));
+ CLEAR_POINTER(&hl_table[hlcnt + 9]);
id_S = hlcnt + 10;
}
for (int i = 0; i < 9; i++) {
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index a64d8e8f00..bddeee119d 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -2139,7 +2139,7 @@ static int ins_compl_add_tv(typval_T *const tv, const Direction dir, bool fast)
}
} else {
word = tv_get_string_chk(tv);
- memset(cptext, 0, sizeof(cptext));
+ CLEAR_FIELD(cptext);
}
if (word == NULL || (!empty && *word == NUL)) {
for (size_t i = 0; i < CPT_COUNT; i++) {
diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c
index 4d6e6090b8..49d49f76b9 100644
--- a/src/nvim/lua/converter.c
+++ b/src/nvim/lua/converter.c
@@ -59,7 +59,7 @@ static LuaTableProps nlua_traverse_table(lua_State *const lstate)
size_t other_keys_num = 0; // Number of keys that are not string, integral
// or type keys.
LuaTableProps ret;
- memset(&ret, 0, sizeof(ret));
+ CLEAR_FIELD(ret);
if (!lua_checkstack(lstate, lua_gettop(lstate) + 3)) {
semsg(_("E1502: Lua failed to grow stack to %i"), lua_gettop(lstate) + 2);
ret.type = kObjectTypeNil;
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 661dbfc4c2..c7b654482c 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -447,7 +447,7 @@ static nlua_ref_state_t *nlua_new_ref_state(lua_State *lstate, bool is_thread)
FUNC_ATTR_NONNULL_ALL
{
nlua_ref_state_t *ref_state = lua_newuserdata(lstate, sizeof(*ref_state));
- memset(ref_state, 0, sizeof(*ref_state));
+ CLEAR_POINTER(ref_state);
ref_state->nil_ref = LUA_NOREF;
ref_state->empty_dict_ref = LUA_NOREF;
if (!is_thread) {
diff --git a/src/nvim/lua/xdiff.c b/src/nvim/lua/xdiff.c
index 71f85385b6..b2b5dfedee 100644
--- a/src/nvim/lua/xdiff.c
+++ b/src/nvim/lua/xdiff.c
@@ -269,9 +269,9 @@ int nlua_xdl_diff(lua_State *lstate)
xpparam_t params;
xdemitcb_t ecb;
- memset(&cfg, 0, sizeof(cfg));
- memset(&params, 0, sizeof(params));
- memset(&ecb, 0, sizeof(ecb));
+ CLEAR_FIELD(cfg);
+ CLEAR_FIELD(params);
+ CLEAR_FIELD(ecb);
NluaXdiffMode mode = kNluaXdiffModeUnified;
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 494ff0b4af..378ca6ba71 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -1418,7 +1418,7 @@ scripterror:
* copied, so that they can be changed. */
static void init_params(mparm_T *paramp, int argc, char **argv)
{
- memset(paramp, 0, sizeof(*paramp));
+ CLEAR_POINTER(paramp);
paramp->argc = argc;
paramp->argv = argv;
paramp->use_debug_break_level = -1;
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
index 342b1b0d47..f0a82b6bec 100644
--- a/src/nvim/mapping.c
+++ b/src/nvim/mapping.c
@@ -333,7 +333,7 @@ static int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *ma
{
const char_u *to_parse = strargs;
to_parse = (char_u *)skipwhite((char *)to_parse);
- memset(mapargs, 0, sizeof(*mapargs));
+ CLEAR_POINTER(mapargs);
// Accept <buffer>, <nowait>, <silent>, <expr>, <script>, and <unique> in
// any order.
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 1fe3327b29..087e64f3c0 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -86,7 +86,7 @@ void clear_fmark(fmark_T *fm)
FUNC_ATTR_NONNULL_ALL
{
free_fmark(*fm);
- memset(fm, 0, sizeof(*fm));
+ CLEAR_POINTER(fm);
}
/*
@@ -1741,7 +1741,7 @@ void free_all_marks(void)
free_xfmark(namedfm[i]);
}
}
- memset(&namedfm[0], 0, sizeof(namedfm));
+ CLEAR_FIELD(namedfm);
}
#endif
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c
index c828334eaf..216ee26620 100644
--- a/src/nvim/memfile.c
+++ b/src/nvim/memfile.c
@@ -821,7 +821,7 @@ static bool mf_do_open(memfile_T *mfp, char_u *fname, int flags)
/// Initialize an empty hash table.
static void mf_hash_init(mf_hashtab_T *mht)
{
- memset(mht, 0, sizeof(mf_hashtab_T));
+ CLEAR_POINTER(mht);
mht->mht_buckets = mht->mht_small_buckets;
mht->mht_mask = MHT_INIT_SIZE - 1;
}
@@ -924,7 +924,7 @@ static void mf_hash_grow(mf_hashtab_T *mht)
/// a power of two.
mf_hashitem_T *tails[MHT_GROWTH_FACTOR];
- memset(tails, 0, sizeof(tails));
+ CLEAR_FIELD(tails);
for (mf_hashitem_T *mhi = mht->mht_buckets[i];
mhi != NULL; mhi = mhi->mhi_next) {
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 064b73a56f..1657b391d0 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -466,7 +466,7 @@ void normal_enter(bool cmdwin, bool noexmode)
static void normal_prepare(NormalState *s)
{
- memset(&s->ca, 0, sizeof(s->ca)); // also resets ca.retval
+ CLEAR_FIELD(s->ca); // also resets s->ca.retval
s->ca.oap = &s->oa;
// Use a count remembered from before entering an operator. After typing "3d"
@@ -4149,7 +4149,7 @@ void do_nv_ident(int c1, int c2)
cmdarg_T ca;
clear_oparg(&oa);
- memset(&ca, 0, sizeof(ca));
+ CLEAR_FIELD(ca);
ca.oap = &oa;
ca.cmdchar = c1;
ca.nchar = c2;
@@ -4845,7 +4845,7 @@ static int normal_search(cmdarg_T *cap, int dir, char_u *pat, int opt, int *wrap
cap->oap->use_reg_one = true;
curwin->w_set_curswant = true;
- memset(&sia, 0, sizeof(sia));
+ CLEAR_FIELD(sia);
i = do_search(cap->oap, dir, dir, pat, cap->count1,
opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, &sia);
if (wrapped != NULL) {
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 53612be697..265109571c 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -5789,7 +5789,7 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char_u *str
void clear_oparg(oparg_T *oap)
{
- memset(oap, 0, sizeof(oparg_T));
+ CLEAR_POINTER(oap);
}
/// Count the number of bytes, characters and "words" in a line.
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 8eb3b64e5b..e6080dabe3 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -6515,7 +6515,7 @@ void buf_copy_options(buf_T *buf, int flags)
}
if (should_copy || (flags & BCO_ALWAYS)) {
- memset(buf->b_p_script_ctx, 0, sizeof(buf->b_p_script_ctx));
+ CLEAR_FIELD(buf->b_p_script_ctx);
init_buf_opt_idx();
// Don't copy the options specific to a help buffer when
// BCO_NOHELP is given or the options were initialized already
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index 901a1bc5a6..3b2bfb5884 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -1051,7 +1051,7 @@ int os_remove(const char *path)
bool os_fileinfo(const char *path, FileInfo *file_info)
FUNC_ATTR_NONNULL_ARG(2)
{
- memset(file_info, 0, sizeof(*file_info));
+ CLEAR_POINTER(file_info);
return os_stat(path, &(file_info->stat)) == kLibuvSuccess;
}
@@ -1063,7 +1063,7 @@ bool os_fileinfo(const char *path, FileInfo *file_info)
bool os_fileinfo_link(const char *path, FileInfo *file_info)
FUNC_ATTR_NONNULL_ARG(2)
{
- memset(file_info, 0, sizeof(*file_info));
+ CLEAR_POINTER(file_info);
if (path == NULL) {
return false;
}
@@ -1087,7 +1087,7 @@ bool os_fileinfo_fd(int file_descriptor, FileInfo *file_info)
FUNC_ATTR_NONNULL_ALL
{
uv_fs_t request;
- memset(file_info, 0, sizeof(*file_info));
+ CLEAR_POINTER(file_info);
fs_loop_lock();
bool ok = uv_fs_fstat(&fs_loop,
&request,
diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c
index 746429e5d5..6cab847528 100644
--- a/src/nvim/popupmnu.c
+++ b/src/nvim/popupmnu.c
@@ -999,7 +999,7 @@ static void pum_execute_menu(vimmenu_T *menu, int mode)
for (vimmenu_T *mp = menu->children; mp != NULL; mp = mp->next) {
if ((mp->modes & mp->enabled & mode) && idx++ == pum_selected) {
- memset(&ea, 0, sizeof(ea));
+ CLEAR_FIELD(ea);
execute_menu(&ea, mp, -1);
break;
}
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 99129bd15e..b7a8717ff2 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -1224,7 +1224,7 @@ static void qf_new_list(qf_info_T *qi, const char *qf_title)
qi->qf_curlist = qi->qf_listcount++;
}
qf_list_T *qfl = qf_get_curlist(qi);
- memset(qfl, 0, sizeof(qf_list_T));
+ CLEAR_POINTER(qfl);
qf_store_title(qfl, qf_title);
qfl->qfl_type = qi->qfl_type;
qfl->qf_id = ++last_qf_id;
@@ -5299,7 +5299,7 @@ static bool existing_swapfile(const buf_T *buf)
/// :{count}vimgrep /{pattern}/[g][j] {file} ...
static int vgr_process_args(exarg_T *eap, vgr_args_T *args)
{
- memset(args, 0, sizeof(*args));
+ CLEAR_POINTER(args);
args->regmatch.regprog = NULL;
args->qf_title = xstrdup(qf_cmdtitle(*eap->cmdlinep));
diff --git a/src/nvim/regexp_bt.c b/src/nvim/regexp_bt.c
index fff5ae9b7f..f79a772795 100644
--- a/src/nvim/regexp_bt.c
+++ b/src/nvim/regexp_bt.c
@@ -466,7 +466,7 @@ static void regcomp_start(char_u *expr, int re_flags) //
num_complex_braces = 0;
regnpar = 1;
- memset(had_endbrace, 0, sizeof(had_endbrace));
+ CLEAR_FIELD(had_endbrace);
regnzpar = 1;
re_has_z = 0;
regsize = 0L;
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index 1a5c250664..7f16373280 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -5055,7 +5055,7 @@ skip_add:
// avoid compiler warnings
save_ptr = NULL;
- memset(&save_multipos, 0, sizeof(save_multipos));
+ CLEAR_FIELD(save_multipos);
// Set the position (with "off" added) in the subexpression. Save
// and restore it when it was in use. Otherwise fill any gap.
@@ -5180,7 +5180,7 @@ skip_add:
save_ptr = sub->list.line[subidx].end;
sub->list.line[subidx].end = rex.input + off;
// avoid compiler warnings
- memset(&save_multipos, 0, sizeof(save_multipos));
+ CLEAR_FIELD(save_multipos);
}
subs = addstate(l, state->out, subs, pim, off_arg);
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 0d3b936c48..50bab38f64 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -2399,7 +2399,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
}
}
- memset(sattrs, 0, sizeof(sattrs));
+ CLEAR_FIELD(sattrs);
num_signs = buf_get_signattrs(wp->w_buffer, lnum, sattrs);
decor_redraw_signs(buf, lnum - 1, &num_signs, sattrs);
diff --git a/src/nvim/search.c b/src/nvim/search.c
index b9aac59e1e..4f396505e3 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -272,7 +272,7 @@ void free_search_patterns(void)
free_spat(&spats[0]);
free_spat(&spats[1]);
- memset(spats, 0, sizeof(spats));
+ CLEAR_FIELD(spats);
if (mr_pattern_alloced) {
xfree(mr_pattern);
@@ -432,7 +432,7 @@ void set_last_csearch(int c, char_u *s, int len)
if (len) {
memcpy(lastc_bytes, s, (size_t)len);
} else {
- memset(lastc_bytes, 0, sizeof(lastc_bytes));
+ CLEAR_FIELD(lastc_bytes);
}
}
@@ -4552,7 +4552,7 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, searchst
static buf_T *lbuf = NULL;
proftime_T start;
- memset(stat, 0, sizeof(searchstat_T));
+ CLEAR_POINTER(stat);
if (dirc == 0 && !recompute && !EMPTY_POS(lastpos)) {
stat->cur = cur;
@@ -5997,7 +5997,7 @@ void get_search_pattern(SearchPattern *const pat)
void get_substitute_pattern(SearchPattern *const pat)
{
memcpy(pat, &(spats[1]), sizeof(spats[1]));
- memset(&(pat->off), 0, sizeof(pat->off));
+ CLEAR_FIELD(pat->off);
}
/// Set last search pattern
@@ -6013,7 +6013,7 @@ void set_substitute_pattern(const SearchPattern pat)
{
free_spat(&spats[1]);
memcpy(&(spats[1]), &pat, sizeof(spats[1]));
- memset(&(spats[1].off), 0, sizeof(spats[1].off));
+ CLEAR_FIELD(spats[1].off);
}
/// Set last used search pattern
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index ee5322752f..daa8e99d31 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -2189,7 +2189,7 @@ static inline ShaDaWriteResult shada_read_when_writing(ShaDaReadDef *const sd_re
k = kh_put(file_marks, &wms->file_marks, fname, &kh_ret);
FileMarks *const filemarks = &kh_val(&wms->file_marks, k);
if (kh_ret > 0) {
- memset(filemarks, 0, sizeof(*filemarks));
+ CLEAR_POINTER(filemarks);
}
if (entry.timestamp > filemarks->greatest_timestamp) {
filemarks->greatest_timestamp = entry.timestamp;
@@ -2752,7 +2752,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, ShaDaReadDef
k = kh_put(file_marks, &wms->file_marks, fname, &kh_ret);
FileMarks *const filemarks = &kh_val(&wms->file_marks, k);
if (kh_ret > 0) {
- memset(filemarks, 0, sizeof(*filemarks));
+ CLEAR_POINTER(filemarks);
}
do {
fmark_T fm;
@@ -3478,7 +3478,7 @@ shada_read_next_item_start:
// data union are NULL so they are safe to xfree(). This is needed in case
// somebody calls goto shada_read_next_item_error before anything is set in
// the switch.
- memset(entry, 0, sizeof(*entry));
+ CLEAR_POINTER(entry);
if (sd_reader->eof) {
return kSDReadStatusFinished;
}
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index 7b6b55fede..a1e61a4d8c 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -490,7 +490,7 @@ int buf_get_signattrs(buf_T *buf, linenr_T lnum, sign_attrs_T sattrs[])
if (sign->se_lnum == lnum) {
sign_attrs_T sattr;
- memset(&sattr, 0, sizeof(sattr));
+ CLEAR_FIELD(sattr);
sattr.sat_typenr = sign->se_typenr;
sp = find_sign_by_typenr(sign->se_typenr);
if (sp != NULL) {
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index ceb35af4b8..64139df689 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -374,7 +374,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou
return 1;
}
- memset(&mi, 0, sizeof(matchinf_T));
+ CLEAR_FIELD(mi);
// A number is always OK. Also skip hexadecimal numbers 0xFF99 and
// 0X99FF. But always do check spelling to find "3GPP" and "11
@@ -2338,7 +2338,7 @@ theend:
// Clear the midword characters for buffer "buf".
static void clear_midword(win_T *wp)
{
- memset(wp->w_s->b_spell_ismw, 0, 256);
+ CLEAR_FIELD(wp->w_s->b_spell_ismw);
XFREE_CLEAR(wp->w_s->b_spell_ismw_mb);
}
@@ -2610,9 +2610,9 @@ void clear_spell_chartab(spelltab_T *sp)
{
int i;
- // Init everything to false.
- memset(sp->st_isw, false, sizeof(sp->st_isw));
- memset(sp->st_isu, false, sizeof(sp->st_isu));
+ // Init everything to false (zero).
+ CLEAR_FIELD(sp->st_isw);
+ CLEAR_FIELD(sp->st_isu);
for (i = 0; i < 256; i++) {
sp->st_fold[i] = (char_u)i;
@@ -3248,7 +3248,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
bool did_intern = false;
// Set the info in "*su".
- memset(su, 0, sizeof(suginfo_T));
+ CLEAR_POINTER(su);
ga_init(&su->su_ga, (int)sizeof(suggest_T), 10);
ga_init(&su->su_sga, (int)sizeof(suggest_T), 10);
if (*badptr == NUL) {
@@ -3760,7 +3760,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// word).
depth = 0;
sp = &stack[0];
- memset(sp, 0, sizeof(trystate_T)); // -V512
+ CLEAR_POINTER(sp); // -V1068
sp->ts_curi = 1;
if (soundfold) {
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 9f21e24d4c..ec419b3f28 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -4146,8 +4146,8 @@ static wordnode_T *get_wordnode(spellinfo_T *spin)
} else {
n = spin->si_first_free;
spin->si_first_free = n->wn_child;
- memset(n, 0, sizeof(wordnode_T));
- --spin->si_free_count;
+ CLEAR_POINTER(n);
+ spin->si_free_count--;
}
#ifdef SPELL_PRINTTREE
if (n != NULL) {
@@ -5282,7 +5282,7 @@ static void mkspell(int fcount, char **fnames, bool ascii, bool over_write, bool
bool error = false;
spellinfo_T spin;
- memset(&spin, 0, sizeof(spin));
+ CLEAR_FIELD(spin);
spin.si_verbose = !added_word;
spin.si_ascii = ascii;
spin.si_followup = true;
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 4ec4a57d68..dd3087dd31 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -2506,7 +2506,7 @@ static void update_si_end(stateitem_T *sip, int startcol, bool force)
static void push_current_state(int idx)
{
stateitem_T *p = GA_APPEND_VIA_PTR(stateitem_T, &current_state);
- memset(p, 0, sizeof(*p));
+ CLEAR_POINTER(p);
p->si_idx = idx;
}
@@ -4453,7 +4453,7 @@ static void syn_cmd_match(exarg_T *eap, int syncing)
// get the pattern.
init_syn_patterns();
- memset(&item, 0, sizeof(item));
+ CLEAR_FIELD(item);
rest = get_syn_pattern(rest, &item);
if (vim_regcomp_had_eol() && !(syn_opt_arg.flags & HL_EXCLUDENL)) {
syn_opt_arg.flags |= HL_HAS_EOL;
@@ -4945,7 +4945,7 @@ static int syn_add_cluster(char_u *name)
syn_cluster_T *scp = GA_APPEND_VIA_PTR(syn_cluster_T,
&curwin->w_s->b_syn_clusters);
- memset(scp, 0, sizeof(*scp));
+ CLEAR_POINTER(scp);
scp->scl_name = name;
scp->scl_name_u = vim_strsave_up(name);
scp->scl_list = NULL;
@@ -5624,8 +5624,7 @@ void ex_ownsyntax(exarg_T *eap)
char_u *new_value;
if (curwin->w_s == &curwin->w_buffer->b_s) {
- curwin->w_s = xmalloc(sizeof(synblock_T));
- memset(curwin->w_s, 0, sizeof(synblock_T));
+ curwin->w_s = xcalloc(1, sizeof(synblock_T));
hash_init(&curwin->w_s->b_keywtab);
hash_init(&curwin->w_s->b_keywtab_ic);
// TODO: Keep the spell checking as it was. NOLINT(readability/todo)
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 5b799be381..320e35a378 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -1520,7 +1520,7 @@ int find_tags(char_u *pat, int *num_matches, char ***matchesp, int flags, int mi
// This is only to avoid a compiler warning for using search_info
// uninitialised.
- memset(&search_info, 0, 1); // -V512
+ CLEAR_FIELD(search_info);
if (*curbuf->b_p_tfu != NUL && use_tfu && !tfu_in_use) {
tfu_in_use = true;
@@ -1860,7 +1860,7 @@ parse_line:
// For "normal" tags: Do a quick check if the tag matches.
// This speeds up tag searching a lot!
if (orgpat.headlen) {
- memset(&tagp, 0, sizeof(tagp));
+ CLEAR_FIELD(tagp);
tagp.tagname = lbuf;
tagp.tagname_end = (char_u *)vim_strchr((char *)lbuf, TAB);
if (tagp.tagname_end == NULL) {
@@ -2342,7 +2342,7 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf)
char_u *r_ptr;
if (first) {
- memset(tnp, 0, sizeof(tagname_T));
+ CLEAR_POINTER(tnp);
}
if (curbuf->b_help) {
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index eedad15e9e..beaf5fdcfa 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -441,6 +441,7 @@ let s:filename_checks = {
\ 'python': ['file.py', 'file.pyw', '.pythonstartup', '.pythonrc', 'file.ptl', 'file.pyi', 'SConstruct'],
\ 'ql': ['file.ql', 'file.qll'],
\ 'quake': ['anybaseq2/file.cfg', 'anyid1/file.cfg', 'quake3/file.cfg', 'baseq2/file.cfg', 'id1/file.cfg', 'quake1/file.cfg', 'some-baseq2/file.cfg', 'some-id1/file.cfg', 'some-quake1/file.cfg'],
+ \ 'quarto': ['file.qmd'],
\ 'r': ['file.r'],
\ 'radiance': ['file.rad', 'file.mat'],
\ 'raku': ['file.pm6', 'file.p6', 'file.t6', 'file.pod6', 'file.raku', 'file.rakumod', 'file.rakudoc', 'file.rakutest'],
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 39133a3275..38e8c15762 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -171,7 +171,7 @@ UI *tui_start(void)
ui->option_set = tui_option_set;
ui->raw_line = tui_raw_line;
- memset(ui->ui_ext, 0, sizeof(ui->ui_ext));
+ CLEAR_FIELD(ui->ui_ext);
ui->ui_ext[kUILinegrid] = true;
ui->ui_ext[kUITermColors] = true;
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index 45c083b034..ab3fda95dc 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -565,7 +565,7 @@ int u_savecommon(buf_T *buf, linenr_T top, linenr_T bot, linenr_T newbot, int re
* add lines in front of entry list
*/
uep = xmalloc(sizeof(u_entry_T));
- memset(uep, 0, sizeof(u_entry_T));
+ CLEAR_POINTER(uep);
#ifdef U_DEBUG
uep->ue_magic = UE_MAGIC;
#endif
@@ -895,7 +895,7 @@ static bool serialize_uhp(bufinfo_T *bi, u_header_T *uhp)
static u_header_T *unserialize_uhp(bufinfo_T *bi, const char *file_name)
{
u_header_T *uhp = xmalloc(sizeof(u_header_T));
- memset(uhp, 0, sizeof(u_header_T));
+ CLEAR_POINTER(uhp);
#ifdef U_DEBUG
uhp->uh_magic = UH_MAGIC;
#endif
@@ -1083,7 +1083,7 @@ static bool serialize_uep(bufinfo_T *bi, u_entry_T *uep)
static u_entry_T *unserialize_uep(bufinfo_T *bi, bool *error, const char *file_name)
{
u_entry_T *uep = xmalloc(sizeof(u_entry_T));
- memset(uep, 0, sizeof(u_entry_T));
+ CLEAR_POINTER(uep);
#ifdef U_DEBUG
uep->ue_magic = UE_MAGIC;
#endif
@@ -1183,7 +1183,6 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf,
FILE *fp = NULL;
int perm;
bool write_ok = false;
- bufinfo_T bi;
if (name == NULL) {
file_name = u_get_undo_file_name(buf->b_ffname, false);
@@ -1310,11 +1309,11 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf,
// Undo must be synced.
u_sync(true);
- /*
- * Write the header.
- */
- bi.bi_buf = buf;
- bi.bi_fp = fp;
+ // Write the header.
+ bufinfo_T bi = {
+ .bi_buf = buf,
+ .bi_fp = fp,
+ };
if (!serialize_header(&bi, hash)) {
goto write_error;
}
@@ -1437,9 +1436,10 @@ void u_read_undo(char *name, const char_u *hash, const char_u *orig_name FUNC_AT
goto error;
}
- bufinfo_T bi;
- bi.bi_buf = curbuf;
- bi.bi_fp = fp;
+ bufinfo_T bi = {
+ .bi_buf = curbuf,
+ .bi_fp = fp,
+ };
// Read the undo file header.
char_u magic_buf[UF_START_MAGIC_LEN];
diff --git a/src/nvim/vim.h b/src/nvim/vim.h
index 31ac5a67ff..b2c7df4cbb 100644
--- a/src/nvim/vim.h
+++ b/src/nvim/vim.h
@@ -199,6 +199,7 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
// Size in bytes of the hash used in the undo file.
#define UNDO_HASH_SIZE 32
+#define CLEAR_FIELD(field) memset(&(field), 0, sizeof(field))
#define CLEAR_POINTER(ptr) memset((ptr), 0, sizeof(*(ptr)))
// defines to avoid typecasts from (char_u *) to (char *) and back
diff --git a/src/nvim/window.c b/src/nvim/window.c
index b737215616..71ada3a604 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -1270,7 +1270,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
wp->w_floating = false;
// non-floating window doesn't store float config or have a border.
wp->w_float_config = FLOAT_CONFIG_INIT;
- memset(wp->w_border_adj, 0, sizeof(wp->w_border_adj));
+ CLEAR_FIELD(wp->w_border_adj);
}
/*
@@ -5175,7 +5175,7 @@ void win_free_grid(win_T *wp, bool reinit)
grid_free(&wp->w_grid_alloc);
if (reinit) {
// if a float is turned into a split, the grid data structure will be reused
- memset(&wp->w_grid_alloc, 0, sizeof(wp->w_grid_alloc));
+ CLEAR_FIELD(wp->w_grid_alloc);
}
}
@@ -7095,7 +7095,7 @@ int switch_win(switchwin_T *switchwin, win_T *win, tabpage_T *tp, bool no_displa
// As switch_win() but without blocking autocommands.
int switch_win_noblock(switchwin_T *switchwin, win_T *win, tabpage_T *tp, bool no_display)
{
- memset(switchwin, 0, sizeof(switchwin_T));
+ CLEAR_POINTER(switchwin);
switchwin->sw_curwin = curwin;
if (win == curwin) {
switchwin->sw_same_win = true;
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index fe623ff824..3338fc6538 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -3829,5 +3829,12 @@ describe('API', function()
eq({'aa'}, meths.buf_get_lines(0, 0, 1, false))
assert_alive()
end)
+ it("'make' command works when argument count isn't 1 #19696", function()
+ command('set makeprg=echo')
+ meths.cmd({ cmd = 'make' }, {})
+ assert_alive()
+ meths.cmd({ cmd = 'make', args = { 'foo', 'bar' } }, {})
+ assert_alive()
+ end)
end)
end)