aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/autoload/freebasic.vim7
-rw-r--r--runtime/doc/api.txt1
-rw-r--r--runtime/doc/filetype.txt20
-rw-r--r--runtime/doc/quickfix.txt3
-rw-r--r--runtime/doc/syntax.txt15
-rw-r--r--runtime/ftplugin/basic.vim13
-rw-r--r--runtime/ftplugin/fetchmail.vim15
-rw-r--r--runtime/ftplugin/freebasic.vim32
-rw-r--r--runtime/ftplugin/vue.vim24
-rw-r--r--runtime/syntax/basic.vim4
-rw-r--r--runtime/syntax/fetchmail.vim110
-rw-r--r--runtime/syntax/freebasic.vim685
-rw-r--r--src/nvim/api/command.c7
-rw-r--r--src/nvim/api/keysets.lua1
-rw-r--r--src/nvim/autocmd.c6
-rw-r--r--src/nvim/buffer.c167
-rw-r--r--src/nvim/buffer_defs.h26
-rw-r--r--src/nvim/change.c60
-rw-r--r--src/nvim/charset.c16
-rw-r--r--src/nvim/cursor_shape.c2
-rw-r--r--src/nvim/debugger.c2
-rw-r--r--src/nvim/diff.c6
-rw-r--r--src/nvim/digraph.c2
-rw-r--r--src/nvim/edit.c38
-rw-r--r--src/nvim/eval.c8
-rw-r--r--src/nvim/eval/funcs.c37
-rw-r--r--src/nvim/eval/typval.c4
-rw-r--r--src/nvim/eval/userfunc.c14
-rw-r--r--src/nvim/event/loop.c2
-rw-r--r--src/nvim/event/loop.h2
-rw-r--r--src/nvim/event/process.c2
-rw-r--r--src/nvim/ex_cmds.c54
-rw-r--r--src/nvim/ex_cmds2.c24
-rw-r--r--src/nvim/ex_docmd.c119
-rw-r--r--src/nvim/ex_getln.c29
-rw-r--r--src/nvim/ex_session.c20
-rw-r--r--src/nvim/file_search.c13
-rw-r--r--src/nvim/fileio.c67
-rw-r--r--src/nvim/fold.c533
-rw-r--r--src/nvim/globals.h11
-rw-r--r--src/nvim/hardcopy.c5
-rw-r--r--src/nvim/hashtab.c4
-rw-r--r--src/nvim/indent.c8
-rw-r--r--src/nvim/indent_c.c14
-rw-r--r--src/nvim/lua/executor.c4
-rw-r--r--src/nvim/lua/stdlib.c4
-rw-r--r--src/nvim/main.c10
-rw-r--r--src/nvim/mapping.c4
-rw-r--r--src/nvim/mark.c14
-rw-r--r--src/nvim/match.c2
-rw-r--r--src/nvim/mbyte.c5
-rw-r--r--src/nvim/memline.c28
-rw-r--r--src/nvim/message.c26
-rw-r--r--src/nvim/msgpack_rpc/channel.c11
-rw-r--r--src/nvim/normal.c2
-rw-r--r--src/nvim/ops.c26
-rw-r--r--src/nvim/option.c32
-rw-r--r--src/nvim/os/env.c11
-rw-r--r--src/nvim/os/fs.c2
-rw-r--r--src/nvim/path.c54
-rw-r--r--src/nvim/quickfix.c17
-rw-r--r--src/nvim/regexp.c4
-rw-r--r--src/nvim/runtime.c18
-rw-r--r--src/nvim/screen.c6
-rw-r--r--src/nvim/search.c18
-rw-r--r--src/nvim/shada.c18
-rw-r--r--src/nvim/sign.c21
-rw-r--r--src/nvim/spell.c27
-rw-r--r--src/nvim/spellfile.c47
-rw-r--r--src/nvim/syntax.c10
-rw-r--r--src/nvim/tag.c23
-rw-r--r--src/nvim/terminal.c2
-rw-r--r--src/nvim/testdir/test_buffer.vim154
-rw-r--r--src/nvim/testdir/test_cmdline.vim74
-rw-r--r--src/nvim/testdir/test_exists.vim4
-rw-r--r--src/nvim/testdir/test_filechanged.vim16
-rw-r--r--src/nvim/testdir/test_history.vim51
-rw-r--r--src/nvim/testdir/test_mapping.vim1
-rw-r--r--src/nvim/testdir/test_marks.vim9
-rw-r--r--src/nvim/testdir/test_menu.vim36
-rw-r--r--src/nvim/testdir/test_normal.vim17
-rw-r--r--src/nvim/testdir/test_plus_arg_edit.vim13
-rw-r--r--src/nvim/testdir/test_quickfix.vim9
-rw-r--r--src/nvim/testdir/test_spell.vim15
-rw-r--r--src/nvim/testdir/test_spell_utf8.vim7
-rw-r--r--src/nvim/testdir/test_visual.vim12
-rw-r--r--src/nvim/undo.c13
-rw-r--r--src/nvim/window.c15
-rw-r--r--test/functional/api/command_spec.lua13
-rw-r--r--test/functional/api/vim_spec.lua61
90 files changed, 2033 insertions, 1165 deletions
diff --git a/runtime/autoload/freebasic.vim b/runtime/autoload/freebasic.vim
index 428cf1382b..6c94cd34ea 100644
--- a/runtime/autoload/freebasic.vim
+++ b/runtime/autoload/freebasic.vim
@@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: FreeBASIC
" Maintainer: Doug Kearns <dougkearns@gmail.com>
-" Last Change: 2021 Mar 16
+" Last Change: 2022 June 24
" Dialects can be one of fb, qb, fblite, or deprecated
" Precedence is forcelang > #lang > lang
@@ -18,17 +18,16 @@ function! freebasic#GetDialect() abort
" override with #lang directive or metacommand
- let skip = "has('syntax_items') && synIDattr(synID(line('.'), col('.'), 1), 'name') =~ 'Comment$'"
let pat = '\c^\s*\%(#\s*lang\s\+\|''\s*$lang\s*:\s*\)"\([^"]*\)"'
let save_cursor = getcurpos()
call cursor(1, 1)
- let lnum = search(pat, 'n', '', '', skip)
+ let lnum = search(pat, 'cn')
call setpos('.', save_cursor)
if lnum
let word = matchlist(getline(lnum), pat)[1]
- if word =~? '\%(fb\|deprecated\|fblite\|qb\)'
+ if word =~? '\<\%(fb\|deprecated\|fblite\|qb\)\>'
let dialect = word
else
echomsg "freebasic#GetDialect: Invalid lang, found '" .. word .. "' at line " .. lnum .. " " .. getline(lnum)
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 9b7f1f1632..c67187d857 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -1951,6 +1951,7 @@ nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()*
• silent: (boolean) |:silent|.
• emsg_silent: (boolean) |:silent!|.
+ • unsilent: (boolean) |:unsilent|.
• sandbox: (boolean) |:sandbox|.
• noautocmd: (boolean) |:noautocmd|.
• browse: (boolean) |:browse|.
diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt
index c2f9411f72..7f88216f43 100644
--- a/runtime/doc/filetype.txt
+++ b/runtime/doc/filetype.txt
@@ -553,12 +553,31 @@ Options:
For further discussion of fortran_have_tabs and the method used for the
detection of source format see |ft-fortran-syntax|.
+
+FREEBASIC *ft-freebasic-plugin*
+
+This plugin aims to treat the four FreeBASIC dialects, "fb", "qb", "fblite"
+and "deprecated", as distinct languages.
+
+The dialect will be set to the first name found in g:freebasic_forcelang, any
+#lang directive or $lang metacommand in the file being edited, or finally
+g:freebasic_lang. These global variables conceptually map to the fbc options
+-forcelang and -lang. If no dialect is explicitly specified "fb" will be
+used.
+
+For example, to set the dialect to a default of "fblite" but still allow for
+any #lang directive overrides, use the following command: >
+
+ let g:freebasic_lang = "fblite"
+
+
GIT COMMIT *ft-gitcommit-plugin*
One command, :DiffGitCached, is provided to show a diff of the current commit
in the preview window. It is equivalent to calling "git diff --cached" plus
any arguments given to the command.
+
GPROF *ft-gprof-plugin*
The gprof filetype plugin defines a mapping <C-]> to jump from a function
@@ -568,6 +587,7 @@ to the details of that function in the call graph.
The mapping can be disabled with: >
let g:no_gprof_maps = 1
+
MAIL *ft-mail-plugin*
Options:
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 8e91b101cd..dab3bfa280 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -556,6 +556,9 @@ pattern is used.
The |:Lfilter| command does the same as |:Cfilter| but operates on the current
location list.
+The current quickfix/location list is not modified by these commands, so you
+can go back to the unfiltered list using the |:colder|/|:lolder| command.
+
=============================================================================
2. The error window *quickfix-window*
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 3c3792ad0b..9ed3c37b8c 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -1659,6 +1659,21 @@ because Fortran90 has no reserved words.
For further information related to fortran, see |ft-fortran-indent| and
|ft-fortran-plugin|.
+FREEBASIC *freebasic.vim* *ft-freebasic-syntax*
+
+FreeBASIC files will be highlighted differently for each of the four available
+dialects, "fb", "qb", "fblite" and "deprecated". See |ft-freebasic-plugin|
+for how to select the correct dialect.
+
+Highlighting is further configurable via the following variables.
+
+Variable Highlight ~
+*freebasic_no_comment_fold* disable multiline comment folding
+*freebasic_operators* non-alpha operators
+*freebasic_space_errors* trailing white space and spaces before a <Tab>
+*freebasic_type_suffixes* QuickBASIC style type suffixes
+
+
FVWM CONFIGURATION FILES *fvwm.vim* *ft-fvwm-syntax*
diff --git a/runtime/ftplugin/basic.vim b/runtime/ftplugin/basic.vim
index a8f6b088d1..4399fbf3ad 100644
--- a/runtime/ftplugin/basic.vim
+++ b/runtime/ftplugin/basic.vim
@@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: BASIC (QuickBASIC 4.5)
" Maintainer: Doug Kearns <dougkearns@gmail.com>
-" Last Change: 2021 Mar 16
+" Last Change: 2022 Jun 22
if exists("b:did_ftplugin")
finish
@@ -15,6 +15,8 @@ setlocal comments=:REM\ ,:Rem\ ,:rem\ ,:'
setlocal commentstring='\ %s
setlocal formatoptions-=t formatoptions+=croql
+let b:undo_ftplugin = "setl fo< com< cms<"
+
" TODO: support exit ... as middle matches?
if exists("loaded_matchit") && !exists("b:match_words")
let s:line_start = '\%(^\s*\)\@<='
@@ -33,10 +35,11 @@ if exists("loaded_matchit") && !exists("b:match_words")
\ '\<while\>:\<wend\>,' ..
\ s:line_start .. 'if\%(.*\<then\s*\%($\|''\)\)\@=:\<\%(' .. s:line_start .. 'else\|elseif\)\>:\<end\s\+if\>,' ..
\ '\<lock\>:\<unlock\>'
-
let b:match_skip = 'synIDattr(synID(line("."),col("."),1),"name") =~? "comment\\|string" || ' ..
\ 'strpart(getline("."), 0, col(".") ) =~? "\\<exit\\s\\+"'
+ let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_skip b:match_words"
+
unlet s:line_start s:not_end s:not_end_or_exit
endif
@@ -44,12 +47,10 @@ if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
let b:browsefilter = "BASIC Source Files (*.bas)\t*.bas\n" ..
\ "BASIC Include Files (*.bi, *.bm)\t*.bi;*.bm\n" ..
\ "All Files (*.*)\t*.*\n"
+ let b:basic_set_browsefilter = 1
+ let b:undo_ftplugin ..= " | unlet! b:browsefilter b:basic_set_browsefilter"
endif
-let b:undo_ftplugin = "setl fo< com< cms<" ..
- \ " | unlet! b:match_ignorecase b:match_skip b:match_words" ..
- \ " | unlet! b:browsefilter"
-
let &cpo = s:cpo_save
unlet s:cpo_save
diff --git a/runtime/ftplugin/fetchmail.vim b/runtime/ftplugin/fetchmail.vim
index 33bb417be4..032f6610f9 100644
--- a/runtime/ftplugin/fetchmail.vim
+++ b/runtime/ftplugin/fetchmail.vim
@@ -1,19 +1,16 @@
" Vim filetype plugin file
-" Language: fetchmail(1) RC File
-" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2008-07-09
+" Language: fetchmail(1) RC File
+" Maintainer: Doug Kearns <dougkearns@gmail.com>
+" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
+" Latest Revision: 2022 Jun 30
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1
-let s:cpo_save = &cpo
-set cpo&vim
+setlocal comments=:# commentstring=#\ %s
+setlocal formatoptions-=t formatoptions+=croql
let b:undo_ftplugin = "setl com< cms< fo<"
-setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
-
-let &cpo = s:cpo_save
-unlet s:cpo_save
diff --git a/runtime/ftplugin/freebasic.vim b/runtime/ftplugin/freebasic.vim
index 58c2b4c9e2..1680e84c9c 100644
--- a/runtime/ftplugin/freebasic.vim
+++ b/runtime/ftplugin/freebasic.vim
@@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: FreeBASIC
" Maintainer: Doug Kearns <dougkearns@gmail.com>
-" Last Change: 2021 Mar 16
+" Last Change: 2022 Jun 24
" Setup {{{1
if exists("b:did_ftplugin")
@@ -21,7 +21,8 @@ let &l:comments = "sO:*\ -,mO:*\ \ ,exO:*/,s1:/',mb:',ex:'/,:''," .. &l:comments
" Match words {{{1
if exists("loaded_matchit")
- let s:not_end = '\%(end\s\+\)\@<!'
+ let s:line_start = '\%(^\s*\)\@<='
+ let s:not_end = '\%(end\s\+\)\@<!'
let b:match_words ..= ','
@@ -49,17 +50,32 @@ if exists("loaded_matchit")
endif
let b:match_words ..= s:not_end .. '\<enum\>:\<end\s\+enum\>,' ..
- \ '^#\s*\%(if\|ifdef\|ifndef\)\>:^#\s*\%(else\|elseif\)\>:^#\s*endif\>,' ..
- \ '^#\s*macro\>:^#\s*endmacro\>'
+ \ s:line_start .. '#\s*\%(if\|ifdef\|ifndef\)\>:' ..
+ \ s:line_start .. '#\s*\%(else\|elseif\)\>:' ..
+ \ s:line_start .. '#\s*endif\>,' ..
+ \ s:line_start .. '#\s*macro\>:' .. s:line_start .. '#\s*endmacro\>,' ..
+ \ "/':'/"
- " skip "function = <retval>"
- let b:match_skip ..= '|| strpart(getline("."), col(".") - 1) =~? "^\\<function\\s\\+="'
+ " skip "function = <retval>" and "continue { do | for | while }"
+ if s:dialect == "qb"
+ let s:continue = "__continue"
+ else
+ let s:continue = "continue"
+ endif
+ let b:match_skip ..= ' || strpart(getline("."), col(".") - 1) =~? "^\\<function\\s\\+="' ..
+ \ ' || strpart(getline("."), 0, col(".") ) =~? "\\<' .. s:continue .. '\\s\\+"'
+
+ unlet s:not_end s:line_start
+endif
- unlet s:not_end
+if (has("gui_win32") || has("gui_gtk")) && exists("b:basic_set_browsefilter")
+ let b:browsefilter = "FreeBASIC Source Files (*.bas)\t*.bas\n" ..
+ \ "FreeBASIC Header Files (*.bi)\t*.bi\n" ..
+ \ "All Files (*.*)\t*.*\n"
endif
" Cleanup {{{1
let &cpo = s:cpo_save
-unlet s:cpo_save
+unlet s:cpo_save s:dialect
" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker:
diff --git a/runtime/ftplugin/vue.vim b/runtime/ftplugin/vue.vim
new file mode 100644
index 0000000000..e8833742ad
--- /dev/null
+++ b/runtime/ftplugin/vue.vim
@@ -0,0 +1,24 @@
+" Vim filetype plugin file
+" Language: vue
+
+if exists("b:did_ftplugin") | finish | endif
+let b:did_ftplugin = 1
+
+" Make sure the continuation lines below do not cause problems in
+" compatibility mode.
+let s:save_cpo = &cpo
+set cpo-=C
+
+" Copied from ftplugin/html.vim
+" Original thanks to Johannes Zellner and Benji Fisher.
+if exists("loaded_matchit")
+ let b:match_ignorecase = 1
+ let b:match_words = '<:>,'
+ \ .. '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,'
+ \ .. '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,'
+ \ .. '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
+endif
+
+" Restore the saved compatibility options.
+let &cpo = s:save_cpo
+unlet s:save_cpo
diff --git a/runtime/syntax/basic.vim b/runtime/syntax/basic.vim
index 7fe411a869..b6bf23a3ed 100644
--- a/runtime/syntax/basic.vim
+++ b/runtime/syntax/basic.vim
@@ -3,7 +3,7 @@
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Previous Maintainer: Allan Kelly <allan@fruitloaf.co.uk>
" Contributors: Thilo Six
-" Last Change: 2021 Aug 08
+" Last Change: 2022 Jun 22
" First version based on Micro$soft QBASIC circa 1989, as documented in
" 'Learn BASIC Now' by Halvorson&Rygmyr. Microsoft Press 1989.
@@ -344,7 +344,7 @@ hi def link basicCommentError Error
hi def link basicDataString basicString
hi def link basicFilenumber basicTypeSuffix " TODO: better group
hi def link basicFloat Float
-hi def link basicFunction Identifier
+hi def link basicFunction Function
hi def link basicKeyword Keyword
hi def link basicLineIdentifier LineNr
hi def link basicLineContinuation Special
diff --git a/runtime/syntax/fetchmail.vim b/runtime/syntax/fetchmail.vim
index 7a421050d0..f9c8e0112f 100644
--- a/runtime/syntax/fetchmail.vim
+++ b/runtime/syntax/fetchmail.vim
@@ -1,7 +1,10 @@
" Vim syntax file
-" Language: fetchmail(1) RC File
-" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2006-04-19
+" Language: fetchmail(1) RC File
+" Maintainer: Doug Kearns <dougkearns@gmail.com>
+" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
+" Latest Revision: 2022 Jun 30
+
+" Version 6.4.3
if exists("b:current_syntax")
finish
@@ -10,64 +13,69 @@ endif
let s:cpo_save = &cpo
set cpo&vim
-syn keyword fetchmailTodo contained FIXME TODO XXX NOTE
+syn keyword fetchmailTodo contained FIXME TODO XXX NOTE
-syn region fetchmailComment start='#' end='$' contains=fetchmailTodo,@Spell
+syn region fetchmailComment start='#' end='$' contains=fetchmailTodo,@Spell
-syn match fetchmailNumber display '\<\d\+\>'
+syn match fetchmailNumber display '\<\d\+\>'
-syn region fetchmailString start=+"+ skip=+\\\\\|\\"+ end=+"+
- \ contains=fetchmailStringEsc
-syn region fetchmailString start=+'+ skip=+\\\\\|\\'+ end=+'+
- \ contains=fetchmailStringEsc
+syn region fetchmailString start=+"+ skip=+\\\\\|\\"+ end=+"+
+ \ contains=fetchmailStringEsc
+syn region fetchmailString start=+'+ skip=+\\\\\|\\'+ end=+'+
+ \ contains=fetchmailStringEsc
-syn match fetchmailStringEsc contained '\\\([ntb]\|0\d*\|x\x\+\)'
+syn match fetchmailStringEsc contained '\\\([ntb]\|0\d*\|x\x\+\)'
-syn region fetchmailKeyword transparent matchgroup=fetchmailKeyword
- \ start='\<poll\|skip\|defaults\>'
- \ end='\<poll\|skip\|defaults\>'
- \ contains=ALLBUT,fetchmailOptions,fetchmailSet
+syn region fetchmailKeyword transparent matchgroup=fetchmailKeyword
+ \ start='\<poll\|skip\|defaults\>'
+ \ end='\<poll\|skip\|defaults\>'
+ \ contains=ALLBUT,fetchmailOptions,fetchmailSet
syn keyword fetchmailServerOpts contained via proto[col] local[domains] port
- \ auth[enticate] timeout envelope qvirtual aka
- \ interface monitor plugin plugout dns
- \ checkalias uidl interval netsec principal
- \ esmtpname esmtppassword
- \ sslcertck sslcertpath sslfingerprint
+ \ service auth[enticate] timeout envelope
+ \ qvirtual aka interface monitor plugin plugout
+ \ dns checkalias uidl interval tracepolls
+ \ principal esmtpname esmtppassword
+" removed in 6.3.0
+syn keyword fetchmailServerOpts contained netsec
+syn match fetchmailServerOpts contained '\<bad-header\>'
syn match fetchmailServerOpts contained '\<no\_s\+\(envelope\|dns\|checkalias\|uidl\)'
-syn keyword fetchmailUserOpts contained user[name] is to pass[word] ssl
- \ sslcert sslkey sslproto folder smtphost
- \ fetchdomains smtpaddress smtpname antispam
- \ mda bsmtp preconnect postconnect keep flush
- \ fetchall rewrite stripcr forcecr pass8bits
- \ dropstatus dropdelivered mimedecode idle
- \ limit warnings batchlimit fetchlimit expunge
- \ tracepolls properties
-syn match fetchmailUserOpts contained '\<no\_s\+\(keep\|flush\|fetchall\|rewrite\|stripcr\|forcecr\|pass8bits\|dropstatus\|dropdelivered\|mimedecode\|noidle\)'
-
-syn keyword fetchmailSpecial contained here there
-
-syn keyword fetchmailNoise and with has wants options
-syn match fetchmailNoise display '[:;,]'
-
-syn keyword fetchmailSet nextgroup=fetchmailOptions skipwhite skipnl set
-
-syn keyword fetchmailOptions daemon postmaster bouncemail spambounce logfile
- \ idfile syslog nosyslog properties
-syn match fetchmailOptions '\<no\_s\+\(bouncemail\|spambounce\)'
-
-hi def link fetchmailComment Comment
-hi def link fetchmailTodo Todo
-hi def link fetchmailNumber Number
-hi def link fetchmailString String
-hi def link fetchmailStringEsc SpecialChar
-hi def link fetchmailKeyword Keyword
+syn keyword fetchmailUserOpts contained user[name] is to pass[word] ssl
+ \ sslcert sslcertck sslcertfile sslcertpath
+ \ sslfingerprint sslkey sslproto folder
+ \ smtphost fetchdomains smtpaddress smtpname
+ \ antispam mda bsmtp preconnect postconnect
+ \ keep flush limitflush fetchall rewrite
+ \ stripcr forcecr pass8bits dropstatus
+ \ dropdelivered mimedecode idle limit warnings
+ \ batchlimit fetchlimit fetchsizelimit
+ \ fastuidl expunge properties
+ \ sslcommonname
+syn match fetchmailUserOpts contained '\<no\_s\+\(sslcertck\|keep\|flush\|fetchall\|rewrite\|stripcr\|forcecr\|pass8bits\|dropstatus\|dropdelivered\|mimedecode\|idle\)'
+
+syn keyword fetchmailSpecial contained here there
+
+syn keyword fetchmailNoise and with has wants options
+syn match fetchmailNoise display '[:;,]'
+
+syn keyword fetchmailSet nextgroup=fetchmailOptions skipwhite skipnl set
+
+syn keyword fetchmailOptions daemon postmaster bouncemail spambounce
+ \ softbounce logfile idfile syslog properties
+syn match fetchmailOptions '\<no\_s\+\(bouncemail\|spambounce\|softbounce\|syslog\)'
+
+hi def link fetchmailComment Comment
+hi def link fetchmailTodo Todo
+hi def link fetchmailNumber Number
+hi def link fetchmailString String
+hi def link fetchmailStringEsc SpecialChar
+hi def link fetchmailKeyword Keyword
hi def link fetchmailServerOpts Identifier
-hi def link fetchmailUserOpts Identifier
-hi def link fetchmailSpecial Special
-hi def link fetchmailSet Keyword
-hi def link fetchmailOptions Identifier
+hi def link fetchmailUserOpts Identifier
+hi def link fetchmailSpecial Special
+hi def link fetchmailSet Keyword
+hi def link fetchmailOptions Identifier
let b:current_syntax = "fetchmail"
diff --git a/runtime/syntax/freebasic.vim b/runtime/syntax/freebasic.vim
index 68e838f393..7549d02555 100644
--- a/runtime/syntax/freebasic.vim
+++ b/runtime/syntax/freebasic.vim
@@ -1,14 +1,14 @@
" Vim syntax file
-" Language: FreeBasic
-" Maintainer: Mark Manning <markem@sim1.us>
-" Updated: 10/9/2019
-" Version: 7.0b
+" Language: FreeBASIC
+" Maintainer: Doug Kearns <dougkearns@gmail.com>
+" Previous Maintainer: Mark Manning <markem@sim1.us>
+" Last Change: 2022 Jun 26
"
" Description:
"
" Based originally on the work done by Allan Kelly <Allan.Kelly@ed.ac.uk>
" Updated by Mark Manning <markem@sim1.us>
-" Applied FreeBasic support to the already excellent support
+" Applied FreeBASIC support to the already excellent support
" for standard basic syntax (like QB).
"
" First version based on Micro$soft QBASIC circa
@@ -17,215 +17,595 @@
" not a complete implementation yet. Send suggestions to
" the maintainer.
"
+" TODO: split this into separate dialect-based files, possibly with a common base
+"
" Quit when a (custom) syntax file was already loaded (Taken from c.vim)
"
if exists("b:current_syntax")
finish
endif
"
+" Dialect detection
+"
+let s:lang = freebasic#GetDialect()
+"
+" Whitespace Errors
+"
+if exists("freebasic_space_errors")
+ if !exists("freebasic_no_trail_space_error")
+ syn match freebasicSpaceError display excludenl "\s\+$"
+ endif
+ if !exists("freebasic_no_tab_space_error")
+ syn match freebasicSpaceError display " \+\t"me=e-1
+ endif
+endif
+"
" Be sure to turn on the "case ignore" since current versions
" of freebasic support both upper as well as lowercase
" letters. - MEM 10/1/2006
"
syn case ignore
"
-" This list of keywords is taken directly from the FreeBasic
-" user's guide as presented by the FreeBasic online site.
+" Do the Basic variables names first. This is because it
+" is the most inclusive of the tests. Later on we change
+" this so the identifiers are split up into the various
+" types of identifiers like functions, basic commands and
+" such. MEM 9/9/2006
+"
+if s:lang =~# '\<\%(qb\|fblite\)\>'
+ syn iskeyword @,48-57,_,192-255,.
+ syn match freebasicIdentifier "\<\h\%(\w\|\.\)*\>"
+ syn match freebasicGenericFunction "\<\h\%(\w\|\.\)*\>\ze\s*("
+else
+ syn iskeyword @,48-57,_,192-255
+ syn match freebasicIdentifier "\<\h\w*\>"
+ syn match freebasicGenericFunction "\<\h\w*\>\ze\s*("
+endif
+"
+" This list of keywords is taken directly from the FreeBASIC
+" user's guide as presented by the FreeBASIC online site.
"
-syn keyword freebasicArrays ERASE LBOUND REDIM PRESERVE UBOUND
+syn keyword freebasicArrays ERASE LBOUND PRESERVE REDIM UBOUND
-syn keyword freebasicBitManipulation BIT BITRESET BITSET HIBYTE HIWORD LOBYTE LOWORD SHL SHR
+" array.bi
+syn keyword freebasicArrays ARRAYLEN ARRAYSIZE
+if s:lang == "fb"
+ syn keyword freebasicArrays ArrayConstDescriptorPtr ArrayDescriptorPtr FBARRAY
+endif
-syn keyword freebasicCompilerSwitches DEFBYTE DEFDBL DEFINT DEFLNG DEFLNGINT DEFSHORT DEFSNG DEFSTR
-syn keyword freebasicCompilerSwitches DEFUBYTE DEFUINT DEFULNGINT DEFUSHORT
-syn match freebasicCompilerSwitches "\<option\s+\(BASE\|BYVAL\|DYNAMIC\|ESCAPE\|EXPLICIT\|NOKEYWORD\)\>"
-syn match freebasicCompilerSwitches "\<option\s+\(PRIVATE\|STATIC\)\>"
+if s:lang == "qb"
+ syn keyword freebasicAsm __ASM
+ syn match freebasicAsm "\<end\s\+__asm\>"
+else
+ syn keyword freebasicAsm ASM
+ syn match freebasicAsm "\<end\s\+asm\>"
+endif
-syn region freebasicConditional start="\son\s+" skip=".*" end="gosub"
-syn region freebasicConditional start="\son\s+" skip=".*" end="goto"
-syn match freebasicConditional "\<select\s+case\>"
-syn keyword freebasicConditional if iif then case else elseif with
+if s:lang == "qb"
+ syn keyword freebasicBitManipulation __BIT __BITRESET __BITSET __HIBYTE __HIWORD __LOBYTE __LOWORD
+else
+ syn keyword freebasicBitManipulation BIT BITRESET BITSET HIBYTE HIWORD LOBYTE LOWORD
+endif
-syn match freebasicConsole "\<open\s+\(CONS\|ERR\|PIPE\|SCRN\)\>"
-syn keyword freebasicConsole BEEP CLS CSRLIN LOCATE PRINT POS SPC TAB VIEW WIDTH
+if s:lang != "fb"
+ syn keyword freebasicCompilerSwitches DEFDBL DEFINT DEFLNG DEFSNG DEFSTR
+endif
+if s:lang == "qb"
+ syn keyword freebasicCompilerSwitches __DEFBYTE __DEFLONGINT __DEFSHORT __DEFUBYTE __DEFUINT __DEFULONGINT __DEFUSHORT
+elseif s:lang == "fblite" || s:lang == "deprecated"
+ syn keyword freebasicCompilerSwitches DEFBYTE DEFLONGINT DEFSHORT DEFUBYTE DEFUINT DEFUILONGINT DEFUSHORT
+endif
-syn keyword freebasicDataTypes BYTE AS DIM CONST DOUBLE ENUM INTEGER LONG LONGINT SHARED SHORT STRING
-syn keyword freebasicDataTypes SINGLE TYPE UBYTE UINTEGER ULONGINT UNION UNSIGNED USHORT WSTRING ZSTRING
+syn match freebasicCompilerSwitches "\<option\s\+\%(BASE\|BYVAL\|DYNAMIC\|ESCAPE\|EXPLICIT\|GOSUB\|NOGOSUB\)\>"
+syn match freebasicCompilerSwitches "\<option\s\+\%(NOKEYWORD\|PRIVATE\|STATIC\)\>"
-syn keyword freebasicDateTime DATE DATEADD DATEDIFF DATEPART DATESERIAL DATEVALUE DAY HOUR MINUTE
-syn keyword freebasicDateTime MONTH MONTHNAME NOW SECOND SETDATE SETTIME TIME TIMESERIAL TIMEVALUE
-syn keyword freebasicDateTime TIMER YEAR WEEKDAY WEEKDAYNAME
+syn keyword freebasicData DATA READ RESTORE
-syn keyword freebasicDebug ASSERT STOP
+syn keyword freebasicProgramFlow EXIT GOTO RETURN SLEEP
+syn match freebasicProgramFlow "\<end\>"
+if s:lang == "qb"
+ syn keyword freebasicProgramFlow __SLEEP
+endif
+if s:lang == "fblite" || s:lang == "qb"
+ syn keyword freebasicProgramFlow GOSUB
+endif
+if s:lang == "fb" || s:lang == "deprecated"
+ syn keyword freebasicProgramFlow SCOPE
+ syn match freebasicProgramFlow "\<end\s\+scope\>"
+endif
-syn keyword freebasicErrorHandling ERR ERL ERROR LOCAL RESUME
-syn match freebasicErrorHandling "\<resume\s+next\>"
-syn match freebasicErrorHandling "\<on\s+error\>"
+if s:lang == "fblite" || s:lang == "qb"
+ syn region freebasicConditional matchgroup=freebasicConditional start="\<on\>" end="\<gosub\>" transparent
+ syn region freebasicConditional matchgroup=freebasicConditional start="\<on\>" end="\<goto\>" transparent
+endif
+syn keyword freebasicConditional IF THEN ELSE ELSEIF
+if s:lang == "qb"
+ syn keyword freebasicConditional __IIF __WITH
+ syn match freebasicConditional "\<end\s\+__with\>"
+else
+ syn keyword freebasicConditional IIF WITH
+ syn match freebasicConditional "\<end\s\+with\>"
+endif
+syn match freebasicConditional "\<end\s\+if\>"
+syn match freebasicConditional "\<select\s\+case\>"
+syn match freebasicConditional "\<case\>"
+syn match freebasicConditional "\<case\s\+is\>"
+syn match freebasicConditional "\<end\s\+select\>"
-syn match freebasicFiles "\<get\s+#\>"
-syn match freebasicFiles "\<input\s+#\>"
-syn match freebasicFiles "\<line\s+input\s+#\>"
-syn match freebasicFiles "\<put\s+#\>"
-syn keyword freebasicFiles ACCESS APPEND BINARY BLOAD BSAVE CLOSE EOF FREEFILE INPUT LOC
-syn keyword freebasicFiles LOCK LOF OPEN OUTPUT RANDOM RESET SEEK UNLOCK WRITE
+syn keyword freebasicConsole BEEP CLS CSRLIN LOCATE PRINT POS SPC TAB USING VIEW WIDTH
+syn match freebasicConsole "?"
-syn keyword freebasicFunctions ALIAS ANY BYREF BYVAL CALL CDECL CONSTRUCTOR DESTRUCTOR
-syn keyword freebasicFunctions DECLARE FUNCTION LIB OVERLOAD PASCAL STATIC SUB STDCALL
-syn keyword freebasicFunctions VA_ARG VA_FIRST VA_NEXT
+syn keyword freebasicDataTypes SINGLE DOUBLE INTEGER LONG
+syn match freebasicDataTypes "\<string\>"
+syn keyword freebasicDataTypes AS DIM CONST ENUM SHARED TYPE
+syn match freebasicDataTypes "\<end\s\+enum\>"
+syn match freebasicDataTypes "\<end\s\+type\>"
+if s:lang == "qb"
+ syn keyword freebasicDataTypes __BOOLEAN __BYTE __LONGINT __SHORT __UBYTE __UINTEGER __ULONG __ULONGINT __UNSIGNED __USHORT __ZSTRING
+ syn match freebasicDataTypes "\<__WSTRING\>"
+ syn keyword freebasicDataTypes __EXPLICIT __EXTENDS __IMPLEMENTS __OBJECT __POINTER __PTR __SIZEOF __TYPEOF
+ syn keyword freebasicDataTypes __UNION
+ syn match freebasicDataTypes "\<end\s\+__union\>"
+else
+ syn keyword freebasicDataTypes BOOLEAN BYTE LONGINT SHORT UBYTE UINTEGER ULONG ULONGINT UNSIGNED USHORT ZSTRING
+ syn match freebasicDataTypes "\<WSTRING\>"
+ syn keyword freebasicDataTypes EXPLICIT EXTENDS IMPLEMENTS OBJECT POINTER PTR SIZEOF TYPEOF
+ syn keyword freebasicDataTypes UNION
+ syn match freebasicDataTypes "\<end\s\+union\>"
+endif
+if s:lang == "fb"
+ syn keyword freebasicDataTypes BASE CLASS THIS VAR
+endif
-syn match freebasicGraphics "\<palette\s+get\>"
-syn keyword freebasicGraphics ALPHA CIRCLE CLS COLOR CUSTOM DRAW FLIP GET
-syn keyword freebasicGraphics IMAGECREATE IMAGEDESTROY LINE PAINT PALETTE PCOPY PMAP POINT
-syn keyword freebasicGraphics PRESET PSET PUT RGB RGBA SCREEN SCREENCOPY SCREENINFO SCREENLIST
-syn keyword freebasicGraphics SCREENLOCK SCREENPTR SCREENRES SCREENSET SCREENSYNC SCREENUNLOCK
-syn keyword freebasicGraphics TRANS USING VIEW WINDOW
+if s:lang == "qb"
+ syn match freebasicDateTime "\<\%(date\|time\)\$"
+elseif s:lang == "fblite" || s:lang == "deprecated"
+ syn match freebasicDateTime "\<\%(date\|time\)\>\$\="
+else " fb
+ syn keyword freebasicDateTime DATE TIME
+endif
+syn keyword freebasicDateTime SETDATE SETTIME
-syn match freebasicHardware "\<open\s+com\>"
-syn keyword freebasicHardware INP OUT WAIT LPT LPOS LPRINT
+" datetime.bi
+syn keyword freebasicDateTime DATEADD DATEDIFF DATEPART DATESERIAL DATEVALUE DAY HOUR ISDATE MINUTE
+syn keyword freebasicDateTime MONTH MONTHNAME NOW SECOND TIMESERIAL TIMEVALUE
+syn keyword freebasicDateTime TIMER YEAR WEEKDAY WEEKDAYNAME
-syn keyword freebasicLogical AND EQV IMP OR NOT XOR
+syn keyword freebasicDebug STOP
+if s:lang == "qb"
+ syn keyword freebasicDebug __ASSERT __ASSERTWARN
+else
+ syn keyword freebasicDebug ASSERT ASSERTWARN
+endif
-syn keyword freebasicMath ABS ACOS ASIN ATAN2 ATN COS EXP FIX INT LOG MOD RANDOMIZE
-syn keyword freebasicMath RND SGN SIN SQR TAN
+syn keyword freebasicErrorHandling ERR ERL ERROR
+if s:lang == "qb"
+ syn keyword freebasicErrorHandling __ERFN __ERMN
+ syn match freebasicErrorHandling "\<on\s\+error\>"
+else
+ syn keyword freebasicErrorHandling ERFN ERMN
+ syn match freebasicErrorHandling "\<on\s\+\%(local\s\+\)\=error\>"
+endif
+if s:lang != "fb"
+ syn match freebasicErrorHandling "\<resume\%(\s\+next\)\=\>"
+endif
-syn keyword freebasicMemory ALLOCATE CALLOCATE CLEAR DEALLOCATE FIELD FRE PEEK POKE REALLOCATE
+syn match freebasicFiles "\<get\s\+#\>"
+syn match freebasicFiles "\<input\s\+#\>"
+syn match freebasicFiles "\<line\s\+input\s\+#\>"
+syn match freebasicFiles "\<put\s\+#\>"
+syn keyword freebasicFiles ACCESS APPEND BINARY CLOSE EOF FREEFILE INPUT LOC
+syn keyword freebasicFiles LOCK LOF OUTPUT RANDOM RESET SEEK UNLOCK WRITE
+syn match freebasicFiles "\<open\>"
+if s:lang == "qb"
+ syn keyword freebasicFiles __ENCODING
+else
+ syn keyword freebasicFiles ENCODING WINPUT
+ syn match freebasicFiles "\<open\s\+\%(cons\|err\|pipe\|scrn\)\>"
+endif
-syn keyword freebasicMisc ASM DATA LET TO READ RESTORE SIZEOF SWAP OFFSETOF
+" file.bi
+syn keyword freebasicFiles FILEATTR FILECOPY FILEDATETIME FILEEXISTS FILEFLUSH FILELEN FILESETEOF
-syn keyword freebasicModularizing CHAIN COMMON EXPORT EXTERN DYLIBFREE DYLIBLOAD DYLIBSYMBOL
-syn keyword freebasicModularizing PRIVATE PUBLIC
+syn keyword freebasicFunctions ALIAS BYREF BYVAL CDECL DECLARE LIB NAKED PASCAL STATIC STDCALL
+syn match freebasicFunctions "\<option\ze\s*("
-syn keyword freebasicMultithreading MUTEXCREATE MUTEXDESTROY MUTEXLOCK MUTEXUNLOCK THREADCREATE THREADWAIT
+if s:lang == "qb"
+ syn keyword freebasicFunctions __CVA_ARG __CVA_COPY __CVA_END __CVA_LIST __CVA_START
+ syn keyword freebasicFunctions __VA_ARG __VA_FIRST __VA_NEXT
+else
+ syn keyword freebasicFunctions CVA_ARG CVA_COPY CVA_END CVA_LIST CVA_START
+ syn keyword freebasicFunctions VA_ARG VA_FIRST VA_NEXT
+ syn keyword freebasicFunctions ANY OVERLOAD
+endif
-syn keyword freebasicShell CHDIR DIR COMMAND ENVIRON EXEC EXEPATH KILL NAME MKDIR RMDIR RUN
+syn keyword freebasicFunctions FUNCTION SUB
+syn match freebasicFunctions "\<end\s\+function\>"
+syn match freebasicFunctions "\<end\s\+sub\>"
-syn keyword freebasicEnviron SHELL SYSTEM WINDOWTITLE POINTERS
+if s:lang == "fb"
+ syn keyword freebasicFunctions ABSTRACT OVERRIDE VIRTUAL __THISCALL
+ syn keyword freebasicFunctions CONSTRUCTOR DESTRUCTOR OPERATOR PROPERTY
+ syn match freebasicFunctions "\<end\s\+constructor\>"
+ syn match freebasicFunctions "\<end\s\+destructor\>"
+ syn match freebasicFunctions "\<end\s\+operator\>"
+ syn match freebasicFunctions "\<end\s\+property\>"
+else
+ syn keyword freebasicFunctions CALL
+endif
-syn keyword freebasicLoops FOR LOOP WHILE WEND DO CONTINUE STEP UNTIL next
+syn match freebasicGraphics "\<palette\s\+get\>"
+syn keyword freebasicGraphics ADD ALPHA BLOAD BSAVE CIRCLE CLS COLOR DRAW GET
+syn keyword freebasicGraphics LINE PAINT PALETTE PCOPY PMAP POINT
+syn keyword freebasicGraphics PRESET PSET PUT SCREEN
+syn keyword freebasicGraphics TRANS WINDOW
+if s:lang == "qb"
+ syn keyword freebasicGraphics __FLIP __IMAGECONVERTROW __IMAGECREATE __IMAGEDESTROY __IMAGEINFO __POINTCOORD
+ syn keyword freebasicGraphics __RGB __RGBA __SCREENCOPY __SCREENCONTROL __SCREENEVENT __SCREENGLPROC __SCREENINFO
+ syn keyword freebasicGraphics __SCREENLIST __SCREENLOCK __SCREENPTR __SCREENRES __SCREENSET __SCREENSYNC
+ syn keyword freebasicGraphics __SCREENUNLOCK __WINDOWTITLE
+else
+ syn keyword freebasicGraphics CUSTOM
+ syn keyword freebasicGraphics FLIP IMAGECONVERTROW IMAGECREATE IMAGEDESTROY IMAGEINFO POINTCOORD
+ syn keyword freebasicGraphics RGB RGBA SCREENCOPY SCREENCONTROL SCREENEVENT SCREENGLPROC SCREENINFO
+ syn keyword freebasicGraphics SCREENLIST SCREENLOCK SCREENPTR SCREENRES SCREENSET SCREENSYNC
+ syn keyword freebasicGraphics SCREENUNLOCK WINDOWTITLE
+endif
-syn match freebasicInclude "\<#\s*\(inclib\|include\)\>"
-syn match freebasicInclude "\<\$\s*include\>"
+if s:lang != "qb"
+ syn match freebasicHardware "\<open\s\+\%(com\|lpt\)\>"
+endif
+syn keyword freebasicHardware INP OUT WAIT LPOS LPRINT
-syn keyword freebasicPointer PROCPTR PTR SADD STRPTR VARPTR
+syn keyword freebasicMath ABS ATN COS EXP FIX FRAC INT LOG MOD RANDOMIZE RND SGN SIN SQR TAN
-syn keyword freebasicPredefined __DATE__ __FB_DOS__ __FB_LINUX__ __FB_MAIN__ __FB_MIN_VERSION__
-syn keyword freebasicPredefined __FB_SIGNATURE__ __FB_VERSION__ __FB_WIN32__ __FB_VER_MAJOR__
-syn keyword freebasicPredefined __FB_VER_MINOR__ __FB_VER_PATCH__ __FILE__ __FUNCTION__
-syn keyword freebasicPredefined __LINE__ __TIME__
+if s:lang == "qb"
+ syn keyword freebasicMath __ACOS __ASIN __ATAN2
+else
+ syn keyword freebasicMath ACOS ASIN ATAN2
+endif
-syn match freebasicPreProcessor "\<^#\s*\(define\|undef\)\>"
-syn match freebasicPreProcessor "\<^#\s*\(ifdef\|ifndef\|else\|elseif\|endif\|if\)\>"
-syn match freebasicPreProcessor "\<#\s*error\>"
-syn match freebasicPreProcessor "\<#\s*\(print\|dynamic\|static\)\>"
-syn keyword freebasicPreProcessor DEFINED ONCE
+if s:lang == "qb"
+ syn keyword freebasicMemory __ALLOCATE __CALLOCATE __DEALLOCATE __REALLOCATE
+else
+ syn keyword freebasicMemory ALLOCATE CALLOCATE DEALLOCATE REALLOCATE
+ syn keyword freebasicMemory PEEK POKE CLEAR FB_MEMCOPY FB_MEMCOPYCLEAR FB_MEMMOVE SWAP SADD
+ syn keyword freebasicMemory FIELD FRE
+endif
-syn keyword freebasicProgramFlow END EXIT GOSUB GOTO
-syn keyword freebasicProgramFlow IS RETURN SCOPE SLEEP
+syn keyword freebasicMisc LET TO
+if s:lang == "qb"
+ syn keyword freebasicMisc __OFFSETOF
+else
+ syn keyword freebasicMisc OFFSETOF
+endif
+
+syn keyword freebasicModularizing CHAIN COMMON
+if s:lang == "fb"
+ syn keyword freebasicModularizing EXTERN
+ syn match freebasicModularizing "\<end\s\+extern\>"
+ syn keyword freebasicModularizing PROTECTED
+endif
+if s:lang == "qb"
+ syn keyword freebasicModularizing __EXPORT __IMPORT __DYLIBFREE __DYLIBLOAD __DYLIBSYMBOL
+else
+ syn keyword freebasicModularizing EXPORT IMPORT DYLIBFREE DYLIBLOAD DYLIBSYMBOL
+ syn keyword freebasicModularizing PRIVATE PUBLIC
+ syn keyword freebasicModularizing NAMESPACE
+ syn match freebasicModularizing "\<end\s\+namespace\>"
+endif
+
+if s:lang != "qb"
+ syn keyword freebasicMultithreading MUTEXCREATE MUTEXDESTROY MUTEXLOCK MUTEXUNLOCK THREADCREATE THREADWAIT
+ syn keyword freebasicMultithreading CONDBROADCAST CONDCREATE CONDDESTROY CONDSIGNAL CONDWAIT
+ syn keyword freebasicMultithreading THREADCALL THREADDETACH THREADSELF
+endif
-syn keyword freebasicString INSTR LCASE LEFT LEN LSET LTRIM MID RIGHT RSET RTRIM
-syn keyword freebasicString SPACE STRING TRIM UCASE ASC BIN CHR CVD CVI CVL CVLONGINT
-syn keyword freebasicString CVS CVSHORT FORMAT HEX MKD MKI MKL MKLONGINT MKS MKSHORT
-syn keyword freebasicString OCT STR VAL VALLNG VALINT VALUINT VALULNG
+syn keyword freebasicShell CHDIR KILL NAME MKDIR RMDIR RUN SETENVIRON
+if s:lang == "qb"
+ syn keyword freebasicShell __CURDIR __DIR __EXEC __EXEPATH
+ syn match freebasicString "\<\%(command\|environ\)\$"
+else
+ " fbio.bi
+ syn keyword freebasicShell ISREDIRECTED
+ syn keyword freebasicShell CURDIR DIR EXEC EXEPATH
+ syn match freebasicString "\<\%(command\|environ\)\>\$\="
+endif
-syn keyword freebasicTypeCasting CAST CBYTE CDBL CINT CLNG CLNGINT CPTR CSHORT CSIGN CSNG
-syn keyword freebasicTypeCasting CUBYTE CUINT CULNGINT CUNSG CURDIR CUSHORT
+syn keyword freebasicEnviron SHELL SYSTEM
-syn match freebasicUserInput "\<line\s+input\>"
-syn keyword freebasicUserInput GETJOYSTICK GETKEY GETMOUSE INKEY INPUT MULTIKEY SETMOUSE
+syn keyword freebasicLoops FOR LOOP WHILE WEND DO STEP UNTIL NEXT
+if s:lang == "qb"
+ syn keyword freebasicLoops __CONTINUE
+else
+ syn keyword freebasicLoops CONTINUE
+endif
"
-" Do the Basic variables names first. This is because it
-" is the most inclusive of the tests. Later on we change
-" this so the identifiers are split up into the various
-" types of identifiers like functions, basic commands and
-" such. MEM 9/9/2006
+" File numbers
"
-syn match freebasicIdentifier "\<[a-zA-Z_][a-zA-Z0-9_]*\>"
-syn match freebasicGenericFunction "\<[a-zA-Z_][a-zA-Z0-9_]*\>\s*("me=e-1,he=e-1
+syn match freebasicFilenumber "#\d\+"
+syn match freebasicFilenumber "#\a[[:alpha:].]*[%&!#]\="
+
+syn match freebasicMetacommand "$\s*\%(dynamic\|static\)"
+syn match freebasicMetacommand "$\s*include\s*\%(once\)\=\s*:\s*'[^']\+'"
+syn match freebasicMetacommand '$\s*include\s*\%(once\)\=\s*:\s*"[^"]\+"'
+syn match freebasicMetacommand '$\s*lang\s*:\s*"[^"]\+"'
+"
+" Intrinsic defines
+"
+syn keyword freebasicPredefined __DATE__ __DATE_ISO__
+syn keyword freebasicPredefined __FB_64BIT__ __FB_ARGC__ __FB_ARG_COUNT__ __FB_ARG_EXTRACT__ __FB_ARG_LEFTOF__
+syn keyword freebasicPredefined __FB_ARG_RIGHTOF__ __FB_ARGV__ __FB_ARM__ __FB_ASM__ __FB_BACKEND__
+syn keyword freebasicPredefined __FB_BIGENDIAN__ __FB_BUILD_DATE__ __FB_BUILD_DATE_ISO__ __FB_BUILD_SHA1__
+syn keyword freebasicPredefined __FB_CYGWIN__ __FB_DARWIN__ __FB_DEBUG__ __FB_DOS__ __FB_ERR__ __FB_EVAL__
+syn keyword freebasicPredefined __FB_FPMODE__ __FB_FPU__ __FB_FREEBSD__ __FB_GCC__ __FB_GUI__ __FB_JOIN__
+syn keyword freebasicPredefined __FB_LANG__ __FB_LINUX__ __FB_MAIN__ __FB_MIN_VERSION__ __FB_MT__ __FB_NETBSD__
+syn keyword freebasicPredefined __FB_OPENBSD__ __FB_OPTIMIZE__ __FB_OPTION_BYVAL__ __FB_OPTION_DYNAMIC__
+syn keyword freebasicPredefined __FB_OPTION_ESCAPE__ __FB_OPTION_EXPLICIT__ __FB_OPTION_GOSUB__
+syn keyword freebasicPredefined __FB_OPTION_PRIVATE__ __FB_OUT_DLL__ __FB_OUT_EXE__ __FB_OUT_LIB__ __FB_OUT_OBJ__
+syn keyword freebasicPredefined __FB_PCOS__ __FB_PPC__ __FB_QUOTE__ __FB_SIGNATURE__ __FB_SSE__ __FB_UNIQUEID__
+syn keyword freebasicPredefined __FB_UNIQUEID_POP__ __FB_UNIQUEID_PUSH__ __FB_UNIX__ __FB_UNQUOTE__
+syn keyword freebasicPredefined __FB_VECTORIZE__ __FB_VER_MAJOR__ __FB_VER_MINOR__ __FB_VER_PATCH__ __FB_VERSION__
+syn keyword freebasicPredefined __FB_WIN32__ __FB_X86__ __FB_XBOX__
+syn keyword freebasicPredefined __FILE__ __FILE_NQ__ __FUNCTION__ __FUNCTION_NQ__
+syn keyword freebasicPredefined __LINE__ __PATH__ __TIME__
+"
+" Preprocessor directives
+"
+syn match freebasicInclude "#\s*\%(inclib\|include\%(\s\+once\)\=\|libpath\)\>"
+
+syn match freebasicPreProcessor "#\s*assert\>"
+syn match freebasicPreProcessor "#\s*cmdline\>"
+syn match freebasicPreProcessor "#\s*\%(define\|undef\)\>"
+syn match freebasicPreProcessor "#\s*\%(if\|ifdef\|ifndef\|else\|elseif\|endif\)\>"
+syn match freebasicPreProcessor "#\s*\%(macro\|endmacro\)\>"
+syn match freebasicPreProcessor "#\s*error\>"
+syn match freebasicPreProcessor "#\s*lang\>"
+syn match freebasicPreProcessor "#\s*line\>"
+syn match freebasicPreProcessor "#\s*pragma\%(\s\+reserve\)\=\>"
+syn match freebasicPreProcessor "#\s*\%(print\|dynamic\|static\)\>"
+syn keyword freebasicPreProcessor DEFINED
+
+syn keyword freebasicString LEN
+syn keyword freebasicString ASC
+" string.bi
+syn keyword freebasicString FORMAT
+syn keyword freebasicString VAL
+syn keyword freebasicString CVD CVI CVL CVS
+syn keyword freebasicString INSTR
+syn keyword freebasicString LSET RSET
+
+if s:lang == "qb"
+ syn match freebasicString "\<string\$\ze\s*("
+ syn match freebasicString "\<__wstring\ze\s*("
+ syn match freebasicString "\<space\$"
+ syn keyword freebasicString __WSPACE
+ syn match freebasicString "\<chr\$"
+ syn keyword freebasicString __WCHR
+ syn keyword freebasicString __WBIN __WHEX __WOCT __WSTR
+ syn match freebasicString "\<\%(bin\|hex\|oct\|str\)\$"
+ syn keyword freebasicString __VALLNG __VALINT __VALUINT __VALULNG
+ syn match freebasicString "\<\%(mkd\|mki\|mkl\|mks\)\$"
+ syn keyword freebasicString __MKLONGINT __MKSHORT
+ syn keyword freebasicString __CVLONGINT __CVSHORT
+ syn match freebasicString "\<\%(left\|mid\|right\|lcase\|ucase\|ltrim\|rtrim\)\$"
+ syn keyword freebasicString __TRIM
+ syn keyword freebasicString __INSTRREV
+else
+ syn match freebasicString "\<string\$\=\ze\s*("
+ syn match freebasicString "\<wstring\ze\s*("
+ syn match freebasicString "\<space\>\$\="
+ syn keyword freebasicString WSPACE
+ syn match freebasicString "\<chr\>\$\="
+ syn keyword freebasicString WCHR
+ syn keyword freebasicString WBIN WHEX WOCT WSTR
+ syn match freebasicString "\<\%(bin\|hex\|oct\|str\)\>\$\="
+ syn keyword freebasicString VALLNG VALINT VALUINT VALULNG
+ syn match freebasicString "\<\%(mkd\|mki\|mkl\|mks\)\>\$\="
+ syn match freebasicString "\<\%(mklongint\|mkshort\)\>\$\="
+ syn keyword freebasicString CVLONGINT CVSHORT
+ syn match freebasicString "\<\%(left\|mid\|right\|lcase\|ucase\|ltrim\|rtrim\)\>\$\="
+ syn match freebasicString "\<trim\>\$\="
+ syn keyword freebasicString INSTRREV
+endif
+
+syn keyword freebasicTypeCasting CDBL CINT CLNG CSNG
+if s:lang == "qb"
+ syn keyword freebasicTypeCasting __CAST __CBOOL __CBYTE __CLNGINT __CPTR __CSHORT __CSIGN __CYBTE __CUINT __CULNG
+ syn keyword freebasicTypeCasting __CULNGINT __CUNSG __CUSHORT
+else
+ syn keyword freebasicTypeCasting CAST CBOOL CBYTE CLNGINT CPTR CSHORT CSIGN CUBYTE CUINT CULNG CULNGINT CUNSG CUSHORT
+endif
+
+syn match freebasicUserInput "\<line\s\+input\>"
+syn keyword freebasicUserInput INKEY INPUT
+if s:lang == "qb"
+ syn keyword freebasicUserInput __GETJOYSTICK __GETKEY __GETMOUSE __MULTIKEY __SETMOUSE STICK STRIG
+else
+ syn keyword freebasicUserInput GETJOYSTICK GETKEY GETMOUSE MULTIKEY SETMOUSE
+endif
"
-" Function list
+" Operators
"
-syn keyword freebasicTodo contained TODO
+" TODO: make these context sensitive to remove the overlap of common operators
+" : alpha operators should probably always be highlighted
+" -- DJK 20/11/19
+if s:lang == "qb"
+ syn match freebasicArithmeticOperator "\<\%(MOD\|__SHL\|__SHR\)\>"
+else
+ syn match freebasicArithmeticOperator "\<\%(MOD\|SHL\|SHR\)\>"
+endif
+syn match freebasicBitwiseOperator "\<\%(AND\|EQV\|IMP\|NOT\|OR\|XOR\)\>" " freebaseLogical?
+if s:lang == "qb"
+ syn match freebasicAssignmentOperator "\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|__SHL\|__SHR\)=\@=" " exclude trailing '='
+else
+ syn match freebasicAssignmentOperator "\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|SHL\|SHR\)=\@="
+endif
+syn match freebasicShortcircuitOperator "\<\%(ANDALSO\|ORELSE\)\>"
+if s:lang == "fb"
+ syn match freebasicMemoryOperator '\<\%(new\|delete\)\>'
+endif
+syn keyword freebasicPointerOperator STRPTR VARPTR
+if s:lang == "qb"
+ syn keyword freebasicPointerOperator __PROCPTR
+else
+ syn keyword freebasicPointerOperator PROCPTR
+endif
+syn match freebasicTypeOperator '\<is\>'
+syn match freebasicTypeOperator '\.' nextgroup=freebasicIdentifier skipwhite
+if s:lang == "fb"
+ syn match freebasicTypeOperator '->' nextgroup=freebasicIdentifier skipwhite
+endif
+
+if exists("freebasic_operators")
+ syn match freebasicAssignmentOperator "=>\=\|[-+&/\\*^]="
+ if s:lang == "qb"
+ syn match freebasicAssignmentOperator "\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|__SHL\|__SHR\)=" " include trailing '='
+ else
+ syn match freebasicAssignmentOperator "\<\%(MOD\|AND\|EQV\|IMP\|OR\|XOR\|SHL\|SHR\)="
+ endif
+ syn match freebasicArithmeticOperator "[-+&/\\*^]"
+ " syn match freebasicIndexingOperator "[[\]()]" " FIXME
+ syn match freebasicRelationalOperator "=\|<>\|<=\|<\|>=\|>"
+ syn match freebasicPreprocessorOperator '\%(^\s*\)\@<!\%(##\|#\)\|[$!]"\@='
+ syn match freebasicPointerOperator '[@*]'
+ syn match freebasicTypeOperator '\.' nextgroup=freebasicIdentifier skipwhite
+ if s:lang == "fb"
+ syn match freebasicTypeOperator '->' nextgroup=freebasicIdentifier skipwhite
+ endif
+endif
+
+syn cluster freebasicOperator contains=freebasic.*Operator
"
" Catch errors caused by wrong parenthesis
"
-syn region freebasicParen transparent start='(' end=')' contains=ALLBUT,@freebasicParenGroup
-syn match freebasicParenError ")"
-syn match freebasicInParen contained "[{}]"
-syn cluster freebasicParenGroup contains=freebasicParenError,freebasicSpecial,freebasicTodo,freebasicUserCont,freebasicUserLabel,freebasicBitField
+" syn region freebasicParen transparent start='(' end=')' contains=ALLBUT,@freebasicParenGroup
+" syn match freebasicParenError ")"
+" syn match freebasicInParen contained "[{}]"
+" syn cluster freebasicParenGroup contains=freebasicParenError,freebasicSpecial,freebasicTodo,freebasicUserCont,freebasicUserLabel,freebasicBitField
"
-" Integer number, or floating point number without a dot and with "f".
+" Integer number
"
-syn region freebasicHex start="&h" end="\W"
-syn region freebasicHexError start="&h\x*[g-zG-Z]" end="\W"
-syn region freebasicOctal start="&o" end="\W"
-syn region freebasicOctalError start="&o[0-7]*[89a-zA-Z]" end="\W"
-syn region freebasicBinary start="&b" end="\W"
-syn region freebasicBinaryError start="&b[01]*[2-9a-zA-Z]" end="\W"
-syn match freebasicInteger "\<\d\+\(u\=l\=\|lu\|f\)\>"
+syn match freebasicHexError "&h\w*\>"
+syn match freebasicOctalError "&o\w*\>"
+syn match freebasicBinaryError "&b\w*\>"
+syn match freebasicHex "&h\x\+\%([%L&U]\|UL\|LL\|ULL\)\=\>"
+syn match freebasicOctal "&o\o\+\%([%L&U]\|UL\|LL\|ULL\)\=\>"
+syn match freebasicBinary "&b[10]\+\%([%L&U]\|UL\|LL\|ULL\)\=\>"
+syn match freebasicInteger "\<\d\+\%([%L&U]\|UL\|LL\|ULL\)\=\>"
"
-" Floating point number, with dot, optional exponent
+" Floating point
+" See: https://www.freebasic.net/forum/viewtopic.php?t=20323
"
-syn match freebasicFloat "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
+" Floating point number, with dot, optional exponent, optional suffix
"
-" Floating point number, starting with a dot, optional exponent
+syn match freebasicFloat "\<\d\+\.\d*\%([de][-+]\=\d*\)\=[f!#]\="
"
-syn match freebasicFloat "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
+" Floating point number, starting with a dot, optional exponent, optional suffix
"
-" Floating point number, without dot, with exponent
+syn match freebasicFloat "\.\d\+\%([de][-+]\=\d*\)\=[f!#]\="
"
-syn match freebasicFloat "\<\d\+e[-+]\=\d\+[fl]\=\>"
+" Floating point number, without dot, with optional exponent, optional suffix
"
-" Octal number
+syn match freebasicFloat "\<\d\+\%([de][-+]\=\d*\)[f!#]\="
"
-syn case match
-syn match freebasicOctal2 "\<0\o*\>"
-syn match freebasicOctal2Error "\<0\o*[89a-zA-Z]"
+" Floating point number, without dot, without exponent, with suffix
"
-" String and Character contstants
+syn match freebasicFloat "\<\d\+[f!#]"
"
-syn region freebasicString start='"' end='"' contains=freebasicSpecial,freebasicTodo
-syn region freebasicString start="'" end="'" contains=freebasicSpecial,freebasicTodo
+" Create the clusters
"
-" Comments
+syn cluster freebasicNumber contains=freebasicHex,freebasicOctal,freebasicBinary,freebasicInteger,freebasicFloat
+syn cluster freebasicNumberError contains=freebasicHexError,freebasicOctalError,freebasicBinaryError
"
-syn match freebasicSpecial contained "\\\\."
-syn region freebasicComment start="^rem" end="$" contains=freebasicSpecial,freebasicTodo
-syn region freebasicComment start=":\s*rem" end="$" contains=freebasicSpecial,freebasicTodo
-syn region freebasicComment start="\s*'" end="$" contains=freebasicSpecial,freebasicTodo
-syn region freebasicComment start="^'" end="$" contains=freebasicSpecial,freebasicTodo
+" Booleans
"
-" Now do the comments and labels
+if s:lang != "qb"
+ syn keyword freebasicBoolean TRUE FALSE
+endif
"
-syn match freebasicLabel "^\d"
-syn match freebasicLabel "\<^\w+:\>"
-syn region freebasicLineNumber start="^\d" end="\s"
"
-" Create the clusters
+" String and escape sequences
"
-syn cluster freebasicNumber contains=freebasicHex,freebasicOctal,freebasicOctal2,freebasicBinary,freebasicInteger,freebasicFloat
-syn cluster freebasicError contains=freebasicHexError,freebasicOctalError,freebasicOctal2,freebasicBinary
+syn match freebasicSpecial contained "\\."
+syn match freebasicSpecial contained "\\\d\{1,3}"
+syn match freebasicSpecial contained "\\&h\x\{1,2}"
+syn match freebasicSpecial contained "\\&o\o\{1,3}"
+syn match freebasicSpecial contained "\\&b[01]\{1,8}"
+syn match freebasicSpecial contained "\\u\x\{1,4}"
+syn region freebasicString start='"' end='"' " TODO: Toggle contains on Option Escape in fblite and qb? -- DJK 20/11/19
+syn region freebasicString start='!\zs"' end='"' contains=freebasicSpecial
+syn region freebasicString start='$\zs"' end='"'
"
-" Used with OPEN statement
+" Line labels
"
-syn match freebasicFilenumber "#\d\+"
-syn match freebasicMathOperator "[\+\-\=\|\*\/\>\<\%\()[\]]" contains=freebasicParen
+if s:lang =~# '\<\%(qb\|fblite\)\>'
+ syn match freebasicLineLabel "^\s*\zs\h\%(\w\|\.\)*\ze\s*:"
+else
+ syn match freebasicLineLabel "^\s*\zs\h\w*\ze\s*:"
+endif
+syn match freebasicLineNumber "^\s*\zs\d\+"
+"
+" Line continuations
+"
+" syn match freebasicLineContinuation "\<_\>" nextgroup=freebasicComment,freebasicPostLineContinuation skipwhite
+syn keyword freebasicLineContinuation _ nextgroup=freebasicComment,freebasicPostLineContinuation skipwhite
+syn match freebasicPostLineContinuation ".*" contained
+"
+"
+" Type suffixes
+if exists("freebasic_type_suffixes") && s:lang =~# '\<\%(qb\|fblite\)\>'
+ syn match freebasicTypeSuffix "\h\%(\w\|.\)*\zs[$%&!#]"
+endif
+"
+" Comments
+"
+syn keyword freebasicTodo TODO FIXME XXX NOTE contained
+syn region freebasicComment start="\<rem\>" end="$" contains=freebasicTodo,@Spell,freebasicMetacommand
+syn region freebasicComment start="'" end="$" contains=freebasicTodo,@Spell,freebasicMetacommand
+syn region freebasicDoubleComment start="''" end="$" contains=freebasicTodo,@Spell
+
+if !exists("freebasic_no_comment_fold")
+ syn region freebasicMultilineComment start="/'" end="'/" contains=freebasicTodo,@Spell,freeBasicMultilineComment fold keepend extend
+ syn region freebasicMultilineComment2 start="^\s*'.*\n\%(\s*'\)\@=" end="^\s*'.*\n\%(\s*'\)\@!" contains=freebasicComment,freebasicDoubleComment keepend fold
+else
+ syn region freebasicMultilineComment start="/'" end="'/" contains=freebasicTodo,@Spell,freeBasicMultilineComment
+endif
+
+syn case match
+
+syn sync linebreaks=1
+
"
" The default methods for highlighting. Can be overridden later
"
hi def link freebasicArrays StorageClass
+hi def link freebasicAsm Special
hi def link freebasicBitManipulation Operator
-hi def link freebasicCompilerSwitches PreCondit
+hi def link freebasicBoolean Boolean
+if s:lang == "fb"
+ hi def link freebasicCompilerSwitches freebasicUnsupportedError
+else
+ hi def link freebasicCompilerSwitches PreCondit
+endif
hi def link freebasicConsole Special
+hi def link freebasicData Special
hi def link freebasicDataTypes Type
hi def link freebasicDateTime Type
hi def link freebasicDebug Special
hi def link freebasicErrorHandling Special
+hi def link freebasicFilenumber Special
hi def link freebasicFiles Special
hi def link freebasicFunctions Function
hi def link freebasicGraphics Function
hi def link freebasicHardware Special
-hi def link freebasicLogical Conditional
+hi def link freebasicLoops Repeat
hi def link freebasicMath Function
+if s:lang == "fb"
+ hi def link freebasicMetacommand freebasicUnsupportedError
+else
+ hi def link freebasicMetacommand SpecialComment
+endif
hi def link freebasicMemory Function
hi def link freebasicMisc Special
hi def link freebasicModularizing Special
@@ -240,18 +620,55 @@ hi def link freebasicString String
hi def link freebasicTypeCasting Type
hi def link freebasicUserInput Statement
hi def link freebasicComment Comment
+hi def link freebasicDoubleComment Comment
+hi def link freebasicMultilineComment Comment
hi def link freebasicConditional Conditional
hi def link freebasicError Error
hi def link freebasicIdentifier Identifier
hi def link freebasicInclude Include
hi def link freebasicGenericFunction Function
-hi def link freebasicLabel Label
-hi def link freebasicLineNumber Label
+hi def link freebasicLineContinuation Special
+hi def link freebasicLineLabel LineNr
+if s:lang == "fb"
+ hi def link freebasicLineNumber freebasicUnsupportedError
+else
+ hi def link freebasicLineNumber LineNr
+endif
hi def link freebasicMathOperator Operator
-hi def link freebasicNumber Number
+
+hi def link freebasicHex Number
+hi def link freebasicOctal Number
+hi def link freebasicBinary Number
+hi def link freebasicInteger Number
+hi def link freebasicFloat Float
+
+hi def link freebasicHexError Error
+hi def link freebasicOctalError Error
+hi def link freebasicBinaryError Error
+
+hi def link freebasicAssignmentOperator Operator
+hi def link freebasicArithmeticOperator Operator
+hi def link freebasicIndexingOperator Operator
+hi def link freebasicRelationalOperator Operator
+hi def link freebasicBitwiseOperator Operator
+hi def link freebasicShortcircuitOperator Operator
+hi def link freebasicPreprocessorOperator Operator
+hi def link freebasicPointerOperator Operator
+if exists("freebasic_operators")
+ hi def link freebasicTypeOperator Operator
+endif
+hi def link freebasicMemoryOperator Operator
+
+hi def link freebasicSpaceError Error
+
hi def link freebasicSpecial Special
hi def link freebasicTodo Todo
+hi def link freebasicUnsupported freebasicUnsupportedError
+hi def link freebasicUnsupportedError Error
+
+unlet s:lang
+
let b:current_syntax = "freebasic"
-" vim: ts=8
+" vim: ts=8 tw=132 fdm=marker
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index e6a055995e..4c2404a0d8 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -54,6 +54,7 @@
/// - force: (boolean) Whether filter is inverted or not.
/// - silent: (boolean) |:silent|.
/// - emsg_silent: (boolean) |:silent!|.
+/// - unsilent: (boolean) |:unsilent|.
/// - sandbox: (boolean) |:sandbox|.
/// - noautocmd: (boolean) |:noautocmd|.
/// - browse: (boolean) |:browse|.
@@ -232,6 +233,7 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err)
PUT(mods, "silent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_SILENT));
PUT(mods, "emsg_silent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_ERRSILENT));
+ PUT(mods, "unsilent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_UNSILENT));
PUT(mods, "sandbox", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_SANDBOX));
PUT(mods, "noautocmd", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_NOAUTOCMD));
PUT(mods, "tab", INTEGER_OBJ(cmdinfo.cmdmod.cmod_tab));
@@ -598,6 +600,7 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
OBJ_TO_CMOD_FLAG(CMOD_SILENT, mods.silent, false, "'mods.silent'");
OBJ_TO_CMOD_FLAG(CMOD_ERRSILENT, mods.emsg_silent, false, "'mods.emsg_silent'");
+ OBJ_TO_CMOD_FLAG(CMOD_UNSILENT, mods.silent, false, "'mods.unsilent'");
OBJ_TO_CMOD_FLAG(CMOD_SANDBOX, mods.sandbox, false, "'mods.sandbox'");
OBJ_TO_CMOD_FLAG(CMOD_NOAUTOCMD, mods.noautocmd, false, "'mods.noautocmd'");
OBJ_TO_CMOD_FLAG(CMOD_BROWSE, mods.browse, false, "'mods.browse'");
@@ -722,6 +725,10 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin
kv_concat(cmdline, "silent ");
}
+ if (cmdinfo->cmdmod.cmod_flags & CMOD_UNSILENT) {
+ kv_concat(cmdline, "unsilent ");
+ }
+
switch (cmdinfo->cmdmod.cmod_split & (WSP_ABOVE | WSP_BELOW | WSP_TOP | WSP_BOT)) {
case WSP_ABOVE:
kv_concat(cmdline, "aboveleft ");
diff --git a/src/nvim/api/keysets.lua b/src/nvim/api/keysets.lua
index 918fe028a8..21319fb7a6 100644
--- a/src/nvim/api/keysets.lua
+++ b/src/nvim/api/keysets.lua
@@ -181,6 +181,7 @@ return {
cmd_mods = {
"silent";
"emsg_silent";
+ "unsilent";
"filter";
"sandbox";
"noautocmd";
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 75666c600c..d51079b515 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -1679,7 +1679,7 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force
} else if (fname != NULL && !ends_excmd(*fname)) {
autocmd_fname = fname;
} else if (buf != NULL) {
- autocmd_fname = (char *)buf->b_ffname;
+ autocmd_fname = buf->b_ffname;
} else {
autocmd_fname = NULL;
}
@@ -1711,9 +1711,9 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force
fname = (char *)buf->b_p_ft;
} else {
if (buf->b_sfname != NULL) {
- sfname = (char *)vim_strsave(buf->b_sfname);
+ sfname = xstrdup(buf->b_sfname);
}
- fname = (char *)buf->b_ffname;
+ fname = buf->b_ffname;
}
}
if (fname == NULL) {
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index a2ecb69ac0..7bdb905dfa 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -113,7 +113,7 @@ static int read_buffer(int read_stdin, exarg_T *eap, int flags)
// the end. This makes it possible to retry when 'fileformat' or
// 'fileencoding' was guessed wrong.
line_count = curbuf->b_ml.ml_line_count;
- retval = readfile(read_stdin ? NULL : (char *)curbuf->b_ffname,
+ retval = readfile(read_stdin ? NULL : curbuf->b_ffname,
read_stdin ? NULL : curbuf->b_fname,
line_count, (linenr_T)0, (linenr_T)MAXLNUM, eap,
flags | READ_BUFFER, silent);
@@ -231,7 +231,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
}
#endif
- retval = readfile((char *)curbuf->b_ffname, curbuf->b_fname,
+ retval = readfile(curbuf->b_ffname, curbuf->b_fname,
(linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, eap,
flags | READ_NEW | (read_fifo ? READ_FIFO : 0), silent);
#ifdef UNIX
@@ -803,8 +803,7 @@ static void free_buffer_stuff(buf_T *buf, int free_flags)
// Avoid losing b:changedtick when deleting buffer: clearing variables
// implies using clear_tv() on b:changedtick and that sets changedtick to
// zero.
- hashitem_T *const changedtick_hi = hash_find(&buf->b_vars->dv_hashtab,
- (const char_u *)"changedtick");
+ hashitem_T *const changedtick_hi = hash_find(&buf->b_vars->dv_hashtab, "changedtick");
assert(changedtick_hi != NULL);
hash_remove(&buf->b_vars->dv_hashtab, changedtick_hi);
}
@@ -814,7 +813,7 @@ static void free_buffer_stuff(buf_T *buf, int free_flags)
buf_init_changedtick(buf);
}
uc_clear(&buf->b_ucmds); // clear local user commands
- buf_delete_signs(buf, (char_u *)"*"); // delete any signs
+ buf_delete_signs(buf, "*"); // delete any signs
extmark_free_all(buf); // delete any extmarks
map_clear_mode(buf, MAP_ALL_MODES, true, false); // clear local mappings
map_clear_mode(buf, MAP_ALL_MODES, true, true); // clear local abbrevs
@@ -943,7 +942,7 @@ void handle_swap_exists(bufref_T *old_curbuf)
/// @param end_bnr buffer nr or last buffer nr in a range
///
/// @return error message or NULL
-char *do_bufdel(int command, char_u *arg, int addr_count, int start_bnr, int end_bnr, int forceit)
+char *do_bufdel(int command, char *arg, int addr_count, int start_bnr, int end_bnr, int forceit)
{
int do_current = 0; // delete current buffer?
int deleted = 0; // number of buffers deleted
@@ -981,17 +980,17 @@ char *do_bufdel(int command, char_u *arg, int addr_count, int start_bnr, int end
break;
}
} else { // addr_count == 1
- arg = (char_u *)skipwhite((char *)arg);
+ arg = skipwhite(arg);
if (*arg == NUL) {
break;
}
if (!ascii_isdigit(*arg)) {
- p = (char *)skiptowhite_esc(arg);
- bnr = buflist_findpat(arg, (char_u *)p, command == DOBUF_WIPE, false, false);
+ p = skiptowhite_esc(arg);
+ bnr = buflist_findpat(arg, p, command == DOBUF_WIPE, false, false);
if (bnr < 0) { // failed
break;
}
- arg = (char_u *)p;
+ arg = p;
} else {
bnr = getdigits_int(&arg, false, 0);
}
@@ -1677,10 +1676,10 @@ static inline void buf_init_changedtick(buf_T *const buf)
/// @param bufnr
///
/// @return pointer to the buffer
-buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int flags)
+buf_T *buflist_new(char *ffname_arg, char *sfname_arg, linenr_T lnum, int flags)
{
- char *ffname = (char *)ffname_arg;
- char *sfname = (char *)sfname_arg;
+ char *ffname = ffname_arg;
+ char *sfname = sfname_arg;
buf_T *buf;
fname_expand(curbuf, &ffname, &sfname); // will allocate ffname
@@ -1747,8 +1746,8 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int fl
}
if (ffname != NULL) {
- buf->b_ffname = (char_u *)ffname;
- buf->b_sfname = vim_strsave((char_u *)sfname);
+ buf->b_ffname = ffname;
+ buf->b_sfname = xstrdup(sfname);
}
clear_wininfo(buf);
@@ -1797,7 +1796,7 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int fl
hash_init(&buf->b_s.b_keywtab);
hash_init(&buf->b_s.b_keywtab_ic);
- buf->b_fname = (char *)buf->b_sfname;
+ buf->b_fname = buf->b_sfname;
if (!file_id_valid) {
buf->file_id_valid = false;
} else {
@@ -2047,13 +2046,13 @@ void buflist_getfpos(void)
/// Find file in buffer list by name (it has to be for the current window).
///
/// @return buffer or NULL if not found
-buf_T *buflist_findname_exp(char_u *fname)
+buf_T *buflist_findname_exp(char *fname)
{
char *ffname;
buf_T *buf = NULL;
// First make the name into a full path name
- ffname = FullName_save((char *)fname,
+ ffname = FullName_save(fname,
#ifdef UNIX
// force expansion, get rid of symbolic links
true
@@ -2062,7 +2061,7 @@ buf_T *buflist_findname_exp(char_u *fname)
#endif
); // NOLINT(whitespace/parens)
if (ffname != NULL) {
- buf = buflist_findname((char_u *)ffname);
+ buf = buflist_findname(ffname);
xfree(ffname);
}
return buf;
@@ -2073,11 +2072,11 @@ buf_T *buflist_findname_exp(char_u *fname)
/// Skips dummy buffers.
///
/// @return buffer or NULL if not found
-buf_T *buflist_findname(char_u *ffname)
+buf_T *buflist_findname(char *ffname)
{
FileID file_id;
- bool file_id_valid = os_fileid((char *)ffname, &file_id);
- return buflist_findname_file_id((char *)ffname, &file_id, file_id_valid);
+ bool file_id_valid = os_fileid(ffname, &file_id);
+ return buflist_findname_file_id(ffname, &file_id, file_id_valid);
}
/// Same as buflist_findname(), but pass the FileID structure to avoid
@@ -2105,7 +2104,7 @@ static buf_T *buflist_findname_file_id(char *ffname, FileID *file_id, bool file_
/// @param curtab_only find buffers in current tab only
///
/// @return fnum of the found buffer or < 0 for error.
-int buflist_findpat(const char_u *pattern, const char_u *pattern_end, bool unlisted, bool diffmode,
+int buflist_findpat(const char *pattern, const char *pattern_end, bool unlisted, bool diffmode,
bool curtab_only)
FUNC_ATTR_NONNULL_ARG(1)
{
@@ -2236,7 +2235,7 @@ static int buf_time_compare(const void *s1, const void *s2)
/// For command line expansion of ":buf" and ":sbuf".
///
/// @return OK if matches found, FAIL otherwise.
-int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
+int ExpandBufnames(char *pat, int *num_file, char ***file, int options)
{
int count = 0;
int round;
@@ -2258,20 +2257,20 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
STRCPY(patc, "\\(^\\|[\\/]\\)");
STRCPY(patc + 11, pat + 1);
} else {
- patc = (char *)pat;
+ patc = pat;
}
// attempt == 0: try match with '\<', match at start of word
// attempt == 1: try match without '\<', match anywhere
for (attempt = 0; attempt <= 1; attempt++) {
- if (attempt > 0 && (char_u *)patc == pat) {
+ if (attempt > 0 && patc == pat) {
break; // there was no anchor, no need to try again
}
regmatch_T regmatch;
regmatch.regprog = vim_regcomp(patc + attempt * 11, RE_MAGIC);
if (regmatch.regprog == NULL) {
- if ((char_u *)patc != pat) {
+ if (patc != pat) {
xfree(patc);
}
return FAIL;
@@ -2298,7 +2297,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
count++;
} else {
if (options & WILD_HOME_REPLACE) {
- p = (char *)home_replace_save(buf, (char_u *)p);
+ p = home_replace_save(buf, p);
} else {
p = xstrdup(p);
}
@@ -2307,7 +2306,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
matches[count].match = p;
count++;
} else {
- (*file)[count++] = (char_u *)p;
+ (*file)[count++] = p;
}
}
}
@@ -2329,7 +2328,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
}
}
- if ((char_u *)patc != pat) {
+ if (patc != pat) {
xfree(patc);
}
@@ -2341,12 +2340,12 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
// if the current buffer is first in the list, place it at the end
if (matches[0].buf == curbuf) {
for (int i = 1; i < count; i++) {
- (*file)[i - 1] = (char_u *)matches[i].match;
+ (*file)[i - 1] = matches[i].match;
}
- (*file)[count - 1] = (char_u *)matches[0].match;
+ (*file)[count - 1] = matches[0].match;
} else {
for (int i = 0; i < count; i++) {
- (*file)[i] = (char_u *)matches[i].match;
+ (*file)[i] = matches[i].match;
}
}
xfree(matches);
@@ -2362,9 +2361,9 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
static char *buflist_match(regmatch_T *rmp, buf_T *buf, bool ignore_case)
{
// First try the short file name, then the long file name.
- char *match = fname_match(rmp, (char *)buf->b_sfname, ignore_case);
+ char *match = fname_match(rmp, buf->b_sfname, ignore_case);
if (match == NULL && rmp->regprog != NULL) {
- match = fname_match(rmp, (char *)buf->b_ffname, ignore_case);
+ match = fname_match(rmp, buf->b_ffname, ignore_case);
}
return match;
}
@@ -2382,12 +2381,12 @@ static char *fname_match(regmatch_T *rmp, char *name, bool ignore_case)
if (name != NULL) {
// Ignore case when 'fileignorecase' or the argument is set.
rmp->rm_ic = p_fic || ignore_case;
- if (vim_regexec(rmp, (char_u *)name, (colnr_T)0)) {
+ if (vim_regexec(rmp, name, (colnr_T)0)) {
match = name;
} else if (rmp->regprog != NULL) {
// Replace $(HOME) with '~' and try matching again.
- p = (char *)home_replace_save(NULL, (char_u *)name);
- if (vim_regexec(rmp, (char_u *)p, (colnr_T)0)) {
+ p = home_replace_save(NULL, name);
+ if (vim_regexec(rmp, p, (colnr_T)0)) {
match = name;
}
xfree(p);
@@ -2414,16 +2413,14 @@ buf_T *buflist_findnr(int nr)
/// @param helptail for help buffers return tail only
///
/// @return a pointer to allocated memory, of NULL when failed.
-char_u *buflist_nr2name(int n, int fullname, int helptail)
+char *buflist_nr2name(int n, int fullname, int helptail)
{
- buf_T *buf;
-
- buf = buflist_findnr(n);
+ buf_T *buf = buflist_findnr(n);
if (buf == NULL) {
return NULL;
}
return home_replace_save(helptail ? buf : NULL,
- fullname ? buf->b_ffname : (char_u *)buf->b_fname);
+ fullname ? buf->b_ffname : buf->b_fname);
}
/// Set the line and column numbers for the given buffer and window
@@ -2719,16 +2716,14 @@ void buflist_list(exarg_T *eap)
/// Used by insert_reg() and cmdline_paste() for '#' register.
///
/// @return FAIL if not found, OK for success.
-int buflist_name_nr(int fnum, char_u **fname, linenr_T *lnum)
+int buflist_name_nr(int fnum, char **fname, linenr_T *lnum)
{
- buf_T *buf;
-
- buf = buflist_findnr(fnum);
+ buf_T *buf = buflist_findnr(fnum);
if (buf == NULL || buf->b_fname == NULL) {
return FAIL;
}
- *fname = (char_u *)buf->b_fname;
+ *fname = buf->b_fname;
*lnum = buflist_findlnum(buf);
return OK;
@@ -2783,16 +2778,16 @@ int setfname(buf_T *buf, char *ffname_arg, char *sfname_arg, bool message)
}
sfname = xstrdup(sfname);
#ifdef USE_FNAME_CASE
- path_fix_case((char_u *)sfname); // set correct case for short file name
+ path_fix_case(sfname); // set correct case for short file name
#endif
if (buf->b_sfname != buf->b_ffname) {
xfree(buf->b_sfname);
}
xfree(buf->b_ffname);
- buf->b_ffname = (char_u *)ffname;
- buf->b_sfname = (char_u *)sfname;
+ buf->b_ffname = ffname;
+ buf->b_sfname = sfname;
}
- buf->b_fname = (char *)buf->b_sfname;
+ buf->b_fname = buf->b_sfname;
if (!file_id_valid) {
buf->file_id_valid = false;
} else {
@@ -2806,22 +2801,20 @@ int setfname(buf_T *buf, char *ffname_arg, char *sfname_arg, bool message)
/// Crude way of changing the name of a buffer. Use with care!
/// The name should be relative to the current directory.
-void buf_set_name(int fnum, char_u *name)
+void buf_set_name(int fnum, char *name)
{
- buf_T *buf;
-
- buf = buflist_findnr(fnum);
+ buf_T *buf = buflist_findnr(fnum);
if (buf != NULL) {
if (buf->b_sfname != buf->b_ffname) {
xfree(buf->b_sfname);
}
xfree(buf->b_ffname);
- buf->b_ffname = vim_strsave(name);
+ buf->b_ffname = xstrdup(name);
buf->b_sfname = NULL;
// Allocate ffname and expand into full path. Also resolves .lnk
// files on Win32.
- fname_expand(buf, (char **)&buf->b_ffname, (char **)&buf->b_sfname);
- buf->b_fname = (char *)buf->b_sfname;
+ fname_expand(buf, &buf->b_ffname, &buf->b_sfname);
+ buf->b_fname = buf->b_sfname;
}
}
@@ -2847,12 +2840,10 @@ void buf_name_changed(buf_T *buf)
/// Used by do_one_cmd(), do_write() and do_ecmd().
///
/// @return the buffer.
-buf_T *setaltfname(char_u *ffname, char_u *sfname, linenr_T lnum)
+buf_T *setaltfname(char *ffname, char *sfname, linenr_T lnum)
{
- buf_T *buf;
-
// Create a buffer. 'buflisted' is not set if it's a new buffer
- buf = buflist_new(ffname, sfname, lnum, 0);
+ buf_T *buf = buflist_new(ffname, sfname, lnum, 0);
if (buf != NULL && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
curwin->w_alt_fnum = buf->b_fnum;
}
@@ -2863,29 +2854,27 @@ buf_T *setaltfname(char_u *ffname, char_u *sfname, linenr_T lnum)
/// Return NULL if there isn't any, and give error message if requested.
///
/// @param errmsg give error message
-char_u *getaltfname(bool errmsg)
+char *getaltfname(bool errmsg)
{
char *fname;
linenr_T dummy;
- if (buflist_name_nr(0, (char_u **)&fname, &dummy) == FAIL) {
+ if (buflist_name_nr(0, &fname, &dummy) == FAIL) {
if (errmsg) {
emsg(_(e_noalt));
}
return NULL;
}
- return (char_u *)fname;
+ return fname;
}
/// Add a file name to the buflist and return its number.
/// Uses same flags as buflist_new(), except BLN_DUMMY.
///
/// Used by qf_init(), main() and doarglist()
-int buflist_add(char_u *fname, int flags)
+int buflist_add(char *fname, int flags)
{
- buf_T *buf;
-
- buf = buflist_new(fname, NULL, (linenr_T)0, flags);
+ buf_T *buf = buflist_new(fname, NULL, (linenr_T)0, flags);
if (buf != NULL) {
return buf->b_fnum;
}
@@ -2919,10 +2908,10 @@ void buflist_altfpos(win_T *win)
/// Fname must have a full path (expanded by path_to_absolute()).
///
/// @param ffname full path name to check
-bool otherfile(char_u *ffname)
+bool otherfile(char *ffname)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
- return otherfile_buf(curbuf, (char *)ffname, NULL, false);
+ return otherfile_buf(curbuf, ffname, NULL, false);
}
/// Check that "ffname" is not the same file as the file loaded in "buf".
@@ -3023,7 +3012,7 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate)
if (!fullname && curbuf->b_fname != NULL) {
name = curbuf->b_fname;
} else {
- name = (char *)curbuf->b_ffname;
+ name = curbuf->b_ffname;
}
home_replace(shorthelp ? curbuf : NULL, name, p,
(size_t)(IOSIZE - (p - buffer)), true);
@@ -3071,7 +3060,7 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate)
n);
validate_virtcol();
len = STRLEN(buffer);
- col_print((char_u *)buffer + len, IOSIZE - len,
+ col_print(buffer + len, IOSIZE - len,
(int)curwin->w_cursor.col + 1, (int)curwin->w_virtcol + 1);
}
@@ -3100,12 +3089,12 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate)
xfree(buffer);
}
-void col_print(char_u *buf, size_t buflen, int col, int vcol)
+void col_print(char *buf, size_t buflen, int col, int vcol)
{
if (col == vcol) {
- vim_snprintf((char *)buf, buflen, "%d", col);
+ vim_snprintf(buf, buflen, "%d", col);
} else {
- vim_snprintf((char *)buf, buflen, "%d-%d", col, vcol);
+ vim_snprintf(buf, buflen, "%d-%d", col, vcol);
}
}
@@ -3200,7 +3189,7 @@ void maketitle(void)
// Get path of file, replace home dir with ~.
*buf_p++ = ' ';
*buf_p++ = '(';
- home_replace(curbuf, (char *)curbuf->b_ffname, buf_p,
+ home_replace(curbuf, curbuf->b_ffname, buf_p,
(SPACE_FOR_DIR - (size_t)(buf_p - buf)), true);
#ifdef BACKSLASH_IN_FILENAME
// Avoid "c:/name" to be reduced to "c".
@@ -3209,7 +3198,7 @@ void maketitle(void)
}
#endif
// Remove the file name.
- char *p = (char *)path_tail_with_sep((char_u *)buf_p);
+ char *p = path_tail_with_sep(buf_p);
if (p == buf_p) {
// Must be a help buffer.
xstrlcpy(buf_p, _("help"), SPACE_FOR_DIR - (size_t)(buf_p - buf));
@@ -3244,7 +3233,7 @@ void maketitle(void)
if (maxlen > 0) {
// Make it shorter by removing a bit in the middle.
if (vim_strsize(buf) > maxlen) {
- trunc_string((char_u *)buf, (char_u *)buf, maxlen, sizeof(buf));
+ trunc_string(buf, buf, maxlen, sizeof(buf));
}
}
title_str = buf;
@@ -3279,18 +3268,18 @@ void maketitle(void)
if (buf_spname(curbuf) != NULL) {
buf_p = buf_spname(curbuf);
} else { // use file name only in icon
- buf_p = path_tail((char *)curbuf->b_ffname);
+ buf_p = path_tail(curbuf->b_ffname);
}
*icon_str = NUL;
// Truncate name at 100 bytes.
len = (int)STRLEN(buf_p);
if (len > 100) {
len -= 100;
- len += mb_tail_off((char_u *)buf_p, (char_u *)buf_p + len) + 1;
+ len += mb_tail_off(buf_p, buf_p + len) + 1;
buf_p += len;
}
STRCPY(icon_str, buf_p);
- trans_characters((char_u *)icon_str, IOSIZE);
+ trans_characters(icon_str, IOSIZE);
}
}
@@ -3688,7 +3677,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, int use_san
// The first digit group is the item's min width
if (ascii_isdigit(*fmt_p)) {
- minwid = getdigits_int((char_u **)&fmt_p, false, 0);
+ minwid = getdigits_int(&fmt_p, false, 0);
}
// User highlight groups override the min width field
@@ -3771,7 +3760,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, int use_san
if (*fmt_p == '.') {
fmt_p++;
if (ascii_isdigit(*fmt_p)) {
- maxwid = getdigits_int((char_u **)&fmt_p, false, 50);
+ maxwid = getdigits_int(&fmt_p, false, 50);
}
}
@@ -3824,11 +3813,11 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, int use_san
if (buf_spname(wp->w_buffer) != NULL) {
STRLCPY(NameBuff, buf_spname(wp->w_buffer), MAXPATHL);
} else {
- char *t = (opt == STL_FULLPATH) ? (char *)wp->w_buffer->b_ffname
+ char *t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname
: wp->w_buffer->b_fname;
home_replace(wp->w_buffer, t, (char *)NameBuff, MAXPATHL, true);
}
- trans_characters(NameBuff, MAXPATHL);
+ trans_characters((char *)NameBuff, MAXPATHL);
if (opt != STL_FILENAME) {
str = (char *)NameBuff;
} else {
@@ -4708,7 +4697,7 @@ void do_arg_all(int count, int forceit, int keep_tabs)
if (i < alist->al_ga.ga_len
&& (AARGLIST(alist)[i].ae_fnum == buf->b_fnum
|| path_full_compare(alist_name(&AARGLIST(alist)[i]),
- (char *)buf->b_ffname,
+ buf->b_ffname,
true, true) & kEqualFiles)) {
int weight = 1;
@@ -5576,7 +5565,7 @@ bool buf_contents_changed(buf_T *buf)
aucmd_prepbuf(&aco, newbuf);
if (ml_open(curbuf) == OK
- && readfile((char *)buf->b_ffname, buf->b_fname,
+ && readfile(buf->b_ffname, buf->b_fname,
(linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,
&ea, READ_NEW | READ_DUMMY, false) == OK) {
// compare the two files line by line
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index e5142f714e..8c70765d30 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -545,8 +545,8 @@ struct file_buffer {
// b_sfname is the name as the user typed it (or NULL).
// b_fname is the same as b_sfname, unless ":cd" has been done,
// then it is the same as b_ffname (NULL for no name).
- char_u *b_ffname; // full path file name, allocated
- char_u *b_sfname; // short file name, allocated, may be equal to
+ char *b_ffname; // full path file name, allocated
+ char *b_sfname; // short file name, allocated, may be equal to
// b_ffname
char *b_fname; // current file name, points to b_ffname or
// b_sfname
@@ -829,7 +829,7 @@ struct file_buffer {
int b_start_eol; // last line had eol when it was read
int b_start_ffc; // first char of 'ff' when edit started
- char_u *b_start_fenc; // 'fileencoding' when edit started or NULL
+ char *b_start_fenc; // 'fileencoding' when edit started or NULL
int b_bad_char; // "++bad=" argument when edit started or 0
int b_start_bomb; // 'bomb' when it was read
@@ -855,7 +855,7 @@ struct file_buffer {
// are not used! Use the B_SPELL macro to
// access b_spell without #ifdef.
- char_u *b_prompt_text; // set by prompt_setprompt()
+ char *b_prompt_text; // set by prompt_setprompt()
Callback b_prompt_callback; // set by prompt_setcallback()
Callback b_prompt_interrupt; // set by prompt_setinterrupt()
int b_prompt_insert; // value for restart_edit when entering
@@ -963,8 +963,8 @@ struct tabpage_S {
frame_T *(tp_snapshot[SNAP_COUNT]); ///< window layout snapshots
ScopeDictDictItem tp_winvar; ///< Variable for "t:" Dictionary.
dict_T *tp_vars; ///< Internal variables, local to tab page.
- char_u *tp_localdir; ///< Absolute path of local cwd or NULL.
- char_u *tp_prevdir; ///< Previous directory.
+ char *tp_localdir; ///< Absolute path of local cwd or NULL.
+ char *tp_prevdir; ///< Previous directory.
};
/*
@@ -1061,7 +1061,7 @@ struct matchitem {
matchitem_T *next;
int id; ///< match ID
int priority; ///< match priority
- char_u *pattern; ///< pattern to highlight
+ char *pattern; ///< pattern to highlight
regmmatch_T match; ///< regexp program for pattern
posmatch_T pos; ///< position matches
match_T hl; ///< struct for doing the actual highlighting
@@ -1409,8 +1409,8 @@ struct window_S {
// out of range!)
int w_arg_idx_invalid; // editing another file than w_arg_idx
- char_u *w_localdir; // absolute path of local directory or NULL
- char_u *w_prevdir; // previous directory
+ char *w_localdir; // absolute path of local directory or NULL
+ char *w_prevdir; // previous directory
// Options local to a window.
// They are local because they influence the layout of the window or
// depend on the window layout.
@@ -1424,10 +1424,10 @@ struct window_S {
uint32_t w_p_wbr_flags; // flags for 'winbar'
uint32_t w_p_fde_flags; // flags for 'foldexpr'
uint32_t w_p_fdt_flags; // flags for 'foldtext'
- int *w_p_cc_cols; // array of columns to highlight or NULL
- char_u w_p_culopt_flags; // flags for cursorline highlighting
- long w_p_siso; // 'sidescrolloff' local value
- long w_p_so; // 'scrolloff' local value
+ int *w_p_cc_cols; // array of columns to highlight or NULL
+ uint8_t w_p_culopt_flags; // flags for cursorline highlighting
+ long w_p_siso; // 'sidescrolloff' local value
+ long w_p_so; // 'scrolloff' local value
int w_briopt_min; // minimum width for breakindent
int w_briopt_shift; // additional shift for breakindent
diff --git a/src/nvim/change.c b/src/nvim/change.c
index f1273c802e..4568b71fd9 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -1059,7 +1059,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
old_cursor = curwin->w_cursor;
ptr = saved_line;
if (flags & OPENLINE_DO_COM) {
- lead_len = get_leader_len(ptr, NULL, false, true);
+ lead_len = get_leader_len((char *)ptr, NULL, false, true);
} else {
lead_len = 0;
}
@@ -1072,7 +1072,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
newindent = get_indent();
}
if (flags & OPENLINE_DO_COM) {
- lead_len = get_leader_len(ptr, NULL, false, true);
+ lead_len = get_leader_len((char *)ptr, NULL, false, true);
} else {
lead_len = 0;
}
@@ -1191,14 +1191,14 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
// This may then be inserted in front of the new line.
end_comment_pending = NUL;
if (flags & OPENLINE_DO_COM) {
- lead_len = get_leader_len(saved_line, &lead_flags, dir == BACKWARD, true);
+ lead_len = get_leader_len((char *)saved_line, (char **)&lead_flags, dir == BACKWARD, true);
if (lead_len == 0 && curbuf->b_p_cin && do_cindent && dir == FORWARD
&& (!has_format_option(FO_NO_OPEN_COMS) || (flags & OPENLINE_FORMAT))) {
// Check for a line comment after code.
comment_start = check_linecomment(saved_line);
if (comment_start != MAXCOL) {
- lead_len = get_leader_len(saved_line + comment_start,
- &lead_flags, false, true);
+ lead_len = get_leader_len((char *)saved_line + comment_start,
+ (char **)&lead_flags, false, true);
if (lead_len != 0) {
lead_len += comment_start;
if (did_do_comment != NULL) {
@@ -1238,7 +1238,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
}
// find start of middle part
- (void)copy_option_part(&p, lead_middle, COM_MAX_LEN, ",");
+ (void)copy_option_part((char **)&p, (char *)lead_middle, COM_MAX_LEN, ",");
require_blank = false;
}
@@ -1249,7 +1249,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
}
p++;
}
- (void)copy_option_part(&p, lead_middle, COM_MAX_LEN, ",");
+ (void)copy_option_part((char **)&p, (char *)lead_middle, COM_MAX_LEN, ",");
while (*p && p[-1] != ':') { // find end of end flags
// Check whether we allow automatic ending of comments
@@ -1258,7 +1258,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
}
p++;
}
- size_t n = copy_option_part(&p, lead_end, COM_MAX_LEN, ",");
+ size_t n = copy_option_part((char **)&p, (char *)lead_end, COM_MAX_LEN, ",");
if (end_comment_pending == -1) { // we can set it now
end_comment_pending = lead_end[n - 1];
@@ -1377,7 +1377,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
if (*p == COM_RIGHT || *p == COM_LEFT) {
c = *p++;
} else if (ascii_isdigit(*p) || *p == '-') {
- off = getdigits_int(&p, true, 0);
+ off = getdigits_int((char **)&p, true, 0);
} else {
p++;
}
@@ -1881,16 +1881,16 @@ void del_lines(long nlines, bool undo)
/// When "flags" is not NULL, it is set to point to the flags of the recognized comment leader.
/// "backward" must be true for the "O" command.
/// If "include_space" is set, include trailing whitespace while calculating the length.
-int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_space)
+int get_leader_len(char *line, char **flags, bool backward, bool include_space)
{
int j;
int got_com = false;
char part_buf[COM_MAX_LEN]; // buffer for one option part
- char_u *string; // pointer to comment string
- char_u *list;
+ char *string; // pointer to comment string
+ char *list;
int middle_match_len = 0;
- char_u *prev_list;
- char_u *saved_flags = NULL;
+ char *prev_list;
+ char *saved_flags = NULL;
int result = 0;
int i = 0;
@@ -1902,15 +1902,15 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa
while (line[i] != NUL) {
// scan through the 'comments' option for a match
int found_one = false;
- for (list = curbuf->b_p_com; *list;) {
+ for (list = (char *)curbuf->b_p_com; *list;) {
// Get one option part into part_buf[]. Advance "list" to next
// one. Put "string" at start of string.
if (!got_com && flags != NULL) {
*flags = list; // remember where flags started
}
prev_list = list;
- (void)copy_option_part(&list, (char_u *)part_buf, COM_MAX_LEN, ",");
- string = (char_u *)vim_strchr(part_buf, ':');
+ (void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
+ string = vim_strchr(part_buf, ':');
if (string == NULL) { // missing ':', ignore this part
continue;
}
@@ -2023,15 +2023,15 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa
///
/// When "flags" is not null, it is set to point to the flags describing the
/// recognized comment leader.
-int get_last_leader_offset(char_u *line, char_u **flags)
+int get_last_leader_offset(char *line, char **flags)
{
int result = -1;
int j;
int lower_check_bound = 0;
- char_u *string;
- char_u *com_leader;
- char_u *com_flags;
- char_u *list;
+ char *string;
+ char *com_leader;
+ char *com_flags;
+ char *list;
char part_buf[COM_MAX_LEN]; // buffer for one option part
// Repeat to match several nested comment strings.
@@ -2039,13 +2039,13 @@ int get_last_leader_offset(char_u *line, char_u **flags)
while (--i >= lower_check_bound) {
// scan through the 'comments' option for a match
int found_one = false;
- for (list = curbuf->b_p_com; *list;) {
- char_u *flags_save = list;
+ for (list = (char *)curbuf->b_p_com; *list;) {
+ char *flags_save = list;
// Get one option part into part_buf[]. Advance list to next one.
// put string at start of string.
- (void)copy_option_part(&list, (char_u *)part_buf, COM_MAX_LEN, ",");
- string = (char_u *)vim_strchr(part_buf, ':');
+ (void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
+ string = vim_strchr(part_buf, ':');
if (string == NULL) { // If everything is fine, this cannot actually
// happen.
continue;
@@ -2124,14 +2124,14 @@ int get_last_leader_offset(char_u *line, char_u **flags)
}
len1 = (int)STRLEN(com_leader);
- for (list = curbuf->b_p_com; *list;) {
- char_u *flags_save = list;
+ for (list = (char *)curbuf->b_p_com; *list;) {
+ char *flags_save = list;
- (void)copy_option_part(&list, (char_u *)part_buf2, COM_MAX_LEN, ",");
+ (void)copy_option_part(&list, part_buf2, COM_MAX_LEN, ",");
if (flags_save == com_flags) {
continue;
}
- string = (char_u *)vim_strchr(part_buf2, ':');
+ string = vim_strchr(part_buf2, ':');
string++;
while (ascii_iswhite(*string)) {
string++;
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 885ebca214..028dd70eb2 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -162,7 +162,7 @@ int buf_init_chartab(buf_T *buf, int global)
}
if (ascii_isdigit(*p)) {
- c = getdigits_int((char_u **)&p, true, 0);
+ c = getdigits_int((char **)&p, true, 0);
} else {
c = mb_ptr2char_adv(&p);
}
@@ -172,7 +172,7 @@ int buf_init_chartab(buf_T *buf, int global)
p++;
if (ascii_isdigit(*p)) {
- c2 = getdigits_int((char_u **)&p, true, 0);
+ c2 = getdigits_int((char **)&p, true, 0);
} else {
c2 = mb_ptr2char_adv(&p);
}
@@ -265,7 +265,7 @@ int buf_init_chartab(buf_T *buf, int global)
///
/// @param buf
/// @param bufsize
-void trans_characters(char_u *buf, int bufsize)
+void trans_characters(char *buf, int bufsize)
{
char_u *trs; // translated character
int len = (int)STRLEN(buf); // length of string needing translation
@@ -274,10 +274,10 @@ void trans_characters(char_u *buf, int bufsize)
while (*buf != 0) {
int trs_len; // length of trs[]
// Assume a multi-byte character doesn't need translation.
- if ((trs_len = utfc_ptr2len((char *)buf)) > 1) {
+ if ((trs_len = utfc_ptr2len(buf)) > 1) {
len -= trs_len;
} else {
- trs = transchar_byte(*buf);
+ trs = transchar_byte((uint8_t)(*buf));
trs_len = (int)STRLEN(trs);
if (trs_len > 1) {
@@ -1302,7 +1302,7 @@ char_u *skiptowhite(const char_u *p)
/// @param p
///
/// @return Pointer to the next whitespace character.
-char_u *skiptowhite_esc(char_u *p)
+char *skiptowhite_esc(char *p)
FUNC_ATTR_PURE
{
while (*p != ' ' && *p != '\t' && *p != NUL) {
@@ -1364,9 +1364,9 @@ intmax_t getdigits(char_u **pp, bool strict, intmax_t def)
/// Gets an int number from a string.
///
/// @see getdigits
-int getdigits_int(char_u **pp, bool strict, int def)
+int getdigits_int(char **pp, bool strict, int def)
{
- intmax_t number = getdigits(pp, strict, def);
+ intmax_t number = getdigits((char_u **)pp, strict, def);
#if SIZEOF_INTMAX_T > SIZEOF_INT
if (strict) {
assert(number >= INT_MIN && number <= INT_MAX);
diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c
index c7c7e6ae58..62cf60e03b 100644
--- a/src/nvim/cursor_shape.c
+++ b/src/nvim/cursor_shape.c
@@ -189,7 +189,7 @@ char *parse_shape_opt(int what)
if (!ascii_isdigit(*p)) {
return N_("E548: digit expected");
}
- int n = getdigits_int((char_u **)&p, false, 0);
+ int n = getdigits_int(&p, false, 0);
if (len == 3) { // "ver" or "hor"
if (n == 0) {
return N_("E549: Illegal percentage");
diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c
index 803427dd17..0eaff06833 100644
--- a/src/nvim/debugger.c
+++ b/src/nvim/debugger.c
@@ -523,7 +523,7 @@ static int dbg_parsearg(char_u *arg, garray_T *gap)
if (bp->dbg_type == DBG_FUNC) {
bp->dbg_name = vim_strsave((char_u *)p);
} else if (here) {
- bp->dbg_name = vim_strsave(curbuf->b_ffname);
+ bp->dbg_name = vim_strsave((char_u *)curbuf->b_ffname);
} else if (bp->dbg_type == DBG_EXPR) {
bp->dbg_name = vim_strsave((char_u *)p);
bp->dbg_val = eval_expr_no_emsg(bp);
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index e4d77cec9c..75021e90d6 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -2143,7 +2143,7 @@ int diffopt_changed(void)
diff_flags_new |= DIFF_FILLER;
} else if ((STRNCMP(p, "context:", 8) == 0) && ascii_isdigit(p[8])) {
p += 8;
- diff_context_new = getdigits_int(&p, false, diff_context_new);
+ diff_context_new = getdigits_int((char **)&p, false, diff_context_new);
} else if (STRNCMP(p, "iblank", 6) == 0) {
p += 6;
diff_flags_new |= DIFF_IBLANK;
@@ -2167,7 +2167,7 @@ int diffopt_changed(void)
diff_flags_new |= DIFF_VERTICAL;
} else if ((STRNCMP(p, "foldcolumn:", 11) == 0) && ascii_isdigit(p[11])) {
p += 11;
- diff_foldcolumn_new = getdigits_int(&p, false, diff_foldcolumn_new);
+ diff_foldcolumn_new = getdigits_int((char **)&p, false, diff_foldcolumn_new);
} else if (STRNCMP(p, "hiddenoff", 9) == 0) {
p += 9;
diff_flags_new |= DIFF_HIDDEN_OFF;
@@ -2562,7 +2562,7 @@ void ex_diffgetput(exarg_T *eap)
// digits only
i = (int)atol(eap->arg);
} else {
- i = buflist_findpat((char_u *)eap->arg, p, false, true, false);
+ i = buflist_findpat(eap->arg, (char *)p, false, true, false);
if (i < 0) {
// error message already given
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index cbff15c84a..355900c93f 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -1683,7 +1683,7 @@ void putdigraph(char_u *str)
emsg(_(e_number_exp));
return;
}
- int n = getdigits_int(&str, true, 0);
+ int n = getdigits_int((char **)&str, true, 0);
registerdigraph(char1, char2, n);
}
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index cba2f812e0..d21583e951 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1618,7 +1618,7 @@ char_u *buf_prompt_text(const buf_T *const buf)
if (buf->b_prompt_text == NULL) {
return (char_u *)"% ";
}
- return buf->b_prompt_text;
+ return (char_u *)buf->b_prompt_text;
}
// Return the effective prompt for the current buffer.
@@ -2955,7 +2955,7 @@ static void ins_compl_dictionaries(char_u *dict_start, char_u *pat, int flags, i
/* Expand wildcards in the dictionary name, but do not allow
* backticks (for security, the 'dict' option may have been set in
* a modeline). */
- copy_option_part(&dict, buf, LSIZE, ",");
+ copy_option_part((char **)&dict, (char *)buf, LSIZE, ",");
if (!thesaurus && STRCMP(buf, "spell") == 0) {
count = -1;
} else if (vim_strchr((char *)buf, '`') != NULL
@@ -3020,7 +3020,7 @@ static void ins_compl_files(int count, char_u **files, int thesaurus, int flags,
while (!got_int && !compl_interrupted
&& !vim_fgets(buf, LSIZE, fp)) {
ptr = buf;
- while (vim_regexec(regmatch, buf, (colnr_T)(ptr - buf))) {
+ while (vim_regexec(regmatch, (char *)buf, (colnr_T)(ptr - buf))) {
ptr = regmatch->startp[0];
if (CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode)) {
ptr = find_line_end(ptr);
@@ -4223,9 +4223,9 @@ static int ins_compl_get_exp(pos_T *ini)
msg_hist_off = true; // reset in msg_trunc_attr()
vim_snprintf((char *)IObuff, IOSIZE, _("Scanning: %s"),
ins_buf->b_fname == NULL
- ? (char_u *)buf_spname(ins_buf)
+ ? buf_spname(ins_buf)
: ins_buf->b_sfname == NULL
- ? (char_u *)ins_buf->b_fname
+ ? ins_buf->b_fname
: ins_buf->b_sfname);
(void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R));
} else if (*e_cpt == NUL) {
@@ -4257,7 +4257,7 @@ static int ins_compl_get_exp(pos_T *ini)
}
// in any case e_cpt is advanced to the next entry
- (void)copy_option_part(&e_cpt, IObuff, IOSIZE, ",");
+ (void)copy_option_part((char **)&e_cpt, (char *)IObuff, IOSIZE, ",");
found_all = true;
if (type == -1) {
@@ -4313,7 +4313,7 @@ static int ins_compl_get_exp(pos_T *ini)
if (find_tags(compl_pattern, &num_matches, &matches,
TAG_REGEXP | TAG_NAMES | TAG_NOIC | TAG_INS_COMP
| (l_ctrl_x_mode != CTRL_X_NORMAL ? TAG_VERBOSE : 0),
- TAG_MANY, curbuf->b_ffname) == OK && num_matches > 0) {
+ TAG_MANY, (char_u *)curbuf->b_ffname) == OK && num_matches > 0) {
ins_compl_add_matches(num_matches, matches, p_ic);
}
g_tag_at_cursor = false;
@@ -4516,7 +4516,8 @@ static int ins_compl_get_exp(pos_T *ini)
}
}
}
- if (ins_compl_add_infercase(ptr, len, p_ic, ins_buf == curbuf ? NULL : ins_buf->b_sfname,
+ if (ins_compl_add_infercase(ptr, len, p_ic,
+ ins_buf == curbuf ? NULL : (char_u *)ins_buf->b_sfname,
0, cont_s_ipos) != NOTDONE) {
found_new_match = OK;
break;
@@ -5773,21 +5774,18 @@ void insertchar(int c, int flags, int second_indent)
// Check whether this character should end a comment.
if (did_ai && c == end_comment_pending) {
- char_u *line;
char_u lead_end[COM_MAX_LEN]; // end-comment string
- int i;
- /*
- * Need to remove existing (middle) comment leader and insert end
- * comment leader. First, check what comment leader we can find.
- */
- i = get_leader_len(line = get_cursor_line_ptr(), &p, false, true);
+ // Need to remove existing (middle) comment leader and insert end
+ // comment leader. First, check what comment leader we can find.
+ char_u *line = get_cursor_line_ptr();
+ int i = get_leader_len((char *)line, (char **)&p, false, true);
if (i > 0 && vim_strchr((char *)p, COM_MIDDLE) != NULL) { // Just checking
// Skip middle-comment string
while (*p && p[-1] != ':') { // find end of middle flags
p++;
}
- int middle_len = (int)copy_option_part(&p, lead_end, COM_MAX_LEN, ",");
+ int middle_len = (int)copy_option_part((char **)&p, (char *)lead_end, COM_MAX_LEN, ",");
// Don't count trailing white space for middle_len
while (middle_len > 0 && ascii_iswhite(lead_end[middle_len - 1])) {
middle_len--;
@@ -5797,7 +5795,7 @@ void insertchar(int c, int flags, int second_indent)
while (*p && p[-1] != ':') { // find end of end flags
p++;
}
- int end_len = (int)copy_option_part(&p, lead_end, COM_MAX_LEN, ",");
+ int end_len = (int)copy_option_part((char **)&p, (char *)lead_end, COM_MAX_LEN, ",");
// Skip white space before the cursor
i = curwin->w_cursor.col;
@@ -5974,12 +5972,12 @@ static void internal_format(int textwidth, int second_indent, int flags, int for
// Don't break until after the comment leader
if (do_comments) {
char_u *line = get_cursor_line_ptr();
- leader_len = get_leader_len(line, NULL, false, true);
+ leader_len = get_leader_len((char *)line, NULL, false, true);
if (leader_len == 0 && curbuf->b_p_cin) {
// Check for a line comment after code.
int comment_start = check_linecomment(line);
if (comment_start != MAXCOL) {
- leader_len = get_leader_len(line + comment_start, NULL, false, true);
+ leader_len = get_leader_len((char *)line + comment_start, NULL, false, true);
if (leader_len != 0) {
leader_len += comment_start;
}
@@ -6374,7 +6372,7 @@ void auto_format(bool trailblank, bool prev_line)
// With the 'c' flag in 'formatoptions' and 't' missing: only format
// comments.
if (has_format_option(FO_WRAP_COMS) && !has_format_option(FO_WRAP)
- && get_leader_len(old, NULL, false, true) == 0) {
+ && get_leader_len((char *)old, NULL, false, true) == 0) {
return;
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 2ce48479b7..c7173c2078 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -986,7 +986,7 @@ void restore_vimvar(int idx, typval_T *save_tv)
vimvars[idx].vv_tv = *save_tv;
if (vimvars[idx].vv_type == VAR_UNKNOWN) {
- hi = hash_find(&vimvarht, vimvars[idx].vv_di.di_key);
+ hi = hash_find(&vimvarht, (char *)vimvars[idx].vv_di.di_key);
if (HASHITEM_EMPTY(hi)) {
internal_error("restore_vimvar()");
} else {
@@ -2822,7 +2822,7 @@ void ex_lockvar(exarg_T *eap)
if (eap->forceit) {
deep = -1;
} else if (ascii_isdigit(*arg)) {
- deep = getdigits_int((char_u **)&arg, false, -1);
+ deep = getdigits_int(&arg, false, -1);
arg = skipwhite(arg);
}
@@ -3019,7 +3019,7 @@ int do_unlet(const char *const name, const size_t name_len, const bool forceit)
}
}
- hashitem_T *hi = hash_find(ht, (const char_u *)varname);
+ hashitem_T *hi = hash_find(ht, varname);
if (HASHITEM_EMPTY(hi)) {
hi = find_hi_in_scoped_ht(name, &ht);
}
@@ -9814,7 +9814,7 @@ void func_line_start(void *cookie)
if (fp->uf_profiling && sourcing_lnum >= 1
&& sourcing_lnum <= fp->uf_lines.ga_len) {
- fp->uf_tml_idx = (int)(sourcing_lnum - 1);
+ fp->uf_tml_idx = sourcing_lnum - 1;
// Skip continuation lines.
while (fp->uf_tml_idx > 0 && FUNCLINE(fp, fp->uf_tml_idx) == NULL) {
fp->uf_tml_idx--;
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 96c6a4704c..8d267f6a9e 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -476,7 +476,7 @@ static buf_T *find_buffer(typval_T *avar)
if (avar->v_type == VAR_NUMBER) {
buf = buflist_findnr((int)avar->vval.v_number);
} else if (avar->v_type == VAR_STRING && avar->vval.v_string != NULL) {
- buf = buflist_findname_exp((char_u *)avar->vval.v_string);
+ buf = buflist_findname_exp(avar->vval.v_string);
if (buf == NULL) {
/* No full path name match, try a match with a URL or a "nofile"
* buffer, these don't use the full path. */
@@ -498,7 +498,7 @@ static void f_bufadd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
char_u *name = (char_u *)tv_get_string(&argvars[0]);
- rettv->vval.v_number = buflist_add(*name == NUL ? NULL : name, 0);
+ rettv->vval.v_number = buflist_add(*name == NUL ? NULL : (char *)name, 0);
}
/// "bufexists(expr)" function
@@ -586,7 +586,7 @@ static void f_bufnr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
&& tv_get_number_chk(&argvars[1], &error) != 0
&& !error
&& (name = tv_get_string_chk(&argvars[0])) != NULL) {
- buf = buflist_new((char_u *)name, NULL, 1, 0);
+ buf = buflist_new((char *)name, NULL, 1, 0);
}
if (buf != NULL) {
@@ -655,7 +655,7 @@ buf_T *tv_get_buf(typval_T *tv, int curtab_only)
save_cpo = p_cpo;
p_cpo = "";
- buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name),
+ buf = buflist_findnr(buflist_findpat((char *)name, (char *)name + STRLEN(name),
true, false, curtab_only));
p_magic = save_magic;
@@ -2396,7 +2396,7 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what)
fresult = find_file_in_path_option(first ? (char_u *)fname : NULL,
first ? strlen(fname) : 0,
0, first, path,
- find_what, curbuf->b_ffname,
+ find_what, (char_u *)curbuf->b_ffname,
(find_what == FINDFILE_DIR
? (char_u *)""
: curbuf->b_p_sua));
@@ -2574,7 +2574,7 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
}
}
- unsigned long count = (unsigned long)(foldend - foldstart + 1);
+ unsigned long count = (unsigned long)foldend - foldstart + 1;
txt = NGETTEXT("+-%s%3ld line: ", "+-%s%3ld lines: ", count);
r = xmalloc(STRLEN(txt)
+ STRLEN(dashes) // for %s
@@ -3308,8 +3308,8 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
[kCdScopeTabpage] = 0, // Number of tab to look at.
};
- char_u *cwd = NULL; // Current working directory to print
- char_u *from = NULL; // The original string to copy
+ char *cwd = NULL; // Current working directory to print
+ char *from = NULL; // The original string to copy
tabpage_T *tp = curtab; // The tabpage to look at.
win_T *win = curwin; // The window to look at.
@@ -3386,13 +3386,13 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
FALLTHROUGH;
case kCdScopeGlobal:
if (globaldir) { // `globaldir` is not always set.
- from = (char_u *)globaldir;
+ from = globaldir;
break;
}
FALLTHROUGH; // In global directory, just need to get OS CWD.
case kCdScopeInvalid: // If called without any arguments, get OS CWD.
- if (os_dirname(cwd, MAXPATHL) == FAIL) {
- from = (char_u *)""; // Return empty string on failure.
+ if (os_dirname((char_u *)cwd, MAXPATHL) == FAIL) {
+ from = ""; // Return empty string on failure.
}
}
@@ -3400,7 +3400,7 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
STRLCPY(cwd, from, MAXPATHL);
}
- rettv->vval.v_string = (char *)vim_strsave(cwd);
+ rettv->vval.v_string = xstrdup(cwd);
#ifdef BACKSLASH_IN_FILENAME
slash_adjust(rettv->vval.v_string);
#endif
@@ -5968,7 +5968,7 @@ static void f_mkdir(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (*path_tail(dir) == NUL) {
// Remove trailing slashes.
- *path_tail_with_sep((char_u *)dir) = NUL;
+ *path_tail_with_sep((char *)dir) = NUL;
}
if (argvars[1].v_type != VAR_UNKNOWN) {
@@ -6366,20 +6366,17 @@ static void f_prompt_getprompt(typval_T *argvars, typval_T *rettv, FunPtr fptr)
/// "prompt_setprompt({buffer}, {text})" function
static void f_prompt_setprompt(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
- buf_T *buf;
- const char_u *text;
-
if (check_secure()) {
return;
}
- buf = tv_get_buf(&argvars[0], false);
+ buf_T *buf = tv_get_buf(&argvars[0], false);
if (buf == NULL) {
return;
}
- text = (const char_u *)tv_get_string(&argvars[1]);
+ const char *text = tv_get_string(&argvars[1]);
xfree(buf->b_prompt_text);
- buf->b_prompt_text = vim_strsave(text);
+ buf->b_prompt_text = xstrdup(text);
}
/// "pum_getpos()" function
@@ -7341,7 +7338,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (!has_trailing_pathsep) {
q = p + strlen(p);
if (after_pathsep(p, q)) {
- *path_tail_with_sep((char_u *)p) = NUL;
+ *path_tail_with_sep(p) = NUL;
}
}
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 97726da5f4..e19cf411c0 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -1434,7 +1434,7 @@ dictitem_T *tv_dict_item_copy(dictitem_T *const di)
void tv_dict_item_remove(dict_T *const dict, dictitem_T *const item)
FUNC_ATTR_NONNULL_ALL
{
- hashitem_T *const hi = hash_find(&dict->dv_hashtab, item->di_key);
+ hashitem_T *const hi = hash_find(&dict->dv_hashtab, (char *)item->di_key);
if (HASHITEM_EMPTY(hi)) {
semsg(_(e_intern2), "tv_dict_item_remove()");
} else {
@@ -1567,7 +1567,7 @@ dictitem_T *tv_dict_find(const dict_T *const d, const char *const key, const ptr
return NULL;
}
hashitem_T *const hi = (len < 0
- ? hash_find(&d->dv_hashtab, (const char_u *)key)
+ ? hash_find(&d->dv_hashtab, key)
: hash_find_len(&d->dv_hashtab, key, (size_t)len));
if (HASHITEM_EMPTY(hi)) {
return NULL;
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 8646520ec3..c2579944e4 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -547,9 +547,7 @@ static char_u *fname_trans_sid(const char_u *const name, char_u *const fname_buf
/// @return NULL for unknown function.
ufunc_T *find_func(const char_u *name)
{
- hashitem_T *hi;
-
- hi = hash_find(&func_hashtab, name);
+ hashitem_T *hi = hash_find(&func_hashtab, (char *)name);
if (!HASHITEM_EMPTY(hi)) {
return HI2UF(hi);
}
@@ -724,7 +722,7 @@ static void funccal_unref(funccall_T *fc, ufunc_T *fp, bool force)
/// @return true if the entry was deleted, false if it wasn't found.
static bool func_remove(ufunc_T *fp)
{
- hashitem_T *hi = hash_find(&func_hashtab, UF2HIKEY(fp));
+ hashitem_T *hi = hash_find(&func_hashtab, (char *)UF2HIKEY(fp));
if (!HASHITEM_EMPTY(hi)) {
hash_remove(&func_hashtab, hi);
@@ -1045,7 +1043,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
char *s = tofree;
char buf[MSG_BUF_LEN];
if (vim_strsize(s) > MSG_BUF_CLEN) {
- trunc_string((char_u *)s, (char_u *)buf, MSG_BUF_CLEN, sizeof(buf));
+ trunc_string(s, buf, MSG_BUF_CLEN, sizeof(buf));
s = buf;
}
msg_puts(s);
@@ -1159,7 +1157,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
emsg_off--;
if (s != NULL) {
if (vim_strsize(s) > MSG_BUF_CLEN) {
- trunc_string((char_u *)s, (char_u *)buf, MSG_BUF_CLEN, MSG_BUF_LEN);
+ trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN);
s = buf;
}
smsg(_("%s returning %s"), sourcing_name, s);
@@ -1976,7 +1974,7 @@ void ex_function(exarg_T *eap)
--todo;
fp = HI2UF(hi);
if (!isdigit(*fp->uf_name)
- && vim_regexec(&regmatch, fp->uf_name, 0)) {
+ && vim_regexec(&regmatch, (char *)fp->uf_name, 0)) {
list_func_head(fp, false, false);
}
}
@@ -2537,7 +2535,7 @@ void ex_function(exarg_T *eap)
// insert the new function in the function list
STRCPY(fp->uf_name, name);
if (overwrite) {
- hi = hash_find(&func_hashtab, name);
+ hi = hash_find(&func_hashtab, (char *)name);
hi->hi_key = UF2HIKEY(fp);
} else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) {
xfree(fp);
diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c
index f40573a0bc..1b5cc23b09 100644
--- a/src/nvim/event/loop.c
+++ b/src/nvim/event/loop.c
@@ -27,6 +27,7 @@ void loop_init(Loop *loop, void *data)
uv_signal_init(&loop->uv, &loop->children_watcher);
uv_timer_init(&loop->uv, &loop->children_kill_timer);
uv_timer_init(&loop->uv, &loop->poll_timer);
+ uv_timer_init(&loop->uv, &loop->exit_delay_timer);
loop->poll_timer.data = xmalloc(sizeof(bool)); // "timeout expired" flag
}
@@ -136,6 +137,7 @@ bool loop_close(Loop *loop, bool wait)
uv_close((uv_handle_t *)&loop->children_watcher, NULL);
uv_close((uv_handle_t *)&loop->children_kill_timer, NULL);
uv_close((uv_handle_t *)&loop->poll_timer, timer_close_cb);
+ uv_close((uv_handle_t *)&loop->exit_delay_timer, NULL);
uv_close((uv_handle_t *)&loop->async, NULL);
uint64_t start = wait ? os_hrtime() : 0;
bool didstop = false;
diff --git a/src/nvim/event/loop.h b/src/nvim/event/loop.h
index c0c5bc527f..65980c6c05 100644
--- a/src/nvim/event/loop.h
+++ b/src/nvim/event/loop.h
@@ -36,6 +36,8 @@ typedef struct loop {
// generic timer, used by loop_poll_events()
uv_timer_t poll_timer;
+ uv_timer_t exit_delay_timer;
+
uv_async_t async;
uv_mutex_t mutex;
int recursive;
diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c
index 1ec11f1eb6..e029f778f6 100644
--- a/src/nvim/event/process.c
+++ b/src/nvim/event/process.c
@@ -386,11 +386,13 @@ static void process_close_handles(void **argv)
{
Process *proc = argv[0];
+ exit_need_delay++;
flush_stream(proc, &proc->out);
flush_stream(proc, &proc->err);
process_close_streams(proc);
process_close(proc);
+ exit_need_delay--;
}
static void on_process_exit(Process *proc)
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index b5b75b76a9..f97caf0703 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -560,7 +560,7 @@ void ex_sort(exarg_T *eap)
start_col = 0;
end_col = len;
- if (regmatch.regprog != NULL && vim_regexec(&regmatch, (char_u *)s, 0)) {
+ if (regmatch.regprog != NULL && vim_regexec(&regmatch, s, 0)) {
if (sort_rx) {
start_col = (colnr_T)(regmatch.startp[0] - (char_u *)s);
end_col = (colnr_T)(regmatch.endp[0] - (char_u *)s);
@@ -1732,19 +1732,19 @@ int rename_buffer(char *new_fname)
* But don't set the alternate file name if the buffer didn't have a
* name.
*/
- fname = (char *)curbuf->b_ffname;
- sfname = (char *)curbuf->b_sfname;
+ fname = curbuf->b_ffname;
+ sfname = curbuf->b_sfname;
xfname = curbuf->b_fname;
curbuf->b_ffname = NULL;
curbuf->b_sfname = NULL;
if (setfname(curbuf, new_fname, NULL, true) == FAIL) {
- curbuf->b_ffname = (char_u *)fname;
- curbuf->b_sfname = (char_u *)sfname;
+ curbuf->b_ffname = fname;
+ curbuf->b_sfname = sfname;
return FAIL;
}
curbuf->b_flags |= BF_NOTEDITED;
if (xfname != NULL && *xfname != NUL) {
- buf = buflist_new((char_u *)fname, (char_u *)xfname, curwin->w_cursor.lnum, 0);
+ buf = buflist_new(fname, xfname, curwin->w_cursor.lnum, 0);
if (buf != NULL && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
curwin->w_alt_fnum = buf->b_fnum;
}
@@ -1842,7 +1842,7 @@ int do_write(exarg_T *eap)
if (free_fname != NULL) {
ffname = free_fname;
}
- other = otherfile((char_u *)ffname);
+ other = otherfile(ffname);
}
/*
@@ -1851,9 +1851,9 @@ int do_write(exarg_T *eap)
if (other) {
if (vim_strchr(p_cpo, CPO_ALTWRITE) != NULL
|| eap->cmdidx == CMD_saveas) {
- alt_buf = setaltfname((char_u *)ffname, (char_u *)fname, (linenr_T)1);
+ alt_buf = setaltfname(ffname, fname, (linenr_T)1);
} else {
- alt_buf = buflist_findname((char_u *)ffname);
+ alt_buf = buflist_findname(ffname);
}
if (alt_buf != NULL && alt_buf->b_ml.ml_mfp != NULL) {
// Overwriting a file that is loaded in another buffer is not a
@@ -1873,7 +1873,7 @@ int do_write(exarg_T *eap)
}
if (!other) {
- ffname = (char *)curbuf->b_ffname;
+ ffname = curbuf->b_ffname;
fname = curbuf->b_fname;
// Not writing the whole file is only allowed with '!'.
if ((eap->line1 != 1
@@ -1913,12 +1913,12 @@ int do_write(exarg_T *eap)
fname = alt_buf->b_fname;
alt_buf->b_fname = curbuf->b_fname;
curbuf->b_fname = fname;
- fname = (char *)alt_buf->b_ffname;
+ fname = alt_buf->b_ffname;
alt_buf->b_ffname = curbuf->b_ffname;
- curbuf->b_ffname = (char_u *)fname;
- fname = (char *)alt_buf->b_sfname;
+ curbuf->b_ffname = fname;
+ fname = alt_buf->b_sfname;
alt_buf->b_sfname = curbuf->b_sfname;
- curbuf->b_sfname = (char_u *)fname;
+ curbuf->b_sfname = fname;
buf_name_changed(curbuf);
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, curbuf);
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, alt_buf);
@@ -1942,7 +1942,7 @@ int do_write(exarg_T *eap)
// Autocommands may have changed buffer names, esp. when
// 'autochdir' is set.
- fname = (char *)curbuf->b_sfname;
+ fname = curbuf->b_sfname;
}
name_was_missing = curbuf->b_ffname == NULL;
@@ -2031,7 +2031,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int oth
} else {
dir = xmalloc(MAXPATHL);
p = (char *)p_dir;
- copy_option_part((char_u **)&p, (char_u *)dir, MAXPATHL, ",");
+ copy_option_part(&p, dir, MAXPATHL, ",");
}
swapname = (char *)makeswapname((char_u *)fname, (char_u *)ffname, curbuf, (char_u *)dir);
xfree(dir);
@@ -2112,7 +2112,7 @@ void do_wqall(exarg_T *eap)
semsg(_("E141: No file name for buffer %" PRId64), (int64_t)buf->b_fnum);
error++;
} else if (check_readonly(&eap->forceit, buf)
- || check_overwrite(eap, buf, buf->b_fname, (char *)buf->b_ffname, false) == FAIL) {
+ || check_overwrite(eap, buf, buf->b_fname, buf->b_ffname, false) == FAIL) {
error++;
} else {
bufref_T bufref;
@@ -2155,8 +2155,8 @@ static int check_readonly(int *forceit, buf_T *buf)
// Handle a file being readonly when the 'readonly' option is set or when
// the file exists and permissions are read-only.
if (!*forceit && (buf->b_p_ro
- || (os_path_exists(buf->b_ffname)
- && !os_file_is_writable((char *)buf->b_ffname)))) {
+ || (os_path_exists((char_u *)buf->b_ffname)
+ && !os_file_is_writable(buf->b_ffname)))) {
if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && buf->b_fname != NULL) {
char buff[DIALOG_MSG_SIZE];
@@ -2218,7 +2218,7 @@ int getfile(int fnum, char *ffname_arg, char *sfname_arg, int setpm, linenr_T ln
if (fnum == 0) {
// make ffname full path, set sfname
fname_expand(curbuf, &ffname, &sfname);
- other = otherfile((char_u *)ffname);
+ other = otherfile(ffname);
free_me = ffname; // has been allocated, free() later
} else {
other = (fnum != curbuf->b_fnum);
@@ -2339,7 +2339,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
}
#ifdef USE_FNAME_CASE
if (sfname != NULL) {
- path_fix_case((char_u *)sfname); // set correct case for sfname
+ path_fix_case(sfname); // set correct case for sfname
}
#endif
@@ -2354,14 +2354,14 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
other_file = false;
} else {
if (*ffname == NUL) { // re-edit with same file name
- ffname = (char *)curbuf->b_ffname;
+ ffname = curbuf->b_ffname;
sfname = curbuf->b_fname;
}
free_fname = fix_fname(ffname); // may expand to full path name
if (free_fname != NULL) {
ffname = free_fname;
}
- other_file = otherfile((char_u *)ffname);
+ other_file = otherfile(ffname);
}
}
@@ -2384,7 +2384,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
| ((flags & ECMD_FORCEIT) ? CCGD_FORCEIT : 0)
| (eap == NULL ? 0 : CCGD_EXCMD))) {
if (fnum == 0 && other_file && ffname != NULL) {
- (void)setaltfname((char_u *)ffname, (char_u *)sfname, newlnum < 0 ? 0 : newlnum);
+ (void)setaltfname(ffname, sfname, newlnum < 0 ? 0 : newlnum);
}
goto theend;
}
@@ -2441,13 +2441,13 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
// Add BLN_NOCURWIN to avoid a new wininfo items are associated
// with the current window.
const buf_T *const newbuf
- = buflist_new((char_u *)ffname, (char_u *)sfname, tlnum, BLN_LISTED | BLN_NOCURWIN);
+ = buflist_new(ffname, sfname, tlnum, BLN_LISTED | BLN_NOCURWIN);
if (newbuf != NULL && (flags & ECMD_ALTBUF)) {
curwin->w_alt_fnum = newbuf->b_fnum;
}
goto theend;
}
- buf = buflist_new((char_u *)ffname, (char_u *)sfname, 0L,
+ buf = buflist_new(ffname, sfname, 0L,
BLN_CURBUF | (flags & ECMD_SET_HELP ? 0 : BLN_LISTED));
// Autocmds may change curwin and curbuf.
if (oldwin != NULL) {
@@ -5388,7 +5388,7 @@ void fix_help_buffer(void)
// $VIMRUNTIME.
char *p = (char *)p_rtp;
while (*p != NUL) {
- copy_option_part((char_u **)&p, NameBuff, MAXPATHL, ",");
+ copy_option_part(&p, (char *)NameBuff, MAXPATHL, ",");
char *const rt = vim_getenv("VIMRUNTIME");
if (rt != NULL
&& path_full_compare(rt, (char *)NameBuff, false, true) != kEqualFiles) {
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 621004103e..defe22ea9a 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -562,7 +562,7 @@ void dialog_changed(buf_T *buf, bool checkall)
if (ret == VIM_YES) {
if (buf->b_fname != NULL
- && check_overwrite(&ea, buf, buf->b_fname, (char *)buf->b_ffname, false) == OK) {
+ && check_overwrite(&ea, buf, buf->b_fname, buf->b_ffname, false) == OK) {
// didn't hit Cancel
(void)buf_write_all(buf, false);
}
@@ -578,8 +578,7 @@ void dialog_changed(buf_T *buf, bool checkall)
set_bufref(&bufref, buf2);
if (buf2->b_fname != NULL
- && check_overwrite(&ea, buf2, buf2->b_fname,
- (char *)buf2->b_ffname, false) == OK) {
+ && check_overwrite(&ea, buf2, buf2->b_fname, buf2->b_ffname, false) == OK) {
// didn't hit Cancel
(void)buf_write_all(buf2, false);
}
@@ -786,7 +785,7 @@ int buf_write_all(buf_T *buf, int forceit)
int retval;
buf_T *old_curbuf = curbuf;
- retval = (buf_write(buf, (char *)buf->b_ffname, buf->b_fname,
+ retval = (buf_write(buf, buf->b_ffname, buf->b_fname,
(linenr_T)1, buf->b_ml.ml_line_count, NULL,
false, forceit, true, false));
if (curbuf != old_curbuf) {
@@ -929,7 +928,7 @@ static int do_arglist(char *str, int what, int after, bool will_edit)
didone = false;
for (match = 0; match < ARGCOUNT; match++) {
- if (vim_regexec(&regmatch, (char_u *)alist_name(&ARGLIST[match]), (colnr_T)0)) {
+ if (vim_regexec(&regmatch, alist_name(&ARGLIST[match]), (colnr_T)0)) {
didone = true;
xfree(ARGLIST[match].ae_fname);
memmove(ARGLIST + match, ARGLIST + match + 1,
@@ -992,7 +991,7 @@ static bool editing_arg_idx(win_T *win)
!= WARGLIST(win)[win->w_arg_idx].ae_fnum
&& (win->w_buffer->b_ffname == NULL
|| !(path_full_compare(alist_name(&WARGLIST(win)[win->w_arg_idx]),
- (char *)win->w_buffer->b_ffname, true,
+ win->w_buffer->b_ffname, true,
true) & kEqualFiles))));
}
@@ -1011,7 +1010,7 @@ void check_arg_idx(win_T *win)
&& (win->w_buffer->b_fnum == GARGLIST[GARGCOUNT - 1].ae_fnum
|| (win->w_buffer->b_ffname != NULL
&& (path_full_compare(alist_name(&GARGLIST[GARGCOUNT - 1]),
- (char *)win->w_buffer->b_ffname, true, true)
+ win->w_buffer->b_ffname, true, true)
& kEqualFiles)))) {
arg_had_last = true;
}
@@ -1138,7 +1137,7 @@ void do_argfile(exarg_T *eap, int argn)
other = true;
if (buf_hide(curbuf)) {
p = fix_fname(alist_name(&ARGLIST[argn]));
- other = otherfile((char_u *)p);
+ other = otherfile(p);
xfree(p);
}
if ((!buf_hide(curbuf) || !other)
@@ -1551,7 +1550,7 @@ static void alist_add_list(int count, char **files, int after, bool will_edit)
for (int i = 0; i < count; i++) {
const int flags = BLN_LISTED | (will_edit ? BLN_CURBUF : 0);
ARGLIST[after + i].ae_fname = (char_u *)files[i];
- ARGLIST[after + i].ae_fnum = buflist_add((char_u *)files[i], flags);
+ ARGLIST[after + i].ae_fnum = buflist_add(files[i], flags);
}
ALIST(curwin)->al_ga.ga_len += count;
if (old_argcount > 0 && curwin->w_arg_idx >= after) {
@@ -1641,7 +1640,7 @@ void ex_options(exarg_T *eap)
bool multi_mods = 0;
buf[0] = NUL;
- (void)add_win_cmd_modifers(buf, &multi_mods);
+ (void)add_win_cmd_modifers(buf, &cmdmod, &multi_mods);
os_setenv("OPTWIN_CMD", buf, 1);
cmd_source(SYS_OPTWIN_FILE, NULL);
@@ -2265,7 +2264,7 @@ char_u *get_scriptname(LastSet last_set, bool *should_free)
}
*should_free = true;
- return home_replace_save(NULL, (char_u *)sname);
+ return (char_u *)home_replace_save(NULL, sname);
}
}
}
@@ -2494,8 +2493,7 @@ void script_line_start(void)
if (si->sn_prof_on && sourcing_lnum >= 1) {
// Grow the array before starting the timer, so that the time spent
// here isn't counted.
- (void)ga_grow(&si->sn_prl_ga,
- (int)(sourcing_lnum - si->sn_prl_ga.ga_len));
+ (void)ga_grow(&si->sn_prl_ga, sourcing_lnum - si->sn_prl_ga.ga_len);
si->sn_prl_idx = sourcing_lnum - 1;
while (si->sn_prl_ga.ga_len <= si->sn_prl_idx
&& si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen) {
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 8fe62ae424..f992badc5e 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1621,21 +1621,21 @@ int execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo, bool preview)
if (eap->cmdidx == CMD_bdelete || eap->cmdidx == CMD_bwipeout
|| eap->cmdidx == CMD_bunload) {
- p = (char *)skiptowhite_esc((char_u *)eap->arg);
+ p = skiptowhite_esc(eap->arg);
} else {
p = eap->arg + STRLEN(eap->arg);
while (p > eap->arg && ascii_iswhite(p[-1])) {
p--;
}
}
- eap->line2 = buflist_findpat((char_u *)eap->arg, (char_u *)p, (eap->argt & EX_BUFUNL) != 0,
+ eap->line2 = buflist_findpat(eap->arg, p, (eap->argt & EX_BUFUNL) != 0,
false, false);
eap->addr_count = 1;
eap->arg = skipwhite(p);
} else {
// If argument positions are specified, just use the first argument
- eap->line2 = buflist_findpat((char_u *)eap->args[0],
- (char_u *)(eap->args[0] + eap->arglens[0]),
+ eap->line2 = buflist_findpat(eap->args[0],
+ eap->args[0] + eap->arglens[0],
(eap->argt & EX_BUFUNL) != 0, false, false);
eap->addr_count = 1;
// Shift each argument by 1
@@ -2281,14 +2281,14 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
*/
if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout
|| ea.cmdidx == CMD_bunload) {
- p = (char *)skiptowhite_esc((char_u *)ea.arg);
+ p = skiptowhite_esc(ea.arg);
} else {
p = ea.arg + STRLEN(ea.arg);
while (p > ea.arg && ascii_iswhite(p[-1])) {
p--;
}
}
- ea.line2 = buflist_findpat((char_u *)ea.arg, (char_u *)p, (ea.argt & EX_BUFUNL) != 0,
+ ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0,
false, false);
if (ea.line2 < 0) { // failed
goto doend;
@@ -2341,7 +2341,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
do_return(&ea, TRUE, FALSE, NULL);
}
}
- need_rethrow = check_cstack = FALSE;
+ need_rethrow = check_cstack = false;
doend:
// can happen with zero line number
@@ -2623,7 +2623,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, cmdmod_T *cmod, bool
}
if (ascii_isdigit(*eap->cmd)) {
// zero means not set, one is verbose == 0, etc.
- cmod->cmod_verbose = atoi((char *)eap->cmd) + 1;
+ cmod->cmod_verbose = atoi(eap->cmd) + 1;
} else {
cmod->cmod_verbose = 2; // default: verbose == 1
}
@@ -5318,7 +5318,7 @@ static void ex_bunload(exarg_T *eap)
: eap->cmdidx == CMD_bwipeout
? DOBUF_WIPE
: DOBUF_UNLOAD,
- (char_u *)eap->arg, eap->addr_count, (int)eap->line1, (int)eap->line2,
+ eap->arg, eap->addr_count, (int)eap->line1, (int)eap->line2,
eap->forceit);
}
@@ -6455,20 +6455,7 @@ static size_t uc_check_code(char *code, size_t len, char *buf, ucmd_T *cmd, exar
}
case ct_MODS:
- result = quote ? 2 : 0;
- if (buf != NULL) {
- if (quote) {
- *buf++ = '"';
- }
- *buf = '\0';
- }
-
- result += uc_mods(buf);
-
- if (quote && buf != NULL) {
- buf += result - 2;
- *buf = '"';
- }
+ result = uc_mods(buf, &cmdmod, quote);
break;
case ct_REGISTER:
@@ -6508,43 +6495,45 @@ static size_t uc_check_code(char *code, size_t len, char *buf, ucmd_T *cmd, exar
return result;
}
-/// Add modifiers from "cmdmod.cmod_split" to "buf". Set "multi_mods" when one
+/// Add modifiers from "cmod->cmod_split" to "buf". Set "multi_mods" when one
/// was added.
///
/// @return the number of bytes added
-size_t add_win_cmd_modifers(char *buf, bool *multi_mods)
+size_t add_win_cmd_modifers(char *buf, const cmdmod_T *cmod, bool *multi_mods)
{
size_t result = 0;
// :aboveleft and :leftabove
- if (cmdmod.cmod_split & WSP_ABOVE) {
+ if (cmod->cmod_split & WSP_ABOVE) {
result += add_cmd_modifier(buf, "aboveleft", multi_mods);
}
// :belowright and :rightbelow
- if (cmdmod.cmod_split & WSP_BELOW) {
+ if (cmod->cmod_split & WSP_BELOW) {
result += add_cmd_modifier(buf, "belowright", multi_mods);
}
// :botright
- if (cmdmod.cmod_split & WSP_BOT) {
+ if (cmod->cmod_split & WSP_BOT) {
result += add_cmd_modifier(buf, "botright", multi_mods);
}
// :tab
- if (cmdmod.cmod_tab > 0) {
+ if (cmod->cmod_tab > 0) {
result += add_cmd_modifier(buf, "tab", multi_mods);
}
// :topleft
- if (cmdmod.cmod_split & WSP_TOP) {
+ if (cmod->cmod_split & WSP_TOP) {
result += add_cmd_modifier(buf, "topleft", multi_mods);
}
// :vertical
- if (cmdmod.cmod_split & WSP_VERT) {
+ if (cmod->cmod_split & WSP_VERT) {
result += add_cmd_modifier(buf, "vertical", multi_mods);
}
return result;
}
-size_t uc_mods(char *buf)
+/// Generate text for the "cmod" command modifiers.
+/// If "buf" is NULL just return the length.
+size_t uc_mods(char *buf, const cmdmod_T *cmod, bool quote)
{
size_t result = 0;
bool multi_mods = false;
@@ -6562,8 +6551,20 @@ size_t uc_mods(char *buf)
{ CMOD_KEEPMARKS, "keepmarks" },
{ CMOD_KEEPPATTERNS, "keeppatterns" },
{ CMOD_LOCKMARKS, "lockmarks" },
- { CMOD_NOSWAPFILE, "noswapfile" }
+ { CMOD_NOSWAPFILE, "noswapfile" },
+ { CMOD_UNSILENT, "unsilent" },
+ { CMOD_NOAUTOCMD, "noautocmd" },
+ { CMOD_SANDBOX, "sandbox" },
};
+
+ result = quote ? 2 : 0;
+ if (buf != NULL) {
+ if (quote) {
+ *buf++ = '"';
+ }
+ *buf = '\0';
+ }
+
// the modifiers that are simple flags
for (size_t i = 0; i < ARRAY_SIZE(mod_entries); i++) {
if (cmdmod.cmod_flags & mod_entries[i].flag) {
@@ -6571,23 +6572,23 @@ size_t uc_mods(char *buf)
}
}
- // TODO(vim): How to support :noautocmd?
- // TODO(vim): How to support :sandbox?
-
// :silent
if (msg_silent > 0) {
- result += add_cmd_modifier(buf, emsg_silent > 0 ? "silent!" : "silent", &multi_mods);
+ result += add_cmd_modifier(buf,
+ (cmod->cmod_flags & CMOD_ERRSILENT) ? "silent!" : "silent",
+ &multi_mods);
}
-
- // TODO(vim): How to support :unsilent?
-
// :verbose
if (p_verbose > 0) {
result += add_cmd_modifier(buf, "verbose", &multi_mods);
}
- // flags from cmdmod.cmod_split
- result += add_win_cmd_modifers(buf, &multi_mods);
+ // flags from cmod->cmod_split
+ result += add_win_cmd_modifers(buf, cmod, &multi_mods);
+ if (quote && buf != NULL) {
+ buf += result - 2;
+ *buf = '"';
+ }
return result;
}
@@ -7507,7 +7508,7 @@ void alist_set(alist_T *al, int count, char **files, int use_curbuf, int *fnum_l
/* May set buffer name of a buffer previously used for the
* argument list, so that it's re-used by alist_add. */
if (fnum_list != NULL && i < fnum_len) {
- buf_set_name(fnum_list[i], (char_u *)files[i]);
+ buf_set_name(fnum_list[i], files[i]);
}
alist_add(al, files[i], use_curbuf ? 2 : 1);
@@ -7537,7 +7538,7 @@ void alist_add(alist_T *al, char *fname, int set_fnum)
AARGLIST(al)[al->al_ga.ga_len].ae_fname = (char_u *)fname;
if (set_fnum > 0) {
AARGLIST(al)[al->al_ga.ga_len].ae_fnum =
- buflist_add((char_u *)fname, BLN_LISTED | (set_fnum == 2 ? BLN_CURBUF : 0));
+ buflist_add(fname, BLN_LISTED | (set_fnum == 2 ? BLN_CURBUF : 0));
}
++al->al_ga.ga_len;
}
@@ -7627,7 +7628,7 @@ void ex_splitview(exarg_T *eap)
if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) {
fname = (char *)find_file_in_path((char_u *)eap->arg, STRLEN(eap->arg),
- FNAME_MESS, true, curbuf->b_ffname);
+ FNAME_MESS, true, (char_u *)curbuf->b_ffname);
if (fname == NULL) {
goto theend;
}
@@ -7829,14 +7830,14 @@ static void ex_find(exarg_T *eap)
linenr_T count;
fname = (char *)find_file_in_path((char_u *)eap->arg, STRLEN(eap->arg),
- FNAME_MESS, true, curbuf->b_ffname);
+ FNAME_MESS, true, (char_u *)curbuf->b_ffname);
if (eap->addr_count > 0) {
// Repeat finding the file "count" times. This matters when it
// appears several times in the path.
count = eap->line2;
while (fname != NULL && --count > 0) {
xfree(fname);
- fname = (char *)find_file_in_path(NULL, 0, FNAME_MESS, false, curbuf->b_ffname);
+ fname = (char *)find_file_in_path(NULL, 0, FNAME_MESS, false, (char_u *)curbuf->b_ffname);
}
}
@@ -8087,11 +8088,11 @@ static void ex_read(exarg_T *eap)
if (check_fname() == FAIL) { // check for no file name
return;
}
- i = readfile((char *)curbuf->b_ffname, curbuf->b_fname,
+ i = readfile(curbuf->b_ffname, curbuf->b_fname,
eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false);
} else {
if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) {
- (void)setaltfname((char_u *)eap->arg, (char_u *)eap->arg, (linenr_T)1);
+ (void)setaltfname(eap->arg, eap->arg, (linenr_T)1);
}
i = readfile(eap->arg, NULL,
eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false);
@@ -8139,10 +8140,10 @@ static char *get_prevdir(CdScope scope)
{
switch (scope) {
case kCdScopeTabpage:
- return (char *)curtab->tp_prevdir;
+ return curtab->tp_prevdir;
break;
case kCdScopeWindow:
- return (char *)curwin->w_prevdir;
+ return curwin->w_prevdir;
break;
default:
return prev_dir;
@@ -8180,10 +8181,10 @@ static void post_chdir(CdScope scope, bool trigger_dirchanged)
XFREE_CLEAR(globaldir);
break;
case kCdScopeTabpage:
- curtab->tp_localdir = (char_u *)xstrdup(cwd);
+ curtab->tp_localdir = xstrdup(cwd);
break;
case kCdScopeWindow:
- curwin->w_localdir = (char_u *)xstrdup(cwd);
+ curwin->w_localdir = xstrdup(cwd);
break;
case kCdScopeInvalid:
abort();
@@ -8249,10 +8250,10 @@ bool changedir_func(char *new_dir, CdScope scope)
char **pp;
switch (scope) {
case kCdScopeTabpage:
- pp = (char **)&curtab->tp_prevdir;
+ pp = &curtab->tp_prevdir;
break;
case kCdScopeWindow:
- pp = (char **)&curwin->w_prevdir;
+ pp = &curwin->w_prevdir;
break;
default:
pp = &prev_dir;
@@ -8380,10 +8381,10 @@ static void ex_winsize(exarg_T *eap)
semsg(_(e_invarg2), arg);
return;
}
- int w = getdigits_int((char_u **)&arg, false, 10);
+ int w = getdigits_int(&arg, false, 10);
arg = skipwhite(arg);
char *p = arg;
- int h = getdigits_int((char_u **)&arg, false, 10);
+ int h = getdigits_int(&arg, false, 10);
if (*p != NUL && *arg == NUL) {
screen_resize(w, h);
} else {
@@ -8559,7 +8560,7 @@ static void ex_join(exarg_T *eap)
}
++eap->line2;
}
- do_join((size_t)(eap->line2 - eap->line1 + 1), !eap->forceit, true, true, true);
+ do_join((size_t)((ssize_t)eap->line2 - eap->line1 + 1), !eap->forceit, true, true, true);
beginline(BL_WHITE | BL_FIX);
ex_may_print(eap);
}
@@ -9478,7 +9479,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
if (*s == '<') { // "#<99" uses v:oldfiles.
s++;
}
- i = getdigits_int((char_u **)&s, false, 0);
+ i = getdigits_int(&s, false, 0);
if ((char_u *)s == src + 2 && src[1] == '-') {
// just a minus sign, don't skip over it
s--;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 49f946d6c0..f8c9e1f3ea 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -4455,14 +4455,13 @@ static void escape_fname(char_u **pp)
*/
void tilde_replace(char_u *orig_pat, int num_files, char_u **files)
{
- int i;
- char_u *p;
+ char *p;
if (orig_pat[0] == '~' && vim_ispathsep(orig_pat[1])) {
- for (i = 0; i < num_files; ++i) {
- p = home_replace_save(NULL, files[i]);
+ for (int i = 0; i < num_files; i++) {
+ p = home_replace_save(NULL, (char *)files[i]);
xfree(files[i]);
- files[i] = p;
+ files[i] = (char_u *)p;
}
}
}
@@ -5164,10 +5163,10 @@ static int ExpandFromContext(expand_T *xp, char_u *pat, int *num_file, char_u **
return OK;
}
if (xp->xp_context == EXPAND_BUFFERS) {
- return ExpandBufnames(pat, num_file, file, options);
+ return ExpandBufnames((char *)pat, num_file, (char ***)file, options);
}
if (xp->xp_context == EXPAND_DIFF_BUFFERS) {
- return ExpandBufnames(pat, num_file, file, options | BUF_DIFF_FILTER);
+ return ExpandBufnames((char *)pat, num_file, (char ***)file, options | BUF_DIFF_FILTER);
}
if (xp->xp_context == EXPAND_TAGS
|| xp->xp_context == EXPAND_TAGS_LISTFILES) {
@@ -5320,8 +5319,8 @@ static void ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, cha
if (*str == NUL) { // skip empty strings
continue;
}
- if (vim_regexec(regmatch, str, (colnr_T)0)) {
- ++count;
+ if (vim_regexec(regmatch, (char *)str, (colnr_T)0)) {
+ count++;
}
}
if (count == 0) {
@@ -5341,7 +5340,7 @@ static void ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, cha
if (*str == NUL) { // Skip empty strings.
continue;
}
- if (vim_regexec(regmatch, str, (colnr_T)0)) {
+ if (vim_regexec(regmatch, (char *)str, (colnr_T)0)) {
if (escaped) {
str = vim_strsave_escaped(str, (char_u *)" \t\\.");
} else {
@@ -5573,7 +5572,7 @@ static int ExpandUserDefined(expand_T *xp, regmatch_T *regmatch, int *num_file,
*e = NUL;
const bool skip = xp->xp_pattern[0]
- && vim_regexec(regmatch, s, (colnr_T)0) == 0;
+ && vim_regexec(regmatch, (char *)s, (colnr_T)0) == 0;
*e = keep;
if (!skip) {
GA_APPEND(char_u *, &ga, vim_strnsave(s, (size_t)(e - s)));
@@ -5814,7 +5813,7 @@ void globpath(char_u *path, char_u *file, garray_T *ga, int expand_options)
// Loop over all entries in {path}.
while (*path != NUL) {
// Copy one item of the path to buf[] and concatenate the file name.
- copy_option_part(&path, buf, MAXPATHL, ",");
+ copy_option_part((char **)&path, (char *)buf, MAXPATHL, ",");
if (STRLEN(buf) + STRLEN(file) + 2 < MAXPATHL) {
add_pathsep((char *)buf);
STRCAT(buf, file); // NOLINT
@@ -6293,7 +6292,7 @@ static int calc_hist_idx(int histype, int num)
wrapped = TRUE;
}
}
- if (hist[i].hisnum == num && hist[i].hisstr != NULL) {
+ if (i >= 0 && hist[i].hisnum == num && hist[i].hisstr != NULL) {
return i;
}
} else if (-num <= hislen) {
@@ -6370,7 +6369,7 @@ int del_history_entry(int histype, char_u *str)
if (hisptr->hisstr == NULL) {
break;
}
- if (vim_regexec(&regmatch, hisptr->hisstr, (colnr_T)0)) {
+ if (vim_regexec(&regmatch, (char *)hisptr->hisstr, (colnr_T)0)) {
found = true;
hist_free_entry(hisptr);
} else {
@@ -6538,7 +6537,7 @@ void ex_history(exarg_T *eap)
snprintf((char *)IObuff, IOSIZE, "%c%6d ", i == idx ? '>' : ' ',
hist[i].hisnum);
if (vim_strsize((char *)hist[i].hisstr) > Columns - 10) {
- trunc_string(hist[i].hisstr, IObuff + STRLEN(IObuff),
+ trunc_string((char *)hist[i].hisstr, (char *)IObuff + STRLEN(IObuff),
Columns - 10, IOSIZE - (int)STRLEN(IObuff));
} else {
STRCAT(IObuff, hist[i].hisstr);
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c
index a02232b402..d18ef3a188 100644
--- a/src/nvim/ex_session.c
+++ b/src/nvim/ex_session.c
@@ -248,9 +248,9 @@ static char *ses_get_fname(buf_T *buf, unsigned *flagp)
&& (ssop_flags & (SSOP_CURDIR | SSOP_SESDIR))
&& !p_acd
&& !did_lcd) {
- return (char *)buf->b_sfname;
+ return buf->b_sfname;
}
- return (char *)buf->b_ffname;
+ return buf->b_ffname;
}
/// Write a buffer name to the session file.
@@ -275,7 +275,7 @@ static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp, bool add_eol)
static char *ses_escape_fname(char *name, unsigned *flagp)
{
char *p;
- char *sname = (char *)home_replace_save(NULL, (char_u *)name);
+ char *sname = home_replace_save(NULL, name);
// Always SSOP_SLASH: change all backslashes to forward slashes.
for (p = sname; *p != NUL; MB_PTR_ADV(p)) {
@@ -517,7 +517,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
if (wp->w_localdir != NULL
&& (flagp != &vop_flags || (*flagp & SSOP_CURDIR))) {
if (fputs("lcd ", fd) < 0
- || ses_put_fname(fd, wp->w_localdir, flagp) == FAIL
+ || ses_put_fname(fd, (char_u *)wp->w_localdir, flagp) == FAIL
|| fprintf(fd, "\n") < 0) {
return FAIL;
}
@@ -542,7 +542,7 @@ static int makeopens(FILE *fd, char_u *dirnow)
int nr;
int restore_size = true;
win_T *wp;
- char_u *sname;
+ char *sname;
win_T *edited_win = NULL;
int tabnr;
win_T *tab_firstwin;
@@ -575,8 +575,8 @@ static int makeopens(FILE *fd, char_u *dirnow)
if (ssop_flags & SSOP_SESDIR) {
PUTLINE_FAIL("exe \"cd \" . escape(expand(\"<sfile>:p:h\"), ' ')");
} else if (ssop_flags & SSOP_CURDIR) {
- sname = home_replace_save(NULL, globaldir != NULL ? (char_u *)globaldir : dirnow);
- char *fname_esc = ses_escape_fname((char *)sname, &ssop_flags);
+ sname = home_replace_save(NULL, globaldir != NULL ? globaldir : (char *)dirnow);
+ char *fname_esc = ses_escape_fname(sname, &ssop_flags);
if (fprintf(fd, "cd %s\n", fname_esc) < 0) {
xfree(fname_esc);
xfree(sname);
@@ -821,7 +821,7 @@ static int makeopens(FILE *fd, char_u *dirnow)
// Take care of tab-local working directories if applicable
if (tp->tp_localdir) {
if (fputs("if exists(':tcd') == 2 | tcd ", fd) < 0
- || ses_put_fname(fd, tp->tp_localdir, &ssop_flags) == FAIL
+ || ses_put_fname(fd, (char_u *)tp->tp_localdir, &ssop_flags) == FAIL
|| fputs(" | endif\n", fd) < 0) {
return FAIL;
}
@@ -1001,7 +1001,7 @@ void ex_mkrc(exarg_T *eap)
*dirnow = NUL;
}
if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) {
- if (vim_chdirfile((char_u *)fname, kCdCauseOther) == OK) {
+ if (vim_chdirfile(fname, kCdCauseOther) == OK) {
shorten_fnames(true);
}
} else if (*dirnow != NUL
@@ -1075,7 +1075,7 @@ static char *get_view_file(int c)
emsg(_(e_noname));
return NULL;
}
- char *sname = (char *)home_replace_save(NULL, curbuf->b_ffname);
+ char *sname = home_replace_save(NULL, curbuf->b_ffname);
// We want a file name without separators, because we're not going to make
// a directory.
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index e327b97fbe..ca276b8a40 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -893,8 +893,7 @@ char_u *vim_findfile(void *search_ctx_arg)
break;
}
assert(MAXPATHL >= len);
- copy_option_part(&suf, file_path + len,
- MAXPATHL - len, ",");
+ copy_option_part((char **)&suf, (char *)file_path + len, MAXPATHL - len, ",");
}
}
} else {
@@ -1503,7 +1502,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
break;
}
assert(MAXPATHL >= l);
- copy_option_part(&buf, NameBuff + l, MAXPATHL - l, ",");
+ copy_option_part((char **)&buf, (char *)NameBuff + l, MAXPATHL - l, ",");
}
}
}
@@ -1543,7 +1542,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
// copy next path
buf[0] = 0;
- copy_option_part(&dir, buf, MAXPATHL, " ,");
+ copy_option_part((char **)&dir, (char *)buf, MAXPATHL, " ,");
// get the stopdir string
r_ptr = vim_findfile_stopdir(buf);
@@ -1653,12 +1652,12 @@ void do_autocmd_dirchanged(char *new_dir, CdScope scope, CdCause cause, bool pre
/// Caller must call shorten_fnames()!
///
/// @return OK or FAIL
-int vim_chdirfile(char_u *fname, CdCause cause)
+int vim_chdirfile(char *fname, CdCause cause)
{
char dir[MAXPATHL];
STRLCPY(dir, fname, MAXPATHL);
- *path_tail_with_sep((char_u *)dir) = NUL;
+ *path_tail_with_sep(dir) = NUL;
if (os_dirname(NameBuff, sizeof(NameBuff)) != OK) {
NameBuff[0] = NUL;
@@ -1688,7 +1687,7 @@ int vim_chdirfile(char_u *fname, CdCause cause)
int vim_chdir(char_u *new_dir)
{
char *dir_name = (char *)find_directory_in_path(new_dir, STRLEN(new_dir),
- FNAME_MESS, curbuf->b_ffname);
+ FNAME_MESS, (char_u *)curbuf->b_ffname);
if (dir_name == NULL) {
return -1;
}
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 9ba55befdd..febde53ce2 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -275,10 +275,9 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
// executing nasty autocommands. Also check if "fname" and "sfname"
// point to one of these values.
old_curbuf = curbuf;
- old_b_ffname = (char *)curbuf->b_ffname;
+ old_b_ffname = curbuf->b_ffname;
old_b_fname = curbuf->b_fname;
- using_b_ffname = ((char_u *)fname == curbuf->b_ffname)
- || ((char_u *)sfname == curbuf->b_ffname);
+ using_b_ffname = (fname == curbuf->b_ffname) || (sfname == curbuf->b_ffname);
using_b_fname = (fname == curbuf->b_fname) || (sfname == curbuf->b_fname);
// After reading a file the cursor line changes but we don't want to
@@ -373,7 +372,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
&& !S_ISFIFO(perm) // ... or fifo
&& !S_ISSOCK(perm) // ... or socket
#ifdef OPEN_CHR_FILES
- && !(S_ISCHR(perm) && is_dev_fd_file((char_u *)fname))
+ && !(S_ISCHR(perm) && is_dev_fd_file(fname))
// ... or a character special file named /dev/fd/<n>
#endif
) {
@@ -466,7 +465,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
// SwapExists autocommand may mess things up
if (curbuf != old_curbuf
|| (using_b_ffname
- && ((char_u *)old_b_ffname != curbuf->b_ffname))
+ && (old_b_ffname != curbuf->b_ffname))
|| (using_b_fname
&& (old_b_fname != curbuf->b_fname))) {
emsg(_(e_auchangedbuf));
@@ -538,7 +537,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
check_need_swap(newfile);
if (!read_stdin
&& (curbuf != old_curbuf
- || (using_b_ffname && ((char_u *)old_b_ffname != curbuf->b_ffname))
+ || (using_b_ffname && (old_b_ffname != curbuf->b_ffname))
|| (using_b_fname && (old_b_fname != curbuf->b_fname)))) {
emsg(_(e_auchangedbuf));
if (!read_buffer) {
@@ -645,7 +644,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
* (cd for example) if it invalidates fname or sfname.
*/
if (!read_stdin && (curbuf != old_curbuf
- || (using_b_ffname && ((char_u *)old_b_ffname != curbuf->b_ffname))
+ || (using_b_ffname && (old_b_ffname != curbuf->b_ffname))
|| (using_b_fname && (old_b_fname != curbuf->b_fname))
|| (fd = os_open(fname, O_RDONLY, 0)) < 0)) {
no_wait_return--;
@@ -1974,12 +1973,12 @@ failed:
/// Do not accept "/dev/fd/[012]", opening these may hang Vim.
///
/// @param fname file name to check
-bool is_dev_fd_file(char_u *fname)
+bool is_dev_fd_file(char *fname)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{
return STRNCMP(fname, "/dev/fd/", 8) == 0
- && ascii_isdigit(fname[8])
- && *skipdigits((char *)fname + 9) == NUL
+ && ascii_isdigit((uint8_t)fname[8])
+ && *skipdigits(fname + 9) == NUL
&& (fname[9] != NUL
|| (fname[8] != '0' && fname[8] != '1' && fname[8] != '2'));
}
@@ -2342,16 +2341,16 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
* Set curbuf to the buffer to be written.
* Careful: The autocommands may call buf_write() recursively!
*/
- if ((char_u *)ffname == buf->b_ffname) {
+ if (ffname == buf->b_ffname) {
buf_ffname = true;
}
- if ((char_u *)sfname == buf->b_sfname) {
+ if (sfname == buf->b_sfname) {
buf_sfname = true;
}
- if ((char_u *)fname == buf->b_ffname) {
+ if (fname == buf->b_ffname) {
buf_fname_f = true;
}
- if ((char_u *)fname == buf->b_sfname) {
+ if (fname == buf->b_sfname) {
buf_fname_s = true;
}
@@ -2491,16 +2490,16 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
* be kept in fname, ffname and sfname.
*/
if (buf_ffname) {
- ffname = (char *)buf->b_ffname;
+ ffname = buf->b_ffname;
}
if (buf_sfname) {
- sfname = (char *)buf->b_sfname;
+ sfname = buf->b_sfname;
}
if (buf_fname_f) {
- fname = (char *)buf->b_ffname;
+ fname = buf->b_ffname;
}
if (buf_fname_s) {
- fname = (char *)buf->b_sfname;
+ fname = buf->b_sfname;
}
}
@@ -2762,7 +2761,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
/*
* Isolate one directory name, using an entry in 'bdir'.
*/
- size_t dir_len = copy_option_part((char_u **)&dirp, IObuff, IOSIZE, ",");
+ size_t dir_len = copy_option_part(&dirp, (char *)IObuff, IOSIZE, ",");
p = (char *)IObuff + dir_len;
bool trailing_pathseps = after_pathsep((char *)IObuff, p) && p[-1] == p[-2];
if (trailing_pathseps) {
@@ -2923,7 +2922,7 @@ nobackup:
/*
* Isolate one directory name and make the backup file name.
*/
- size_t dir_len = copy_option_part((char_u **)&dirp, IObuff, IOSIZE, ",");
+ size_t dir_len = copy_option_part(&dirp, (char *)IObuff, IOSIZE, ",");
p = (char *)IObuff + dir_len;
bool trailing_pathseps = after_pathsep((char *)IObuff, p) && p[-1] == p[-2];
if (trailing_pathseps) {
@@ -4304,24 +4303,24 @@ static int make_bom(char_u *buf, char_u *name)
/// name.
void shorten_buf_fname(buf_T *buf, char_u *dirname, int force)
{
- char_u *p;
+ char *p;
if (buf->b_fname != NULL
&& !bt_nofile(buf)
&& !path_with_url(buf->b_fname)
&& (force
|| buf->b_sfname == NULL
- || path_is_absolute(buf->b_sfname))) {
+ || path_is_absolute((char_u *)buf->b_sfname))) {
if (buf->b_sfname != buf->b_ffname) {
XFREE_CLEAR(buf->b_sfname);
}
- p = path_shorten_fname(buf->b_ffname, dirname);
+ p = (char *)path_shorten_fname((char_u *)buf->b_ffname, dirname);
if (p != NULL) {
- buf->b_sfname = vim_strsave(p);
- buf->b_fname = (char *)buf->b_sfname;
+ buf->b_sfname = xstrdup(p);
+ buf->b_fname = buf->b_sfname;
}
if (p == NULL) {
- buf->b_fname = (char *)buf->b_ffname;
+ buf->b_fname = buf->b_ffname;
}
}
}
@@ -4918,7 +4917,7 @@ int buf_check_timestamp(buf_T *buf)
bool file_info_ok;
if (!(buf->b_flags & BF_NOTEDITED)
&& buf->b_mtime != 0
- && (!(file_info_ok = os_fileinfo((char *)buf->b_ffname, &file_info))
+ && (!(file_info_ok = os_fileinfo(buf->b_ffname, &file_info))
|| time_differs(&file_info, buf->b_mtime, buf->b_mtime_ns)
|| (int)file_info.stat.st_mode != buf->b_orig_mode)) {
const long prev_b_mtime = buf->b_mtime;
@@ -5016,7 +5015,7 @@ int buf_check_timestamp(buf_T *buf)
}
}
} else if ((buf->b_flags & BF_NEW) && !(buf->b_flags & BF_NEW_W)
- && os_path_exists(buf->b_ffname)) {
+ && os_path_exists((char_u *)buf->b_ffname)) {
retval = 1;
mesg = _("W13: Warning: File \"%s\" has been created after editing started");
buf->b_flags |= BF_NEW_W;
@@ -5024,7 +5023,7 @@ int buf_check_timestamp(buf_T *buf)
}
if (mesg != NULL) {
- path = home_replace_save(buf, (char_u *)buf->b_fname);
+ path = (char_u *)home_replace_save(buf, buf->b_fname);
if (!helpmesg) {
mesg2 = "";
}
@@ -5169,7 +5168,7 @@ void buf_reload(buf_T *buf, int orig_mode, bool reload_options)
if (saved == OK) {
curbuf->b_flags |= BF_CHECK_RO; // check for RO again
keep_filetype = true; // don't detect 'filetype'
- if (readfile((char *)buf->b_ffname, buf->b_fname, (linenr_T)0, (linenr_T)0,
+ if (readfile(buf->b_ffname, buf->b_fname, (linenr_T)0, (linenr_T)0,
(linenr_T)MAXLNUM, &ea, flags, false) != OK) {
if (!aborting()) {
semsg(_("E321: Could not reload \"%s\""), buf->b_fname);
@@ -5547,10 +5546,10 @@ bool match_file_pat(char *pattern, regprog_T **prog, char *fname, char *sfname,
*/
if (regmatch.regprog != NULL
&& ((allow_dirs
- && (vim_regexec(&regmatch, (char_u *)fname, (colnr_T)0)
+ && (vim_regexec(&regmatch, fname, (colnr_T)0)
|| (sfname != NULL
- && vim_regexec(&regmatch, (char_u *)sfname, (colnr_T)0))))
- || (!allow_dirs && vim_regexec(&regmatch, (char_u *)tail, (colnr_T)0)))) {
+ && vim_regexec(&regmatch, sfname, (colnr_T)0))))
+ || (!allow_dirs && vim_regexec(&regmatch, tail, (colnr_T)0)))) {
result = true;
}
@@ -5586,7 +5585,7 @@ bool match_file_list(char_u *list, char_u *sfname, char_u *ffname)
// try all patterns in 'wildignore'
p = list;
while (*p) {
- copy_option_part(&p, buf, ARRAY_SIZE(buf), ",");
+ copy_option_part((char **)&p, (char *)buf, ARRAY_SIZE(buf), ",");
regpat = (char_u *)file_pat_to_reg_pat((char *)buf, NULL, &allow_dirs, false);
if (regpat == NULL) {
break;
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index 3c3aaa1031..8f26e03a94 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -3,9 +3,7 @@
// vim: set fdm=marker fdl=1 fdc=3
-/*
- * fold.c: code for folding
- */
+// fold.c: code for folding
#include <inttypes.h>
#include <string.h>
@@ -41,12 +39,12 @@
// local declarations. {{{1
// typedef fold_T {{{2
-/*
- * The toplevel folds for each window are stored in the w_folds growarray.
- * Each toplevel fold can contain an array of second level folds in the
- * fd_nested growarray.
- * The info stored in both growarrays is the same: An array of fold_T.
- */
+
+// The toplevel folds for each window are stored in the w_folds growarray.
+// Each toplevel fold can contain an array of second level folds in the
+// fd_nested growarray.
+// The info stored in both growarrays is the same: An array of fold_T.
+
typedef struct {
linenr_T fd_top; // first line of fold; for nested fold
// relative to parent
@@ -93,20 +91,16 @@ typedef void (*LevelGetter)(fline_T *);
#endif
static char *e_nofold = N_("E490: No fold found");
-/*
- * While updating the folds lines between invalid_top and invalid_bot have an
- * undefined fold level. Only used for the window currently being updated.
- */
+// While updating the folds lines between invalid_top and invalid_bot have an
+// undefined fold level. Only used for the window currently being updated.
static linenr_T invalid_top = (linenr_T)0;
static linenr_T invalid_bot = (linenr_T)0;
-/*
- * When using 'foldexpr' we sometimes get the level of the next line, which
- * calls foldlevel() to get the level of the current line, which hasn't been
- * stored yet. To get around this chicken-egg problem the level of the
- * previous line is stored here when available. prev_lnum is zero when the
- * level is not available.
- */
+// When using 'foldexpr' we sometimes get the level of the next line, which
+// calls foldlevel() to get the level of the current line, which hasn't been
+// stored yet. To get around this chicken-egg problem the level of the
+// previous line is stored here when available. prev_lnum is zero when the
+// level is not available.
static linenr_T prev_lnum = 0;
static int prev_lnum_lvl = -1;
@@ -130,7 +124,7 @@ void copyFoldingState(win_T *wp_from, win_T *wp_to)
}
// hasAnyFolding() {{{2
-/// @return TRUE if there may be folded lines in the current window.
+/// @return true if there may be folded lines in the current window.
int hasAnyFolding(win_T *win)
{
// very simple now, but can become more complex later
@@ -160,16 +154,6 @@ bool hasFolding(linenr_T lnum, linenr_T *firstp, linenr_T *lastp)
bool hasFoldingWin(win_T *const win, const linenr_T lnum, linenr_T *const firstp,
linenr_T *const lastp, const bool cache, foldinfo_T *const infop)
{
- bool had_folded = false;
- linenr_T first = 0;
- linenr_T last = 0;
- linenr_T lnum_rel = lnum;
- fold_T *fp;
- int level = 0;
- bool use_level = false;
- bool maybe_small = false;
- int low_level = 0;
-
checkupdate(win);
// Return quickly when there is no folding at all in this window.
@@ -180,11 +164,13 @@ bool hasFoldingWin(win_T *const win, const linenr_T lnum, linenr_T *const firstp
return false;
}
+ bool had_folded = false;
+ linenr_T first = 0;
+ linenr_T last = 0;
+
if (cache) {
- /*
- * First look in cached info for displayed lines. This is probably
- * the fastest, but it can only be used if the entry is still valid.
- */
+ // First look in cached info for displayed lines. This is probably
+ // the fastest, but it can only be used if the entry is still valid.
const int x = find_wl_entry(win, lnum);
if (x >= 0) {
first = win->w_lines[x].wl_lnum;
@@ -193,10 +179,15 @@ bool hasFoldingWin(win_T *const win, const linenr_T lnum, linenr_T *const firstp
}
}
+ linenr_T lnum_rel = lnum;
+ int level = 0;
+ int low_level = 0;
+ fold_T *fp;
+ bool maybe_small = false;
+ bool use_level = false;
+
if (first == 0) {
- /*
- * Recursively search for a fold that contains "lnum".
- */
+ // Recursively search for a fold that contains "lnum".
garray_T *gap = &win->w_folds;
for (;;) {
if (!foldFind(gap, lnum_rel, &fp)) {
@@ -224,7 +215,7 @@ bool hasFoldingWin(win_T *const win, const linenr_T lnum, linenr_T *const firstp
// relative to containing fold.
gap = &fp->fd_nested;
lnum_rel -= fp->fd_top;
- ++level;
+ level++;
}
}
@@ -311,42 +302,42 @@ foldinfo_T fold_info(win_T *win, linenr_T lnum)
}
// foldmethodIsManual() {{{2
-/// @return TRUE if 'foldmethod' is "manual"
+/// @return true if 'foldmethod' is "manual"
int foldmethodIsManual(win_T *wp)
{
return wp->w_p_fdm[3] == 'u';
}
// foldmethodIsIndent() {{{2
-/// @return TRUE if 'foldmethod' is "indent"
+/// @return true if 'foldmethod' is "indent"
int foldmethodIsIndent(win_T *wp)
{
return wp->w_p_fdm[0] == 'i';
}
// foldmethodIsExpr() {{{2
-/// @return TRUE if 'foldmethod' is "expr"
+/// @return true if 'foldmethod' is "expr"
int foldmethodIsExpr(win_T *wp)
{
return wp->w_p_fdm[1] == 'x';
}
// foldmethodIsMarker() {{{2
-/// @return TRUE if 'foldmethod' is "marker"
+/// @return true if 'foldmethod' is "marker"
int foldmethodIsMarker(win_T *wp)
{
return wp->w_p_fdm[2] == 'r';
}
// foldmethodIsSyntax() {{{2
-/// @return TRUE if 'foldmethod' is "syntax"
+/// @return true if 'foldmethod' is "syntax"
int foldmethodIsSyntax(win_T *wp)
{
return wp->w_p_fdm[0] == 's';
}
// foldmethodIsDiff() {{{2
-/// @return TRUE if 'foldmethod' is "diff"
+/// @return true if 'foldmethod' is "diff"
int foldmethodIsDiff(win_T *wp)
{
return wp->w_p_fdm[0] == 'd';
@@ -372,18 +363,17 @@ void closeFoldRecurse(pos_T pos)
/// Open or Close folds for current window in lines "first" to "last".
/// Used for "zo", "zO", "zc" and "zC" in Visual mode.
///
-/// @param opening TRUE to open, FALSE to close
-/// @param recurse TRUE to do it recursively
-/// @param had_visual TRUE when Visual selection used
+/// @param opening true to open, false to close
+/// @param recurse true to do it recursively
+/// @param had_visual true when Visual selection used
void opFoldRange(pos_T firstpos, pos_T lastpos, int opening, int recurse, int had_visual)
{
int done = DONE_NOTHING; // avoid error messages
linenr_T first = firstpos.lnum;
linenr_T last = lastpos.lnum;
- linenr_T lnum;
linenr_T lnum_next;
- for (lnum = first; lnum <= last; lnum = lnum_next + 1) {
+ for (linenr_T lnum = first; lnum <= last; lnum = lnum_next + 1) {
pos_T temp = { lnum, 0, 0 };
lnum_next = lnum;
// Opening one level only: next fold to open is after the one going to
@@ -426,12 +416,10 @@ void openFoldRecurse(pos_T pos)
/// Open folds until the cursor line is not in a closed fold.
void foldOpenCursor(void)
{
- int done;
-
checkupdate(curwin);
if (hasAnyFolding(curwin)) {
for (;;) {
- done = DONE_NOTHING;
+ int done = DONE_NOTHING;
(void)setManualFold(curwin->w_cursor, true, false, &done);
if (!(done & DONE_ACTION)) {
break;
@@ -447,9 +435,7 @@ void newFoldLevel(void)
newFoldLevelWin(curwin);
if (foldmethodIsDiff(curwin) && curwin->w_p_scb) {
- /*
- * Set the same foldlevel in other windows in diff mode.
- */
+ // Set the same foldlevel in other windows in diff mode.
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp != curwin && foldmethodIsDiff(wp) && wp->w_p_scb) {
wp->w_p_fdl = curwin->w_p_fdl;
@@ -461,15 +447,13 @@ void newFoldLevel(void)
static void newFoldLevelWin(win_T *wp)
{
- fold_T *fp;
-
checkupdate(wp);
if (wp->w_fold_manual) {
// Set all flags for the first level of folds to FD_LEVEL. Following
// manual open/close will then change the flags to FD_OPEN or
// FD_CLOSED for those folds that don't use 'foldlevel'.
- fp = (fold_T *)wp->w_folds.ga_data;
- for (int i = 0; i < wp->w_folds.ga_len; ++i) {
+ fold_T *fp = (fold_T *)wp->w_folds.ga_data;
+ for (int i = 0; i < wp->w_folds.ga_len; i++) {
fp[i].fd_flags = FD_LEVEL;
}
wp->w_fold_manual = false;
@@ -491,19 +475,18 @@ void foldCheckClose(void)
}
// checkCloseRec() {{{2
-static int checkCloseRec(garray_T *gap, linenr_T lnum, int level)
+static bool checkCloseRec(garray_T *gap, linenr_T lnum, int level)
{
- fold_T *fp;
- int retval = FALSE;
+ bool retval = false;
- fp = (fold_T *)gap->ga_data;
- for (int i = 0; i < gap->ga_len; ++i) {
+ fold_T *fp = (fold_T *)gap->ga_data;
+ for (int i = 0; i < gap->ga_len; i++) {
// Only manually opened folds may need to be closed.
if (fp[i].fd_flags == FD_OPEN) {
if (level <= 0 && (lnum < fp[i].fd_top
|| lnum >= fp[i].fd_top + fp[i].fd_len)) {
fp[i].fd_flags = FD_LEVEL;
- retval = TRUE;
+ retval = true;
} else {
retval |= checkCloseRec(&fp[i].fd_nested, lnum - fp[i].fd_top,
level - 1);
@@ -514,19 +497,19 @@ static int checkCloseRec(garray_T *gap, linenr_T lnum, int level)
}
// foldCreateAllowed() {{{2
-/// @return TRUE if it's allowed to manually create or delete a fold or,
-/// give an error message and return FALSE if not.
+/// @return true if it's allowed to manually create or delete a fold or,
+/// give an error message and return false if not.
int foldManualAllowed(bool create)
{
if (foldmethodIsManual(curwin) || foldmethodIsMarker(curwin)) {
- return TRUE;
+ return true;
}
if (create) {
emsg(_("E350: Cannot create fold with current 'foldmethod'"));
} else {
emsg(_("E351: Cannot delete fold with current 'foldmethod'"));
}
- return FALSE;
+ return false;
}
// foldCreate() {{{2
@@ -534,13 +517,8 @@ int foldManualAllowed(bool create)
/// window.
void foldCreate(win_T *wp, pos_T start, pos_T end)
{
- fold_T *fp;
- garray_T *gap;
- garray_T fold_ga;
- int i;
- int cont;
- int use_level = FALSE;
- int closed = FALSE;
+ int use_level = false;
+ int closed = false;
int level = 0;
pos_T start_rel = start;
pos_T end_rel = end;
@@ -561,11 +539,14 @@ void foldCreate(win_T *wp, pos_T start, pos_T end)
checkupdate(wp);
+ int i;
+
// Find the place to insert the new fold
- gap = &wp->w_folds;
+ garray_T *gap = &wp->w_folds;
if (gap->ga_len == 0) {
i = 0;
} else {
+ fold_T *fp;
for (;;) {
if (!foldFind(gap, start_rel.lnum, &fp)) {
break;
@@ -599,10 +580,12 @@ void foldCreate(win_T *wp, pos_T start, pos_T end)
ga_grow(gap, 1);
{
- fp = (fold_T *)gap->ga_data + i;
+ fold_T *fp = (fold_T *)gap->ga_data + i;
+ garray_T fold_ga;
ga_init(&fold_ga, (int)sizeof(fold_T), 10);
// Count number of folds that will be contained in the new fold.
+ int cont;
for (cont = 0; i + cont < gap->ga_len; cont++) {
if (fp[cont].fd_top > end_rel.lnum) {
break;
@@ -668,7 +651,6 @@ void foldCreate(win_T *wp, pos_T start, pos_T end)
void deleteFold(win_T *const wp, const linenr_T start, const linenr_T end, const int recursive,
const bool had_visual)
{
- fold_T *fp;
fold_T *found_fp = NULL;
linenr_T found_off = 0;
bool maybe_small = false;
@@ -687,6 +669,7 @@ void deleteFold(win_T *const wp, const linenr_T start, const linenr_T end, const
linenr_T lnum_off = 0;
bool use_level = false;
for (;;) {
+ fold_T *fp;
if (!foldFind(gap, lnum - lnum_off, &fp)) {
break;
}
@@ -704,10 +687,10 @@ void deleteFold(win_T *const wp, const linenr_T start, const linenr_T end, const
// check nested folds
gap = &fp->fd_nested;
lnum_off += fp->fd_top;
- ++level;
+ level++;
}
if (found_ga == NULL) {
- ++lnum;
+ lnum++;
} else {
lnum = found_fp->fd_top + found_fp->fd_len + found_off;
@@ -808,7 +791,7 @@ void foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
int save_got_int = got_int;
// reset got_int here, otherwise it won't work
- got_int = FALSE;
+ got_int = false;
foldUpdateIEMS(wp, top, bot);
got_int |= save_got_int;
}
@@ -944,7 +927,7 @@ int foldMoveTo(const bool updown, const int dir, const long count)
// Check nested folds (if any).
gap = &fp->fd_nested;
lnum_off += fp->fd_top;
- ++level;
+ level++;
}
if (lnum_found != curwin->w_cursor.lnum) {
if (retval == FAIL) {
@@ -970,15 +953,13 @@ void foldInitWin(win_T *new_win)
// find_wl_entry() {{{2
/// Find an entry in the win->w_lines[] array for buffer line "lnum".
-/// Only valid entries are considered (for entries where wl_valid is FALSE the
+/// Only valid entries are considered (for entries where wl_valid is false the
/// line number can be wrong).
///
/// @return index of entry or -1 if not found.
int find_wl_entry(win_T *win, linenr_T lnum)
{
- int i;
-
- for (i = 0; i < win->w_lines_valid; ++i) {
+ for (int i = 0; i < win->w_lines_valid; i++) {
if (win->w_lines[i].wl_valid) {
if (lnum < win->w_lines[i].wl_lnum) {
return -1;
@@ -995,13 +976,13 @@ int find_wl_entry(win_T *win, linenr_T lnum)
/// Adjust the Visual area to include any fold at the start or end completely.
void foldAdjustVisual(void)
{
- pos_T *start, *end;
- char_u *ptr;
-
if (!VIsual_active || !hasAnyFolding(curwin)) {
return;
}
+ pos_T *start, *end;
+ char_u *ptr;
+
if (ltoreq(VIsual, curwin->w_cursor)) {
start = &VIsual;
end = &curwin->w_cursor;
@@ -1035,9 +1016,6 @@ void foldAdjustCursor(void)
/// Will "clone" (i.e deep copy) a garray_T of folds.
void cloneFoldGrowArray(garray_T *from, garray_T *to)
{
- fold_T *from_p;
- fold_T *to_p;
-
ga_init(to, from->ga_itemsize, from->ga_growsize);
if (GA_EMPTY(from)) {
@@ -1046,8 +1024,8 @@ void cloneFoldGrowArray(garray_T *from, garray_T *to)
ga_grow(to, from->ga_len);
- from_p = (fold_T *)from->ga_data;
- to_p = (fold_T *)to->ga_data;
+ fold_T *from_p = (fold_T *)from->ga_data;
+ fold_T *to_p = (fold_T *)to->ga_data;
for (int i = 0; i < from->ga_len; i++) {
to_p->fd_top = from_p->fd_top;
@@ -1055,9 +1033,9 @@ void cloneFoldGrowArray(garray_T *from, garray_T *to)
to_p->fd_flags = from_p->fd_flags;
to_p->fd_small = from_p->fd_small;
cloneFoldGrowArray(&from_p->fd_nested, &to_p->fd_nested);
- ++to->ga_len;
- ++from_p;
- ++to_p;
+ to->ga_len++;
+ from_p++;
+ to_p++;
}
}
@@ -1069,22 +1047,17 @@ void cloneFoldGrowArray(garray_T *from, garray_T *to)
/// @return false when there is no fold that contains "lnum".
static bool foldFind(const garray_T *gap, linenr_T lnum, fold_T **fpp)
{
- linenr_T low, high;
- fold_T *fp;
-
if (gap->ga_len == 0) {
*fpp = NULL;
return false;
}
- /*
- * Perform a binary search.
- * "low" is lowest index of possible match.
- * "high" is highest index of possible match.
- */
- fp = (fold_T *)gap->ga_data;
- low = 0;
- high = gap->ga_len - 1;
+ // Perform a binary search.
+ // "low" is lowest index of possible match.
+ // "high" is highest index of possible match.
+ fold_T *fp = (fold_T *)gap->ga_data;
+ linenr_T low = 0;
+ linenr_T high = gap->ga_len - 1;
while (low <= high) {
linenr_T i = (low + high) / 2;
if (fp[i].fd_top > lnum) {
@@ -1110,10 +1083,9 @@ static int foldLevelWin(win_T *wp, linenr_T lnum)
fold_T *fp;
linenr_T lnum_rel = lnum;
int level = 0;
- garray_T *gap;
// Recursively search for a fold that contains "lnum".
- gap = &wp->w_folds;
+ garray_T *gap = &wp->w_folds;
for (;;) {
if (!foldFind(gap, lnum_rel, &fp)) {
break;
@@ -1121,7 +1093,7 @@ static int foldLevelWin(win_T *wp, linenr_T lnum)
// Check nested folds. Line number is relative to containing fold.
gap = &fp->fd_nested;
lnum_rel -= fp->fd_top;
- ++level;
+ level++;
}
return level;
@@ -1142,11 +1114,8 @@ static void checkupdate(win_T *wp)
/// Repeat "count" times.
static void setFoldRepeat(pos_T pos, long count, int do_open)
{
- int done;
- long n;
-
- for (n = 0; n < count; ++n) {
- done = DONE_NOTHING;
+ for (int n = 0; n < count; n++) {
+ int done = DONE_NOTHING;
(void)setManualFold(pos, do_open, false, &done);
if (!(done & DONE_ACTION)) {
// Only give an error message when no fold could be opened.
@@ -1162,18 +1131,15 @@ static void setFoldRepeat(pos_T pos, long count, int do_open)
/// Open or close the fold in the current window which contains "lnum".
/// Also does this for other windows in diff mode when needed.
///
-/// @param opening TRUE when opening, FALSE when closing
-/// @param recurse TRUE when closing/opening recursive
+/// @param opening true when opening, false when closing
+/// @param recurse true when closing/opening recursive
static linenr_T setManualFold(pos_T pos, int opening, int recurse, int *donep)
{
- linenr_T lnum = pos.lnum;
if (foldmethodIsDiff(curwin) && curwin->w_p_scb) {
linenr_T dlnum;
- /*
- * Do the same operation in other windows in diff mode. Calculate the
- * line number from the diffs.
- */
+ // Do the same operation in other windows in diff mode. Calculate the
+ // line number from the diffs.
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp != curwin && foldmethodIsDiff(wp) && wp->w_p_scb) {
dlnum = diff_lnum_win(curwin->w_cursor.lnum, wp);
@@ -1184,7 +1150,7 @@ static linenr_T setManualFold(pos_T pos, int opening, int recurse, int *donep)
}
}
- return setManualFoldWin(curwin, lnum, opening, recurse, donep);
+ return setManualFoldWin(curwin, pos.lnum, opening, recurse, donep);
}
// setManualFoldWin() {{{2
@@ -1194,31 +1160,27 @@ static linenr_T setManualFold(pos_T pos, int opening, int recurse, int *donep)
/// When "donep" is NULL give an error message when no fold was found for
/// "lnum", but only if "wp" is "curwin".
///
-/// @param opening TRUE when opening, FALSE when closing
-/// @param recurse TRUE when closing/opening recursive
+/// @param opening true when opening, false when closing
+/// @param recurse true when closing/opening recursive
///
/// @return the line number of the next line that could be closed.
-/// It's only valid when "opening" is TRUE!
+/// It's only valid when "opening" is true!
static linenr_T setManualFoldWin(win_T *wp, linenr_T lnum, int opening, int recurse, int *donep)
{
fold_T *fp;
fold_T *fp2;
fold_T *found = NULL;
- int j;
int level = 0;
- int use_level = FALSE;
- int found_fold = FALSE;
- garray_T *gap;
+ bool use_level = false;
+ bool found_fold = false;
linenr_T next = MAXLNUM;
linenr_T off = 0;
int done = 0;
checkupdate(wp);
- /*
- * Find the fold, open or close it.
- */
- gap = &wp->w_folds;
+ // Find the fold, open or close it.
+ garray_T *gap = &wp->w_folds;
for (;;) {
if (!foldFind(gap, lnum, &fp)) {
// If there is a following fold, continue there next time.
@@ -1229,7 +1191,7 @@ static linenr_T setManualFoldWin(win_T *wp, linenr_T lnum, int opening, int recu
}
// lnum is inside this fold
- found_fold = TRUE;
+ found_fold = true;
// If there is a following fold, continue there next time.
if (fp + 1 < (fold_T *)gap->ga_data + gap->ga_len) {
@@ -1238,14 +1200,14 @@ static linenr_T setManualFoldWin(win_T *wp, linenr_T lnum, int opening, int recu
// Change from level-dependent folding to manual.
if (use_level || fp->fd_flags == FD_LEVEL) {
- use_level = TRUE;
+ use_level = true;
if (level >= wp->w_p_fdl) {
fp->fd_flags = FD_CLOSED;
} else {
fp->fd_flags = FD_OPEN;
}
fp2 = (fold_T *)fp->fd_nested.ga_data;
- for (j = 0; j < fp->fd_nested.ga_len; ++j) {
+ for (int j = 0; j < fp->fd_nested.ga_len; j++) {
fp2[j].fd_flags = FD_LEVEL;
}
}
@@ -1273,7 +1235,7 @@ static linenr_T setManualFoldWin(win_T *wp, linenr_T lnum, int opening, int recu
gap = &fp->fd_nested;
lnum -= fp->fd_top;
off += fp->fd_top;
- ++level;
+ level++;
}
if (found_fold) {
// When closing and not recurse, close deepest open fold.
@@ -1301,10 +1263,8 @@ static linenr_T setManualFoldWin(win_T *wp, linenr_T lnum, int opening, int recu
/// Open all nested folds in fold "fpr" recursively.
static void foldOpenNested(fold_T *fpr)
{
- fold_T *fp;
-
- fp = (fold_T *)fpr->fd_nested.ga_data;
- for (int i = 0; i < fpr->fd_nested.ga_len; ++i) {
+ fold_T *fp = (fold_T *)fpr->fd_nested.ga_data;
+ for (int i = 0; i < fpr->fd_nested.ga_len; i++) {
foldOpenNested(&fp[i]);
fp[i].fd_flags = FD_OPEN;
}
@@ -1390,14 +1350,12 @@ void foldMarkAdjust(win_T *wp, linenr_T line1, linenr_T line2, linenr_T amount,
static void foldMarkAdjustRecurse(win_T *wp, garray_T *gap, linenr_T line1, linenr_T line2,
linenr_T amount, linenr_T amount_after)
{
- fold_T *fp;
- linenr_T last;
- linenr_T top;
-
if (gap->ga_len == 0) {
return;
}
+ linenr_T top;
+
// In Insert mode an inserted line at the top of a fold is considered part
// of the fold, otherwise it isn't.
if ((State & MODE_INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM) {
@@ -1407,25 +1365,22 @@ static void foldMarkAdjustRecurse(win_T *wp, garray_T *gap, linenr_T line1, line
}
// Find the fold containing or just below "line1".
+ fold_T *fp;
(void)foldFind(gap, line1, &fp);
- /*
- * Adjust all folds below "line1" that are affected.
- */
- for (int i = (int)(fp - (fold_T *)gap->ga_data); i < gap->ga_len; ++i, ++fp) {
- /*
- * Check for these situations:
- * 1 2 3
- * 1 2 3
- * line1 2 3 4 5
- * 2 3 4 5
- * 2 3 4 5
- * line2 2 3 4 5
- * 3 5 6
- * 3 5 6
- */
-
- last = fp->fd_top + fp->fd_len - 1; // last line of fold
+ // Adjust all folds below "line1" that are affected.
+ for (int i = (int)(fp - (fold_T *)gap->ga_data); i < gap->ga_len; i++, fp++) {
+ // Check for these situations:
+ // 1 2 3
+ // 1 2 3
+ // line1 2 3 4 5
+ // 2 3 4 5
+ // 2 3 4 5
+ // line2 2 3 4 5
+ // 3 5 6
+ // 3 5 6
+
+ linenr_T last = fp->fd_top + fp->fd_len - 1; // last line of fold
// 1. fold completely above line1: nothing to do
if (last < line1) {
@@ -1498,13 +1453,11 @@ int getDeepestNesting(win_T *wp)
static int getDeepestNestingRecurse(garray_T *gap)
{
- int level;
int maxlevel = 0;
- fold_T *fp;
- fp = (fold_T *)gap->ga_data;
- for (int i = 0; i < gap->ga_len; ++i) {
- level = getDeepestNestingRecurse(&fp[i].fd_nested) + 1;
+ fold_T *fp = (fold_T *)gap->ga_data;
+ for (int i = 0; i < gap->ga_len; i++) {
+ int level = getDeepestNestingRecurse(&fp[i].fd_nested) + 1;
if (level > maxlevel) {
maxlevel = level;
}
@@ -1622,14 +1575,13 @@ static void foldCreateMarkers(win_T *wp, pos_T start, pos_T end)
static void foldAddMarker(buf_T *buf, pos_T pos, const char_u *marker, size_t markerlen)
{
char_u *cms = buf->b_p_cms;
- char_u *line;
char_u *newline;
char_u *p = (char_u *)strstr((char *)buf->b_p_cms, "%s");
bool line_is_comment = false;
linenr_T lnum = pos.lnum;
// Allocate a new line: old-line + 'cms'-start + marker + 'cms'-end
- line = ml_get_buf(buf, lnum, false);
+ char_u *line = ml_get_buf(buf, lnum, false);
size_t line_len = STRLEN(line);
size_t added = 0;
@@ -1681,14 +1633,12 @@ static void deleteFoldMarkers(win_T *wp, fold_T *fp, int recursive, linenr_T lnu
/// close-marker.
static void foldDelMarker(buf_T *buf, linenr_T lnum, char_u *marker, size_t markerlen)
{
- char_u *newline;
- char_u *cms = buf->b_p_cms;
- char_u *cms2;
-
// end marker may be missing and fold extends below the last line
if (lnum > buf->b_ml.ml_line_count) {
return;
}
+
+ char_u *cms = buf->b_p_cms;
char_u *line = ml_get_buf(buf, lnum, false);
for (char_u *p = line; *p != NUL; p++) {
if (STRNCMP(p, marker, markerlen) != 0) {
@@ -1697,11 +1647,11 @@ static void foldDelMarker(buf_T *buf, linenr_T lnum, char_u *marker, size_t mark
// Found the marker, include a digit if it's there.
size_t len = markerlen;
if (ascii_isdigit(p[len])) {
- ++len;
+ len++;
}
if (*cms != NUL) {
// Also delete 'commentstring' if it matches.
- cms2 = (char_u *)strstr((char *)cms, "%s");
+ char_u *cms2 = (char_u *)strstr((char *)cms, "%s");
if (p - line >= cms2 - cms
&& STRNCMP(p - (cms2 - cms), cms, cms2 - cms) == 0
&& STRNCMP(p + len, cms2 + 2, STRLEN(cms2 + 2)) == 0) {
@@ -1711,7 +1661,7 @@ static void foldDelMarker(buf_T *buf, linenr_T lnum, char_u *marker, size_t mark
}
if (u_save(lnum - 1, lnum + 1) == OK) {
// Make new line: text-before-marker + text-after-marker
- newline = xmalloc(STRLEN(line) - len + 1);
+ char_u *newline = xmalloc(STRLEN(line) - len + 1);
assert(p >= line);
memcpy(newline, line, (size_t)(p - line));
STRCPY(newline + (p - line), p + len);
@@ -1737,26 +1687,23 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
{
char_u *text = NULL;
// an error occurred when evaluating 'fdt' setting
- static int got_fdt_error = FALSE;
+ static bool got_fdt_error = false;
int save_did_emsg = did_emsg;
static win_T *last_wp = NULL;
static linenr_T last_lnum = 0;
if (last_wp == NULL || last_wp != wp || last_lnum > lnum || last_lnum == 0) {
// window changed, try evaluating foldtext setting once again
- got_fdt_error = FALSE;
+ got_fdt_error = false;
}
if (!got_fdt_error) {
// a previous error should not abort evaluating 'foldexpr'
- did_emsg = FALSE;
+ did_emsg = false;
}
if (*wp->w_p_fdt != NUL) {
char dashes[MAX_LEVEL + 2];
- win_T *save_curwin;
- int level;
- char_u *p;
// Set "v:foldstart" and "v:foldend".
set_vim_var_nr(VV_FOLDSTART, (varnumber_T)lnum);
@@ -1764,7 +1711,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
// Set "v:folddashes" to a string of "level" dashes.
// Set "v:foldlevel" to "level".
- level = foldinfo.fi_level;
+ int level = foldinfo.fi_level;
if (level > (int)sizeof(dashes) - 1) {
level = (int)sizeof(dashes) - 1;
}
@@ -1775,7 +1722,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
// skip evaluating foldtext on errors
if (!got_fdt_error) {
- save_curwin = curwin;
+ win_T *save_curwin = curwin;
curwin = wp;
curbuf = wp->w_buffer;
@@ -1786,7 +1733,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
emsg_silent--;
if (text == NULL || did_emsg) {
- got_fdt_error = TRUE;
+ got_fdt_error = true;
}
curwin = save_curwin;
@@ -1803,6 +1750,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
if (text != NULL) {
// Replace unprintable characters, if there are any. But
// replace a TAB with a space.
+ char_u *p;
for (p = text; *p != NUL; p++) {
int len = utfc_ptr2len((char *)p);
@@ -1840,11 +1788,6 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
/// Remove 'foldmarker' and 'commentstring' from "str" (in-place).
void foldtext_cleanup(char_u *str)
{
- char_u *s;
- char_u *p;
- bool did1 = false;
- bool did2 = false;
-
// Ignore leading and trailing white space in 'commentstring'.
char_u *cms_start = (char_u *)skipwhite((char *)curbuf->b_p_cms);
size_t cms_slen = STRLEN(cms_start);
@@ -1865,13 +1808,16 @@ void foldtext_cleanup(char_u *str)
}
// skip "%s" and white space after it
- s = (char_u *)skipwhite((char *)cms_end + 2);
+ char_u *s = (char_u *)skipwhite((char *)cms_end + 2);
cms_elen -= (size_t)(s - cms_end);
cms_end = s;
}
parseMarker(curwin);
- for (s = str; *s != NUL;) {
+ bool did1 = false;
+ bool did2 = false;
+
+ for (char_u *s = str; *s != NUL;) {
size_t len = 0;
if (STRNCMP(s, curwin->w_p_fmr, foldstartmarkerlen) == 0) {
len = foldstartmarkerlen;
@@ -1880,11 +1826,12 @@ void foldtext_cleanup(char_u *str)
}
if (len > 0) {
if (ascii_isdigit(s[len])) {
- ++len;
+ len++;
}
// May remove 'commentstring' start. Useful when it's a double
// quote and we already removed a double quote.
+ char_u *p;
for (p = s; p > str && ascii_iswhite(p[-1]); p--) {}
if (p >= str + cms_slen
&& STRNCMP(p - cms_slen, cms_start, cms_slen) == 0) {
@@ -1903,7 +1850,7 @@ void foldtext_cleanup(char_u *str)
}
if (len != 0) {
while (ascii_iswhite(s[len])) {
- ++len;
+ len++;
}
STRMOVE(s, s + len);
} else {
@@ -1920,10 +1867,6 @@ void foldtext_cleanup(char_u *str)
/// IEMS = "Indent Expr Marker Syntax"
static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot)
{
- fline_T fline;
- LevelGetter getlevel = NULL;
- fold_T *fp;
-
// Avoid problems when being called recursively.
if (invalid_top != (linenr_T)0) {
return;
@@ -1955,6 +1898,8 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot)
top = wp->w_buffer->b_ml.ml_line_count;
}
+ fline_T fline;
+
fold_changed = false;
fline.wp = wp;
fline.off = 0;
@@ -1967,6 +1912,8 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot)
invalid_top = top;
invalid_bot = bot;
+ LevelGetter getlevel = NULL;
+
if (foldmethodIsMarker(wp)) {
getlevel = foldlevelMarker;
@@ -2032,13 +1979,11 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot)
}
}
- /*
- * If folding is defined by the syntax, it is possible that a change in
- * one line will cause all sub-folds of the current fold to change (e.g.,
- * closing a C-style comment can cause folds in the subsequent lines to
- * appear). To take that into account we should adjust the value of "bot"
- * to point to the end of the current fold:
- */
+ // If folding is defined by the syntax, it is possible that a change in
+ // one line will cause all sub-folds of the current fold to change (e.g.,
+ // closing a C-style comment can cause folds in the subsequent lines to
+ // appear). To take that into account we should adjust the value of "bot"
+ // to point to the end of the current fold:
if (foldlevelSyntax == getlevel) {
garray_T *gap = &wp->w_folds;
fold_T *fpn = NULL;
@@ -2050,7 +1995,7 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot)
if (!foldFind(gap, lnum_rel, &fpn)) {
break;
}
- ++current_fdl;
+ current_fdl++;
fold_start_lnum += fpn->fd_top;
gap = &fpn->fd_nested;
@@ -2071,6 +2016,9 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot)
if (start > end && end < wp->w_buffer->b_ml.ml_line_count) {
end = start;
}
+
+ fold_T *fp;
+
while (!got_int) {
// Always stop at the end of the file ("end" can be past the end of
// the file).
@@ -2115,7 +2063,7 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot)
if (fline.lnum == wp->w_buffer->b_ml.ml_line_count) {
break;
}
- ++fline.lnum;
+ fline.lnum++;
fline.lvl = fline.lvl_next;
getlevel(&fline);
}
@@ -2173,23 +2121,12 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
const linenr_T startlnum, fline_T *const flp,
LevelGetter getlevel, linenr_T bot, const char topflags)
{
- linenr_T ll;
fold_T *fp = NULL;
- fold_T *fp2;
- int lvl = level;
- linenr_T startlnum2 = startlnum;
- const linenr_T firstlnum = flp->lnum; // first lnum we got
- int i;
- bool finish = false;
- const linenr_T linecount = flp->wp->w_buffer->b_ml.ml_line_count - flp->off;
- int concat;
-
- /*
- * If using the marker method, the start line is not the start of a fold
- * at the level we're dealing with and the level is non-zero, we must use
- * the previous fold. But ignore a fold that starts at or below
- * startlnum, it must be deleted.
- */
+
+ // If using the marker method, the start line is not the start of a fold
+ // at the level we're dealing with and the level is non-zero, we must use
+ // the previous fold. But ignore a fold that starts at or below
+ // startlnum, it must be deleted.
if (getlevel == foldlevelMarker && flp->start <= flp->lvl - level
&& flp->lvl > 0) {
(void)foldFind(gap, startlnum - 1, &fp);
@@ -2200,17 +2137,22 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
}
}
- /*
- * Loop over all lines in this fold, or until "bot" is hit.
- * Handle nested folds inside of this fold.
- * "flp->lnum" is the current line. When finding the end of the fold, it
- * is just below the end of the fold.
- * "*flp" contains the level of the line "flp->lnum" or a following one if
- * there are lines with an invalid fold level. "flp->lnum_save" is the
- * line number that was used to get the fold level (below "flp->lnum" when
- * it has an invalid fold level). When called the fold level is always
- * valid, thus "flp->lnum_save" is equal to "flp->lnum".
- */
+ fold_T *fp2;
+ int lvl = level;
+ linenr_T startlnum2 = startlnum;
+ const linenr_T firstlnum = flp->lnum; // first lnum we got
+ bool finish = false;
+ const linenr_T linecount = flp->wp->w_buffer->b_ml.ml_line_count - flp->off;
+
+ // Loop over all lines in this fold, or until "bot" is hit.
+ // Handle nested folds inside of this fold.
+ // "flp->lnum" is the current line. When finding the end of the fold, it
+ // is just below the end of the fold.
+ // "*flp" contains the level of the line "flp->lnum" or a following one if
+ // there are lines with an invalid fold level. "flp->lnum_save" is the
+ // line number that was used to get the fold level (below "flp->lnum" when
+ // it has an invalid fold level). When called the fold level is always
+ // valid, thus "flp->lnum_save" is equal to "flp->lnum".
flp->lnum_save = flp->lnum;
while (!got_int) {
// Updating folds can be slow, check for CTRL-C.
@@ -2240,15 +2182,15 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
&& getlevel != foldlevelSyntax) {
break;
}
- i = 0;
+ int i = 0;
fp2 = fp;
if (lvl >= level) {
// Compute how deep the folds currently are, if it's deeper
// than "lvl" then some must be deleted, need to update
// at least one nested fold.
- ll = flp->lnum - fp->fd_top;
+ int ll = flp->lnum - fp->fd_top;
while (foldFind(&fp2->fd_nested, ll, &fp2)) {
- ++i;
+ i++;
ll -= fp2->fd_top;
}
}
@@ -2273,13 +2215,12 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
|| flp->start != 0
|| flp->had_end <= MAX_LEVEL
|| flp->lnum == linecount)) {
- /*
- * Remove or update folds that have lines between startlnum and
- * firstlnum.
- */
+ // Remove or update folds that have lines between startlnum and
+ // firstlnum.
while (!got_int) {
// set concat to 1 if it's allowed to concatenate this fold
// with a previous one that touches it.
+ int concat;
if (flp->start != 0 || flp->had_end <= MAX_LEVEL) {
concat = 0;
} else {
@@ -2347,7 +2288,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
}
foldRemove(flp->wp, &fp->fd_nested, breakstart - fp->fd_top,
breakend - fp->fd_top);
- i = (int)(fp - (fold_T *)gap->ga_data);
+ int i = (int)(fp - (fold_T *)gap->ga_data);
foldSplit(flp->wp->w_buffer, gap, i, breakstart, breakend - 1);
fp = (fold_T *)gap->ga_data + i + 1;
// If using the "marker" or "syntax" method, we
@@ -2360,7 +2301,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
}
}
if (fp->fd_top == startlnum && concat) {
- i = (int)(fp - (fold_T *)gap->ga_data);
+ int i = (int)(fp - (fold_T *)gap->ga_data);
if (i != 0) {
fp2 = fp - 1;
if (fp2->fd_top + fp2->fd_len == fp->fd_top) {
@@ -2389,6 +2330,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
} else {
// Insert new fold. Careful: ga_data may be NULL and it
// may change!
+ int i;
if (gap->ga_len == 0) {
i = 0;
} else {
@@ -2429,17 +2371,13 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
}
if (lvl < level || flp->lnum > linecount) {
- /*
- * Found a line with a lower foldlevel, this fold ends just above
- * "flp->lnum".
- */
+ // Found a line with a lower foldlevel, this fold ends just above
+ // "flp->lnum".
break;
}
- /*
- * The fold includes the line "flp->lnum" and "flp->lnum_save".
- * Check "fp" for safety.
- */
+ // The fold includes the line "flp->lnum" and "flp->lnum_save".
+ // Check "fp" for safety.
if (lvl > level && fp != NULL) {
// There is a nested fold, handle it recursively.
// At least do one line (can happen when finish is true).
@@ -2451,7 +2389,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
// this fold.
flp->lnum = flp->lnum_save - fp->fd_top;
flp->off += fp->fd_top;
- i = (int)(fp - (fold_T *)gap->ga_data);
+ int i = (int)(fp - (fold_T *)gap->ga_data);
bot = foldUpdateIEMSRecurse(&fp->fd_nested, level + 1,
startlnum2 - fp->fd_top, flp, getlevel,
bot - fp->fd_top, fp->fd_flags);
@@ -2464,14 +2402,12 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
// This fold may end at the same line, don't incr. flp->lnum.
} else {
- /*
- * Get the level of the next line, then continue the loop to check
- * if it ends there.
- * Skip over undefined lines, to find the foldlevel after it.
- * For the last line in the file the foldlevel is always valid.
- */
+ // Get the level of the next line, then continue the loop to check
+ // if it ends there.
+ // Skip over undefined lines, to find the foldlevel after it.
+ // For the last line in the file the foldlevel is always valid.
flp->lnum = flp->lnum_save;
- ll = flp->lnum + 1;
+ int ll = flp->lnum + 1;
while (!got_int) {
// Make the previous level available to foldlevel().
prev_lnum = flp->lnum;
@@ -2502,11 +2438,9 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
return bot;
}
- /*
- * Get here when:
- * lvl < level: the folds ends just above "flp->lnum"
- * lvl >= level: fold continues below "bot"
- */
+ // Get here when:
+ // lvl < level: the folds ends just above "flp->lnum"
+ // lvl >= level: fold continues below "bot"
// Current fold at least extends until lnum.
if (fp->fd_len < flp->lnum - fp->fd_top) {
@@ -2538,7 +2472,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
} else {
// indent or expr method: split fold to create a new one
// below bot
- i = (int)(fp - (fold_T *)gap->ga_data);
+ int i = (int)(fp - (fold_T *)gap->ga_data);
foldSplit(flp->wp->w_buffer, gap, i, flp->lnum, bot);
fp = (fold_T *)gap->ga_data + i;
}
@@ -2590,11 +2524,9 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
/// Insert a new fold in "gap" at position "i".
static void foldInsert(garray_T *gap, int i)
{
- fold_T *fp;
-
ga_grow(gap, 1);
- fp = (fold_T *)gap->ga_data + i;
+ fold_T *fp = (fold_T *)gap->ga_data + i;
if (gap->ga_len > 0 && i < gap->ga_len) {
memmove(fp + 1, fp, sizeof(fold_T) * (size_t)(gap->ga_len - i));
}
@@ -2666,12 +2598,12 @@ static void foldSplit(buf_T *buf, garray_T *const gap, const int i, const linenr
/// 6: not changed
static void foldRemove(win_T *const wp, garray_T *gap, linenr_T top, linenr_T bot)
{
- fold_T *fp = NULL;
-
if (bot < top) {
return; // nothing to do
}
+ fold_T *fp = NULL;
+
while (gap->ga_len > 0) {
// Find fold that includes top or a following one.
if (foldFind(gap, top, &fp) && fp->fd_top < top) {
@@ -2881,7 +2813,6 @@ static void foldMerge(win_T *const wp, fold_T *fp1, garray_T *gap, fold_T *fp2)
{
fold_T *fp3;
fold_T *fp4;
- int idx;
garray_T *gap1 = &fp1->fd_nested;
garray_T *gap2 = &fp2->fd_nested;
@@ -2894,11 +2825,11 @@ static void foldMerge(win_T *const wp, fold_T *fp1, garray_T *gap, fold_T *fp2)
// Move nested folds in fp2 to the end of fp1.
if (!GA_EMPTY(gap2)) {
ga_grow(gap1, gap2->ga_len);
- for (idx = 0; idx < gap2->ga_len; ++idx) {
+ for (int idx = 0; idx < gap2->ga_len; idx++) {
((fold_T *)gap1->ga_data)[gap1->ga_len]
= ((fold_T *)gap2->ga_data)[idx];
((fold_T *)gap1->ga_data)[gap1->ga_len].fd_top += fp1->fd_len;
- ++gap1->ga_len;
+ gap1->ga_len++;
}
gap2->ga_len = 0;
}
@@ -2915,12 +2846,10 @@ static void foldMerge(win_T *const wp, fold_T *fp1, garray_T *gap, fold_T *fp2)
/// @return a level of -1 if the foldlevel depends on surrounding lines.
static void foldlevelIndent(fline_T *flp)
{
- char_u *s;
- buf_T *buf;
linenr_T lnum = flp->lnum + flp->off;
- buf = flp->wp->w_buffer;
- s = (char_u *)skipwhite((char *)ml_get_buf(buf, lnum, false));
+ buf_T *buf = flp->wp->w_buffer;
+ char_u *s = (char_u *)skipwhite((char *)ml_get_buf(buf, lnum, false));
// empty line or lines starting with a character in 'foldignore': level
// depends on surrounding lines
@@ -2958,11 +2887,9 @@ static void foldlevelDiff(fline_T *flp)
/// @return a level of -1 if the foldlevel depends on surrounding lines.
static void foldlevelExpr(fline_T *flp)
{
- win_T *win;
- int c;
linenr_T lnum = flp->lnum + flp->off;
- win = curwin;
+ win_T *win = curwin;
curwin = flp->wp;
curbuf = flp->wp->w_buffer;
set_vim_var_nr(VV_LNUM, (varnumber_T)lnum);
@@ -2977,6 +2904,8 @@ static void foldlevelExpr(fline_T *flp)
// KeyTyped may be reset to 0 when calling a function which invokes
// do_cmdline(). To make 'foldopen' work correctly restore KeyTyped.
const bool save_keytyped = KeyTyped;
+
+ int c;
const int n = eval_foldexpr((char *)flp->wp->w_p_fde, &c);
KeyTyped = save_keytyped;
@@ -3070,31 +2999,26 @@ static void parseMarker(win_T *wp)
/// Sets flp->start when a start marker was found.
static void foldlevelMarker(fline_T *flp)
{
- char_u *startmarker;
- int cstart;
- int cend;
int start_lvl = flp->lvl;
- char_u *s;
- int n;
// cache a few values for speed
- startmarker = flp->wp->w_p_fmr;
- cstart = *startmarker;
- ++startmarker;
- cend = *foldendmarker;
+ char_u *startmarker = flp->wp->w_p_fmr;
+ int cstart = *startmarker;
+ startmarker++;
+ int cend = *foldendmarker;
// Default: no start found, next level is same as current level
flp->start = 0;
flp->lvl_next = flp->lvl;
- s = ml_get_buf(flp->wp->w_buffer, flp->lnum + flp->off, false);
+ char_u *s = ml_get_buf(flp->wp->w_buffer, flp->lnum + flp->off, false);
while (*s) {
if (*s == cstart
&& STRNCMP(s + 1, startmarker, foldstartmarkerlen - 1) == 0) {
// found startmarker: set flp->lvl
s += foldstartmarkerlen;
if (ascii_isdigit(*s)) {
- n = atoi((char *)s);
+ int n = atoi((char *)s);
if (n > 0) {
flp->lvl = n;
flp->lvl_next = n;
@@ -3105,16 +3029,16 @@ static void foldlevelMarker(fline_T *flp)
}
}
} else {
- ++flp->lvl;
- ++flp->lvl_next;
- ++flp->start;
+ flp->lvl++;
+ flp->lvl_next++;
+ flp->start++;
}
} else if (*s == cend && STRNCMP(s + 1, foldendmarker + 1,
foldendmarkerlen - 1) == 0) {
// found endmarker: set flp->lvl_next
s += foldendmarkerlen;
if (ascii_isdigit(*s)) {
- n = atoi((char *)s);
+ int n = atoi((char *)s);
if (n > 0) {
flp->lvl = n;
flp->lvl_next = n - 1;
@@ -3143,13 +3067,12 @@ static void foldlevelMarker(fline_T *flp)
static void foldlevelSyntax(fline_T *flp)
{
linenr_T lnum = flp->lnum + flp->off;
- int n;
// Use the maximum fold level at the start of this line and the next.
flp->lvl = syn_get_foldlevel(flp->wp, lnum);
flp->start = 0;
if (lnum < flp->wp->w_buffer->b_ml.ml_line_count) {
- n = syn_get_foldlevel(flp->wp, lnum + 1);
+ int n = syn_get_foldlevel(flp->wp, lnum + 1);
if (n > flp->lvl) {
flp->start = n - flp->lvl; // fold(s) start here
flp->lvl = n;
@@ -3198,7 +3121,7 @@ static int put_folds_recurse(FILE *fd, garray_T *gap, linenr_T off)
|| put_eol(fd) == FAIL) {
return FAIL;
}
- ++fp;
+ fp++;
}
return OK;
}
@@ -3209,8 +3132,6 @@ static int put_folds_recurse(FILE *fd, garray_T *gap, linenr_T off)
/// @return FAIL when writing failed.
static int put_foldopen_recurse(FILE *fd, win_T *wp, garray_T *gap, linenr_T off)
{
- int level;
-
fold_T *fp = (fold_T *)gap->ga_data;
for (int i = 0; i < gap->ga_len; i++) {
if (fp->fd_flags != FD_LEVEL) {
@@ -3236,7 +3157,7 @@ static int put_foldopen_recurse(FILE *fd, win_T *wp, garray_T *gap, linenr_T off
// Open or close the leaf according to the window foldlevel.
// Do not close a leaf that is already closed, as it will close
// the parent.
- level = foldLevelWin(wp, off + fp->fd_top);
+ int level = foldLevelWin(wp, off + fp->fd_top);
if ((fp->fd_flags == FD_CLOSED && wp->w_p_fdl >= level)
|| (fp->fd_flags != FD_CLOSED && wp->w_p_fdl < level)) {
if (put_fold_open_close(fd, fp, off) == FAIL) {
@@ -3245,7 +3166,7 @@ static int put_foldopen_recurse(FILE *fd, win_T *wp, garray_T *gap, linenr_T off
}
}
}
- ++fp;
+ fp++;
}
return OK;
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index d2f56c739b..b539d50784 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -224,7 +224,7 @@ EXTERN dict_T vimvardict; // Dictionary with v: variables
EXTERN dict_T globvardict; // Dictionary with g: variables
/// g: value
#define globvarht globvardict.dv_hashtab
-EXTERN int did_emsg; // set by emsg() when the message
+EXTERN bool did_emsg; // set by emsg() when the message
// is displayed or thrown
EXTERN bool called_vim_beep; // set if vim_beep() is called
EXTERN bool did_emsg_syntax; // did_emsg set because of a
@@ -274,11 +274,11 @@ EXTERN except_T *current_exception;
/// Set when a throw that cannot be handled in do_cmdline() must be propagated
/// to the cstack of the previously called do_cmdline().
-EXTERN int need_rethrow INIT(= false);
+EXTERN bool need_rethrow INIT(= false);
/// Set when a ":finish" or ":return" that cannot be handled in do_cmdline()
/// must be propagated to the cstack of the previously called do_cmdline().
-EXTERN int check_cstack INIT(= false);
+EXTERN bool check_cstack INIT(= false);
/// Number of nested try conditionals (across function calls and ":source"
/// commands).
@@ -725,8 +725,7 @@ EXTERN bool need_highlight_changed INIT(= true);
EXTERN FILE *scriptout INIT(= NULL); ///< Stream to write script to.
// volatile because it is used in a signal handler.
-EXTERN volatile int got_int INIT(= false); // set to true when interrupt
- // signal occurred
+EXTERN bool got_int INIT(= false); // set to true when interrupt signal occurred
EXTERN bool bangredo INIT(= false); // set to true with ! command
EXTERN int searchcmdlen; // length of previous search cmd
EXTERN int reg_do_extmatch INIT(= 0); // Used when compiling regexp:
@@ -1076,4 +1075,6 @@ typedef enum {
// Only filled for Win32.
EXTERN char windowsVersion[20] INIT(= { 0 });
+EXTERN int exit_need_delay INIT(= 0);
+
#endif // NVIM_GLOBALS_H
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index b96220d547..a4cf65e816 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -342,7 +342,7 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_
break;
}
- table[idx].number = getdigits_int(&p, false, 0);
+ table[idx].number = getdigits_int((char **)&p, false, 0);
}
table[idx].string = p;
@@ -659,7 +659,8 @@ void ex_hardcopy(exarg_T *eap)
*/
if (mch_print_init(&settings,
curbuf->b_fname == NULL ? (char_u *)buf_spname(curbuf) : curbuf->b_sfname ==
- NULL ? (char_u *)curbuf->b_fname : curbuf->b_sfname, eap->forceit) == FAIL) {
+ NULL ? (char_u *)curbuf->b_fname : (char_u *)curbuf->b_sfname,
+ eap->forceit) == FAIL) {
return;
}
diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c
index ca6f033c47..95ae7a152c 100644
--- a/src/nvim/hashtab.c
+++ b/src/nvim/hashtab.c
@@ -85,9 +85,9 @@ void hash_clear_all(hashtab_T *ht, unsigned int off)
/// used for that key.
/// WARNING: Returned pointer becomes invalid as soon as the hash table
/// is changed in any way.
-hashitem_T *hash_find(const hashtab_T *const ht, const char_u *const key)
+hashitem_T *hash_find(const hashtab_T *const ht, const char *const key)
{
- return hash_lookup(ht, (const char *)key, STRLEN(key), hash_hash(key));
+ return hash_lookup(ht, key, STRLEN(key), hash_hash((char_u *)key));
}
/// Like hash_find, but key is not NUL-terminated
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index 8a5b4cbf0f..9d60cf9dfe 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -400,7 +400,7 @@ int get_number_indent(linenr_T lnum)
// In format_lines() (i.e. not insert mode), fo+=q is needed too...
if ((State & MODE_INSERT) || has_format_option(FO_Q_COMS)) {
- lead_len = get_leader_len(ml_get(lnum), NULL, false, true);
+ lead_len = get_leader_len((char *)ml_get(lnum), NULL, false, true);
}
regmatch.regprog = vim_regcomp((char *)curbuf->b_p_flp, RE_MAGIC);
@@ -409,7 +409,7 @@ int get_number_indent(linenr_T lnum)
// vim_regexec() expects a pointer to a line. This lets us
// start matching for the flp beyond any comment leader...
- if (vim_regexec(&regmatch, ml_get(lnum) + lead_len, (colnr_T)0)) {
+ if (vim_regexec(&regmatch, (char *)ml_get(lnum) + lead_len, (colnr_T)0)) {
pos.lnum = lnum;
pos.col = (colnr_T)(*regmatch.endp - ml_get(lnum));
pos.coladd = 0;
@@ -468,7 +468,7 @@ int get_breakindent_win(win_T *wp, char_u *line)
if (regmatch.regprog != NULL) {
regmatch.rm_ic = false;
- if (vim_regexec(&regmatch, line, 0)) {
+ if (vim_regexec(&regmatch, (char *)line, 0)) {
if (wp->w_briopt_list > 0) {
bri += wp->w_briopt_list;
} else {
@@ -769,7 +769,7 @@ static int lisp_match(char_u *p)
char_u *word = *curbuf->b_p_lw != NUL ? curbuf->b_p_lw : p_lispwords;
while (*word != NUL) {
- (void)copy_option_part(&word, buf, LSIZE, ",");
+ (void)copy_option_part((char **)&word, (char *)buf, LSIZE, ",");
len = (int)STRLEN(buf);
if ((STRNCMP(buf, p, len) == 0) && (p[len] == ' ')) {
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index cb807dec24..3c74b4bd8d 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -224,7 +224,7 @@ bool cin_is_cinword(const char_u *line)
line = (char_u *)skipwhite((char *)line);
for (char_u *cinw = curbuf->b_p_cinw; *cinw;) {
- size_t len = copy_option_part(&cinw, cinw_buf, cinw_len, ",");
+ size_t len = copy_option_part((char **)&cinw, (char *)cinw_buf, cinw_len, ",");
if (STRNCMP(line, cinw_buf, len) == 0
&& (!vim_iswordc(line[len]) || !vim_iswordc(line[len - 1]))) {
retval = true;
@@ -520,7 +520,7 @@ bool cin_isscopedecl(const char_u *p)
bool found = false;
for (char_u *cinsd = curbuf->b_p_cinsd; *cinsd;) {
- const size_t len = copy_option_part(&cinsd, cinsd_buf, cinsd_len, ",");
+ const size_t len = copy_option_part((char **)&cinsd, (char *)cinsd_buf, cinsd_len, ",");
if (STRNCMP(s, cinsd_buf, len) == 0) {
const char_u *skip = cin_skipcomment(s + len);
if (*skip == ':' && skip[1] != ':') {
@@ -1501,7 +1501,7 @@ retry:
if ((trypos = findmatchlimit(NULL, c, 0, ind_maxp_wk)) != NULL) {
// check if the ( is in a // comment
if ((colnr_T)cin_skip2pos(trypos) > trypos->col) {
- ind_maxp_wk = ind_maxparen - (int)(cursor_save.lnum - trypos->lnum);
+ ind_maxp_wk = ind_maxparen - (cursor_save.lnum - trypos->lnum);
if (ind_maxp_wk > 0) {
curwin->w_cursor = *trypos;
curwin->w_cursor.col = 0; // XXX
@@ -1515,7 +1515,7 @@ retry:
trypos = &pos_copy;
curwin->w_cursor = *trypos;
if ((trypos_wk = ind_find_start_CORS(NULL)) != NULL) { // XXX
- ind_maxp_wk = ind_maxparen - (int)(cursor_save.lnum - trypos_wk->lnum);
+ ind_maxp_wk = ind_maxparen - (cursor_save.lnum - trypos_wk->lnum);
if (ind_maxp_wk > 0) {
curwin->w_cursor = *trypos_wk;
goto retry;
@@ -1746,7 +1746,7 @@ void parse_cino(buf_T *buf)
p++;
}
char_u *digits_start = p; // remember where the digits start
- int n = getdigits_int(&p, true, 0);
+ int n = getdigits_int((char **)&p, true, 0);
divider = 0;
if (*p == '.') { // ".5s" means a fraction.
fraction = atoi((char *)++p);
@@ -2075,7 +2075,7 @@ int get_c_indent(void)
} else if (*p == COM_LEFT || *p == COM_RIGHT) {
align = *p++;
} else if (ascii_isdigit(*p) || *p == '-') {
- off = getdigits_int(&p, true, 0);
+ off = getdigits_int((char **)&p, true, 0);
} else {
p++;
}
@@ -2084,7 +2084,7 @@ int get_c_indent(void)
if (*p == ':') {
p++;
}
- (void)copy_option_part(&p, (char_u *)lead_end, COM_MAX_LEN, ",");
+ (void)copy_option_part((char **)&p, lead_end, COM_MAX_LEN, ",");
if (what == COM_START) {
STRCPY(lead_start, lead_end);
lead_start_len = (int)STRLEN(lead_start);
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 164542f4ab..0406ba2199 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -1915,7 +1915,7 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview)
// every possible modifier (with room to spare). If the list of possible
// modifiers grows this may need to be updated.
char buf[200] = { 0 };
- (void)uc_mods(buf);
+ (void)uc_mods(buf, &cmdmod, false);
lua_pushstring(lstate, buf);
lua_setfield(lstate, -2, "mods");
@@ -1946,6 +1946,8 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview)
lua_setfield(lstate, -2, "silent");
lua_pushboolean(lstate, cmdmod.cmod_flags & CMOD_ERRSILENT);
lua_setfield(lstate, -2, "emsg_silent");
+ lua_pushboolean(lstate, cmdmod.cmod_flags & CMOD_UNSILENT);
+ lua_setfield(lstate, -2, "unsilent");
lua_pushboolean(lstate, cmdmod.cmod_flags & CMOD_SANDBOX);
lua_setfield(lstate, -2, "sandbox");
lua_pushboolean(lstate, cmdmod.cmod_flags & CMOD_NOAUTOCMD);
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c
index 2a89592edb..8fde85b163 100644
--- a/src/nvim/lua/stdlib.c
+++ b/src/nvim/lua/stdlib.c
@@ -55,7 +55,7 @@ static int regex_match(lua_State *lstate, regprog_T **prog, char_u *str)
regmatch_T rm;
rm.regprog = *prog;
rm.rm_ic = false;
- bool match = vim_regexec(&rm, str, 0);
+ bool match = vim_regexec(&rm, (char *)str, 0);
*prog = rm.regprog;
if (match) {
@@ -252,7 +252,7 @@ static int nlua_str_utf_end(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
if (offset < 0 || offset > (intptr_t)s1_len) {
return luaL_error(lstate, "index out of range");
}
- int tail_offset = mb_tail_off((char_u *)s1, (char_u *)s1 + offset - 1);
+ int tail_offset = mb_tail_off(s1, s1 + offset - 1);
lua_pushinteger(lstate, tail_offset);
return 1;
}
diff --git a/src/nvim/main.c b/src/nvim/main.c
index a7e39b7655..db588d4694 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -802,7 +802,7 @@ static void init_locale(void)
char localepath[MAXPATHL] = { 0 };
snprintf(localepath, sizeof(localepath), "%s", get_vim_var_str(VV_PROGPATH));
- char *tail = (char *)path_tail_with_sep((char_u *)localepath);
+ char *tail = path_tail_with_sep(localepath);
*tail = NUL;
tail = path_tail(localepath);
xstrlcpy(tail, "share/locale",
@@ -1354,11 +1354,11 @@ scripterror:
// Add the file to the global argument list.
ga_grow(&global_alist.al_ga, 1);
- char_u *p = vim_strsave((char_u *)argv[0]);
+ char *p = xstrdup(argv[0]);
- if (parmp->diff_mode && os_isdir(p) && GARGCOUNT > 0
+ if (parmp->diff_mode && os_isdir((char_u *)p) && GARGCOUNT > 0
&& !os_isdir((char_u *)alist_name(&GARGLIST[0]))) {
- char_u *r = (char_u *)concat_fnames((char *)p, path_tail(alist_name(&GARGLIST[0])), true);
+ char *r = concat_fnames(p, path_tail(alist_name(&GARGLIST[0])), true);
xfree(p);
p = r;
}
@@ -1371,7 +1371,7 @@ scripterror:
int alist_fnum_flag = edit_stdin(had_stdin_file, parmp)
? 1 // add buffer nr after exp.
: 2; // add buffer number now and use curbuf
- alist_add(&global_alist, (char *)p, alist_fnum_flag);
+ alist_add(&global_alist, p, alist_fnum_flag);
}
// If there are no more letters after the current "-", go to next argument.
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
index ff7a3da5c3..9a4db520a6 100644
--- a/src/nvim/mapping.c
+++ b/src/nvim/mapping.c
@@ -1266,7 +1266,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
continue;
}
- if (vim_regexec(regmatch, p, (colnr_T)0)) {
+ if (vim_regexec(regmatch, (char *)p, (colnr_T)0)) {
if (round == 1) {
count++;
} else {
@@ -1289,7 +1289,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
for (; mp; mp = mp->m_next) {
if (mp->m_mode & expand_mapmodes) {
p = translate_mapping(mp->m_keys, CPO_TO_CPO_FLAGS);
- if (p != NULL && vim_regexec(regmatch, p, (colnr_T)0)) {
+ if (p != NULL && vim_regexec(regmatch, (char *)p, (colnr_T)0)) {
if (round == 1) {
count++;
} else {
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 6ca1dde270..2402ea3035 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -280,7 +280,7 @@ fmark_T *get_jumplist(win_T *win, int count)
}
break;
}
- return jmp != NULL ? &jmp->fmark : NULL;
+ return &jmp->fmark;
}
/// Get mark in "count" position in the |changelist| relative to the current index.
@@ -430,6 +430,10 @@ fmark_T *mark_get_local(buf_T *buf, win_T *win, int name)
mark = mark_get_motion(buf, win, name);
}
+ if (mark) {
+ mark->fnum = buf->b_fnum;
+ }
+
return mark;
}
@@ -686,7 +690,7 @@ static void fname2fnum(xfmark_T *fm)
p = path_shorten_fname(NameBuff, IObuff);
// buflist_new() will call fmarks_check_names()
- (void)buflist_new(NameBuff, p, (linenr_T)1, 0);
+ (void)buflist_new((char *)NameBuff, (char *)p, (linenr_T)1, 0);
}
}
@@ -697,7 +701,7 @@ static void fname2fnum(xfmark_T *fm)
*/
void fmarks_check_names(buf_T *buf)
{
- char_u *name = buf->b_ffname;
+ char_u *name = (char_u *)buf->b_ffname;
int i;
if (buf->b_ffname == NULL) {
@@ -802,7 +806,7 @@ char_u *fm_getname(fmark_T *fmark, int lead_len)
if (fmark->fnum == curbuf->b_fnum) { // current buffer
return mark_line(&(fmark->mark), lead_len);
}
- return buflist_nr2name(fmark->fnum, FALSE, TRUE);
+ return (char_u *)buflist_nr2name(fmark->fnum, false, true);
}
/*
@@ -1847,7 +1851,7 @@ void get_global_marks(list_T *l)
// Marks 'A' to 'Z' and '0' to '9'
for (int i = 0; i < NMARKS + EXTRA_MARKS; i++) {
if (namedfm[i].fmark.fnum != 0) {
- name = (char *)buflist_nr2name(namedfm[i].fmark.fnum, true, true);
+ name = buflist_nr2name(namedfm[i].fmark.fnum, true, true);
} else {
name = namedfm[i].fname;
}
diff --git a/src/nvim/match.c b/src/nvim/match.c
index 3aa82527aa..54bd3066ab 100644
--- a/src/nvim/match.c
+++ b/src/nvim/match.c
@@ -86,7 +86,7 @@ static int match_add(win_T *wp, const char *const grp, const char *const pat, in
m = xcalloc(1, sizeof(matchitem_T));
m->id = id;
m->priority = prio;
- m->pattern = pat == NULL ? NULL: (char_u *)xstrdup(pat);
+ m->pattern = pat == NULL ? NULL: xstrdup(pat);
m->hlg_id = hlg_id;
m->match.regprog = regprog;
m->match.rmm_ic = false;
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index 1032986a02..a9792cf1b9 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -1840,8 +1840,9 @@ int mb_off_next(const char_u *base, const char_u *p)
/// Return the offset from "p" to the last byte of the character it points
/// into. Can start anywhere in a stream of bytes.
/// Composing characters are not included.
-int mb_tail_off(const char_u *base, const char_u *p)
+int mb_tail_off(const char *base, const char *p_in)
{
+ const uint8_t *p = (uint8_t *)p_in;
int i;
int j;
@@ -1853,7 +1854,7 @@ int mb_tail_off(const char_u *base, const char_u *p)
for (i = 0; (p[i + 1] & 0xc0) == 0x80; i++) {}
// Check for illegal sequence.
- for (j = 0; p - j > base; j++) {
+ for (j = 0; p_in - j > base; j++) {
if ((p[-j] & 0xc0) != 0x80) {
break;
}
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index ce47e0add6..1c54035a9e 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -665,7 +665,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf)
* First replace home dir path with "~/" with home_replace().
* Then insert the user name to get "~user/".
*/
- home_replace(NULL, (char *)buf->b_ffname, (char *)b0p->b0_fname,
+ home_replace(NULL, buf->b_ffname, (char *)b0p->b0_fname,
B0_FNAME_SIZE_CRYPT, true);
if (b0p->b0_fname[0] == '~') {
// If there is no user name or it is too long, don't use "~/"
@@ -680,7 +680,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf)
}
}
FileInfo file_info;
- if (os_fileinfo((char *)buf->b_ffname, &file_info)) {
+ if (os_fileinfo(buf->b_ffname, &file_info)) {
long_to_char(file_info.stat.st_mtim.tv_sec, b0p->b0_mtime);
long_to_char((long)os_fileinfo_inode(&file_info), b0p->b0_ino);
buf_store_file_info(buf, &file_info);
@@ -708,7 +708,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf)
/// not set.
static void set_b0_dir_flag(ZERO_BL *b0p, buf_T *buf)
{
- if (same_directory(buf->b_ml.ml_mfp->mf_fname, buf->b_ffname)) {
+ if (same_directory(buf->b_ml.ml_mfp->mf_fname, (char_u *)buf->b_ffname)) {
b0p->b0_flags |= B0_SAME_DIR;
} else {
b0p->b0_flags &= ~B0_SAME_DIR;
@@ -944,7 +944,7 @@ void ml_recover(bool checkext)
if (buf_spname(curbuf) != NULL) {
STRLCPY(NameBuff, buf_spname(curbuf), MAXPATHL);
} else {
- home_replace(NULL, (char *)curbuf->b_ffname, (char *)NameBuff, MAXPATHL, true);
+ home_replace(NULL, curbuf->b_ffname, (char *)NameBuff, MAXPATHL, true);
}
smsg(_("Original file \"%s\""), NameBuff);
msg_putchar('\n');
@@ -956,7 +956,7 @@ void ml_recover(bool checkext)
FileInfo swp_file_info;
mtime = char_to_long(b0p->b0_mtime);
if (curbuf->b_ffname != NULL
- && os_fileinfo((char *)curbuf->b_ffname, &org_file_info)
+ && os_fileinfo(curbuf->b_ffname, &org_file_info)
&& ((os_fileinfo((char *)mfp->mf_fname, &swp_file_info)
&& org_file_info.stat.st_mtim.tv_sec
> swp_file_info.stat.st_mtim.tv_sec)
@@ -990,7 +990,7 @@ void ml_recover(bool checkext)
* 'fileencoding', etc. Ignore errors. The text itself is not used.
*/
if (curbuf->b_ffname != NULL) {
- orig_file_status = readfile((char *)curbuf->b_ffname, NULL, (linenr_T)0,
+ orig_file_status = readfile(curbuf->b_ffname, NULL, (linenr_T)0,
(linenr_T)0, (linenr_T)MAXLNUM, NULL, READ_NEW, false);
}
@@ -1064,7 +1064,7 @@ void ml_recover(bool checkext)
*/
if (!cannot_open) {
line_count = pp->pb_pointer[idx].pe_line_count;
- if (readfile((char *)curbuf->b_ffname, NULL, lnum,
+ if (readfile(curbuf->b_ffname, NULL, lnum,
pp->pb_pointer[idx].pe_old_lnum - 1, line_count,
NULL, 0, false) != OK) {
cannot_open = true;
@@ -1305,7 +1305,7 @@ int recover_names(char_u *fname, int list, int nr, char_u **fname_out)
// Isolate a directory name from *dirp and put it in dir_name (we know
// it is large enough, so use 31000 for length).
// Advance dirp to next directory name.
- (void)copy_option_part(&dirp, dir_name, 31000, ",");
+ (void)copy_option_part((char **)&dirp, (char *)dir_name, 31000, ",");
if (dir_name[0] == '.' && dir_name[1] == NUL) { // check current dir
if (fname == NULL) {
@@ -1694,7 +1694,7 @@ void ml_sync_all(int check_file, int check_char, bool do_fsync)
* call ml_preserve() to get rid of all negative numbered blocks.
*/
FileInfo file_info;
- if (!os_fileinfo((char *)buf->b_ffname, &file_info)
+ if (!os_fileinfo(buf->b_ffname, &file_info)
|| file_info.stat.st_mtim.tv_sec != buf->b_mtime_read
|| file_info.stat.st_mtim.tv_nsec != buf->b_mtime_read_ns
|| os_fileinfo_size(&file_info) != buf->b_orig_size) {
@@ -3426,12 +3426,12 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
*/
const size_t dir_len = strlen(*dirp) + 1;
dir_name = xmalloc(dir_len);
- (void)copy_option_part((char_u **)dirp, (char_u *)dir_name, dir_len, ",");
+ (void)copy_option_part(dirp, dir_name, dir_len, ",");
/*
* we try different names until we find one that does not exist yet
*/
- fname = (char *)makeswapname((char_u *)buf_fname, buf->b_ffname, buf,
+ fname = (char *)makeswapname((char_u *)buf_fname, (char_u *)buf->b_ffname, buf,
(char_u *)dir_name);
for (;;) {
@@ -3479,12 +3479,12 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
if (b0.b0_flags & B0_SAME_DIR) {
if (FNAMECMP(path_tail((char *)buf->b_ffname),
path_tail((char *)b0.b0_fname)) != 0
- || !same_directory((char_u *)fname, buf->b_ffname)) {
+ || !same_directory((char_u *)fname, (char_u *)buf->b_ffname)) {
// Symlinks may point to the same file even
// when the name differs, need to check the
// inode too.
expand_env(b0.b0_fname, NameBuff, MAXPATHL);
- if (fnamecmp_ino(buf->b_ffname, NameBuff,
+ if (fnamecmp_ino((char_u *)buf->b_ffname, NameBuff,
char_to_long(b0.b0_ino))) {
differ = TRUE;
}
@@ -3493,7 +3493,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
// The name in the swap file may be
// "~user/path/file". Expand it first.
expand_env(b0.b0_fname, NameBuff, MAXPATHL);
- if (fnamecmp_ino(buf->b_ffname, NameBuff,
+ if (fnamecmp_ino((char_u *)buf->b_ffname, NameBuff,
char_to_long(b0.b0_ino))) {
differ = TRUE;
}
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 0cd323c234..6ab0a5d3e6 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -387,7 +387,7 @@ char_u *msg_strtrunc(char_u *s, int force)
// composing chars)
len = (room + 2) * 18;
buf = xmalloc((size_t)len);
- trunc_string(s, buf, room, len);
+ trunc_string((char *)s, (char *)buf, room, len);
}
}
return buf;
@@ -395,7 +395,7 @@ char_u *msg_strtrunc(char_u *s, int force)
/// Truncate a string "s" to "buf" with cell width "room".
/// "s" and "buf" may be equal.
-void trunc_string(char_u *s, char_u *buf, int room_in, int buflen)
+void trunc_string(char *s, char *buf, int room_in, int buflen)
{
int room = room_in - 3; // "..." takes 3 chars
int half;
@@ -423,13 +423,13 @@ void trunc_string(char_u *s, char_u *buf, int room_in, int buflen)
buf[e] = NUL;
return;
}
- n = ptr2cells((char *)s + e);
+ n = ptr2cells(s + e);
if (len + n > half) {
break;
}
len += n;
buf[e] = s[e];
- for (n = utfc_ptr2len((char *)s + e); --n > 0;) {
+ for (n = utfc_ptr2len(s + e); --n > 0;) {
if (++e == buflen) {
break;
}
@@ -441,9 +441,9 @@ void trunc_string(char_u *s, char_u *buf, int room_in, int buflen)
half = i = (int)STRLEN(s);
for (;;) {
do {
- half = half - utf_head_off(s, s + half - 1) - 1;
- } while (half > 0 && utf_iscomposing(utf_ptr2char((char *)s + half)));
- n = ptr2cells((char *)s + half);
+ half = half - utf_head_off((char_u *)s, (char_u *)s + half - 1) - 1;
+ } while (half > 0 && utf_iscomposing(utf_ptr2char(s + half)));
+ n = ptr2cells(s + half);
if (len + n > room || half == 0) {
break;
}
@@ -652,7 +652,7 @@ static bool emsg_multiline(const char *s, bool multiline)
// interrupt message).
if (cause_errthrow(s, severe, &ignore)) {
if (!ignore) {
- did_emsg++;
+ did_emsg = true;
}
return true;
}
@@ -717,7 +717,7 @@ static bool emsg_multiline(const char *s, bool multiline)
} else {
flush_buffers(FLUSH_MINIMAL); // flush internal buffers
}
- did_emsg++; // flag for DoOneCmd()
+ did_emsg = true; // flag for DoOneCmd()
}
emsg_on_display = true; // remember there is an error message
@@ -1477,10 +1477,8 @@ void msg_home_replace_hl(char_u *fname)
static void msg_home_replace_attr(char_u *fname, int attr)
{
- char_u *name;
-
- name = home_replace_save(NULL, fname);
- msg_outtrans_attr(name, attr);
+ char *name = home_replace_save(NULL, (char *)fname);
+ msg_outtrans_attr((char_u *)name, attr);
xfree(name);
}
@@ -2329,7 +2327,7 @@ bool message_filtered(char_u *msg)
return false;
}
- bool match = vim_regexec(&cmdmod.cmod_filter_regmatch, msg, (colnr_T)0);
+ bool match = vim_regexec(&cmdmod.cmod_filter_regmatch, (char *)msg, (colnr_T)0);
return cmdmod.cmod_filter_force ? match : !match;
}
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index 388fa2584c..de01443313 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -532,8 +532,19 @@ void rpc_close(Channel *channel)
}
}
+static void exit_delay_cb(uv_timer_t *handle)
+{
+ uv_timer_stop(&main_loop.exit_delay_timer);
+ multiqueue_put(main_loop.fast_events, exit_event, 0);
+}
+
static void exit_event(void **argv)
{
+ if (exit_need_delay) {
+ uv_timer_start(&main_loop.exit_delay_timer, exit_delay_cb, 0, 0);
+ return;
+ }
+
if (!exiting) {
os_exit(0);
}
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index beeb49ea66..c7f7b569e7 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -3143,7 +3143,7 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_
}
break;
}
- if (get_leader_len(get_cursor_line_ptr(), NULL, false, true) > 0) {
+ if (get_leader_len((char *)get_cursor_line_ptr(), NULL, false, true) > 0) {
// Ignore this line, continue at start of next line.
curwin->w_cursor.lnum++;
curwin->w_cursor.col = 0;
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 639b7fd738..a8198cfce9 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -1347,7 +1347,7 @@ bool get_spec_reg(int regname, char_u **argp, bool *allocated, bool errmsg)
return true;
case '#': // alternate file name
- *argp = getaltfname(errmsg); // may give emsg if not set
+ *argp = (char_u *)getaltfname(errmsg); // may give emsg if not set
return true;
case '=': // result of expression
@@ -1810,10 +1810,8 @@ setmarks:
/// Used for deletion.
static void mb_adjust_opend(oparg_T *oap)
{
- char_u *p;
-
if (oap->inclusive) {
- p = ml_get(oap->end.lnum);
+ char *p = (char *)ml_get(oap->end.lnum);
oap->end.col += mb_tail_off(p, p + oap->end.col);
}
}
@@ -3886,12 +3884,12 @@ void ex_display(exarg_T *eap)
// display alternate file name
if ((arg == NULL || vim_strchr((char *)arg, '%') != NULL) && !got_int) {
- char_u *fname;
+ char *fname;
linenr_T dummy;
- if (buflist_name_nr(0, &fname, &dummy) != FAIL && !message_filtered(fname)) {
+ if (buflist_name_nr(0, &fname, &dummy) != FAIL && !message_filtered((char_u *)fname)) {
msg_puts("\n c \"# ");
- dis_msg(fname, false);
+ dis_msg((char_u *)fname, false);
}
}
@@ -3950,7 +3948,7 @@ char_u *skip_comment(char_u *line, bool process, bool include_space, bool *is_co
{
char_u *comment_flags = NULL;
int lead_len;
- int leader_offset = get_last_leader_offset(line, &comment_flags);
+ int leader_offset = get_last_leader_offset((char *)line, (char **)&comment_flags);
*is_comment = false;
if (leader_offset != -1) {
@@ -3972,7 +3970,7 @@ char_u *skip_comment(char_u *line, bool process, bool include_space, bool *is_co
return line;
}
- lead_len = get_leader_len(line, &comment_flags, false, include_space);
+ lead_len = get_leader_len((char *)line, (char **)&comment_flags, false, include_space);
if (lead_len == 0) {
return line;
@@ -4654,7 +4652,7 @@ static int fmt_check_par(linenr_T lnum, int *leader_len, char_u **leader_flags,
ptr = ml_get(lnum);
if (do_comments) {
- *leader_len = get_leader_len(ptr, leader_flags, false, true);
+ *leader_len = get_leader_len((char *)ptr, (char **)leader_flags, false, true);
} else {
*leader_len = 0;
}
@@ -5597,7 +5595,7 @@ void write_reg_contents_ex(int name, const char_u *str, ssize_t len, bool must_a
semsg(_(e_nobufnr), (int64_t)num);
}
} else {
- buf = buflist_findnr(buflist_findpat(str, str + STRLEN(str),
+ buf = buflist_findnr(buflist_findpat((char *)str, (char *)str + STRLEN(str),
true, false, false));
}
if (buf == NULL) {
@@ -5993,9 +5991,9 @@ void cursor_pos_info(dict_T *dict)
} else {
p = get_cursor_line_ptr();
validate_virtcol();
- col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
+ col_print((char *)buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
(int)curwin->w_virtcol + 1);
- col_print(buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p));
+ col_print((char *)buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p));
if (char_count_cursor == byte_count_cursor
&& char_count == byte_count) {
@@ -6961,7 +6959,7 @@ bool prepare_yankreg_from_object(yankreg_T *reg, String regtype, size_t lines)
return false;
}
const char *p = regtype.data + 1;
- reg->y_width = getdigits_int((char_u **)&p, false, 1) - 1;
+ reg->y_width = getdigits_int((char **)&p, false, 1) - 1;
if (regtype.size > (size_t)(p - regtype.data)) {
return false;
}
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 09a597f7e2..bcaa4bb9b8 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -1400,7 +1400,7 @@ int do_set(char *arg, int opt_flags)
*/
else if (varp == (char_u *)&p_bs
&& ascii_isdigit(**(char_u **)varp)) {
- i = getdigits_int((char_u **)varp, true, 0);
+ i = getdigits_int((char **)varp, true, 0);
switch (i) {
case 0:
*(char_u **)varp = empty_option;
@@ -1435,7 +1435,7 @@ int do_set(char *arg, int opt_flags)
else if (varp == (char_u *)&p_ww
&& ascii_isdigit(*arg)) {
*errbuf = NUL;
- i = getdigits_int((char_u **)&arg, true, 0);
+ i = getdigits_int(&arg, true, 0);
if (i & 1) {
STRLCAT(errbuf, "b,", sizeof(errbuf));
}
@@ -1728,7 +1728,7 @@ skip:
IObuff[i + ((char_u *)arg - startarg)] = NUL;
}
// make sure all characters are printable
- trans_characters(IObuff, IOSIZE);
+ trans_characters((char *)IObuff, IOSIZE);
no_wait_return++; // wait_return done later
emsg((char *)IObuff); // show error highlighted
@@ -2941,7 +2941,7 @@ ambw_end:
if (*++s == '-') { // ignore a '-'
s++;
}
- wid = getdigits_int(&s, true, 0);
+ wid = getdigits_int((char **)&s, true, 0);
if (wid && *s == '(' && (errmsg = check_stl_option((char *)p_ruf)) == NULL) {
ru_wid = wid;
} else {
@@ -3457,7 +3457,7 @@ char *check_colorcolumn(win_T *wp)
if (!ascii_isdigit(*s)) {
return e_invarg;
}
- col = col * getdigits_int(&s, true, 0);
+ col = col * getdigits_int((char **)&s, true, 0);
if (wp->w_buffer->b_p_tw == 0) {
goto skip; // 'textwidth' not set, skip this item
}
@@ -3472,7 +3472,7 @@ char *check_colorcolumn(win_T *wp)
goto skip;
}
} else if (ascii_isdigit(*s)) {
- col = getdigits_int(&s, true, 0);
+ col = getdigits_int((char **)&s, true, 0);
} else {
return e_invarg;
}
@@ -5650,7 +5650,7 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, uint6
if (fprintf(fd, "%s %s+=", cmd, name) < 0) {
goto fail;
}
- (void)copy_option_part(&p, part, size, ",");
+ (void)copy_option_part((char **)&p, (char *)part, size, ",");
if (put_escstr(fd, part, 2) == FAIL || put_eol(fd) == FAIL) {
goto fail;
}
@@ -6921,7 +6921,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***
if (xp->xp_context != EXPAND_BOOL_SETTINGS) {
for (match = 0; match < (int)ARRAY_SIZE(names);
match++) {
- if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) {
+ if (vim_regexec(regmatch, names[match], (colnr_T)0)) {
if (loop == 0) {
num_normal++;
} else {
@@ -6940,10 +6940,10 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***
continue;
}
match = false;
- if (vim_regexec(regmatch, str, (colnr_T)0)
+ if (vim_regexec(regmatch, (char *)str, (colnr_T)0)
|| (options[opt_idx].shortname != NULL
&& vim_regexec(regmatch,
- (char_u *)options[opt_idx].shortname,
+ options[opt_idx].shortname,
(colnr_T)0))) {
match = true;
}
@@ -7460,7 +7460,7 @@ void save_file_ff(buf_T *buf)
if (buf->b_start_fenc == NULL
|| STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0) {
xfree(buf->b_start_fenc);
- buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
+ buf->b_start_fenc = (char *)vim_strsave(buf->b_p_fenc);
}
}
@@ -7827,10 +7827,10 @@ static bool briopt_check(win_T *wp)
if (STRNCMP(p, "shift:", 6) == 0
&& ((p[6] == '-' && ascii_isdigit(p[7])) || ascii_isdigit(p[6]))) {
p += 6;
- bri_shift = getdigits_int(&p, true, 0);
+ bri_shift = getdigits_int((char **)&p, true, 0);
} else if (STRNCMP(p, "min:", 4) == 0 && ascii_isdigit(p[4])) {
p += 4;
- bri_min = getdigits_int(&p, true, 0);
+ bri_min = getdigits_int((char **)&p, true, 0);
} else if (STRNCMP(p, "sbr", 3) == 0) {
p += 3;
bri_sbr = true;
@@ -7991,10 +7991,10 @@ char_u *skip_to_option_part(const char_u *p)
/// @param[in] sep_chars chars that separate the option parts
///
/// @return length of `*option`
-size_t copy_option_part(char_u **option, char_u *buf, size_t maxlen, char *sep_chars)
+size_t copy_option_part(char **option, char *buf, size_t maxlen, char *sep_chars)
{
size_t len = 0;
- char_u *p = *option;
+ char *p = *option;
// skip '.' at start of option part, for 'suffixes'
if (*p == '.') {
@@ -8015,7 +8015,7 @@ size_t copy_option_part(char_u **option, char_u *buf, size_t maxlen, char *sep_c
if (*p != NUL && *p != ',') { // skip non-standard separator
p++;
}
- p = skip_to_option_part(p); // p points to next file name
+ p = (char *)skip_to_option_part((char_u *)p); // p points to next file name
*option = p;
return len;
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index 2a7f7a221f..9c93057fe7 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -884,7 +884,7 @@ void vim_get_prefix_from_exepath(char *exe_name)
// TODO(bfredl): param could have been written as "char exe_name[MAXPATHL]"
// but c_grammar.lua does not recognize it (yet).
xstrlcpy(exe_name, get_vim_var_str(VV_PROGPATH), MAXPATHL * sizeof(*exe_name));
- char *path_end = (char *)path_tail_with_sep((char_u *)exe_name);
+ char *path_end = path_tail_with_sep(exe_name);
*path_end = '\0'; // remove the trailing "nvim.exe"
path_end = path_tail(exe_name);
*path_end = '\0'; // remove the trailing "bin/"
@@ -1143,15 +1143,16 @@ size_t home_replace(const buf_T *const buf, const char *src, char *const dst, si
/// Like home_replace, store the replaced string in allocated memory.
/// @param buf When not NULL, check for help files
/// @param src Input file name
-char_u *home_replace_save(buf_T *buf, char_u *src) FUNC_ATTR_NONNULL_RET
+char *home_replace_save(buf_T *buf, char *src)
+ FUNC_ATTR_NONNULL_RET
{
size_t len = 3; // space for "~/" and trailing NUL
if (src != NULL) { // just in case
len += STRLEN(src);
}
char *dst = xmalloc(len);
- home_replace(buf, (char *)src, dst, len, true);
- return (char_u *)dst;
+ home_replace(buf, src, dst, len, true);
+ return dst;
}
/// Function given to ExpandGeneric() to obtain an environment variable name.
@@ -1189,7 +1190,7 @@ bool os_setenv_append_path(const char *fname)
internal_error("os_setenv_append_path()");
return false;
}
- const char *tail = (char *)path_tail_with_sep((char_u *)fname);
+ const char *tail = path_tail_with_sep((char *)fname);
size_t dirlen = (size_t)(tail - fname);
assert(tail >= fname && dirlen + 1 < sizeof(os_buf));
xstrlcpy(os_buf, fname, dirlen + 1);
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index 7c5e4f31d7..901a1bc5a6 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -935,7 +935,7 @@ int os_mkdir_recurse(const char *const dir, int32_t mode, char **const failed_di
const char *const real_end = e;
const char past_head_save = *past_head;
while (!os_isdir((char_u *)curdir)) {
- e = (char *)path_tail_with_sep((char_u *)curdir);
+ e = path_tail_with_sep(curdir);
if (e <= past_head) {
*past_head = NUL;
break;
diff --git a/src/nvim/path.c b/src/nvim/path.c
index f5c662ca88..b22c0a18bd 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -125,14 +125,14 @@ char *path_tail(const char *fname)
/// - Pointer to the last path separator of `fname`, if there is any.
/// - `fname` if it contains no path separator.
/// - Never NULL.
-char_u *path_tail_with_sep(char_u *fname)
+char *path_tail_with_sep(char *fname)
{
assert(fname != NULL);
// Don't remove the '/' from "c:/file".
- char_u *past_head = get_past_head(fname);
- char_u *tail = (char_u *)path_tail((char *)fname);
- while (tail > past_head && after_pathsep((char *)fname, (char *)tail)) {
+ char *past_head = (char *)get_past_head((char_u *)fname);
+ char *tail = path_tail(fname);
+ while (tail > past_head && after_pathsep(fname, tail)) {
tail--;
}
return tail;
@@ -326,11 +326,11 @@ void shorten_dir(char_u *str)
*/
bool dir_of_file_exists(char_u *fname)
{
- char_u *p = path_tail_with_sep(fname);
- if (p == fname) {
+ char *p = path_tail_with_sep((char *)fname);
+ if ((char_u *)p == fname) {
return true;
}
- char_u c = *p;
+ char c = *p;
*p = NUL;
bool retval = os_isdir(fname);
*p = c;
@@ -731,7 +731,7 @@ static size_t do_path_expand(garray_T *gap, const char_u *path, size_t wildoff,
|| ((flags & EW_DODOT)
&& name[1] != NUL
&& (name[1] != '.' || name[2] != NUL))) // -V557
- && ((regmatch.regprog != NULL && vim_regexec(&regmatch, name, 0))
+ && ((regmatch.regprog != NULL && vim_regexec(&regmatch, (char *)name, 0))
|| ((flags & EW_NOTWILD)
&& FNAMENCMP(path + (s - buf), name, e - s) == 0))) {
STRCPY(s, name);
@@ -845,7 +845,7 @@ static void expand_path_option(char_u *curdir, garray_T *gap)
char_u *buf = xmalloc(MAXPATHL);
while (*path_option != NUL) {
- copy_option_part(&path_option, buf, MAXPATHL, " ,");
+ copy_option_part((char **)&path_option, (char *)buf, MAXPATHL, " ,");
if (buf[0] == '.' && (buf[1] == NUL || vim_ispathsep(buf[1]))) {
/* Relative to current buffer:
@@ -854,8 +854,8 @@ static void expand_path_option(char_u *curdir, garray_T *gap)
if (curbuf->b_ffname == NULL) {
continue;
}
- char_u *p = (char_u *)path_tail((char *)curbuf->b_ffname);
- size_t len = (size_t)(p - curbuf->b_ffname);
+ char_u *p = (char_u *)path_tail(curbuf->b_ffname);
+ size_t len = (size_t)(p - (char_u *)curbuf->b_ffname);
if (len + STRLEN(buf) >= MAXPATHL) {
continue;
}
@@ -996,7 +996,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
if (pattern[0] == '*' && pattern[1] == '*'
&& vim_ispathsep_nocolon(pattern[2])
&& path_cutoff != NULL
- && vim_regexec(&regmatch, path_cutoff, (colnr_T)0)
+ && vim_regexec(&regmatch, (char *)path_cutoff, (colnr_T)0)
&& is_unique(path_cutoff, gap, i)) {
sort_again = true;
memmove(path, path_cutoff, STRLEN(path_cutoff) + 1);
@@ -1005,7 +1005,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
// unique path. We start at the end of the path. */
pathsep_p = path + len - 1;
while (find_previous_pathsep(path, &pathsep_p)) {
- if (vim_regexec(&regmatch, pathsep_p + 1, (colnr_T)0)
+ if (vim_regexec(&regmatch, (char *)pathsep_p + 1, (colnr_T)0)
&& is_unique(pathsep_p + 1, gap, i)
&& path_cutoff != NULL && pathsep_p + 1 >= path_cutoff) {
sort_again = true;
@@ -1877,7 +1877,7 @@ char *fix_fname(const char *fname)
fname = xstrdup(fname);
# ifdef USE_FNAME_CASE
- path_fix_case((char_u *)fname); // set correct case for file name
+ path_fix_case(fname); // set correct case for file name
# endif
return (char *)fname;
@@ -1889,17 +1889,17 @@ char *fix_fname(const char *fname)
/// Only required for file systems where case is ignored and preserved.
// TODO(SplinterOfChaos): Could also be used when mounting case-insensitive
// file systems.
-void path_fix_case(char_u *name)
+void path_fix_case(char *name)
FUNC_ATTR_NONNULL_ALL
{
FileInfo file_info;
- if (!os_fileinfo_link((char *)name, &file_info)) {
+ if (!os_fileinfo_link(name, &file_info)) {
return;
}
// Open the directory where the file is located.
- char_u *slash = STRRCHR(name, '/');
- char_u *tail;
+ char *slash = (char *)STRRCHR(name, '/');
+ char *tail;
Directory dir;
bool ok;
if (slash == NULL) {
@@ -1907,7 +1907,7 @@ void path_fix_case(char_u *name)
tail = name;
} else {
*slash = NUL;
- ok = os_scandir(&dir, (char *)name);
+ ok = os_scandir(&dir, name);
*slash = '/';
tail = slash + 1;
}
@@ -1916,8 +1916,8 @@ void path_fix_case(char_u *name)
return;
}
- char_u *entry;
- while ((entry = (char_u *)os_scandir_next(&dir))) {
+ char *entry;
+ while ((entry = (char *)os_scandir_next(&dir))) {
// Only accept names that differ in case and are the same byte
// length. TODO: accept different length name.
if (STRICMP(tail, entry) == 0 && STRLEN(tail) == STRLEN(entry)) {
@@ -1956,9 +1956,9 @@ int after_pathsep(const char *b, const char *p)
*/
bool same_directory(char_u *f1, char_u *f2)
{
- char_u ffname[MAXPATHL];
- char_u *t1;
- char_u *t2;
+ char ffname[MAXPATHL];
+ char *t1;
+ char *t2;
// safety check
if (f1 == NULL || f2 == NULL) {
@@ -1967,8 +1967,8 @@ bool same_directory(char_u *f1, char_u *f2)
(void)vim_FullName((char *)f1, (char *)ffname, MAXPATHL, FALSE);
t1 = path_tail_with_sep(ffname);
- t2 = path_tail_with_sep(f2);
- return t1 - ffname == t2 - f2
+ t2 = path_tail_with_sep((char *)f2);
+ return t1 - ffname == (char_u *)t2 - f2
&& pathcmp((char *)ffname, (char *)f2, (int)(t1 - ffname)) == 0;
}
@@ -2246,7 +2246,7 @@ int match_suffix(char_u *fname)
size_t fnamelen = STRLEN(fname);
size_t setsuflen = 0;
for (char_u *setsuf = p_su; *setsuf;) {
- setsuflen = copy_option_part(&setsuf, suf_buf, MAXSUFLEN, ".,");
+ setsuflen = copy_option_part((char **)&setsuf, (char *)suf_buf, MAXSUFLEN, ".,");
if (setsuflen == 0) {
char_u *tail = (char_u *)path_tail((char *)fname);
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index edf964f5dd..2138437b29 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -1563,7 +1563,7 @@ static int qf_parse_get_fields(char *linebuf, size_t linelen, efm_T *fmt_ptr, qf
// Always ignore case when looking for a matching error.
regmatch.rm_ic = true;
regmatch.regprog = fmt_ptr->prog;
- r = vim_regexec(&regmatch, (char_u *)linebuf, (colnr_T)0);
+ r = vim_regexec(&regmatch, linebuf, (colnr_T)0);
fmt_ptr->prog = regmatch.regprog;
if (r) {
status = qf_parse_match(linebuf, linelen, fmt_ptr, &regmatch, fields,
@@ -2139,7 +2139,7 @@ static int qf_get_fnum(qf_list_T *qfl, char *directory, char *fname)
xfree(ptr);
} else {
xfree(qf_last_bufname);
- buf = buflist_new((char_u *)bufname, NULL, (linenr_T)0, BLN_NOOPT);
+ buf = buflist_new(bufname, NULL, (linenr_T)0, BLN_NOOPT);
qf_last_bufname = (bufname == ptr) ? bufname : xstrdup(bufname);
set_bufref(&qf_last_bufref, buf);
}
@@ -3301,7 +3301,7 @@ static void qf_msg(qf_info_T *qi, int which, char *lead)
}
STRLCAT(buf, title, IOSIZE);
}
- trunc_string((char_u *)buf, (char_u *)buf, Columns - 1, IOSIZE);
+ trunc_string(buf, buf, Columns - 1, IOSIZE);
msg(buf);
}
@@ -4035,7 +4035,7 @@ static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum, const qfli
// buffer.
if (first_bufline
&& (errbuf->b_sfname == NULL
- || path_is_absolute(errbuf->b_sfname))) {
+ || path_is_absolute((char_u *)errbuf->b_sfname))) {
if (*dirname == NUL) {
os_dirname((char_u *)dirname, MAXPATHL);
}
@@ -5462,7 +5462,7 @@ static int vgr_process_files(win_T *wp, qf_info_T *qi, vgr_args_T *cmd_args, boo
vgr_display_fname(fname);
}
- buf_T *buf = buflist_findname_exp((char_u *)cmd_args->fnames[fi]);
+ buf_T *buf = buflist_findname_exp(cmd_args->fnames[fi]);
bool using_dummy;
if (buf == NULL || buf->b_ml.ml_mfp == NULL) {
// Remember that a buffer with this name already exists.
@@ -6936,8 +6936,7 @@ void ex_cbuffer(exarg_T *eap)
qf_title = qf_cmdtitle(*eap->cmdlinep);
if (buf->b_sfname) {
- vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)",
- qf_title, (char *)buf->b_sfname);
+ vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)", qf_title, buf->b_sfname);
qf_title = (char *)IObuff;
}
@@ -7099,7 +7098,7 @@ static void hgr_search_file(qf_list_T *qfl, char *fname, regmatch_T *p_regmatch)
while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) {
char *line = (char *)IObuff;
- if (vim_regexec(p_regmatch, (char_u *)line, (colnr_T)0)) {
+ if (vim_regexec(p_regmatch, line, (colnr_T)0)) {
int l = (int)STRLEN(line);
// remove trailing CR, LF, spaces, etc.
@@ -7181,7 +7180,7 @@ static void hgr_search_in_rtp(qf_list_T *qfl, regmatch_T *p_regmatch, const char
// Go through all directories in 'runtimepath'
char *p = (char *)p_rtp;
while (*p != NUL && !got_int) {
- copy_option_part((char_u **)&p, NameBuff, MAXPATHL, ",");
+ copy_option_part(&p, (char *)NameBuff, MAXPATHL, ",");
hgr_search_files_in_dir(qfl, (char *)NameBuff, p_regmatch, (char *)lang);
}
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 45f2cf0e1d..bb6cbc35bc 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -2516,9 +2516,9 @@ bool vim_regexec_prog(regprog_T **prog, bool ignore_case, char_u *line, colnr_T
// Note: "rmp->regprog" may be freed and changed.
// Return true if there is a match, false if not.
-bool vim_regexec(regmatch_T *rmp, char_u *line, colnr_T col)
+bool vim_regexec(regmatch_T *rmp, char *line, colnr_T col)
{
- return vim_regexec_string(rmp, line, col, false);
+ return vim_regexec_string(rmp, (char_u *)line, col, false);
}
// Like vim_regexec(), but consider a "\n" in "line" to be a line break.
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index 28d85b54bd..045cee2439 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -93,7 +93,7 @@ int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback,
char_u *rtp = rtp_copy;
while (*rtp != NUL && ((flags & DIP_ALL) || !did_one)) {
// Copy the path from 'runtimepath' to buf[].
- copy_option_part(&rtp, buf, MAXPATHL, ",");
+ copy_option_part((char **)&rtp, (char *)buf, MAXPATHL, ",");
size_t buflen = STRLEN(buf);
// Skip after or non-after directories.
@@ -118,8 +118,7 @@ int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback,
while (*np != NUL && ((flags & DIP_ALL) || !did_one)) {
// Append the pattern from "name" to buf[].
assert(MAXPATHL >= (tail - buf));
- copy_option_part(&np, tail, (size_t)(MAXPATHL - (tail - buf)),
- "\t ");
+ copy_option_part((char **)&np, (char *)tail, (size_t)(MAXPATHL - (tail - buf)), "\t ");
if (p_verbose > 10) {
verbose_enter();
@@ -252,8 +251,7 @@ int do_in_cached_path(char_u *name, int flags, DoInRuntimepathCB callback, void
while (*np != NUL && ((flags & DIP_ALL) || !did_one)) {
// Append the pattern from "name" to buf[].
assert(MAXPATHL >= (tail - buf));
- copy_option_part(&np, tail, (size_t)(MAXPATHL - (tail - buf)),
- "\t ");
+ copy_option_part((char **)&np, (char *)tail, (size_t)(MAXPATHL - (tail - buf)), "\t ");
if (p_verbose > 10) {
verbose_enter();
@@ -513,7 +511,7 @@ RuntimeSearchPath runtime_search_path_build(void)
static char_u buf[MAXPATHL];
for (char *entry = (char *)p_pp; *entry != NUL;) {
char *cur_entry = entry;
- copy_option_part((char_u **)&entry, buf, MAXPATHL, ",");
+ copy_option_part(&entry, (char *)buf, MAXPATHL, ",");
String the_entry = { .data = cur_entry, .size = STRLEN(buf) };
@@ -524,7 +522,7 @@ RuntimeSearchPath runtime_search_path_build(void)
char *rtp_entry;
for (rtp_entry = (char *)p_rtp; *rtp_entry != NUL;) {
char *cur_entry = rtp_entry;
- copy_option_part((char_u **)&rtp_entry, buf, MAXPATHL, ",");
+ copy_option_part(&rtp_entry, (char *)buf, MAXPATHL, ",");
size_t buflen = STRLEN(buf);
if (path_is_after(buf, buflen)) {
@@ -558,7 +556,7 @@ RuntimeSearchPath runtime_search_path_build(void)
// "after" dirs in rtp
for (; *rtp_entry != NUL;) {
- copy_option_part((char_u **)&rtp_entry, buf, MAXPATHL, ",");
+ copy_option_part(&rtp_entry, (char *)buf, MAXPATHL, ",");
expand_rtp_entry(&search_path, &rtp_used, (char *)buf, path_is_after(buf, STRLEN(buf)));
}
@@ -700,7 +698,7 @@ static int add_pack_dir_to_rtp(char_u *fname, bool is_pack)
for (const char *entry = (const char *)p_rtp; *entry != NUL;) {
const char *cur_entry = entry;
- copy_option_part((char_u **)&entry, buf, MAXPATHL, ",");
+ copy_option_part((char **)&entry, (char *)buf, MAXPATHL, ",");
if (insp == NULL) {
add_pathsep((char *)buf);
char *const rtp_ffname = fix_fname((char *)buf);
@@ -849,7 +847,7 @@ static void add_pack_plugin(bool opt, char_u *fname, void *cookie)
const char *p = (const char *)p_rtp;
while (*p != NUL) {
- copy_option_part((char_u **)&p, (char_u *)buf, MAXPATHL, ",");
+ copy_option_part((char **)&p, buf, MAXPATHL, ",");
if (path_fnamecmp(buf, (char *)fname) == 0) {
found = true;
break;
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index c2a88bb4a6..32e2d515e1 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -4845,7 +4845,7 @@ void win_redr_status_matches(expand_T *xp, int num_matches, char_u **matches, in
clen = len;
i = first_match;
- while ((long)(clen + status_match_len(xp, L_MATCH(i)) + 2) < Columns) {
+ while (clen + status_match_len(xp, L_MATCH(i)) + 2 < Columns) {
if (i == match) {
selstart = buf + len;
selstart_col = clen;
@@ -6412,7 +6412,7 @@ void get_trans_bufname(buf_T *buf)
} else {
home_replace(buf, buf->b_fname, (char *)NameBuff, MAXPATHL, true);
}
- trans_characters(NameBuff, MAXPATHL);
+ trans_characters((char *)NameBuff, MAXPATHL);
}
/*
@@ -6613,7 +6613,7 @@ static void win_redr_ruler(win_T *wp, bool always)
(wp->w_buffer->b_ml.ml_flags & ML_EMPTY) ? (int64_t)0L
: (int64_t)wp->w_cursor.lnum);
size_t len = STRLEN(buffer);
- col_print((char_u *)buffer + len, RULER_BUF_LEN - len,
+ col_print(buffer + len, RULER_BUF_LEN - len,
empty_line ? 0 : (int)wp->w_cursor.col + 1,
(int)virtcol + 1);
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 2a248a53e7..15e8bd9e13 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -5406,9 +5406,9 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo
for (;;) {
if (incl_regmatch.regprog != NULL
- && vim_regexec(&incl_regmatch, line, (colnr_T)0)) {
+ && vim_regexec(&incl_regmatch, (char *)line, (colnr_T)0)) {
char_u *p_fname = (curr_fname == (char_u *)curbuf->b_fname)
- ? curbuf->b_ffname : curr_fname;
+ ? (char_u *)curbuf->b_ffname : curr_fname;
if (inc_opt != NULL && strstr((char *)inc_opt, "\\zs") != NULL) {
// Use text from '\zs' to '\ze' (or end) of 'include'.
@@ -5586,12 +5586,10 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo
search_line:
define_matched = false;
if (def_regmatch.regprog != NULL
- && vim_regexec(&def_regmatch, line, (colnr_T)0)) {
- /*
- * Pattern must be first identifier after 'define', so skip
- * to that position before checking for match of pattern. Also
- * don't let it match beyond the end of this identifier.
- */
+ && vim_regexec(&def_regmatch, (char *)line, (colnr_T)0)) {
+ // Pattern must be first identifier after 'define', so skip
+ // to that position before checking for match of pattern. Also
+ // don't let it match beyond the end of this identifier.
p = def_regmatch.endp[0];
while (*p && !vim_iswordc(*p)) {
p++;
@@ -5618,7 +5616,7 @@ search_line:
matched = false;
}
} else if (regmatch.regprog != NULL
- && vim_regexec(&regmatch, line, (colnr_T)(p - line))) {
+ && vim_regexec(&regmatch, (char *)line, (colnr_T)(p - line))) {
matched = true;
startp = regmatch.startp[0];
// Check if the line is not a comment line (unless we are
@@ -5627,7 +5625,7 @@ search_line:
if (skip_comments) {
if ((*line != '#'
|| STRNCMP(skipwhite((char *)line + 1), "define", 6) != 0)
- && get_leader_len(line, NULL, false, true)) {
+ && get_leader_len((char *)line, NULL, false, true)) {
matched = false;
}
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 834355f2b7..6e80b550d8 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -1328,8 +1328,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
char *const sfname =
(char *)path_try_shorten_fname((char_u *)cur_entry.data.buffer_list.buffers[i].fname);
buf_T *const buf =
- buflist_new((char_u *)cur_entry.data.buffer_list.buffers[i].fname, (char_u *)sfname, 0,
- BLN_LISTED);
+ buflist_new(cur_entry.data.buffer_list.buffers[i].fname, sfname, 0, BLN_LISTED);
if (buf != NULL) {
fmarkv_T view = INIT_FMARKV;
RESET_FMARK(&buf->b_last_cursor,
@@ -2307,7 +2306,7 @@ static inline ShadaEntry shada_get_buflist(khash_t(bufset) *const removable_bufs
}
buflist_entry.data.buffer_list.buffers[i] = (struct buffer_list_buffer) {
.pos = buf->b_last_cursor.mark,
- .fname = (char *)buf->b_ffname,
+ .fname = buf->b_ffname,
.additional_data = buf->additional_data,
};
i++;
@@ -2445,7 +2444,7 @@ static inline void replace_numbered_mark(WriteMergerState *const wms, const size
static inline void find_removable_bufs(khash_t(bufset) *removable_bufs)
{
FOR_ALL_BUFFERS(buf) {
- if (buf->b_ffname != NULL && shada_removable((char *)buf->b_ffname)) {
+ if (buf->b_ffname != NULL && shada_removable(buf->b_ffname)) {
int kh_ret;
(void)kh_put(bufset, removable_bufs, (uintptr_t)buf, &kh_ret);
}
@@ -2804,7 +2803,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, ShaDaReadDef
.mark = curwin->w_cursor,
.name = '0',
.additional_data = NULL,
- .fname = (char *)curbuf->b_ffname,
+ .fname = curbuf->b_ffname,
}
}
},
@@ -2998,7 +2997,7 @@ shada_write_file_open: {}
}
if (nomerge) {
shada_write_file_nomerge: {}
- char *const tail = (char *)path_tail_with_sep((char_u *)fname);
+ char *const tail = path_tail_with_sep(fname);
if (tail != fname) {
const char tail_save = *tail;
*tail = NUL;
@@ -3974,9 +3973,9 @@ static bool shada_removable(const char *name)
char part[MAXPATHL + 1];
bool retval = false;
- char *new_name = (char *)home_replace_save(NULL, (char_u *)name);
+ char *new_name = home_replace_save(NULL, (char *)name);
for (p = (char *)p_shada; *p;) {
- (void)copy_option_part((char_u **)&p, (char_u *)part, ARRAY_SIZE(part), ", ");
+ (void)copy_option_part(&p, part, ARRAY_SIZE(part), ", ");
if (part[0] == 'r') {
home_replace(NULL, part + 1, (char *)NameBuff, MAXPATHL, true);
size_t n = STRLEN(NameBuff);
@@ -4026,8 +4025,7 @@ static inline size_t shada_init_jumps(PossiblyFreedShadaEntry *jumps,
continue;
}
const char *const fname =
- (char *)(fm.fmark.fnum ==
- 0 ? (fm.fname == NULL ? NULL : (char_u *)fm.fname) : buf ? buf->b_ffname : NULL);
+ (fm.fmark.fnum == 0 ? (fm.fname == NULL ? NULL : fm.fname) : buf ? buf->b_ffname : NULL);
if (fname == NULL) {
continue;
}
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index 940cd1d274..9a4b304d6c 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -100,10 +100,9 @@ static signgroup_T *sign_group_ref(const char_u *groupname)
/// removed, then remove the group.
static void sign_group_unref(char_u *groupname)
{
- hashitem_T *hi;
signgroup_T *group;
- hi = hash_find(&sg_table, groupname);
+ hashitem_T *hi = hash_find(&sg_table, (char *)groupname);
if (!HASHITEM_EMPTY(hi)) {
group = HI2SG(hi);
group->sg_refcount--;
@@ -136,7 +135,7 @@ static int sign_group_get_next_signid(buf_T *buf, const char_u *groupname)
int found = false;
if (groupname != NULL) {
- hi = hash_find(&sg_table, groupname);
+ hi = hash_find(&sg_table, (char *)groupname);
if (HASHITEM_EMPTY(hi)) {
return id;
}
@@ -647,7 +646,7 @@ static int buf_findsign_id(buf_T *buf, linenr_T lnum, char_u *groupname)
}
/// Delete signs in buffer "buf".
-void buf_delete_signs(buf_T *buf, char_u *group)
+void buf_delete_signs(buf_T *buf, char *group)
{
sign_entry_T *sign;
sign_entry_T **lastp; // pointer to pointer to current sign
@@ -662,7 +661,7 @@ void buf_delete_signs(buf_T *buf, char_u *group)
lastp = &buf->b_signlist;
for (sign = buf->b_signlist; sign != NULL; sign = next) {
next = sign->se_next;
- if (sign_in_group(sign, group)) {
+ if (sign_in_group(sign, (char_u *)group)) {
*lastp = next;
if (next != NULL) {
next->se_prev = sign->se_prev;
@@ -1086,7 +1085,7 @@ static int sign_unplace(int sign_id, char_u *sign_group, buf_T *buf, linenr_T at
if (sign_id == 0) {
// Delete all the signs in the specified buffer
redraw_buf_later(buf, NOT_VALID);
- buf_delete_signs(buf, sign_group);
+ buf_delete_signs(buf, (char *)sign_group);
} else {
linenr_T lnum;
@@ -1173,7 +1172,7 @@ static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
if (*arg == NUL) {
break;
}
- p = skiptowhite_esc(arg);
+ p = (char_u *)skiptowhite_esc((char *)arg);
if (STRNCMP(arg, "icon=", 5) == 0) {
arg += 5;
XFREE_CLEAR(icon);
@@ -1273,7 +1272,7 @@ static void sign_unplace_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int i
// :sign unplace * group=*
FOR_ALL_BUFFERS(cbuf) {
if (cbuf->b_signlist != NULL) {
- buf_delete_signs(cbuf, group);
+ buf_delete_signs(cbuf, (char *)group);
}
}
}
@@ -1341,7 +1340,7 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
// first arg could be placed sign id
arg1 = arg;
if (ascii_isdigit(*arg)) {
- *signid = getdigits_int(&arg, true, 0);
+ *signid = getdigits_int((char **)&arg, true, 0);
if (!ascii_iswhite(*arg) && *arg != NUL) {
*signid = -1;
arg = arg1;
@@ -1388,12 +1387,12 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
} else if (STRNCMP(arg, "file=", 5) == 0) {
arg += 5;
filename = arg;
- *buf = buflist_findname_exp(arg);
+ *buf = buflist_findname_exp((char *)arg);
break;
} else if (STRNCMP(arg, "buffer=", 7) == 0) {
arg += 7;
filename = arg;
- *buf = buflist_findnr(getdigits_int(&arg, true, 0));
+ *buf = buflist_findnr(getdigits_int((char **)&arg, true, 0));
if (*skipwhite((char *)arg) != NUL) {
emsg(_(e_trailing));
}
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index e4805f3c4a..304fd30b36 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -504,7 +504,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou
// Check for end of sentence.
regmatch.regprog = wp->w_s->b_cap_prog;
regmatch.rm_ic = false;
- int r = vim_regexec(&regmatch, ptr, 0);
+ int r = vim_regexec(&regmatch, (char *)ptr, 0);
wp->w_s->b_cap_prog = regmatch.regprog;
if (r) {
*capcol = (int)(regmatch.endp[0] - ptr);
@@ -1908,12 +1908,11 @@ void count_common_word(slang_T *lp, char_u *word, int len, int count)
/// @param split word was split, less bonus
static int score_wordcount_adj(slang_T *slang, int score, char_u *word, bool split)
{
- hashitem_T *hi;
wordcount_T *wc;
int bonus;
int newscore;
- hi = hash_find(&slang->sl_wordcount, word);
+ hashitem_T *hi = hash_find(&slang->sl_wordcount, (char *)word);
if (!HASHITEM_EMPTY(hi)) {
wc = HI2WC(hi);
if (wc->wc_count < SCORE_THRES2) {
@@ -2083,7 +2082,7 @@ char *did_set_spelllang(win_T *wp)
// Loop over comma separated language names.
for (splp = spl_copy; *splp != NUL;) {
// Get one language name.
- copy_option_part(&splp, lang, MAXWLEN, ",");
+ copy_option_part((char **)&splp, (char *)lang, MAXWLEN, ",");
region = NULL;
len = (int)STRLEN(lang);
@@ -2215,7 +2214,7 @@ char *did_set_spelllang(win_T *wp)
int_wordlist_spl(spf_name);
} else {
// One entry in 'spellfile'.
- copy_option_part(&spf, spf_name, MAXPATHL - 5, ",");
+ copy_option_part((char **)&spf, (char *)spf_name, MAXPATHL - 5, ",");
STRCAT(spf_name, ".spl");
// If it was already found above then skip it.
@@ -2805,12 +2804,12 @@ int spell_check_sps(void)
sps_limit = 9999;
for (p = p_sps; *p != NUL;) {
- copy_option_part(&p, buf, MAXPATHL, ",");
+ copy_option_part((char **)&p, (char *)buf, MAXPATHL, ",");
f = 0;
if (ascii_isdigit(*buf)) {
s = buf;
- sps_limit = getdigits_int(&s, true, 0);
+ sps_limit = getdigits_int((char **)&s, true, 0);
if (*s != NUL && !ascii_isdigit(*s)) {
f = -1;
}
@@ -3121,7 +3120,7 @@ static bool check_need_cap(linenr_T lnum, colnr_T col)
if (p == line || spell_iswordp_nmw(p, curwin)) {
break;
}
- if (vim_regexec(&regmatch, p, 0)
+ if (vim_regexec(&regmatch, (char *)p, 0)
&& regmatch.endp[0] == line + endcol) {
need_cap = true;
break;
@@ -3328,7 +3327,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
// Loop over the items in 'spellsuggest'.
for (p = sps_copy; *p != NUL;) {
- copy_option_part(&p, buf, MAXPATHL, ",");
+ copy_option_part((char **)&p, (char *)buf, MAXPATHL, ",");
if (STRNCMP(buf, "expr:", 5) == 0) {
// Evaluate an expression. Skip this when called recursively,
@@ -4034,8 +4033,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
break;
}
if ((sp->ts_complen == sp->ts_compsplit
- && WAS_BANNED(su, preword + sp->ts_prewordlen))
- || WAS_BANNED(su, preword)) {
+ && WAS_BANNED(su, (char *)preword + sp->ts_prewordlen))
+ || WAS_BANNED(su, (char *)preword)) {
if (slang->sl_compprog == NULL) {
break;
}
@@ -5661,7 +5660,7 @@ static bool similar_chars(slang_T *slang, int c1, int c2)
if (c1 >= 256) {
buf[utf_char2bytes(c1, (char *)buf)] = 0;
- hi = hash_find(&slang->sl_map_hash, (char_u *)buf);
+ hi = hash_find(&slang->sl_map_hash, buf);
if (HASHITEM_EMPTY(hi)) {
m1 = 0;
} else {
@@ -5676,7 +5675,7 @@ static bool similar_chars(slang_T *slang, int c1, int c2)
if (c2 >= 256) {
buf[utf_char2bytes(c2, (char *)buf)] = 0;
- hi = hash_find(&slang->sl_map_hash, (char_u *)buf);
+ hi = hash_find(&slang->sl_map_hash, buf);
if (HASHITEM_EMPTY(hi)) {
m2 = 0;
} else {
@@ -7144,7 +7143,7 @@ static void dump_word(slang_T *slang, char_u *word, char_u *pat, Direction *dir,
hashitem_T *hi;
// Include the word count for ":spelldump!".
- hi = hash_find(&slang->sl_wordcount, tw);
+ hi = hash_find(&slang->sl_wordcount, (char *)tw);
if (!HASHITEM_EMPTY(hi)) {
vim_snprintf((char *)IObuff, IOSIZE, "%s\t%d",
tw, HI2WC(hi)->wc_count);
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 07f3d39886..a532c106ef 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -2351,7 +2351,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
// "S" flag on all but the last block, thus we check for that
// and store it in ah_follows.
STRLCPY(key, items[1], AH_KEY_LEN);
- hi = hash_find(tp, key);
+ hi = hash_find(tp, (char *)key);
if (!HASHITEM_EMPTY(hi)) {
cur_aff = HI2AH(hi);
if (cur_aff->ah_combine != (*items[2] == 'Y')) {
@@ -2688,9 +2688,8 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
} else if (STRCMP(items[0], "COMMON") == 0) {
int i;
- for (i = 1; i < itemcnt; ++i) {
- if (HASHITEM_EMPTY(hash_find(&spin->si_commonwords,
- items[i]))) {
+ for (i = 1; i < itemcnt; i++) {
+ if (HASHITEM_EMPTY(hash_find(&spin->si_commonwords, (char *)items[i]))) {
p = vim_strsave(items[i]);
hash_add(&spin->si_commonwords, p);
}
@@ -2872,7 +2871,7 @@ static unsigned get_affitem(int flagtype, char_u **pp)
++*pp; // always advance, avoid getting stuck
return 0;
}
- res = getdigits_int(pp, true, 0);
+ res = getdigits_int((char **)pp, true, 0);
if (res == 0) {
res = ZERO_FLAG;
}
@@ -2932,7 +2931,7 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compfla
// Find the flag in the hashtable. If it was used before, use
// the existing ID. Otherwise add a new entry.
STRLCPY(key, prevp, p - prevp + 1);
- hi = hash_find(&aff->af_comp, key);
+ hi = hash_find(&aff->af_comp, (char *)key);
if (!HASHITEM_EMPTY(hi)) {
id = HI2CI(hi)->ci_newID;
} else {
@@ -2997,7 +2996,7 @@ static bool flag_in_afflist(int flagtype, char_u *afflist, unsigned flag)
case AFT_NUM:
for (p = afflist; *p != NUL;) {
- int digits = getdigits_int(&p, true, 0);
+ int digits = getdigits_int((char **)&p, true, 0);
assert(digits >= 0);
n = (unsigned int)digits;
if (n == 0) {
@@ -3359,7 +3358,7 @@ static int get_pfxlist(afffile_T *affile, char_u *afflist, char_u *store_afflist
// A flag is a postponed prefix flag if it appears in "af_pref"
// and its ID is not zero.
STRLCPY(key, prevp, p - prevp + 1);
- hi = hash_find(&affile->af_pref, key);
+ hi = hash_find(&affile->af_pref, (char *)key);
if (!HASHITEM_EMPTY(hi)) {
id = HI2AH(hi)->ah_newID;
if (id != 0) {
@@ -3392,7 +3391,7 @@ static void get_compflags(afffile_T *affile, char_u *afflist, char_u *store_affl
if (get_affitem(affile->af_flagtype, &p) != 0) {
// A flag is a compound flag if it appears in "af_comp".
STRLCPY(key, prevp, p - prevp + 1);
- hi = hash_find(&affile->af_comp, key);
+ hi = hash_find(&affile->af_comp, (char *)key);
if (!HASHITEM_EMPTY(hi)) {
store_afflist[cnt++] = HI2CI(hi)->ci_newID;
}
@@ -3904,6 +3903,21 @@ static wordnode_T *wordtree_alloc(spellinfo_T *spin)
return (wordnode_T *)getroom(spin, sizeof(wordnode_T), true);
}
+/// Return true if "word" contains valid word characters.
+/// Control characters and trailing '/' are invalid. Space is OK.
+static bool valid_spell_word(const char_u *word)
+{
+ if (!utf_valid_string(word, NULL)) {
+ return false;
+ }
+ for (const char_u *p = word; *p != NUL; p += utfc_ptr2len((const char *)p)) {
+ if (*p < ' ' || (p[0] == '/' && p[1] == NUL)) {
+ return false;
+ }
+ }
+ return true;
+}
+
/// Store a word in the tree(s).
/// Always store it in the case-folded tree. For a keep-case word this is
/// useful when the word can also be used with all caps (no WF_FIXCAP flag) and
@@ -3925,7 +3939,7 @@ static int store_word(spellinfo_T *spin, char_u *word, int flags, int region, co
int res = OK;
// Avoid adding illegal bytes to the word tree.
- if (!utf_valid_string(word, NULL)) {
+ if (!valid_spell_word(word)) {
return FAIL;
}
@@ -5522,7 +5536,7 @@ void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo
int i;
char_u *spf;
- if (!utf_valid_string(word, NULL)) {
+ if (!valid_spell_word(word)) {
emsg(_(e_illegal_character_in_word));
return;
}
@@ -5548,8 +5562,8 @@ void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo
}
fnamebuf = xmalloc(MAXPATHL);
- for (spf = curwin->w_s->b_p_spf, i = 1; *spf != NUL; ++i) {
- copy_option_part(&spf, fnamebuf, MAXPATHL, ",");
+ for (spf = curwin->w_s->b_p_spf, i = 1; *spf != NUL; i++) {
+ copy_option_part((char **)&spf, (char *)fnamebuf, MAXPATHL, ",");
if (i == idx) {
break;
}
@@ -5561,7 +5575,7 @@ void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo
}
// Check that the user isn't editing the .add file somewhere.
- buf = buflist_findname_exp(fnamebuf);
+ buf = buflist_findname_exp((char *)fnamebuf);
if (buf != NULL && buf->b_ml.ml_mfp == NULL) {
buf = NULL;
}
@@ -5623,7 +5637,8 @@ void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo
// file. We may need to create the "spell" directory first. We
// already checked the runtime directory is writable in
// init_spellfile().
- if (!dir_of_file_exists(fname) && (p = path_tail_with_sep(fname)) != fname) {
+ if (!dir_of_file_exists(fname)
+ && (p = (char_u *)path_tail_with_sep((char *)fname)) != fname) {
int c = *p;
// The directory doesn't exist. Try creating it and opening
@@ -5701,7 +5716,7 @@ static void init_spellfile(void)
lstart - curbuf->b_s.b_p_spl);
} else {
// Copy the path from 'runtimepath' to buf[].
- copy_option_part(&rtp, buf, MAXPATHL, ",");
+ copy_option_part((char **)&rtp, (char *)buf, MAXPATHL, ",");
}
if (os_file_is_writable((char *)buf) == 2) {
// Use the first language name from 'spelllang' and the
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 9615423765..43dbeccf01 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -3005,7 +3005,7 @@ static int check_keyword_id(char_u *const line, const int startcol, int *const e
/// Accept a keyword at other levels only if it is in the contains list.
static keyentry_T *match_keyword(char_u *keyword, hashtab_T *ht, stateitem_T *cur_si)
{
- hashitem_T *hi = hash_find(ht, keyword);
+ hashitem_T *hi = hash_find(ht, (char *)keyword);
if (!HASHITEM_EMPTY(hi)) {
for (keyentry_T *kp = HI2KE(hi); kp != NULL; kp = kp->ke_next) {
if (current_next_list != 0
@@ -5123,7 +5123,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
ci->sp_off_flags |= (1 << idx);
if (idx == SPO_LC_OFF) { // lc=99
end += 3;
- *p = getdigits_int(&end, true, 0);
+ *p = getdigits_int((char **)&end, true, 0);
// "lc=" offset automatically sets "ms=" offset
if (!(ci->sp_off_flags & (1 << SPO_MS_OFF))) {
@@ -5134,10 +5134,10 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
end += 4;
if (*end == '+') {
end++;
- *p = getdigits_int(&end, true, 0); // positive offset
+ *p = getdigits_int((char **)&end, true, 0); // positive offset
} else if (*end == '-') {
end++;
- *p = -getdigits_int(&end, true, 0); // negative offset
+ *p = -getdigits_int((char **)&end, true, 0); // negative offset
}
}
if (*end != ',') {
@@ -5382,7 +5382,7 @@ static int get_id_list(char_u **const arg, const int keylen, int16_t **const lis
regmatch.rm_ic = TRUE;
id = 0;
for (int i = highlight_num_groups(); --i >= 0;) {
- if (vim_regexec(&regmatch, highlight_group_name(i), (colnr_T)0)) {
+ if (vim_regexec(&regmatch, (char *)highlight_group_name(i), (colnr_T)0)) {
if (round == 2) {
// Got more items than expected; can happen
// when adding items that match:
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index bb884ffb3a..5b62d11bc9 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -167,7 +167,7 @@ bool do_tag(char_u *tag, int type, int count, int forceit, int verbose)
char_u **new_matches;
int use_tagstack;
int skip_msg = false;
- char_u *buf_ffname = curbuf->b_ffname; // name for priority computation
+ char_u *buf_ffname = (char_u *)curbuf->b_ffname; // name for priority computation
int use_tfu = 1;
// remember the matches for the last used tag
@@ -423,7 +423,7 @@ bool do_tag(char_u *tag, int type, int count, int forceit, int verbose)
buf_T *buf = buflist_findnr(cur_fnum);
if (buf != NULL) {
- buf_ffname = buf->b_ffname;
+ buf_ffname = (char_u *)buf->b_ffname;
}
}
@@ -2031,14 +2031,13 @@ parse_line:
cc = *tagp.tagname_end;
*tagp.tagname_end = NUL;
- match = vim_regexec(&orgpat.regmatch, tagp.tagname, (colnr_T)0);
+ match = vim_regexec(&orgpat.regmatch, (char *)tagp.tagname, (colnr_T)0);
if (match) {
matchoff = (int)(orgpat.regmatch.startp[0] - tagp.tagname);
if (orgpat.regmatch.rm_ic) {
- orgpat.regmatch.rm_ic = FALSE;
- match_no_ic = vim_regexec(&orgpat.regmatch, tagp.tagname,
- (colnr_T)0);
- orgpat.regmatch.rm_ic = TRUE;
+ orgpat.regmatch.rm_ic = false;
+ match_no_ic = vim_regexec(&orgpat.regmatch, (char *)tagp.tagname, (colnr_T)0);
+ orgpat.regmatch.rm_ic = true;
}
}
*tagp.tagname_end = (char_u)cc;
@@ -2423,7 +2422,7 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf)
* Copy next file name into buf.
*/
buf[0] = NUL;
- (void)copy_option_part(&tnp->tn_np, buf, MAXPATHL - 1, " ,");
+ (void)copy_option_part((char **)&tnp->tn_np, (char *)buf, MAXPATHL - 1, " ,");
r_ptr = vim_findfile_stopdir(buf);
// move the filename one char forward and truncate the
@@ -2436,7 +2435,7 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf)
r_ptr, 100,
FALSE, // don't free visited list
FINDFILE_FILE, // we search for a file
- tnp->tn_search_ctx, TRUE, curbuf->b_ffname);
+ tnp->tn_search_ctx, true, (char_u *)curbuf->b_ffname);
if (tnp->tn_search_ctx != NULL) {
tnp->tn_did_filefind_init = TRUE;
}
@@ -2749,7 +2748,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
// If it was a CTRL-W CTRL-] command split window now. For ":tab tag"
// open a new tab page.
if (postponed_split && (swb_flags & (SWB_USEOPEN | SWB_USETAB))) {
- buf_T *const existing_buf = buflist_findname_exp(fname);
+ buf_T *const existing_buf = buflist_findname_exp((char *)fname);
if (existing_buf != NULL) {
const win_T *wp = NULL;
@@ -3112,11 +3111,11 @@ int expand_tags(int tagnames, char_u *pat, int *num_file, char_u ***file)
if (pat[0] == '/') {
ret = find_tags(pat + 1, num_file, file,
TAG_REGEXP | extra_flag | TAG_VERBOSE | TAG_NO_TAGFUNC,
- TAG_MANY, curbuf->b_ffname);
+ TAG_MANY, (char_u *)curbuf->b_ffname);
} else {
ret = find_tags(pat, num_file, file,
TAG_REGEXP | extra_flag | TAG_VERBOSE | TAG_NO_TAGFUNC | TAG_NOIC,
- TAG_MANY, curbuf->b_ffname);
+ TAG_MANY, (char_u *)curbuf->b_ffname);
}
if (ret == OK && !tagnames) {
// Reorganize the tags for display and matching as strings of:
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index 85517a71a4..be49048aec 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -228,7 +228,7 @@ Terminal *terminal_open(buf_T *buf, TerminalOptions opts)
set_option_value("wrap", false, NULL, OPT_LOCAL);
set_option_value("list", false, NULL, OPT_LOCAL);
if (buf->b_ffname != NULL) {
- buf_set_term_title(buf, (char *)buf->b_ffname);
+ buf_set_term_title(buf, buf->b_ffname);
}
RESET_BINDING(curwin);
// Reset cursor in current window.
diff --git a/src/nvim/testdir/test_buffer.vim b/src/nvim/testdir/test_buffer.vim
index 9eb768f124..02360b4e75 100644
--- a/src/nvim/testdir/test_buffer.vim
+++ b/src/nvim/testdir/test_buffer.vim
@@ -2,6 +2,160 @@
source check.vim
+" Test for the :bunload command with an offset
+func Test_bunload_with_offset()
+ %bwipe!
+ call writefile(['B1'], 'b1')
+ call writefile(['B2'], 'b2')
+ call writefile(['B3'], 'b3')
+ call writefile(['B4'], 'b4')
+
+ " Load four buffers. Unload the second and third buffers and then
+ " execute .+3bunload to unload the last buffer.
+ edit b1
+ new b2
+ new b3
+ new b4
+
+ bunload b2
+ bunload b3
+ exe bufwinnr('b1') . 'wincmd w'
+ .+3bunload
+ call assert_equal(0, getbufinfo('b4')[0].loaded)
+ call assert_equal('b1',
+ \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
+
+ " Load four buffers. Unload the third and fourth buffers. Execute .+3bunload
+ " and check whether the second buffer is unloaded.
+ ball
+ bunload b3
+ bunload b4
+ exe bufwinnr('b1') . 'wincmd w'
+ .+3bunload
+ call assert_equal(0, getbufinfo('b2')[0].loaded)
+ call assert_equal('b1',
+ \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
+
+ " Load four buffers. Unload the second and third buffers and from the last
+ " buffer execute .-3bunload to unload the first buffer.
+ ball
+ bunload b2
+ bunload b3
+ exe bufwinnr('b4') . 'wincmd w'
+ .-3bunload
+ call assert_equal(0, getbufinfo('b1')[0].loaded)
+ call assert_equal('b4',
+ \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
+
+ " Load four buffers. Unload the first and second buffers. Execute .-3bunload
+ " from the last buffer and check whether the third buffer is unloaded.
+ ball
+ bunload b1
+ bunload b2
+ exe bufwinnr('b4') . 'wincmd w'
+ .-3bunload
+ call assert_equal(0, getbufinfo('b3')[0].loaded)
+ call assert_equal('b4',
+ \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
+
+ %bwipe!
+ call delete('b1')
+ call delete('b2')
+ call delete('b3')
+ call delete('b4')
+
+ call assert_fails('1,4bunload', 'E16:')
+ call assert_fails(',100bunload', 'E16:')
+
+ " Use a try-catch for this test. When assert_fails() is used for this
+ " test, the command fails with E515: instead of E90:
+ let caught_E90 = 0
+ try
+ $bunload
+ catch /E90:/
+ let caught_E90 = 1
+ endtry
+ call assert_equal(1, caught_E90)
+ call assert_fails('$bunload', 'E515:')
+endfunc
+
+" Test for :buffer, :bnext, :bprevious, :brewind, :blast and :bmodified
+" commands
+func Test_buflist_browse()
+ %bwipe!
+ call assert_fails('buffer 1000', 'E86:')
+
+ call writefile(['foo1', 'foo2', 'foo3', 'foo4'], 'Xfile1')
+ call writefile(['bar1', 'bar2', 'bar3', 'bar4'], 'Xfile2')
+ call writefile(['baz1', 'baz2', 'baz3', 'baz4'], 'Xfile3')
+ edit Xfile1
+ let b1 = bufnr()
+ edit Xfile2
+ let b2 = bufnr()
+ edit +/baz4 Xfile3
+ let b3 = bufnr()
+
+ call assert_fails('buffer ' .. b1 .. ' abc', 'E488:')
+ call assert_equal(b3, bufnr())
+ call assert_equal(4, line('.'))
+ exe 'buffer +/bar2 ' .. b2
+ call assert_equal(b2, bufnr())
+ call assert_equal(2, line('.'))
+ exe 'buffer +/bar1'
+ call assert_equal(b2, bufnr())
+ call assert_equal(1, line('.'))
+
+ brewind +/foo3
+ call assert_equal(b1, bufnr())
+ call assert_equal(3, line('.'))
+
+ blast +/baz2
+ call assert_equal(b3, bufnr())
+ call assert_equal(2, line('.'))
+
+ bprevious +/bar4
+ call assert_equal(b2, bufnr())
+ call assert_equal(4, line('.'))
+
+ bnext +/baz3
+ call assert_equal(b3, bufnr())
+ call assert_equal(3, line('.'))
+
+ call assert_fails('bmodified', 'E84:')
+ call setbufvar(b2, '&modified', 1)
+ exe 'bmodified +/bar3'
+ call assert_equal(b2, bufnr())
+ call assert_equal(3, line('.'))
+
+ " With no listed buffers in the list, :bnext and :bprev should fail
+ %bwipe!
+ set nobuflisted
+ call assert_fails('bnext', 'E85:')
+ call assert_fails('bprev', 'E85:')
+ set buflisted
+
+ call assert_fails('sandbox bnext', 'E48:')
+
+ call delete('Xfile1')
+ call delete('Xfile2')
+ call delete('Xfile3')
+ %bwipe!
+endfunc
+
+" Test for :bdelete
+func Test_bdelete_cmd()
+ %bwipe!
+ call assert_fails('bdelete 5', 'E516:')
+
+ " Deleting a unlisted and unloaded buffer
+ edit Xfile1
+ let bnr = bufnr()
+ set nobuflisted
+ enew
+ call assert_fails('bdelete ' .. bnr, 'E516:')
+ %bwipe!
+endfunc
+
func Test_buffer_error()
new foo1
new foo2
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 3aacda6af6..aedcad5296 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -71,6 +71,12 @@ func Test_complete_wildmenu()
cunmap <C-K>
endif
+ " Completion using a relative path
+ cd Xdir1/Xdir2
+ call feedkeys(":e ../\<Tab>\<Right>\<Down>\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"e Xtestfile3 Xtestfile4', @:)
+ cd -
+
" cleanup
%bwipe
call delete('Xdir1/Xdir2/Xtestfile4')
@@ -581,6 +587,10 @@ func Test_cmdline_paste()
" ignore error E32
endtry
call assert_equal("Xtestfile", bufname("%"))
+
+ " Use an invalid expression for <C-\>e
+ call assert_beeps('call feedkeys(":\<C-\>einvalid\<CR>", "tx")')
+
bwipe!
endfunc
@@ -818,9 +828,32 @@ func Test_cmdline_search_range()
1,\&s/b/B/
call assert_equal('B', getline(2))
+ let @/ = 'apple'
+ call assert_fails('\/print', 'E486:')
+
bwipe!
endfunc
+" Test for the tick mark (') in an excmd range
+func Test_tick_mark_in_range()
+ " If only the tick is passed as a range and no command is specified, there
+ " should not be an error
+ call feedkeys(":'\<CR>", 'xt')
+ call assert_equal("'", getreg(':'))
+ call assert_fails("',print", 'E78:')
+endfunc
+
+" Test for using a line number followed by a search pattern as range
+func Test_lnum_and_pattern_as_range()
+ new
+ call setline(1, ['foo 1', 'foo 2', 'foo 3'])
+ let @" = ''
+ 2/foo/yank
+ call assert_equal("foo 3\n", @")
+ call assert_equal(1, line('.'))
+ close!
+endfunc
+
" Tests for getcmdline(), getcmdpos() and getcmdtype()
func Check_cmdline(cmdtype)
call assert_equal('MyCmd a', getcmdline())
@@ -853,6 +886,8 @@ func Test_getcmdtype()
cnoremap <expr> <F6> Check_cmdline('=')
call feedkeys("a\<C-R>=MyCmd a\<F6>\<Esc>\<Esc>", "xt")
cunmap <F6>
+
+ call assert_equal('', getcmdline())
endfunc
func Test_getcmdwintype()
@@ -1105,6 +1140,30 @@ func Test_cmdwin_autocmd()
augroup! CmdWin
endfunc
+func Test_cmdwin_jump_to_win()
+ call assert_fails('call feedkeys("q:\<C-W>\<C-W>\<CR>", "xt")', 'E11:')
+ new
+ set modified
+ call assert_fails('call feedkeys("q/:qall\<CR>", "xt")', 'E162:')
+ close!
+ call feedkeys("q/:close\<CR>", "xt")
+ call assert_equal(1, winnr('$'))
+ call feedkeys("q/:exit\<CR>", "xt")
+ call assert_equal(1, winnr('$'))
+
+ " opening command window twice should fail
+ call assert_beeps('call feedkeys("q:q:\<CR>\<CR>", "xt")')
+ call assert_equal(1, winnr('$'))
+endfunc
+
+" Test for backtick expression in the command line
+func Test_cmd_backtick()
+ %argd
+ argadd `=['a', 'b', 'c']`
+ call assert_equal(['a', 'b', 'c'], argv())
+ %argd
+endfunc
+
func Test_cmdlineclear_tabenter()
" See test/functional/legacy/cmdline_spec.lua
CheckScreendump
@@ -1152,6 +1211,21 @@ func Test_cmd_bang_E135()
%bwipe!
endfunc
+" Test for using ~ for home directory in cmdline completion matches
+func Test_cmdline_expand_home()
+ call mkdir('Xdir')
+ call writefile([], 'Xdir/Xfile1')
+ call writefile([], 'Xdir/Xfile2')
+ cd Xdir
+ let save_HOME = $HOME
+ let $HOME = getcwd()
+ call feedkeys(":e ~/\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"e ~/Xfile1 ~/Xfile2', @:)
+ let $HOME = save_HOME
+ cd ..
+ call delete('Xdir', 'rf')
+endfunc
+
" test that ";" works to find a match at the start of the first line
func Test_zero_line_search()
new
diff --git a/src/nvim/testdir/test_exists.vim b/src/nvim/testdir/test_exists.vim
index fd34be83b0..471c77853d 100644
--- a/src/nvim/testdir/test_exists.vim
+++ b/src/nvim/testdir/test_exists.vim
@@ -94,8 +94,12 @@ func Test_exists()
call assert_equal(0, exists(':edit/a'))
" Valid internal command (partial match)
call assert_equal(1, exists(':q'))
+ " Valid internal command with a digit
+ call assert_equal(2, exists(':2match'))
" Non-existing internal command
call assert_equal(0, exists(':invalidcmd'))
+ " Internal command with a count
+ call assert_equal(0, exists(':3buffer'))
" User defined command (full match)
command! MyCmd :echo 'My command'
diff --git a/src/nvim/testdir/test_filechanged.vim b/src/nvim/testdir/test_filechanged.vim
index 8e1cb2c3ee..1b0f49ca51 100644
--- a/src/nvim/testdir/test_filechanged.vim
+++ b/src/nvim/testdir/test_filechanged.vim
@@ -245,3 +245,19 @@ func Test_file_changed_dialog()
bwipe!
call delete('Xchanged_d')
endfunc
+
+" Test for editing a new buffer from a FileChangedShell autocmd
+func Test_FileChangedShell_newbuf()
+ call writefile(['one', 'two'], 'Xfile')
+ new Xfile
+ augroup testnewbuf
+ autocmd FileChangedShell * enew
+ augroup END
+ sleep 10m " make the test less flaky in Nvim
+ call writefile(['red'], 'Xfile')
+ call assert_fails('checktime', 'E811:')
+ au! testnewbuf
+ call delete('Xfile')
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_history.vim b/src/nvim/testdir/test_history.vim
index 2f0dc2dae1..3b3dc17f44 100644
--- a/src/nvim/testdir/test_history.vim
+++ b/src/nvim/testdir/test_history.vim
@@ -86,6 +86,8 @@ function Test_History()
call assert_fails('call histget([])', 'E730:')
call assert_equal(-1, histnr('abc'))
call assert_fails('call histnr([])', 'E730:')
+ call assert_fails('history xyz', 'E488:')
+ call assert_fails('history ,abc', 'E488:')
endfunction
function Test_Search_history_window()
@@ -109,3 +111,52 @@ function Test_history_completion()
call feedkeys(":history \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"history / : = > ? @ all cmd debug expr input search', @:)
endfunc
+
+" Test for increasing the 'history' option value
+func Test_history_size()
+ let save_histsz = &history
+ call histdel(':')
+ set history=5
+ for i in range(1, 5)
+ call histadd(':', 'cmd' .. i)
+ endfor
+ call assert_equal(5, histnr(':'))
+ call assert_equal('cmd5', histget(':', -1))
+
+ set history=10
+ for i in range(6, 10)
+ call histadd(':', 'cmd' .. i)
+ endfor
+ call assert_equal(10, histnr(':'))
+ call assert_equal('cmd1', histget(':', 1))
+ call assert_equal('cmd10', histget(':', -1))
+
+ set history=5
+ call histadd(':', 'abc')
+ call assert_equal('', histget(':', 6))
+ call assert_equal('', histget(':', 12))
+ call assert_equal('cmd7', histget(':', 7))
+ call assert_equal('abc', histget(':', -1))
+
+ let &history=save_histsz
+endfunc
+
+" Test for recalling old search patterns in /
+func Test_history_search()
+ call histdel('/')
+ let g:pat = []
+ func SavePat()
+ call add(g:pat, getcmdline())
+ return ''
+ endfunc
+ cnoremap <F2> <C-\>eSavePat()<CR>
+ call histadd('/', 'pat1')
+ call histadd('/', 'pat2')
+ let @/ = ''
+ call feedkeys("/\<Up>\<F2>\<Up>\<F2>\<Down>\<Down>\<F2>\<Esc>", 'xt')
+ call assert_equal(['pat2', 'pat1', ''], g:pat)
+ cunmap <F2>
+ delfunc SavePat
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim
index 494f09e0e5..e2b7554797 100644
--- a/src/nvim/testdir/test_mapping.vim
+++ b/src/nvim/testdir/test_mapping.vim
@@ -31,6 +31,7 @@ func Test_abclear()
abclear
call assert_equal("\n\nNo abbreviation found", execute('abbrev'))
+ call assert_fails('%abclear', 'E481:')
endfunc
func Test_abclear_buffer()
diff --git a/src/nvim/testdir/test_marks.vim b/src/nvim/testdir/test_marks.vim
index 00ee8f6d6a..608f9883c2 100644
--- a/src/nvim/testdir/test_marks.vim
+++ b/src/nvim/testdir/test_marks.vim
@@ -232,6 +232,15 @@ func Test_lockmarks_with_put()
bwipe!
endfunc
+" Test for :k command to set a mark
+func Test_marks_k_cmd()
+ new
+ call setline(1, ['foo', 'bar', 'baz', 'qux'])
+ 1,3kr
+ call assert_equal([0, 3, 1, 0], getpos("'r"))
+ close!
+endfunc
+
" Test for the getmarklist() function
func Test_getmarklist()
new
diff --git a/src/nvim/testdir/test_menu.vim b/src/nvim/testdir/test_menu.vim
index 61c3a16125..a2ef6e5c67 100644
--- a/src/nvim/testdir/test_menu.vim
+++ b/src/nvim/testdir/test_menu.vim
@@ -89,3 +89,39 @@ func Test_menu_commands()
unlet g:did_menu
endfun
+
+" Test for menu item completion in command line
+func Test_menu_expand()
+ " Create the menu itmes for test
+ for i in range(1, 4)
+ let m = 'menu Xmenu.A' .. i .. '.A' .. i
+ for j in range(1, 4)
+ exe m .. 'B' .. j .. ' :echo "A' .. i .. 'B' .. j .. '"' .. "<CR>"
+ endfor
+ endfor
+ set wildmenu
+
+ " Test for <CR> selecting a submenu
+ call feedkeys(":emenu Xmenu.A\<Tab>\<CR>\<Right>x\<BS>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"emenu Xmenu.A1.A1B2', @:)
+
+ " Test for <Down> selecting a submenu
+ call feedkeys(":emenu Xmenu.A\<Tab>\<Right>\<Right>\<Down>" ..
+ \ "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"emenu Xmenu.A3.A3B1 A3B2 A3B3 A3B4', @:)
+
+ " Test for <Up> to go up a submenu
+ call feedkeys(":emenu Xmenu.A\<Tab>\<Down>\<Up>\<Right>\<Right>" ..
+ \ "\<Left>\<Down>\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"emenu Xmenu.A2.A2B1 A2B2 A2B3 A2B4', @:)
+
+ " Test for <Up> to go up a menu
+ call feedkeys(":emenu Xmenu.A\<Tab>\<Down>\<Up>\<Up>\<Up>" ..
+ \ "\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"emenu Buffers. Xmenu.', @:)
+
+ set wildmenu&
+ unmenu Xmenu
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim
index d1cb89bbd4..b44d65c2a4 100644
--- a/src/nvim/testdir/test_normal.vim
+++ b/src/nvim/testdir/test_normal.vim
@@ -2748,6 +2748,23 @@ func Test_normal_gk()
set cpoptions& number& numberwidth&
endfunc
+" Test for cursor movement with '-' in 'cpoptions'
+func Test_normal_cpo_minus()
+ throw 'Skipped: Nvim does not support cpoptions flag "-"'
+ new
+ call setline(1, ['foo', 'bar', 'baz'])
+ let save_cpo = &cpo
+ set cpo+=-
+ call assert_beeps('normal 10j')
+ call assert_equal(1, line('.'))
+ normal G
+ call assert_beeps('normal 10k')
+ call assert_equal(3, line('.'))
+ call assert_fails(10, 'E16:')
+ let &cpo = save_cpo
+ close!
+endfunc
+
" Some commands like yy, cc, dd, >>, << and !! accept a count after
" typing the first letter of the command.
func Test_normal_count_after_operator()
diff --git a/src/nvim/testdir/test_plus_arg_edit.vim b/src/nvim/testdir/test_plus_arg_edit.vim
index e31680e7b6..64533e71cf 100644
--- a/src/nvim/testdir/test_plus_arg_edit.vim
+++ b/src/nvim/testdir/test_plus_arg_edit.vim
@@ -32,3 +32,16 @@ func Test_edit_bad()
bw!
call delete('Xfile')
endfunc
+
+" Test for ++bin and ++nobin arguments
+func Test_binary_arg()
+ new
+ edit ++bin Xfile1
+ call assert_equal(1, &binary)
+ edit ++nobin Xfile2
+ call assert_equal(0, &binary)
+ call assert_fails('edit ++binabc Xfile3', 'E474:')
+ close!
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index 5826666cbb..4f83c45770 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -553,6 +553,15 @@ func Xtest_browse(cchar)
10Xcc
call assert_equal(11, line('.'))
call assert_equal('Xqftestfile2', bufname('%'))
+ Xopen
+ call cursor(2, 1)
+ if a:cchar == 'c'
+ .cc
+ else
+ .ll
+ endif
+ call assert_equal(6, line('.'))
+ call assert_equal('Xqftestfile1', bufname('%'))
" Jumping to an error from the error window (when only the error window is
" present)
diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim
index 215d4387d6..d0895a48b4 100644
--- a/src/nvim/testdir/test_spell.vim
+++ b/src/nvim/testdir/test_spell.vim
@@ -699,6 +699,21 @@ func Test_spellsuggest_too_deep()
bwipe!
endfunc
+func Test_spell_good_word_invalid()
+ " This was adding a word with a 0x02 byte, which causes havoc.
+ enew
+ norm o0
+ sil! norm rzzWs00/
+ 2
+ sil! norm VzGprzzW
+ sil! norm z=
+
+ bwipe!
+ " clear the internal word list
+ " set enc=latin1
+ set enc=utf-8
+endfunc
+
func LoadAffAndDic(aff_contents, dic_contents)
throw 'skipped: Nvim does not support enc=latin1'
set enc=latin1
diff --git a/src/nvim/testdir/test_spell_utf8.vim b/src/nvim/testdir/test_spell_utf8.vim
index 3c07e0782b..3d240a8f2c 100644
--- a/src/nvim/testdir/test_spell_utf8.vim
+++ b/src/nvim/testdir/test_spell_utf8.vim
@@ -780,7 +780,12 @@ func Test_no_crash_with_weird_text()
€
END
call setline(1, lines)
- exe "%norm \<C-v>ez=>\<C-v>wzG"
+ try
+ exe "%norm \<C-v>ez=>\<C-v>wzG"
+ catch /E1280:/
+ let caught = 'yes'
+ endtry
+ call assert_equal('yes', caught)
bwipe!
endfunc
diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim
index 41c29c5bb0..492750fa66 100644
--- a/src/nvim/testdir/test_visual.vim
+++ b/src/nvim/testdir/test_visual.vim
@@ -1431,5 +1431,17 @@ func Test_visual_paste_clipboard()
bwipe!
endfunc
+func Test_visual_area_adjusted_when_hiding()
+ " The Visual area ended after the end of the line after :hide
+ call setline(1, 'xxx')
+ vsplit Xfile
+ call setline(1, 'xxxxxxxx')
+ norm! $o
+ hid
+ norm! zW
+ bwipe!
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index 078cb6a210..135c46203f 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -693,8 +693,7 @@ char *u_get_undo_file_name(const char *const buf_ffname, const bool reading)
// When not reading use the first directory that exists or ".".
dirp = (char *)p_udir;
while (*dirp != NUL) {
- size_t dir_len = copy_option_part((char_u **)&dirp, (char_u *)dir_name,
- MAXPATHL, ",");
+ size_t dir_len = copy_option_part(&dirp, dir_name, MAXPATHL, ",");
if (dir_len == 1 && dir_name[0] == '.') {
// Use same directory as the ffname,
// "dir/name" -> "dir/.name.un~"
@@ -1186,7 +1185,7 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf,
bufinfo_T bi;
if (name == NULL) {
- file_name = u_get_undo_file_name((char *)buf->b_ffname, false);
+ file_name = u_get_undo_file_name(buf->b_ffname, false);
if (file_name == NULL) {
if (p_verbose > 0) {
verbose_enter();
@@ -1291,7 +1290,7 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf,
FileInfo file_info_old;
FileInfo file_info_new;
if (buf->b_ffname != NULL
- && os_fileinfo((char *)buf->b_ffname, &file_info_old)
+ && os_fileinfo(buf->b_ffname, &file_info_old)
&& os_fileinfo(file_name, &file_info_new)
&& file_info_old.stat.st_gid != file_info_new.stat.st_gid
&& os_fchown(fd, (uv_uid_t)-1, (uv_gid_t)file_info_old.stat.st_gid)) {
@@ -1370,10 +1369,8 @@ write_error:
#ifdef HAVE_ACL
if (buf->b_ffname != NULL) {
- vim_acl_T acl;
-
// For systems that support ACL: get the ACL from the original file.
- acl = mch_get_acl(buf->b_ffname);
+ vim_acl_T acl = mch_get_acl((char_u *)buf->b_ffname);
mch_set_acl((char_u *)file_name, acl);
mch_free_acl(acl);
}
@@ -1398,7 +1395,7 @@ void u_read_undo(char *name, const char_u *hash, const char_u *orig_name FUNC_AT
char *file_name;
if (name == NULL) {
- file_name = u_get_undo_file_name((char *)curbuf->b_ffname, true);
+ file_name = u_get_undo_file_name(curbuf->b_ffname, true);
if (file_name == NULL) {
return;
}
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 9ac027d80f..ee0d19b1fe 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -1554,9 +1554,9 @@ static void win_init(win_T *newp, win_T *oldp, int flags)
copy_loclist_stack(oldp, newp);
}
newp->w_localdir = (oldp->w_localdir == NULL)
- ? NULL : vim_strsave(oldp->w_localdir);
+ ? NULL : xstrdup(oldp->w_localdir);
newp->w_prevdir = (oldp->w_prevdir == NULL)
- ? NULL : vim_strsave(oldp->w_prevdir);
+ ? NULL : xstrdup(oldp->w_prevdir);
// copy tagstack and folds
for (i = 0; i < oldp->w_tagstacklen; i++) {
@@ -2741,6 +2741,8 @@ int win_close(win_T *win, bool free_buf, bool force)
* to be the last one left, return now.
*/
if (wp->w_buffer != curbuf) {
+ reset_VIsual_and_resel(); // stop Visual mode
+
other_buffer = true;
win->w_closing = true;
apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, false, curbuf);
@@ -4074,7 +4076,7 @@ int win_new_tabpage(int after, char_u *filename)
}
newtp->tp_localdir = old_curtab->tp_localdir
- ? vim_strsave(old_curtab->tp_localdir) : NULL;
+ ? xstrdup(old_curtab->tp_localdir) : NULL;
curtab = newtp;
@@ -4897,8 +4899,7 @@ static void win_enter_ext(win_T *const wp, const int flags)
void fix_current_dir(void)
{
// New directory is either the local directory of the window, tab or NULL.
- char *new_dir = (char *)(curwin->w_localdir
- ? curwin->w_localdir : curtab->tp_localdir);
+ char *new_dir = curwin->w_localdir ? curwin->w_localdir : curtab->tp_localdir;
char cwd[MAXPATHL];
if (os_dirname((char_u *)cwd, MAXPATHL) != OK) {
cwd[0] = NUL;
@@ -6482,7 +6483,7 @@ char_u *grab_file_name(long count, linenr_T *file_lnum)
*file_lnum = getdigits_long(&p, false, 0);
}
- return find_file_name_in_path(ptr, len, options, count, curbuf->b_ffname);
+ return find_file_name_in_path(ptr, len, options, count, (char_u *)curbuf->b_ffname);
}
return file_name_at_cursor(options | FNAME_HYP, count, file_lnum);
}
@@ -6503,7 +6504,7 @@ char_u *grab_file_name(long count, linenr_T *file_lnum)
char_u *file_name_at_cursor(int options, long count, linenr_T *file_lnum)
{
return file_name_in_line(get_cursor_line_ptr(),
- curwin->w_cursor.col, options, count, curbuf->b_ffname,
+ curwin->w_cursor.col, options, count, (char_u *)curbuf->b_ffname,
file_lnum);
}
diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua
index a9ec2b6541..7eb7ee73f9 100644
--- a/test/functional/api/command_spec.lua
+++ b/test/functional/api/command_spec.lua
@@ -136,6 +136,7 @@ describe('nvim_create_user_command', function()
silent = false,
split = "",
tab = 0,
+ unsilent = false,
verbose = -1,
vertical = false,
},
@@ -170,6 +171,7 @@ describe('nvim_create_user_command', function()
silent = false,
split = "",
tab = 0,
+ unsilent = false,
verbose = -1,
vertical = false,
},
@@ -204,6 +206,7 @@ describe('nvim_create_user_command', function()
silent = false,
split = "",
tab = 0,
+ unsilent = false,
verbose = -1,
vertical = false,
},
@@ -221,10 +224,10 @@ describe('nvim_create_user_command', function()
bang = true,
line1 = 10,
line2 = 10,
- mods = "botright",
+ mods = "confirm unsilent botright",
smods = {
browse = false,
- confirm = false,
+ confirm = true,
emsg_silent = false,
hide = false,
keepalt = false,
@@ -238,6 +241,7 @@ describe('nvim_create_user_command', function()
silent = false,
split = "botright",
tab = 0,
+ unsilent = true,
verbose = -1,
vertical = false,
},
@@ -245,7 +249,7 @@ describe('nvim_create_user_command', function()
count = 10,
reg = "",
}, exec_lua [=[
- vim.api.nvim_command('botright 10CommandWithLuaCallback! h\tey ')
+ vim.api.nvim_command('unsilent botright confirm 10CommandWithLuaCallback! h\tey ')
return result
]=])
@@ -272,6 +276,7 @@ describe('nvim_create_user_command', function()
silent = false,
split = "",
tab = 0,
+ unsilent = false,
verbose = -1,
vertical = false,
},
@@ -306,6 +311,7 @@ describe('nvim_create_user_command', function()
silent = false,
split = "",
tab = 0,
+ unsilent = false,
verbose = -1,
vertical = false,
},
@@ -352,6 +358,7 @@ describe('nvim_create_user_command', function()
silent = false,
split = "",
tab = 0,
+ unsilent = false,
verbose = -1,
vertical = false,
},
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 002bcd92a4..989ed27e16 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -3181,10 +3181,11 @@ describe('API', function()
noswapfile = false,
sandbox = false,
silent = false,
- vertical = false,
split = "",
tab = 0,
- verbose = -1
+ unsilent = false,
+ verbose = -1,
+ vertical = false,
}
}, meths.parse_cmd('echo foo', {}))
end)
@@ -3221,10 +3222,11 @@ describe('API', function()
noswapfile = false,
sandbox = false,
silent = false,
- vertical = false,
split = "",
tab = 0,
- verbose = -1
+ unsilent = false,
+ verbose = -1,
+ vertical = false,
}
}, meths.parse_cmd('4,6s/math.random/math.max/', {}))
end)
@@ -3261,10 +3263,11 @@ describe('API', function()
noswapfile = false,
sandbox = false,
silent = false,
- vertical = false,
split = "",
tab = 0,
- verbose = -1
+ unsilent = false,
+ verbose = -1,
+ vertical = false,
}
}, meths.parse_cmd('buffer 1', {}))
end)
@@ -3301,10 +3304,11 @@ describe('API', function()
noswapfile = false,
sandbox = false,
silent = false,
- vertical = false,
split = "",
tab = 0,
- verbose = -1
+ unsilent = false,
+ verbose = -1,
+ vertical = false,
}
}, meths.parse_cmd('put +', {}))
end)
@@ -3341,10 +3345,11 @@ describe('API', function()
noswapfile = false,
sandbox = false,
silent = false,
- vertical = false,
split = "",
tab = 0,
- verbose = -1
+ unsilent = false,
+ verbose = -1,
+ vertical = false,
}
}, meths.parse_cmd('1,3delete * 5', {}))
end)
@@ -3381,10 +3386,11 @@ describe('API', function()
noswapfile = false,
sandbox = false,
silent = false,
- vertical = false,
split = "",
tab = 0,
- verbose = -1
+ unsilent = false,
+ verbose = -1,
+ vertical = false,
},
}, meths.parse_cmd('w!', {}))
end)
@@ -3421,10 +3427,11 @@ describe('API', function()
noswapfile = false,
sandbox = false,
silent = true,
- vertical = false,
split = "topleft",
tab = 2,
- verbose = 15
+ unsilent = false,
+ verbose = 15,
+ vertical = false,
},
}, meths.parse_cmd('15verbose silent! aboveleft topleft tab filter /foo/ split foo.txt', {}))
eq({
@@ -3443,7 +3450,7 @@ describe('API', function()
nextcmd = '',
mods = {
browse = false,
- confirm = false,
+ confirm = true,
emsg_silent = false,
filter = {
pattern = "foo",
@@ -3459,12 +3466,13 @@ describe('API', function()
noswapfile = false,
sandbox = false,
silent = false,
- vertical = false,
- split = "",
+ split = "botright",
tab = 0,
- verbose = -1
+ unsilent = true,
+ verbose = 0,
+ vertical = false,
},
- }, meths.parse_cmd('filter! /foo/ split foo.txt', {}))
+ }, meths.parse_cmd('0verbose unsilent botright confirm filter! /foo/ split foo.txt', {}))
end)
it('works with user commands', function()
command('command -bang -nargs=+ -range -addr=lines MyCommand echo foo')
@@ -3500,10 +3508,11 @@ describe('API', function()
noswapfile = false,
sandbox = false,
silent = false,
- vertical = false,
split = "",
tab = 0,
- verbose = -1
+ unsilent = false,
+ verbose = -1,
+ vertical = false,
}
}, meths.parse_cmd('4,6MyCommand! test it', {}))
end)
@@ -3540,10 +3549,11 @@ describe('API', function()
noswapfile = false,
sandbox = false,
silent = false,
- vertical = false,
split = "",
tab = 0,
- verbose = -1
+ unsilent = false,
+ verbose = -1,
+ vertical = false,
}
}, meths.parse_cmd('argadd a.txt | argadd b.txt', {}))
end)
@@ -3581,10 +3591,11 @@ describe('API', function()
noswapfile = false,
sandbox = false,
silent = false,
- vertical = false,
split = "",
tab = 0,
- verbose = -1
+ unsilent = false,
+ verbose = -1,
+ vertical = false,
}
}, meths.parse_cmd('MyCommand test it', {}))
end)