From d4634a26cdcdbd0f22ec608bb4954cd7eb8db528 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 3 Jan 2024 10:17:24 -0500 Subject: [PATCH 001/143] runtime(vim): Add support for `syntax foldlevel` command (#6182) Signed-off-by: Brad King Signed-off-by: Doug Kearns Signed-off-by: Christian Brabandt --- runtime/syntax/vim.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index ca54162dc5..08414a62dd 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -557,6 +557,13 @@ syn match vimGroupAdd contained "add=" nextgroup=vimGroupList syn match vimGroupRem contained "remove=" nextgroup=vimGroupList syn cluster vimFuncBodyList add=vimSynType,vimGroupAdd,vimGroupRem +" Syntax: foldlevel {{{2 +syn keyword vimSynType contained foldlevel skipwhite nextgroup=vimSynFoldMethod,vimSynFoldMethodError +if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimsynfoldmethoderror") + syn match vimSynFoldMethodError contained "\i\+" +endif +syn keyword vimSynFoldMethod contained start minimum + " Syntax: iskeyword {{{2 syn keyword vimSynType contained iskeyword skipwhite nextgroup=vimIskList syn match vimIskList contained '\S\+' contains=vimIskSep @@ -901,6 +908,7 @@ if !exists("skip_vim_syntax_inits") hi def link vimMapModErr vimError hi def link vimSubstFlagErr vimError hi def link vimSynCaseError vimError + hi def link vimSynFoldMethodError vimError hi def link vimBufnrWarn vimWarn endif @@ -1038,6 +1046,8 @@ if !exists("skip_vim_syntax_inits") hi def link vimSyncNone Type hi def link vimSynContains vimSynOption hi def link vimSynError Error + hi def link vimSynFoldMethodError Error + hi def link vimSynFoldMethod Type hi def link vimSynKeyContainedin vimSynContains hi def link vimSynKeyOpt vimSynOption hi def link vimSynMtchGrp vimSynOption From 80beeef0c6a4c44b190631725bce3dcc5635e3ee Mon Sep 17 00:00:00 2001 From: dezza <402927+dezza@users.noreply.github.com> Date: Wed, 3 Jan 2024 16:20:22 +0100 Subject: [PATCH 002/143] runtime(vim): Add support for syntax (#10686) Adding `` to list of angle-bracket notation syntax, just like `` `` is already highlighted. ```vim nnoremap o Oldfiles() ``` `` is not. Signed-off-by: dezza <402927+dezza@users.noreply.github.com> Signed-off-by: Doug Kearns Signed-off-by: Christian Brabandt --- runtime/syntax/vim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 08414a62dd..d0f66d1ae5 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -487,7 +487,7 @@ syn match vimMenuBang "!" contained skipwhite nextgroup=@vimMenuList " Angle-Bracket Notation: (tnx to Michael Geddes) {{{2 " ====================== syn case ignore -syn match vimNotation "\%#=1\(\\\|\)\=<\([scamd]-\)\{0,4}x\=\(f\d\{1,2}\|[^ \t:]\|cmd\|cr\|lf\|linefeed\|retu\%[rn]\|k\=del\%[ete]\|bs\|backspace\|tab\|esc\|right\|left\|help\|undo\|insert\|ins\|mouse\|k\=home\|k\=end\|kplus\|kminus\|kdivide\|kmultiply\|kenter\|kpoint\|space\|k\=\(page\)\=\(\|down\|up\|k\d\>\)\)>" contains=vimBracket +syn match vimNotation "\%#=1\(\\\|\)\=<\([scamd]-\)\{0,4}x\=\(f\d\{1,2}\|[^ \t:]\|cmd\|scriptcmd\|cr\|lf\|linefeed\|retu\%[rn]\|k\=del\%[ete]\|bs\|backspace\|tab\|esc\|right\|left\|help\|undo\|insert\|ins\|mouse\|k\=home\|k\=end\|kplus\|kminus\|kdivide\|kmultiply\|kenter\|kpoint\|space\|k\=\(page\)\=\(\|down\|up\|k\d\>\)\)>" contains=vimBracket syn match vimNotation "\%#=1\(\\\|\)\=<\([scam2-4]-\)\{0,4}\(right\|left\|middle\)\(mouse\)\=\(drag\|release\)\=>" contains=vimBracket syn match vimNotation "\%#=1\(\\\|\)\=<\(bslash\|plug\|sid\|space\|bar\|nop\|nul\|lt\)>" contains=vimBracket syn match vimNotation '\(\\\|\)\=[0-9a-z"%#:.\-=]'he=e-1 contains=vimBracket From b1392bee701d887b66b596c9af26bfcb6f0614b8 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Wed, 3 Jan 2024 17:59:38 +0100 Subject: [PATCH 003/143] runtime(doc): document that the diff filetype uses Diff hl groups related: #13776 Signed-off-by: Christian Brabandt --- runtime/doc/syntax.txt | 12 ++++++++++-- runtime/doc/tags | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 040780b355..bc833b11fc 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 9.1. Last change: 2023 Dec 27 +*syntax.txt* For Vim version 9.1. Last change: 2024 Jan 03 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1261,7 +1261,7 @@ To highlight KDE-reserved features, set > g:desktop_enable_kde follows g:desktop_enable_nonstd if not supplied -DIFF *diff.vim* +DIFF *diff.vim* *ft-diff-syntax* The diff highlighting normally finds translated headers. This can be slow if there are very long lines in the file. To disable translations: > @@ -1270,7 +1270,15 @@ there are very long lines in the file. To disable translations: > Also see |diff-slow|. +Since the Vim 9.1 release |version-9.1| the diff filetype links the diffAdded, +diffRemoved and diffChanged highlighting groups to |hl-DiffAdd|, +|hl-DiffDelete| and |hl-DiffChange| by default. If you do not want this, you +can change it to the previous groups like this in your |.vimrc| > + hi link diffRemoved Special + hi link diffChanged PreProc + hi link diffAdded Identifier +< DIRCOLORS *dircolors.vim* *ft-dircolors-syntax* The dircolors utility highlighting definition has one option. It exists to diff --git a/runtime/doc/tags b/runtime/doc/tags index 215e189847..e8ac2bc191 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -7207,6 +7207,7 @@ ft-cynlib-syntax syntax.txt /*ft-cynlib-syntax* ft-dart-syntax syntax.txt /*ft-dart-syntax* ft-dash-syntax syntax.txt /*ft-dash-syntax* ft-desktop-syntax syntax.txt /*ft-desktop-syntax* +ft-diff-syntax syntax.txt /*ft-diff-syntax* ft-dircolors-syntax syntax.txt /*ft-dircolors-syntax* ft-docbk-syntax syntax.txt /*ft-docbk-syntax* ft-docbksgml-syntax syntax.txt /*ft-docbksgml-syntax* From b5352931b354eb67eb7d223cc09c98dcf1b547b6 Mon Sep 17 00:00:00 2001 From: Hugo van de Vliert Date: Wed, 3 Jan 2024 18:03:29 +0100 Subject: [PATCH 004/143] runtime(vim): add jumpoptions to syntax file (#13808) * Add jumpoptions and jop to vim syntax file * Clean up some whitespace Signed-off-by: Hugo van de Vliert Signed-off-by: Christian Brabandt --- runtime/syntax/vim.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index d0f66d1ae5..d697538db6 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -40,8 +40,8 @@ syn keyword vimOption contained ai anti asd awa balloondelay bevalterm bkc briop syn keyword vimOption contained akm antialias autochdir background ballooneval bex bl brk buftype cdpath cindent cinwords cocu complete copyindent cryptmethod csl cuc debug dictionary display ef endoffile errorfile fcl fdn ffs fillchars fo foldmarker formatoptions gdefault gp guifontwide helpheight history hlsearch imaf ims includeexpr infercase iskeyword keyprotocol langnoremap linespace lnr lw mat maxmemtot mkspellmem mod mousef mouseshape mzschemedll odev pa path pheader previewheight printmbcharset pvp pyxversion redrawtime ri rs sb scroll sections shcf shelltype showbreak si sm sn spellfile splitkeep ssl stmp swapsync synmaxcol tagcase tbi termbidi textauto thesaurusfunc tl ts ttybuiltin tws undodir varsofttabstop vfile visualbell wc wh wildignore wincolor winptydll wmw writebackup syn keyword vimOption contained al ar autoindent backspace balloonevalterm bexpr bo browsedir casemap cedit cink clipboard cole completefunc cot cscopepathcomp cspc cul deco diff dy efm endofline errorformat fcs fdo fic fixendofline foldclose foldmethod formatprg gfm grepformat guiheadroom helplang hk ic imak imsearch incsearch insertmode isp keywordprg langremap lisp loadplugins lz matchpairs mco ml modeline mousefocus mouset mzschemegcdll oft packpath pdev pi previewpopup printmbfont pvw qe regexpengine rightleft rtp sbo scrollbind secure shell shellxescape showcmd sidescroll smartcase so spelllang splitright ssop sts swb syntax tagfunc tbidi termencoding textmode tildeop tm tsl ttyfast twsl undofile vartabstop vi vop wcm whichwrap wildignorecase window winwidth wop writedelay syn keyword vimOption contained aleph arab autoread backup balloonexpr bg bomb bs cb cf cinkeys cm colorcolumn completeopt cp cscopeprg csprg culopt def diffexpr ea ei eof esckeys fdc fdt fileencoding fixeol foldcolumn foldminlines fp gfn grepprg guiligatures hf hkmap icon imc imsf inde is isprint km laststatus lispoptions lop ma matchtime mef mle modelineexpr mousehide mousetime nf ofu para penc pm previewwindow printoptions pw qftf relativenumber rightleftcmd ru sbr scrollfocus sel shellcmdflag shellxquote showcmdloc sidescrolloff smartindent softtabstop spelloptions spo st su swf ta taglength tbis termguicolors textwidth timeout to tsr ttym twt undolevels vb viewdir vsts wcr wi wildmenu winfixheight wiv wrap ws -syn keyword vimOption contained allowrevins arabic autoshelldir backupcopy bdir bh breakat bsdir cc cfu cino cmdheight columns completepopup cpo cscopequickfix csqf cursorbind define diffopt ead ek eol et fde fen fileencodings fk foldenable foldnestmax fs gfs gtl guioptions hh hkmapp iconstring imcmdline imst indentexpr isf joinspaces kmp lazyredraw lispwords lpl macatsui maxcombine menc mls modelines mousem mp nrformats omnifunc paragraphs perldll pmbcs printdevice prompt pythondll quickfixtextfunc remap rl rubydll sc scrolljump selection shellpipe shiftround showfulltag signcolumn smarttab sol spellsuggest spr sta sua switchbuf tabline tagrelative tbs termwinkey tf timeoutlen toolbar tsrfu ttymouse tx undoreload vbs viewoptions vts wd wic wildmode winfixwidth wiw wrapmargin ww -syn keyword vimOption contained altkeymap arabicshape autowrite backupdir bdlay bin breakindent bsk ccv ch cinoptions cmdwinheight com completeslash cpoptions cscoperelative csre cursorcolumn delcombine digraph eadirection emo ep eventignore fdi fenc fileformat fkmap foldexpr foldopen fsync gfw gtt guipty hi hkp ignorecase imd imstatusfunc indentkeys isfname js kp lbr list lrm magic maxfuncdepth menuitems mm modifiable mousemev mps nu opendevice paste pex pmbfn printencoding pt pythonhome quoteescape renderoptions rlc ruf scb scrolloff selectmode shellquote shiftwidth showmatch siso smc sp spf sps stal suffixes sws tabpagemax tags tc termwinscroll tfu title toolbariconsize ttimeout ttyscroll uc updatecount vdir vif wa weirdinvert wig wildoptions winheight wm wrapscan xtermcodes +syn keyword vimOption contained allowrevins arabic autoshelldir backupcopy bdir bh breakat bsdir cc cfu cino cmdheight columns completepopup cpo cscopequickfix csqf cursorbind define diffopt ead ek eol et fde fen fileencodings fk foldenable foldnestmax fs gfs gtl guioptions hh hkmapp iconstring imcmdline imst indentexpr isf joinspaces jumpoptions kmp lazyredraw lispwords lpl macatsui maxcombine menc mls modelines mousem mp nrformats omnifunc paragraphs perldll pmbcs printdevice prompt pythondll quickfixtextfunc remap rl rubydll sc scrolljump selection shellpipe shiftround showfulltag signcolumn smarttab sol spellsuggest spr sta sua switchbuf tabline tagrelative tbs termwinkey tf timeoutlen toolbar tsrfu ttymouse tx undoreload vbs viewoptions vts wd wic wildmode winfixwidth wiw wrapmargin ww +syn keyword vimOption contained altkeymap arabicshape autowrite backupdir bdlay bin breakindent bsk ccv ch cinoptions cmdwinheight com completeslash cpoptions cscoperelative csre cursorcolumn delcombine digraph eadirection emo ep eventignore fdi fenc fileformat fkmap foldexpr foldopen fsync gfw gtt guipty hi hkp ignorecase imd imstatusfunc indentkeys isfname js jop kp lbr list lrm magic maxfuncdepth menuitems mm modifiable mousemev mps nu opendevice paste pex pmbfn printencoding pt pythonhome quoteescape renderoptions rlc ruf scb scrolloff selectmode shellquote shiftwidth showmatch siso smc sp spf sps stal suffixes sws tabpagemax tags tc termwinscroll tfu title toolbariconsize ttimeout ttyscroll uc updatecount vdir vif wa weirdinvert wig wildoptions winheight wm wrapscan xtermcodes syn keyword vimOption contained ambiwidth ari autowriteall backupext belloff binary breakindentopt bt cd charconvert cinscopedecls cmp comments concealcursor cpp cscopetag cst cursorline dex dip eb emoji equalalways ex fdl fencs fileformats flp foldignore foldtext ft ghr guicursor guitablabel hid hl im imdisable imstyle indk isi key kpc lcs listchars ls makeef maxmapdepth mfd mmd modified mousemodel msm number operatorfunc pastetoggle pexpr popt printexpr pumheight pythonthreedll rdt report rnu ruler scf scrollopt sessionoptions shellredir shm showmode sj smd spc spk sr startofline suffixesadd sxe tabstop tagstack tcldll termwinsize tgc titlelen top ttimeoutlen ttytype udf updatetime ve viminfo wak " vimOptions: These are the turn-off setting variants {{{2 @@ -181,8 +181,8 @@ syn match vimNumber '-\d\+\%(\.\d\+\%([eE][+-]\=\d\+\)\=\)\=' skipwhite nextgro syn match vimNumber '\<0[xX]\x\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment syn match vimNumber '\<0[zZ][a-zA-Z0-9.]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment -syn match vimNumber '0[0-7]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment -syn match vimNumber '0[bB][01]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment +syn match vimNumber '0[0-7]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment +syn match vimNumber '0[bB][01]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment " All vimCommands are contained by vimIsCommand. {{{2 syn match vimCmdSep "[:|]\+" skipwhite nextgroup=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimEcho,vimEchoHL,vimExecute,vimIsCommand,vimExtCmd,vimFilter,vimGlobal,vimHighlight,vimLet,vimMap,vimMark,vimNorm,vimSet,vimSyntax,vimUnlet,vimUnmap,vimUserCmd From bf44b69d1f91d9778ae1887128c63d35d9a3d19b Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Wed, 3 Jan 2024 18:52:52 +0100 Subject: [PATCH 005/143] patch 9.1.0001: when closing window, wincmd p may fail Avoid `prevwin == curwin` when closing `curwin` Problem: When closing the current window (or when moving it to a tabpage), the previous window may refer to the new current window (`winnr() == winnr('#')`) if that window is selected as the new current window. Solution: Set `prevwin = NULL` when switching away from an invalid `curwin` and the target window was the `prevwin`. (Sean Dewar) related: #4537 closes: #13762 Signed-off-by: Sean Dewar Signed-off-by: Christian Brabandt --- src/testdir/test_window_cmd.vim | 58 +++++++++++++++++++++++++++++++++ src/version.c | 2 ++ src/window.c | 4 +++ 3 files changed, 64 insertions(+) diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim index 818fef0394..6b7dccbb00 100644 --- a/src/testdir/test_window_cmd.vim +++ b/src/testdir/test_window_cmd.vim @@ -131,6 +131,64 @@ func Test_window_quit() bw Xa Xb endfunc +func Test_window_curwin_not_prevwin() + botright split + call assert_equal(2, winnr()) + call assert_equal(1, winnr('#')) + quit + call assert_equal(1, winnr()) + call assert_equal(0, winnr('#')) + + botright split + botright split + call assert_equal(3, winnr()) + call assert_equal(2, winnr('#')) + 1quit + call assert_equal(2, winnr()) + call assert_equal(1, winnr('#')) + + botright split + call assert_equal(1, tabpagenr()) + call assert_equal(3, winnr()) + call assert_equal(2, winnr('#')) + wincmd T + call assert_equal(2, tabpagenr()) + call assert_equal(1, winnr()) + call assert_equal(0, winnr('#')) + tabfirst + call assert_equal(1, tabpagenr()) + call assert_equal(2, winnr()) + call assert_equal(0, winnr('#')) + + tabonly + botright split + wincmd t + wincmd p + call assert_equal(3, winnr()) + call assert_equal(1, winnr('#')) + quit + call assert_equal(2, winnr()) + call assert_equal(1, winnr('#')) + + botright split + wincmd t + wincmd p + call assert_equal(1, tabpagenr()) + call assert_equal(3, winnr()) + call assert_equal(1, winnr('#')) + wincmd T + call assert_equal(2, tabpagenr()) + call assert_equal(1, winnr()) + call assert_equal(0, winnr('#')) + tabfirst + call assert_equal(1, tabpagenr()) + call assert_equal(2, winnr()) + call assert_equal(1, winnr('#')) + + tabonly + only +endfunc + func Test_window_horizontal_split() call assert_equal(1, winnr('$')) 3wincmd s diff --git a/src/version.c b/src/version.c index 1fc040ed18..c4e7fa3db7 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1, /**/ 0 }; diff --git a/src/window.c b/src/window.c index 9f80657124..54e17be2db 100644 --- a/src/window.c +++ b/src/window.c @@ -5381,11 +5381,15 @@ win_enter_ext(win_T *wp, int flags) // may have to copy the buffer options when 'cpo' contains 'S' if (wp->w_buffer != curbuf) buf_copy_options(wp->w_buffer, BCO_ENTER | BCO_NOHELP); + if (curwin_invalid == 0) { prevwin = curwin; // remember for CTRL-W p curwin->w_redr_status = TRUE; } + else if (wp == prevwin) + prevwin = NULL; // don't want it to be the new curwin + curwin = wp; curbuf = wp->w_buffer; check_cursor(); From 0689b870595c687a23e102913ce5037f65d03748 Mon Sep 17 00:00:00 2001 From: Shota Nozaki Date: Wed, 3 Jan 2024 19:18:43 +0100 Subject: [PATCH 006/143] patch 9.1.0002: a closing fold expr, may start a new fold Problem: a closing fold expression may unexpectedly start a new fold when it should end a fold (reported by Shota Nozaki) Solution: if a fold hasn't started yet, do not immediately start a new fold with level 1 (Shota Nozaki) fixes: #12768 closes: #13748 Signed-off-by: Shota Nozaki Signed-off-by: Christian Brabandt --- src/fold.c | 4 +++- src/testdir/test_fold.vim | 13 +++++++++++++ src/version.c | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/fold.c b/src/fold.c index be20991c7a..5c41ed1b05 100644 --- a/src/fold.c +++ b/src/fold.c @@ -3362,7 +3362,9 @@ foldlevelExpr(fline_T *flp) break; // "<1", "<2", .. : end a fold with a certain level - case '<': flp->lvl_next = n - 1; + case '<': // To prevent an unexpected start of a new fold, the next + // level must not exceed the level of the current fold. + flp->lvl_next = MIN(flp->lvl, n - 1); flp->end = n; break; diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim index cb29d43d54..3c78e62c3e 100644 --- a/src/testdir/test_fold.vim +++ b/src/testdir/test_fold.vim @@ -1778,4 +1778,17 @@ func Test_foldexpr_return_empty_string() bwipe! endfunc +" Make sure that when ending a fold that hasn't been started, it does not +" start a new fold. +func Test_foldexpr_end_fold() + new + setlocal foldmethod=expr + let &l:foldexpr = 'v:lnum == 2 ? "<2" : "="' + call setline(1, range(1, 3)) + redraw + call assert_equal([0, 0, 0], range(1, 3)->map('foldlevel(v:val)')) + + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index c4e7fa3db7..8c71b6864f 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2, /**/ 1, /**/ From 443657b32becb2318ae40e30a849bbe5cc1a153c Mon Sep 17 00:00:00 2001 From: Isao Sato Date: Wed, 3 Jan 2024 19:31:05 +0100 Subject: [PATCH 007/143] patch 9.1.0003: Cannot build against Ruby 33 dynamically Problem: Cannot build against Ruby 33 dynamically Solution: Ruby 33 removed transient heap, so do not use rb_ary_transient anymore, NoMethodError format changed, so update test for expected error message (Isao Sato) - ruby-3.3 removed transient heap for ruby/dyn when +ruby/dyn with ruby-3.3 do command :ruby, E448 occur. ruby-3.3 has no transient heap anymore, so disable rb_ary_transient etc. $ LC_ALL=C VIMRUNTIME=runtime ./src/vim -u NONE -c 'ruby puts RUBY_VERSION' "=> Error detected while processing command line: "=> E448: Could not load library function rb_ary_detransient "=> E266: Sorry, this command is disabled, the Ruby library could not be loaded. - ruby-3.3 changed NoMethodError format: $ rvm 3.2.2, 3.3.0-rc1 do ruby -e 'begin; nil.name; rescue => e; puts "%s : %s"%[RUBY_VERSION, e.message]; end ' => 3.2.2 : undefined method `name' for nil:NilClass => 3.3.0 : undefined method `name' for nil so loose pattern in Test_ruby_Vim_buffer_get() closes: #13741 Signed-off-by: Isao Sato Signed-off-by: Christian Brabandt --- src/if_ruby.c | 10 +++++----- src/testdir/test_ruby.vim | 2 +- src/version.c | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/if_ruby.c b/src/if_ruby.c index a921205255..7fab211a8a 100644 --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -83,7 +83,7 @@ # define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub # endif -# if RUBY_VERSION >= 26 +# if RUBY_VERSION >= 26 && RUBY_VERSION <= 32 # define rb_ary_detransient rb_ary_detransient_stub # endif @@ -456,7 +456,7 @@ static VALUE (*dll_rb_float_new) (double); static VALUE (*dll_rb_ary_new) (void); static VALUE (*dll_rb_ary_new4) (long n, const VALUE *elts); static VALUE (*dll_rb_ary_push) (VALUE, VALUE); -# if RUBY_VERSION >= 26 +# if RUBY_VERSION >= 26 && RUBY_VERSION <= 32 static void (*dll_rb_ary_detransient) (VALUE); # endif # ifdef __ia64 @@ -491,7 +491,7 @@ NORETURN(static void (*dll_ruby_malloc_size_overflow)(size_t, size_t)); # endif # endif -# if RUBY_VERSION >= 26 +# if RUBY_VERSION >= 26 && RUBY_VERSION <= 32 void rb_ary_detransient_stub(VALUE x); # endif @@ -561,7 +561,7 @@ rb_gc_writebarrier_unprotect_stub(VALUE obj) } # endif # endif -# if RUBY_VERSION >= 26 +# if RUBY_VERSION >= 26 && RUBY_VERSION <= 32 void rb_ary_detransient_stub(VALUE x) { @@ -718,7 +718,7 @@ static struct {"rb_ary_new4", (RUBY_PROC*)&dll_rb_ary_new4}, # endif {"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push}, -# if RUBY_VERSION >= 26 +# if RUBY_VERSION >= 26 && RUBY_VERSION <= 32 {"rb_ary_detransient", (RUBY_PROC*)&dll_rb_ary_detransient}, # endif {"rb_int2big", (RUBY_PROC*)&dll_rb_int2big}, diff --git a/src/testdir/test_ruby.vim b/src/testdir/test_ruby.vim index 224dffb994..2e0835cbe0 100644 --- a/src/testdir/test_ruby.vim +++ b/src/testdir/test_ruby.vim @@ -275,7 +275,7 @@ func Test_ruby_Vim_buffer_get() call assert_match('Xfoo1$', rubyeval('Vim::Buffer[1].name')) call assert_match('Xfoo2$', rubyeval('Vim::Buffer[2].name')) call assert_fails('ruby print Vim::Buffer[3].name', - \ "NoMethodError: undefined method `name' for nil:NilClass") + \ "NoMethodError: undefined method `name' for nil") %bwipe endfunc diff --git a/src/version.c b/src/version.c index 8c71b6864f..749d6af13a 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 3, /**/ 2, /**/ From 83ad2726ff56db70cb2da78e1e4ea0e09941c73b Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Wed, 3 Jan 2024 19:48:51 +0100 Subject: [PATCH 008/143] patch 9.1.0004: reloading colorscheme when not changing 'background' Problem: reloading colorscheme when not changing 'background' Solution: Check, if the background option value actually changed, if not, return early. Only reload colorscheme when bg is changed Currently the highlight groups are re-initialized and the colorscheme (if any) is reloaded anytime 'background' is set, even if it is not changed. This is unnecessary, because if the value was not changed then there is no need to change highlight groups or do anything with the colorscheme. Instead, only reload the colorscheme if the value of 'background' was actually changed. closes: #13700 Signed-off-by: Gregory Anders Signed-off-by: Christian Brabandt --- runtime/doc/options.txt | 10 +++++----- src/optionstr.c | 6 +++++- src/version.c | 2 ++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index e6c20220b5..4dff6b53f3 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 9.1. Last change: 2023 Dec 20 +*options.txt* For Vim version 9.1. Last change: 2024 Jan 03 VIM REFERENCE MANUAL by Bram Moolenaar @@ -997,11 +997,11 @@ A jump table for the options with a short description can be found at |Q_op|. what the background color looks like. For changing the background color, see |:hi-normal|. - When 'background' is set Vim will adjust the default color groups for - the new value. But the colors used for syntax highlighting will not - change. *g:colors_name* + When 'background' is changed Vim will adjust the default color groups + for the new value. But the colors used for syntax highlighting will + not change. *g:colors_name* When a color scheme is loaded (the "g:colors_name" variable is set) - setting 'background' will cause the color scheme to be reloaded. If + changing 'background' will cause the color scheme to be reloaded. If the color scheme adjusts to the value of 'background' this will work. However, if the color scheme sets 'background' itself the effect may be undone. First delete the "g:colors_name" variable when needed. diff --git a/src/optionstr.c b/src/optionstr.c index 326e625526..65a80afe1a 100644 --- a/src/optionstr.c +++ b/src/optionstr.c @@ -1050,11 +1050,15 @@ expand_set_ambiwidth(optexpand_T *args, int *numMatches, char_u ***matches) * The 'background' option is changed. */ char * -did_set_background(optset_T *args UNUSED) +did_set_background(optset_T *args) { if (check_opt_strings(p_bg, p_bg_values, FALSE) == FAIL) return e_invalid_argument; + if (args->os_oldval.string != NULL && args->os_oldval.string[0] == *p_bg) + // Value was not changed + return NULL; + #ifdef FEAT_EVAL int dark = (*p_bg == 'd'); #endif diff --git a/src/version.c b/src/version.c index 749d6af13a..e83654fd56 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4, /**/ 3, /**/ From d94ca966ca6d85d3dd03c8b68ff6a4cbae4da1af Mon Sep 17 00:00:00 2001 From: Ajit-Thakkar <142174202+Ajit-Thakkar@users.noreply.github.com> Date: Wed, 3 Jan 2024 14:58:21 -0400 Subject: [PATCH 009/143] runtime(fortran): syntax and documentation updates (#13811) closes: #13802 Signed-off-by: Ajit-Thakkar <142174202+Ajit-Thakkar@users.noreply.github.com> Signed-off-by: Christian Brabandt --- runtime/doc/syntax.txt | 24 ++-- runtime/syntax/fortran.vim | 225 ++++++++++++++++++------------------- 2 files changed, 115 insertions(+), 134 deletions(-) diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index bc833b11fc..e3cac2e248 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1677,27 +1677,19 @@ placed prior to the :syntax on command. Unfortunately, the use of tabs will mean that the syntax file will not be able to detect incorrect margins. Syntax folding of Fortran files ~ -If you wish to use foldmethod=syntax, then you must first set the variable -fortran_fold with a command such as > +Vim will fold your file using foldmethod=syntax, if you set the variable +fortran_fold in your .vimrc with a command such as > :let fortran_fold=1 to instruct the syntax script to define fold regions for program units, that is main programs starting with a program statement, subroutines, function -subprograms, modules, submodules, and block data units. Block, interface, -associate, critical, type definition, and change team constructs will also be -folded. If you also set the variable fortran_fold_conditionals with a command -such as > +subprograms, modules, submodules, blocks of comment lines, and block data +units. Block, interface, associate, critical, type definition, and change team +constructs will also be folded. If you also set the variable +fortran_fold_conditionals with a command such as > :let fortran_fold_conditionals=1 then fold regions will also be defined for do loops, if blocks, select case, -select type, and select rank constructs. If you also set the variable -fortran_fold_multilinecomments with a command such as > - :let fortran_fold_multilinecomments=1 -then fold regions will also be defined for three or more consecutive comment -lines. Note that defining fold regions can be slow for large files. - -If fortran_fold, and possibly fortran_fold_conditionals and/or -fortran_fold_multilinecomments, have been set, then vim will fold your file. -Comments or blank lines placed between two program units are not folded -because they are seen as not belonging to any program unit. +select type, and select rank constructs. Note that defining fold regions can +be slow for large files. The syntax/fortran.vim script contains embedded comments that tell you how to comment and/or uncomment some lines to (a) activate recognition of some diff --git a/runtime/syntax/fortran.vim b/runtime/syntax/fortran.vim index 99e11528de..1fb8a1c424 100644 --- a/runtime/syntax/fortran.vim +++ b/runtime/syntax/fortran.vim @@ -1,6 +1,6 @@ " Vim syntax file " Language: Fortran 2023 (and Fortran 2018, 2008, 2003, 95, 90, and 77) -" Version: (v109) 2023 December 29 +" Version: (v110) 2024 January 03 " Maintainers: Ajit J. Thakkar ; " Joshua Hollett " Usage: For instructions, do :help fortran-syntax from Vim @@ -68,18 +68,18 @@ if b:fortran_fixed_source == 1 else syn match fortranConstructName "^\s*\zs\a\w*\ze\s*:" endif -syn match fortranConstructName "\(\" -syn match fortranConstructName "\(\" -syn match fortranConstructName "\(\" +syn match fortranConstructName "\%(\" +syn match fortranConstructName "\%(\" +syn match fortranConstructName "\%(\" -syn match fortranUnitName "\(\(end\s*\)\?\(subroutine\|function\|module\|program\|submodule\)\s\+\)\@12<=\a\w\+" -syn match fortranUnitHeader "\\ze\s*\%(!.*\)\?$" syn keyword fortranIntrinsic abs acos aimag aint anint asin atan atan2 char cmplx conjg cos cosh exp ichar index int log log10 max min nint sign sin sinh sqrt tan tanh syn keyword fortranIntrinsicR achar iachar transfer dble dprod dim lge lgt lle llt mod @@ -91,7 +91,7 @@ syn keyword fortranIntrinsic dot_product eoshift exponent floor fraction iand syn keyword fortranIntrinsic modulo mvbits nearest pack precision present radix random_number random_seed range repeat reshape rrspacing scale scan set_exponent shape size spacing "syn keyword fortranIntrinsic count epsilon maxval minval product sum huge tiny " intrinsic names often used for variables in older Fortran code -syn match fortranIntrinsic '\<\(count\|epsilon\|maxval\|minval\|product\|sum\|huge\|tiny\)\>\ze\s*(' +syn match fortranIntrinsic '\<\%(count\|epsilon\|maxval\|minval\|product\|sum\|huge\|tiny\)\>\ze\s*(' syn keyword fortranIntrinsic spread system_clock transpose trim ubound unpack verify syn keyword fortranIntrinsic atomic_define atomic_ref execute_command_line leadz trailz storage_size merge_bits syn keyword fortranIntrinsic bge bgt ble blt dshiftl dshiftr findloc iall iany iparity image_index lcobound ucobound maskl maskr num_images parity popcnt poppar shifta shiftl shiftr this_image @@ -116,30 +116,30 @@ syn keyword fortranExtraIntrinsic algama cdabs cdcos cdexp cdlog cdsin cdsqrt cq syn keyword fortranType generic final enumerator import syn keyword fortranType c_ptr c_funptr elemental pure impure recursive non_recursive -syn match fortranTypeOb "^\s*\(character\s*\)\@15<=\*" -syn match fortranType "^\s*\(implicit \)\?\s*\(real\|integer\|logical\|complex\|character\|type\)\>" -syn match fortranType "^\s*implicit\s\+none" -syn match fortranType "\(class\|type\)\(of\)\?" -syn match fortranType "\(end\s*\)\?\" +syn match fortranTypeOb "^\s*\zs\%(character\s*\)\@15<=\*" +syn match fortranType "^\s*\zs\%(implicit\s\+\)\?\%(real\|integer\|logical\|complex\|character\|type\)\>" +syn match fortranType "^\s*\zsimplicit\s\+none\>" +syn match fortranType "\<\%(class\|type\)\%(of\)\?\>" +syn match fortranType "\<\%(end\s*\)\?interface\>" syn match fortranType "\" -syn match fortranType "\(end\s*\)\?enumeration\s\+type" -syn match fortranType "\(end\s*\)\?\(\" -syn match fortranTypeR display "double\s*precision" -syn match fortranTypeR display "double\s\+complex" +syn match fortranType "\" +syn match fortranType "\<\%(end\s*\)\?enumeration\s\+type" +syn match fortranType "\<\%(end\s*\)\?\%(module\s\+\)\?procedure\>" +syn match fortranTypeR display "\" +syn match fortranTypeR display "\" syn keyword fortranAttribute value bind deferred contiguous intrinsic non_intrinsic syn keyword fortranAttribute asynchronous nopass non_overridable pass volatile extends syn keyword fortranAttribute abstract external private public protected intent optional syn keyword fortranAttribute pointer target allocatable dimension codimension sequence parameter save syn keyword fortranUnitHeader result operator assignment -syn match fortranUnitHeader "\<\(end\s*\)\?\(subroutine\|function\|module\|program\|submodule\)\>" -syn match fortranBlock "\<\(end\s*\)\?\(block\|critical\|associate\)\>" -syn match fortranCalled "\(call\s\+\)\@7<=\a\w*" +syn match fortranUnitHeader "\<\%(end\s*\)\?\%(subroutine\|function\|module\|program\|submodule\)\>" +syn match fortranBlock "\<\%(end\s*\)\?\%(block\|critical\|associate\)\>" +syn match fortranCalled "\<\%(call\s\+\)\@7<=\a\w*" syn match fortranRepeat "\" syn keyword fortranRepeat concurrent syn keyword fortranRepeatR while -syn match fortranRepeat "\" syn keyword fortranRepeatOb forall syn match fortranRepeatOb "\" @@ -150,16 +150,16 @@ syn region fortranParen transparent start="(" end=")" contains=ALLBUT,fortranPar syn match fortranParenError ")" syn match fortranOperator "\.\s*n\=eqv\s*\." -syn match fortranOperator "\.\s*\(and\|or\|not\)\s*\." -syn match fortranOperator "\(+\|-\|/\|\*\)" -syn match fortranOperator "\(\(>\|<\)=\=\|==\|/=\|=\)" -syn match fortranOperator "\(%\|?\|=>\)" -syn match fortranOperator "\([\|]\)" +syn match fortranOperator "\.\s*\%(and\|or\|not\)\s*\." +syn match fortranOperator "\%(+\|-\|/\|\*\)" +syn match fortranOperator "\%(\%(>\|<\)=\=\|==\|/=\|=\)" +syn match fortranOperator "\%(%\|?\|=>\)" +syn match fortranOperator "\%([\|]\)" syn match fortranOperatorR "\.\s*[gl][et]\s*\." -syn match fortranOperatorR "\.\s*\(eq\|ne\)\s*\." +syn match fortranOperatorR "\.\s*\%(eq\|ne\)\s*\." syn keyword fortranReadWrite print flush -syn match fortranReadWrite '\<\(backspace\|close\|endfile\|inquire\|open\|read\|rewind\|write\)\ze\s*(' +syn match fortranReadWrite '\<\%(backspace\|close\|endfile\|inquire\|open\|read\|rewind\|write\)\ze\s*(' "If tabs are allowed then the left margin checks do not work if exists("fortran_have_tabs") @@ -170,17 +170,17 @@ endif "Numbers of various sorts " Integers -syn match fortranNumber display "\<\d\+\(_\a\w*\)\=\>" +syn match fortranNumber display "\<\d\+\%(_\a\w*\)\=\>" " floating point number, without a decimal point -syn match fortranFloatIll display "\<\d\+[deq][-+]\=\d\+\(_\a\w*\)\=\>" +syn match fortranFloatIll display "\<\d\+[deq][-+]\=\d\+\%(_\a\w*\)\=\>" " floating point number, starting with a decimal point -syn match fortranFloatIll display "\.\d\+\([deq][-+]\=\d\+\)\=\(_\a\w*\)\=\>" +syn match fortranFloatIll display "\.\d\+\%([deq][-+]\=\d\+\)\=\%(_\a\w*\)\=\>" " floating point number, no digits after decimal -syn match fortranFloatIll display "\<\d\+\.\([deq][-+]\=\d\+\)\=\(_\a\w*\)\=\>" +syn match fortranFloatIll display "\<\d\+\.\%([deq][-+]\=\d\+\)\=\%(_\a\w*\)\=\>" " floating point number, D or Q exponents -syn match fortranFloatIll display "\<\d\+\.\d\+\([dq][-+]\=\d\+\)\=\(_\a\w*\)\=\>" +syn match fortranFloatIll display "\<\d\+\.\d\+\%([dq][-+]\=\d\+\)\=\%(_\a\w*\)\=\>" " floating point number -syn match fortranFloat display "\<\d\+\.\d\+\(e[-+]\=\d\+\)\=\(_\a\w*\)\=\>" +syn match fortranFloat display "\<\d\+\.\d\+\%(e[-+]\=\d\+\)\=\%(_\a\w*\)\=\>" " binary number syn match fortranBinary display "b["'][01]\+["']" " octal number @@ -189,30 +189,29 @@ syn match fortranOctal display "o["'][0-7]\+["']" syn match fortranHex display "z["'][0-9A-F]\+["']" " Numbers in formats syn match fortranFormatSpec display "\d*f\d\+\.\d\+" -syn match fortranFormatSpec display "\d*e[sn]\=\d\+\.\d\+\(e\d+\>\)\=" -syn match fortranFormatSpec display "\d*\(d\|q\|g\)\d\+\.\d\+\(e\d+\)\=" +syn match fortranFormatSpec display "\d*e[sn]\=\d\+\.\d\+\%(e\d+\>\)\=" +syn match fortranFormatSpec display "\d*\%(d\|q\|g\)\d\+\.\d\+\%(e\d+\)\=" syn match fortranFormatSpec display "\d\+x\>" " The next match cannot be used because it would pick up identifiers as well -" syn match fortranFormatSpec display "\<\(a\|i\)\d\+" +" syn match fortranFormatSpec display "\<\%(a\|i\)\d\+" " Numbers as labels -syn match fortranLabelNumber display "^\d\{1,5}\s"me=e-1 -syn match fortranLabelNumber display "^ \d\{1,4}\s"ms=s+1,me=e-1 -syn match fortranLabelNumber display "^ \d\{1,3}\s"ms=s+2,me=e-1 -syn match fortranLabelNumber display "^ \d\d\=\s"ms=s+3,me=e-1 -syn match fortranLabelNumber display "^ \d\s"ms=s+4,me=e-1 +syn match fortranLabelNumber display "^\zs\d\{1,5}\ze\s" +syn match fortranLabelNumber display "^ \zs\d\{1,4}\ze\s" +syn match fortranLabelNumber display "^ \zs\d\{1,3}\ze\s" +syn match fortranLabelNumber display "^ \zs\d\d\=\ze\s" +syn match fortranLabelNumber display "^ \zs\d\ze\s" " Numbers as targets -syn match fortranTarget display "\(\" -syn match fortranTarget display "\(\" -syn match fortranTarget display "\(\" +syn match fortranTarget display "\%(\" +syn match fortranTarget display "\%(\" +syn match fortranTarget display "\%(\" -syn match fortranBoolean "\.\s*\(true\|false\)\s*\." +syn match fortranBoolean "\.\s*\%(true\|false\)\s*\." -syn match fortranKeyword "call" +syn keyword fortranKeyword call syn keyword fortranKeyword use only contains -syn match fortranKeyword "fail\s\+image\>" -syn match fortranKeyword "\(error\s\+\)\=stop" -syn match fortranKeyword "\" -syn match fortranKeyword "^\s*\d\+\s\+continue\>" +syn match fortranKeyword "\" +syn match fortranKeyword "\<\%(error\s\+\)\=stop\>" +syn keyword fortranKeyword continue syn match fortranKeyword "\" syn match fortranKeywordDel "\" -syn match fortranConditional "\" -syn match fortranConditional "\(case\|rank\)\(\s\+default\)\?" +syn match fortranConditional "\" +syn match fortranConditional "\<\%(end\s*\)\?\%(if\|where\|select\)\>" +syn match fortranConditional "\" +syn match fortranConditional "\<\%(class\|type\)\s\+is\>" +syn match fortranConditional "\<\%(case\|rank\)\%(\s\+default\)\?\>" syn match fortranConditionalDel "\" -syn match fortranImageControl "\(change\|form\|end\)\s\+team\>" -syn match fortranImageControl "event\s\+\(post\|wait\)" -syn match fortranImageControl "\(un\)\?lock\ze\s*(" -syn match fortranImageControl "notify\s\+wait\ze\s*(" +syn match fortranImageControl "\" +syn match fortranImageControl "\<\%(change\|form\|end\)\s\+team\>" +syn match fortranImageControl "\" syn keyword fortranStorageClass in out syn match fortranStorageClass "\" syn match fortranStorageClass "\\(\s\+\a\w*\s*/\)\@=" -syn match fortranStorageClassOb "^\s*common\>" -syn match fortranStorageClassOb "^\s*common\>\(\s*/\)\@=" +syn match fortranStorageClass "^\s*\zsdata\>\%(\s\+\a\w*\s*/\)\@=" +syn match fortranStorageClassOb "^\s*\zscommon\>" +syn match fortranStorageClassOb "^\s*\zscommon\>\%(\s*/\)\@=" syn keyword fortranStorageClassOb equivalence syn keyword fortranConstant c_null_char c_alert c_backspace c_form_feed c_new_line c_carriage_return c_horizontal_tab c_vertical_tab @@ -284,10 +283,10 @@ if exists("fortran_CUDA") syn keyword fortranTypeCUDA cudaErrorNotReady cudaSuccess cudaErrorInvalidValue syn keyword fortranTypeCUDA c_devptr - syn match fortranStringCUDA "blockidx%[xyz]" - syn match fortranStringCUDA "blockdim%[xyz]" - syn match fortranStringCUDA "griddim%[xyz]" - syn match fortranStringCUDA "threadidx%[xyz]" + syn match fortranStringCUDA "\" + syn match fortranStringCUDA "\" + syn match fortranStringCUDA "\" + syn match fortranStringCUDA "\" syn keyword fortranIntrinsicCUDA warpsize syncthreads syncthreads_and syncthreads_count syncthreads_or threadfence threadfence_block threadfence_system gpu_time allthreads anythread ballot syn keyword fortranIntrinsicCUDA atomicadd atomicsub atomicmax atomicmin atomicand atomicor atomicxor atomicexch atomicinc atomicdec atomiccas sizeof __shfl __shfl_up __shfl_down __shfl_xor @@ -325,14 +324,14 @@ else endif syn match fortranComment excludenl "!.*$" contains=@fortranCommentGroup,@spell -syn match fortranOpenMP excludenl "^\s*!\$\(OMP\)\=&\=\s.*$" +syn match fortranOpenMP excludenl "^\s*\zs!\$\%(OMP\)\=&\=\s.*$" syn match fortranEndStatement display ";" "cpp is often used with Fortran -syn match cPreProc "^\s*#\s*\(define\|ifdef\)\>.*" -syn match cPreProc "^\s*#\s*\(elif\|if\)\>.*" -syn match cPreProc "^\s*#\s*\(ifndef\|undef\)\>.*" -syn match cPreCondit "^\s*#\s*\(else\|endif\)\>.*" +syn match cPreProc "^\s*#\s*\%(define\|ifdef\)\>.*" +syn match cPreProc "^\s*#\s*\%(elif\|if\)\>.*" +syn match cPreProc "^\s*#\s*\%(ifndef\|undef\)\>.*" +syn match cPreCondit "^\s*#\s*\%(else\|endif\)\>.*" syn region cIncluded contained start=+"[^("]+ skip=+\\\\\|\\"+ end=+"+ contains=fortranLeftMargin,fortranContinueMark,fortranSerialNumber "syn region cIncluded contained start=+"[^("]+ skip=+\\\\\|\\"+ end=+"+ syn match cIncluded contained "<[^>]*>" @@ -353,61 +352,50 @@ if exists("fortran_fold") setlocal foldmethod=syntax endif if (b:fortran_fixed_source == 1) - syn region fortranProgram transparent fold keepend start="^\s*program\s\+\z(\a\w*\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\\)\=\|$\)" contains=ALLBUT,fortranModule - syn region fortranModule transparent fold keepend start="^\s*submodule\s\+(\a\w*\s*\(:\a\w*\s*\)*)\s*\z\(\a\w*\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\\)\=\|$\)" contains=ALLBUT,fortranProgram,fortranModule - syn region fortranModule transparent fold keepend start="^\s*module\s\+\(procedure\)\@!\z(\a\w*\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\\)\=\|$\)" contains=ALLBUT,fortranProgram - syn region fortranFunction transparent fold keepend extend start="^\s*\(elemental \|pure \|impure \|module \|recursive \)\=\s*\(\(\(real \|integer \|logical \|complex \|double \s*precision \)\s*\((\(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\|type\s\+(\s*\w\+\s*) \|character \((\(\s*len\s*=\)\=\s*\d\+\s*)\|(\(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\=\s*function\s\+\z(\a\w*\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\\)\=\)" contains=ALLBUT,fortranProgram,fortranModule - syn region fortranSubroutine transparent fold keepend extend start="^\s*\(elemental \|pure \|impure \|module \|recursive \)\=\s*subroutine\s\+\z(\a\w*\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\\)\=\)" contains=ALLBUT,fortranProgram,fortranModule + syn region fortranProgram transparent fold keepend start="^\s*program\s\+\z(\a\w*\)" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\\)\=\|$\)" contains=ALLBUT,fortranModule + syn region fortranModule transparent fold keepend start="^\s*submodule\s\+(\a\w*\s*\%(:\a\w*\s*\)*)\s*\z\(\a\w*\)" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\\)\=\|$\)" contains=ALLBUT,fortranProgram,fortranModule + syn region fortranModule transparent fold keepend start="^\s*module\s\+\%(procedure\)\@!\z(\a\w*\)" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\\)\=\|$\)" contains=ALLBUT,fortranProgram + syn region fortranFunction transparent fold keepend extend start="^\s*\%(elemental \|pure \|impure \|module \|recursive \)\=\s*\%(\%(\%(real \|integer \|logical \|complex \|double \s*precision \)\s*\%((\%(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\|type\s\+(\s*\w\+\s*) \|character \%((\%(\s*len\s*=\)\=\s*\d\+\s*)\|(\%(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\=\s*function\s\+\z(\a\w*\)" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\\)\=\)" contains=ALLBUT,fortranProgram,fortranModule + syn region fortranSubroutine transparent fold keepend extend start="^\s*\%(elemental \|pure \|impure \|module \|recursive \)\=\s*subroutine\s\+\z(\a\w*\)" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\\)\=\)" contains=ALLBUT,fortranProgram,fortranModule syn region fortranBlockData transparent fold keepend start="\" skip="^\s*[!#].*$" excludenl end="\" contains=ALLBUT,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortran77Loop,fortranCase,fortran90Loop,fortranIfBlock - syn region fortranAssociate transparent fold keepend start="^\s*\ Date: Thu, 4 Jan 2024 21:01:13 +0100 Subject: [PATCH 010/143] patch 9.1.0005: OpenVMS does not support python3 and xterm_save Problem: OpenVMS build does not support python3 and xterm_save Solution: Enable python3 + xterm_save feature, fix style issues (Zoltan Arpadffy) closes: #13812 Signed-off-by: Zoltan Arpadffy Signed-off-by: Christian Brabandt --- READMEdir/README_vms.txt | 14 +++++--- src/Make_vms.mms | 73 +++++++++++++++++++++++++++------------- src/os_vms_conf.h | 1 + src/version.c | 2 ++ 4 files changed, 62 insertions(+), 28 deletions(-) diff --git a/READMEdir/README_vms.txt b/READMEdir/README_vms.txt index 6e8660d3e6..4c47921c67 100644 --- a/READMEdir/README_vms.txt +++ b/READMEdir/README_vms.txt @@ -19,14 +19,16 @@ src/INSTALLvms.txt. To use the binary version, you need one of these archives: - vim-XX-exe-ia64-gui.zip IA64 GUI/Motif executables - vim-XX-exe-ia64-gtk.zip IA64 GUI/GTK executables - vim-XX-exe-ia64-term.zip IA64 console executables + vim-XX-exe-x86-gui.zip X86_64 GUI/Motif executables + vim-XX-exe-x86-term.zip X86_64 console executables + vim-XX-exe-ia64-gui.zip IA64 GUI/Motif executables + vim-XX-exe-ia64-gtk.zip IA64 GUI/GTK executables + vim-XX-exe-ia64-term.zip IA64 console executables vim-XX-exe-axp-gui.zip Alpha GUI/Motif executables vim-XX-exe-axp-gtk.zip Alpha GUI/GTK executables - vim-XX-exe-axp-term.zip Alpha console executables + vim-XX-exe-axp-term.zip Alpha console executables vim-XX-exe-vax-gui.zip VAX GUI executables - vim-XX-exe-vax-term.zip VAX console executables + vim-XX-exe-vax-term.zip VAX console executables and of course vim-XX-runtime.zip runtime files @@ -34,6 +36,8 @@ and of course The binary archives contain: vim.exe, ctags.exe, xxd.exe files, but there are also prepared "deploy ready" archives: +vim-XX-x86.zip GUI and console executables with runtime and + help files for X86_64 systems vim-XX-ia64.zip GUI and console executables with runtime and help files for IA64 systems vim-XX-axp.zip GUI and console executables with runtime and diff --git a/src/Make_vms.mms b/src/Make_vms.mms index 85b825e2dd..f050c9db2f 100644 --- a/src/Make_vms.mms +++ b/src/Make_vms.mms @@ -1,8 +1,8 @@ # # Makefile for Vim on OpenVMS # -# Maintainer: Zoltan Arpadffy -# Last change: 2023 Nov 27 +# Maintainer: Zoltan Arpadffy +# Last change: 2024 Jan 03 # # This script has been tested on VMS 6.2 to 9.2 on VAX, ALPHA, IA64 and X86_64 # with MMS and MMK @@ -65,6 +65,7 @@ CCVER = YES # VIM_TCL = YES # VIM_PERL = YES # VIM_PYTHON = YES +# VIM_PYTHON3= YES # VIM_RUBY = YES # VIM_LUA = YES @@ -113,7 +114,7 @@ CC_DEF = cc PREFIX = /prefix=all/name=(upper,short) OPTIMIZE= /opt .IFDEF MMSX86_64 -ARCH_DEF= # ,__CRTL_VER_OVERRIDE=80400000 +ARCH_DEF= # ,__CRTL_VER_OVERRIDE=80400000 .ENDIF .ENDIF @@ -224,6 +225,16 @@ PYTHON_LIB = ,OS_VMS_PYTHON.OPT/OPT PYTHON_INC = ,PYTHON_INCLUDE .ENDIF +.IFDEF VIM_PYTHON3 +# Python related setup. +PYTHON3_DEF = ,"FEAT_PYTHON3" +PYTHON3_SRC = if_python3.c +PYTHON3_OBJ = if_python3.obj +PYTHON3_LIB = ,OS_VMS_PYTHON3.OPT/OPT +PYTHON3_INC = ,PYTHON3_INCLUDE +.ENDIF + + .IFDEF VIM_TCL # TCL related setup. TCL_DEF = ,"FEAT_TCL" @@ -260,9 +271,9 @@ XIM_DEF = ,"FEAT_XIM" .IFDEF VIM_MZSCHEME # MZSCHEME related setup -MZSCH_DEF = ,"FEAT_MZSCHEME" -MZSCH_SRC = if_mzsch.c -MZSCH_OBJ = if_mzsch.obj +MZSCHEME_DEF = ,"FEAT_MZSCHEME" +MZSCHEME_SRC = if_mzsch.c +MZSCHEME_OBJ = if_mzsch.obj .ENDIF .IFDEF VIM_ICONV @@ -275,7 +286,7 @@ XDIFF_SRC = xdiffi.c,xemit.c,xprepare.c,xutils.c,xhistogram.c,xpatience.c XDIFF_OBJ = xdiffi.obj,xemit.obj,xprepare.obj,xutils.obj,xhistogram.obj,xpatience.obj XDIFF_INC = ,[.xdiff] -.IFDEF MODIFIED_BY +.IFDEF MODIFIED_BY DEF_MODIFIED = YES .ELSE DEF_MODIFIED = NO @@ -294,26 +305,26 @@ VIMHOST = "''F$TRNLNM("SYS$NODE")'''F$TRNLNM("UCX$INET_HOST")'.''F$TRNLNM("UCX$I .SUFFIXES : .obj .c -ALL_CFLAGS = /def=($(MODEL_DEF)$(DEFS)$(DEBUG_DEF)$(PERL_DEF)$(PYTHON_DEF) - - $(TCL_DEF)$(RUBY_DEF)$(LUA_DEF)$(XIM_DEF)$(TAG_DEF)$(MZSCH_DEF) - +ALL_CFLAGS = /def=($(MODEL_DEF)$(DEFS)$(DEBUG_DEF)$(PERL_DEF)$(PYTHON_DEF)$(PYTHON3_DEF) - + $(TCL_DEF)$(RUBY_DEF)$(LUA_DEF)$(XIM_DEF)$(TAG_DEF)$(MZSCHEME_DEF) - $(ICONV_DEF)$(ARCH_DEF)) - $(CFLAGS)$(GUI_FLAG) - - /include=($(C_INC)$(GUI_INC_DIR)$(GUI_INC)$(PERL_INC)$(PYTHON_INC) - + /include=($(C_INC)$(GUI_INC_DIR)$(GUI_INC)$(PERL_INC)$(PYTHON_INC)$(PYTHON3_INC) - $(TCL_INC)$(XDIFF_INC)$(XPM_INC)) # CFLAGS displayed in :ver information # It is specially formatted for correct display of unix like includes # as $(GUI_INC) - replaced with $(GUI_INC_VER) # Otherwise should not be any other difference. -ALL_CFLAGS_VER = /def=($(MODEL_DEF)$(DEFS)$(DEBUG_DEF)$(PERL_DEF)$(PYTHON_DEF) - - $(TCL_DEF)$(RUBY_DEF)$(LUA_DEF)$(XIM_DEF)$(TAG_DEF)$(MZSCH_DEF) - +ALL_CFLAGS_VER = /def=($(MODEL_DEF)$(DEFS)$(DEBUG_DEF)$(PERL_DEF)$(PYTHON_DEF)$(PYTHON3_DEF) - + $(TCL_DEF)$(RUBY_DEF)$(LUA_DEF)$(XIM_DEF)$(TAG_DEF)$(MZSCHEME_DEF) - $(ICONV_DEF)$(ARCH_DEF)) - $(CFLAGS)$(GUI_FLAG) - - /include=($(C_INC)$(GUI_INC_DIR)$(GUI_INC_VER)$(PERL_INC)$(PYTHON_INC) - + /include=($(C_INC)$(GUI_INC_DIR)$(GUI_INC_VER)$(PERL_INC)$(PYTHON_INC)$(PYTHON3_INC) - $(TCL_INC)$(XDIFF_INC)$(XPM_INC)) ALL_LIBS = $(LIBS) $(GUI_LIB_DIR) $(GUI_LIB) $(XPM_LIB)\ - $(PERL_LIB) $(PYTHON_LIB) $(TCL_LIB) $(RUBY_LIB) $(LUA_LIB) + $(PERL_LIB) $(PYTHON_LIB) $(PYTHON3_LIB) $(TCL_LIB) $(RUBY_LIB) $(LUA_LIB) SRC = \ alloc.c \ @@ -437,13 +448,14 @@ SRC = \ viminfo.c \ window.c \ $(GUI_SRC) \ + $(XDIFF_SRC) \ + $(LUA_SRC) \ + $(MZSCHEME_SRC) \ $(PERL_SRC) \ $(PYTHON_SRC) \ + $(PYTHON3_SRC) \ $(TCL_SRC) \ - $(RUBY_SRC) \ - $(LUA_SRC) \ - $(MZSCH_SRC) \ - $(XDIFF_SRC) + $(RUBY_SRC) OBJ = \ alloc.obj \ @@ -568,13 +580,14 @@ OBJ = \ viminfo.obj \ window.obj \ $(GUI_OBJ) \ + $(XDIFF_OBJ) \ + $(LUA_OBJ) \ + $(MZSCHEME_OBJ) \ $(PERL_OBJ) \ $(PYTHON_OBJ) \ + $(PYTHON3_OBJ) \ $(TCL_OBJ) \ - $(RUBY_OBJ) \ - $(LUA_OBJ) \ - $(MZSCH_OBJ) \ - $(XDIFF_OBJ) + $(RUBY_OBJ) # Default target is making the executable all : [.auto]config.h mmk_compat motif_env gtk_env perl_env python_env tcl_env ruby_env lua_env $(TARGET) @@ -735,6 +748,20 @@ python_env : -@ ! .ENDIF +.IFDEF VIM_PYTHON3 +python3_env : + -@ write sys$output "using PYTHON3 environment:" + -@ show logical PYTHON3_INCLUDE + -@ show logical PYTHON3_OLB + -@ write sys$output "creating OS_VMS_PYTHON3.OPT file." + -@ open/write opt_file OS_VMS_PYTHON3.OPT + -@ write opt_file "PYTHON3_OLB:PYTHON3.OLB /share" + -@ close opt_file +.ELSE +python3_env : + -@ ! +.ENDIF + .IFDEF VIM_TCL tcl_env : -@ write sys$output "using TCL environment:" @@ -1085,7 +1112,7 @@ sign.obj : sign.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h termdefs.h macros.h option.h structs.h regexp.h gui.h \ beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h proto.h \ errors.h globals.h -sound.obj : sound.c vim.h [.auto]config.h feature.h +sound.obj : sound.c vim.h [.auto]config.h feature.h spell.obj : spell.c vim.h [.auto]config.h feature.h os_unix.h \ ascii.h keymap.h termdefs.h macros.h structs.h regexp.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ diff --git a/src/os_vms_conf.h b/src/os_vms_conf.h index c1e1ea11b0..ad19dbef4a 100644 --- a/src/os_vms_conf.h +++ b/src/os_vms_conf.h @@ -144,6 +144,7 @@ // Default features #define FEAT_IPV6 +#define FEAT_XTERM_SAVE // Hardware specific #if defined(__VAX) || defined(VAX) diff --git a/src/version.c b/src/version.c index e83654fd56..42d58897e5 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 5, /**/ 4, /**/ From 184f71cc6868a240dc872ed2852542bbc1d43e28 Mon Sep 17 00:00:00 2001 From: Keith Thompson Date: Thu, 4 Jan 2024 21:19:04 +0100 Subject: [PATCH 011/143] patch 9.1.0006: is*() and to*() function may be unsafe Problem: is*() and to*() function may be unsafe Solution: Add SAFE_* macros and start using those instead (Keith Thompson) Use SAFE_() macros for is*() and to*() functions The standard is*() and to*() functions declared in have undefined behavior for negative arguments other than EOF. If plain char is signed, passing an unchecked value from argv for from user input to one of these functions has undefined behavior. Solution: Add SAFE_*() macros that cast the argument to unsigned char. Most implementations behave sanely for negative arguments, and most character values in practice are non-negative, but it's still best to avoid undefined behavior. The change from #13347 has been omitted, as this has already been separately fixed in commit ac709e2fc0db6d31abb7da96f743c40956b60c3a (v9.0.2054) fixes: #13332 closes: #13347 Signed-off-by: Keith Thompson Signed-off-by: Christian Brabandt --- runtime/tools/ccfilter.c | 6 +++--- runtime/tools/xcmdsrv_client.c | 6 +++--- src/buffer.c | 4 ++-- src/charset.c | 4 ++-- src/cmdhist.c | 2 +- src/diff.c | 4 ++-- src/dosinst.c | 2 +- src/edit.c | 2 +- src/eval.c | 2 +- src/evalfunc.c | 2 +- src/evalvars.c | 4 ++-- src/ex_cmds.c | 2 +- src/ex_docmd.c | 6 +++--- src/filepath.c | 2 +- src/findfile.c | 6 +++--- src/getchar.c | 4 ++-- src/gui.c | 2 +- src/gui_haiku.cc | 11 ----------- src/gui_photon.c | 6 +++--- src/gui_xim.c | 6 +++--- src/hardcopy.c | 4 ++-- src/highlight.c | 2 +- src/if_py_both.h | 2 +- src/if_xcmdsrv.c | 6 +++--- src/macros.h | 30 ++++++++++++++++++++++++++---- src/mbyte.c | 6 +++--- src/normal.c | 8 ++++---- src/ops.c | 8 ++++---- src/option.c | 2 +- src/os_mswin.c | 6 +++--- src/os_unix.c | 2 +- src/os_win32.c | 2 +- src/spellfile.c | 4 ++-- src/tag.c | 2 +- src/term.c | 8 ++++---- src/terminal.c | 14 +++++++------- src/typval.c | 2 +- src/uninstall.c | 2 +- src/userfunc.c | 10 +++++----- src/version.c | 6 ++++-- src/vim9compile.c | 2 +- src/vim9expr.c | 2 +- src/viminfo.c | 4 ++-- src/xxd/xxd.c | 14 +++++++------- 44 files changed, 122 insertions(+), 109 deletions(-) diff --git a/runtime/tools/ccfilter.c b/runtime/tools/ccfilter.c index 43489f16c2..ae1443e203 100644 --- a/runtime/tools/ccfilter.c +++ b/runtime/tools/ccfilter.c @@ -249,7 +249,7 @@ int main( int argc, char *argv[] ) stay = (echogets(Line2, echo) != NULL); while ( stay && (Line2[0] == '|') ) - { for (p=&Line2[2]; (*p) && (isspace(*p)); p++); + { for (p=&Line2[2]; (*p) && (isspace((unsigned char)*p)); p++); strcat( Reason, ": " ); strcat( Reason, p ); Line2[0] = 0; @@ -265,7 +265,7 @@ int main( int argc, char *argv[] ) ok = 0; if ( !strncmp(Line, "cfe: ", 5) ) { p = &Line[5]; - Severity = tolower(*p); + Severity = tolower((unsigned char)*p); p = strchr( &Line[5], ':' ); if (p == NULL) { ok = 0; @@ -313,7 +313,7 @@ int main( int argc, char *argv[] ) } else { - for (p=Reason; (*p) && (isspace(*p)); p++); + for (p=Reason; (*p) && (isspace((unsigned char)*p)); p++); if ( BasePath[CWDlen] == 0 ) printf( "%s:%lu:%lu:%c:%s\n", FileName, Row, Col, Severity, p ); else diff --git a/runtime/tools/xcmdsrv_client.c b/runtime/tools/xcmdsrv_client.c index e1aea10667..81ca66ceb9 100644 --- a/runtime/tools/xcmdsrv_client.c +++ b/runtime/tools/xcmdsrv_client.c @@ -336,7 +336,7 @@ LookupName( for (p = regProp; (p - regProp) < numItems; ) { entry = p; - while ((*p != 0) && (!isspace(*p))) + while ((*p != 0) && (!isspace((unsigned char)*p))) p++; if ((*p != 0) && (strcasecmp(name, p + 1) == 0)) { @@ -353,7 +353,7 @@ LookupName( for (p = regProp; (p - regProp) < numItems; ) { entry = p; - while ((*p != 0) && (!isspace(*p))) + while ((*p != 0) && (!isspace((unsigned char)*p))) p++; if ((*p != 0) && IsSerialName(p + 1) && (strncmp(name, p + 1, strlen(name)) == 0)) @@ -574,5 +574,5 @@ IsSerialName(char *str) { int len = strlen(str); - return (len > 1 && isdigit(str[len - 1])); + return (len > 1 && isdigit((unsigned char)str[len - 1])); } diff --git a/src/buffer.c b/src/buffer.c index 9ee74f54dd..64e4926475 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -4022,7 +4022,7 @@ maketitle(void) buf + off, SPACE_FOR_DIR - off, TRUE); #ifdef BACKSLASH_IN_FILENAME // avoid "c:/name" to be reduced to "c" - if (isalpha(buf[off]) && buf[off + 1] == ':') + if (SAFE_isalpha(buf[off]) && buf[off + 1] == ':') off += 2; #endif // remove the file name @@ -5671,7 +5671,7 @@ chk_modeline( && (s[0] != 'V' || STRNCMP(skipwhite(e + 1), "set", 3) == 0) && (s[3] == ':' - || (VIM_VERSION_100 >= vers && isdigit(s[3])) + || (VIM_VERSION_100 >= vers && SAFE_isdigit(s[3])) || (VIM_VERSION_100 < vers && s[3] == '<') || (VIM_VERSION_100 > vers && s[3] == '>') || (VIM_VERSION_100 == vers && s[3] == '='))) diff --git a/src/charset.c b/src/charset.c index bda3f911b6..0e4dbbe1dc 100644 --- a/src/charset.c +++ b/src/charset.c @@ -1958,7 +1958,7 @@ vim_islower(int c) if (enc_latin1like) return (latin1flags[c] & LATIN1LOWER) == LATIN1LOWER; } - return islower(c); + return SAFE_islower(c); } int @@ -1982,7 +1982,7 @@ vim_isupper(int c) if (enc_latin1like) return (latin1flags[c] & LATIN1UPPER) == LATIN1UPPER; } - return isupper(c); + return SAFE_isupper(c); } int diff --git a/src/cmdhist.c b/src/cmdhist.c index 96a9b3e95b..6342f02bdd 100644 --- a/src/cmdhist.c +++ b/src/cmdhist.c @@ -674,7 +674,7 @@ remove_key_from_history(void) return; for ( ; *p; ++p) - if (STRNCMP(p, "key", 3) == 0 && !isalpha(p[3])) + if (STRNCMP(p, "key", 3) == 0 && !SAFE_isalpha(p[3])) { p = vim_strchr(p + 3, '='); if (p == NULL) diff --git a/src/diff.c b/src/diff.c index 158870402b..9b8c816b5b 100644 --- a/src/diff.c +++ b/src/diff.c @@ -1712,7 +1712,7 @@ diff_read( // --- file1 2018-03-20 13:23:35.783153140 +0100 // +++ file2 2018-03-20 13:23:41.183156066 +0100 // @@ -1,3 +1,5 @@ - if (isdigit(*line)) + if (SAFE_isdigit(*line)) diffstyle = DIFF_ED; else if ((STRNCMP(line, "@@ ", 3) == 0)) diffstyle = DIFF_UNIFIED; @@ -1730,7 +1730,7 @@ diff_read( if (diffstyle == DIFF_ED) { - if (!isdigit(*line)) + if (!SAFE_isdigit(*line)) continue; // not the start of a diff block if (parse_diff_ed(line, hunk) == FAIL) continue; diff --git a/src/dosinst.c b/src/dosinst.c index 4eae5aadc4..35625a7946 100644 --- a/src/dosinst.c +++ b/src/dosinst.c @@ -2760,7 +2760,7 @@ main(int argc, char **argv) rewind(stdin); if (scanf("%99s", buf) == 1) { - if (isdigit(buf[0])) + if (isdigit((unsigned char)buf[0])) { // Change a choice. i = atoi(buf); diff --git a/src/edit.c b/src/edit.c index 9435fd6fc7..f89d43eec6 100644 --- a/src/edit.c +++ b/src/edit.c @@ -5318,7 +5318,7 @@ ins_ctrl_ey(int tc) // was typed after a CTRL-V, and pretend 'textwidth' // wasn't set. Digits, 'o' and 'x' are special after a // CTRL-V, don't use it for these. - if (c < 256 && !isalnum(c)) + if (c < 256 && !SAFE_isalnum(c)) AppendToRedobuff((char_u *)CTRL_V_STR); // CTRL-V tw_save = curbuf->b_p_tw; curbuf->b_p_tw = -1; diff --git a/src/eval.c b/src/eval.c index 8563aa6d79..815d13d42a 100644 --- a/src/eval.c +++ b/src/eval.c @@ -4276,7 +4276,7 @@ eval9( return FAIL; end_leader = *arg; - if (**arg == '.' && (!isdigit(*(*arg + 1)) || in_old_script(2))) + if (**arg == '.' && (!SAFE_isdigit(*(*arg + 1)) || in_old_script(2))) { semsg(_(e_invalid_expression_str), *arg); ++*arg; diff --git a/src/evalfunc.c b/src/evalfunc.c index f87c08ffc5..513ddccdbe 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -6744,7 +6744,7 @@ f_has(typval_T *argvars, typval_T *rettv) && has_patch(atoi(end + 3)))))); } } - else if (isdigit(name[5])) + else if (SAFE_isdigit(name[5])) n = has_patch(atoi((char *)name + 5)); } else if (STRICMP(name, "vim_starting") == 0) diff --git a/src/evalvars.c b/src/evalvars.c index ea039cbed1..8e42c5a307 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -3332,7 +3332,7 @@ find_var(char_u *name, hashtab_T **htp, int no_autoload) dictitem_T * find_var_also_in_script(char_u *name, hashtab_T **htp, int no_autoload) { - if (STRNCMP(name, "", 5) == 0 && isdigit(name[5])) + if (STRNCMP(name, "", 5) == 0 && SAFE_isdigit(name[5])) { char_u *p = name + 5; int sid = getdigits(&p); @@ -4975,7 +4975,7 @@ get_callback(typval_T *arg) else { if (arg->v_type == VAR_STRING && arg->vval.v_string != NULL - && isdigit(*arg->vval.v_string)) + && SAFE_isdigit(*arg->vval.v_string)) r = FAIL; else if (arg->v_type == VAR_FUNC || arg->v_type == VAR_STRING) { diff --git a/src/ex_cmds.c b/src/ex_cmds.c index d214933626..d8e891c2ba 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -3707,7 +3707,7 @@ skip_substitute(char_u *start, int delimiter) static int check_regexp_delim(int c) { - if (isalpha(c)) + if (SAFE_isalpha(c)) { emsg(_(e_regular_expressions_cant_be_delimited_by_letters)); return FAIL; diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 534cd7e038..c18a9107ec 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -7996,7 +7996,7 @@ ex_winsize(exarg_T *eap) char_u *arg = eap->arg; char_u *p; - if (!isdigit(*arg)) + if (!SAFE_isdigit(*arg)) { semsg(_(e_invalid_argument_str), arg); return; @@ -8387,7 +8387,7 @@ ex_later(exarg_T *eap) if (*p == NUL) count = 1; - else if (isdigit(*p)) + else if (SAFE_isdigit(*p)) { count = getdigits(&p); switch (*p) @@ -8490,7 +8490,7 @@ ex_redir(exarg_T *eap) arg++; // Make register empty when not using @A-@Z and the // command is valid. - if (*arg == NUL && !isupper(redir_reg)) + if (*arg == NUL && !SAFE_isupper(redir_reg)) write_reg_contents(redir_reg, (char_u *)"", -1, FALSE); } } diff --git a/src/filepath.c b/src/filepath.c index 1ea0623867..cbf2da4136 100644 --- a/src/filepath.c +++ b/src/filepath.c @@ -2953,7 +2953,7 @@ get_past_head(char_u *path) #if defined(MSWIN) // may skip "c:" - if (isalpha(path[0]) && path[1] == ':') + if (SAFE_isalpha(path[0]) && path[1] == ':') retval = path + 2; else retval = path; diff --git a/src/findfile.c b/src/findfile.c index 246a81898a..2636609250 100644 --- a/src/findfile.c +++ b/src/findfile.c @@ -1847,7 +1847,7 @@ grab_file_name(long count, linenr_T *file_lnum) if (get_visual_text(NULL, &ptr, &len) == FAIL) return NULL; // Only recognize ":123" here - if (file_lnum != NULL && ptr[len] == ':' && isdigit(ptr[len + 1])) + if (file_lnum != NULL && ptr[len] == ':' && SAFE_isdigit(ptr[len + 1])) { char_u *p = ptr + len + 1; @@ -1981,10 +1981,10 @@ file_name_in_line( p = skipwhite(p); if (*p != NUL) { - if (!isdigit(*p)) + if (!SAFE_isdigit(*p)) ++p; // skip the separator p = skipwhite(p); - if (isdigit(*p)) + if (SAFE_isdigit(*p)) *file_lnum = (int)getdigits(&p); } } diff --git a/src/getchar.c b/src/getchar.c index da05033709..3427a9f8da 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -870,7 +870,7 @@ start_redo(long count, int old_redo) { c = read_redo(FALSE, old_redo); add_char_buff(&readbuf2, c); - if (!isdigit(c)) + if (!SAFE_isdigit(c)) break; } c = read_redo(FALSE, old_redo); @@ -1873,7 +1873,7 @@ vgetc(void) // Handle {sid}; Do up to 20 digits for safety. last_used_sid = 0; - for (j = 0; j < 20 && isdigit(c = vgetorpeek(TRUE)); ++j) + for (j = 0; j < 20 && SAFE_isdigit(c = vgetorpeek(TRUE)); ++j) last_used_sid = last_used_sid * 10 + (c - '0'); last_used_map = NULL; continue; diff --git a/src/gui.c b/src/gui.c index 9c9aa3cbec..16c1b54c67 100644 --- a/src/gui.c +++ b/src/gui.c @@ -5030,7 +5030,7 @@ display_errors(void) // avoid putting up a message box with blanks only for (p = (char_u *)error_ga.ga_data; *p != NUL; ++p) - if (!isspace(*p)) + if (!SAFE_isspace(*p)) { // Truncate a very long message, it will go off-screen. if (STRLEN(p) > 2000) diff --git a/src/gui_haiku.cc b/src/gui_haiku.cc index c8b05e1be2..d083226547 100644 --- a/src/gui_haiku.cc +++ b/src/gui_haiku.cc @@ -4031,17 +4031,6 @@ gui_mch_mousehide(int hide) // TODO } - static int -hex_digit(int c) -{ - if (isdigit(c)) - return c - '0'; - c = TOLOWER_ASC(c); - if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - return -1000; -} - /* * This function has been lifted from gui_w32.c and extended a bit. * diff --git a/src/gui_photon.c b/src/gui_photon.c index b987e9b8a8..9bce94ddfa 100644 --- a/src/gui_photon.c +++ b/src/gui_photon.c @@ -977,7 +977,7 @@ gui_ph_is_buffer_item(vimmenu_T *menu, vimmenu_T *parent) if (mark != NULL) { mark++; - while (isdigit(*mark)) + while (SAFE_isdigit(*mark)) mark++; if (*mark == ')') @@ -2545,7 +2545,7 @@ gui_mch_add_menu(vimmenu_T *menu, int index) if (menu->mnemonic != 0) { - PtAddHotkeyHandler(gui.vimWindow, tolower(menu->mnemonic), + PtAddHotkeyHandler(gui.vimWindow, SAFE_tolower(menu->mnemonic), Pk_KM_Alt, 0, menu, gui_ph_handle_pulldown_menu); } } @@ -2829,7 +2829,7 @@ gui_ph_parse_font_name( { while (*mark != NUL && *mark++ == ':') { - switch (tolower(*mark++)) + switch (SAFE_tolower(*mark++)) { case 'a': *font_flags |= PF_STYLE_ANTIALIAS; break; case 'b': *font_flags |= PF_STYLE_BOLD; break; diff --git a/src/gui_xim.c b/src/gui_xim.c index 88de7a4e98..c9b1c6cb4d 100644 --- a/src/gui_xim.c +++ b/src/gui_xim.c @@ -1471,7 +1471,7 @@ xim_real_init(Window x11_window, Display *x11_display) break; if ((ns = end = strchr(s, ',')) == NULL) end = s + strlen(s); - while (isspace(((char_u *)end)[-1])) + while (SAFE_isspace(end[-1])) end--; *end = NUL; @@ -1533,7 +1533,7 @@ xim_real_init(Window x11_window, Display *x11_display) strcpy(tmp, gui.rsrc_preedit_type_name); for (s = tmp; s && !found; ) { - while (*s && isspace((unsigned char)*s)) + while (*s && SAFE_isspace(*s)) s++; if (!*s) break; @@ -1541,7 +1541,7 @@ xim_real_init(Window x11_window, Display *x11_display) ns++; else end = s + strlen(s); - while (isspace((unsigned char)*end)) + while (SAFE_isspace(*end)) end--; *end = '\0'; diff --git a/src/hardcopy.c b/src/hardcopy.c index e91a7dc2d7..8abfff2107 100644 --- a/src/hardcopy.c +++ b/src/hardcopy.c @@ -1745,7 +1745,7 @@ prt_resfile_skip_nonws(int offset) idx = prt_resfile.line_start + offset; while (idx < prt_resfile.line_end) { - if (isspace(prt_resfile.buffer[idx])) + if (SAFE_isspace(prt_resfile.buffer[idx])) return idx - prt_resfile.line_start; idx++; } @@ -1760,7 +1760,7 @@ prt_resfile_skip_ws(int offset) idx = prt_resfile.line_start + offset; while (idx < prt_resfile.line_end) { - if (!isspace(prt_resfile.buffer[idx])) + if (!SAFE_isspace(prt_resfile.buffer[idx])) return idx - prt_resfile.line_start; idx++; } diff --git a/src/highlight.c b/src/highlight.c index 31c3280e85..318564c74b 100644 --- a/src/highlight.c +++ b/src/highlight.c @@ -2307,7 +2307,7 @@ gui_adjust_rgb(guicolor_T c) static int hex_digit(int c) { - if (isdigit(c)) + if (SAFE_isdigit(c)) return c - '0'; c = TOLOWER_ASC(c); if (c >= 'a' && c <= 'f') diff --git a/src/if_py_both.h b/src/if_py_both.h index f8438639e6..42db5101d8 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -3240,7 +3240,7 @@ FunctionNew(PyTypeObject *subtype, char_u *name, int argc, typval_T *argv, if (self == NULL) return NULL; - if (isdigit(*name)) + if (isdigit((unsigned char)*name)) { if (!translated_function_exists(name, FALSE)) { diff --git a/src/if_xcmdsrv.c b/src/if_xcmdsrv.c index d9408398d9..716665a7be 100644 --- a/src/if_xcmdsrv.c +++ b/src/if_xcmdsrv.c @@ -657,7 +657,7 @@ serverGetVimNames(Display *dpy) for (p = regProp; (long_u)(p - regProp) < numItems; p++) { entry = p; - while (*p != 0 && !isspace(*p)) + while (*p != 0 && !SAFE_isspace(*p)) p++; if (*p != 0) { @@ -928,7 +928,7 @@ LookupName( for (p = regProp; (long_u)(p - regProp) < numItems; ) { entry = p; - while (*p != 0 && !isspace(*p)) + while (*p != 0 && !SAFE_isspace(*p)) p++; if (*p != 0 && STRICMP(name, p + 1) == 0) { @@ -945,7 +945,7 @@ LookupName( for (p = regProp; (long_u)(p - regProp) < numItems; ) { entry = p; - while (*p != 0 && !isspace(*p)) + while (*p != 0 && !SAFE_isspace(*p)) p++; if (*p != 0 && IsSerialName(p + 1) && STRNICMP(name, p + 1, STRLEN(name)) == 0) diff --git a/src/macros.h b/src/macros.h index cc2d11fdd1..190778eca3 100644 --- a/src/macros.h +++ b/src/macros.h @@ -50,6 +50,28 @@ */ #define BUFEMPTY() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == NUL) +// The is*() and to*() functions declared in have +// undefined behavior for values other than EOF outside the range of +// unsigned char. If plain char is signed, a call with a negative +// value has undefined behavior. These macros cast the argument to +// unsigned char. (Most implementations behave more or less sanely +// with negative values, and most character values in practice are +// positive, but we want to avoid undefined behavior anyway.) +#define SAFE_isalnum(c) (isalnum ((unsigned char)(c))) +#define SAFE_isalpha(c) (isalpha ((unsigned char)(c))) +#define SAFE_isblank(c) (isblank ((unsigned char)(c))) +#define SAFE_iscntrl(c) (iscntrl ((unsigned char)(c))) +#define SAFE_isdigit(c) (isdigit ((unsigned char)(c))) +#define SAFE_isgraph(c) (isgraph ((unsigned char)(c))) +#define SAFE_islower(c) (islower ((unsigned char)(c))) +#define SAFE_isprint(c) (isprint ((unsigned char)(c))) +#define SAFE_ispunct(c) (ispunct ((unsigned char)(c))) +#define SAFE_isspace(c) (isspace ((unsigned char)(c))) +#define SAFE_isupper(c) (isupper ((unsigned char)(c))) +#define SAFE_isxdigit(c) (isxdigit((unsigned char)(c))) +#define SAFE_tolower(c) (tolower ((unsigned char)(c))) +#define SAFE_toupper(c) (toupper ((unsigned char)(c))) + /* * toupper() and tolower() that use the current locale. * On some systems toupper()/tolower() only work on lower/uppercase @@ -64,11 +86,11 @@ # define TOLOWER_LOC(c) tolower_tab[(c) & 255] #else # ifdef BROKEN_TOUPPER -# define TOUPPER_LOC(c) (islower(c) ? toupper(c) : (c)) -# define TOLOWER_LOC(c) (isupper(c) ? tolower(c) : (c)) +# define TOUPPER_LOC(c) (SAFE_islower(c) ? SAFE_toupper(c) : (c)) +# define TOLOWER_LOC(c) (SAFE_isupper(c) ? SAFE_tolower(c) : (c)) # else -# define TOUPPER_LOC toupper -# define TOLOWER_LOC tolower +# define TOUPPER_LOC SAFE_toupper +# define TOLOWER_LOC SAFE_tolower # endif #endif diff --git a/src/mbyte.c b/src/mbyte.c index 34592bd56c..ee2834cf42 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -4628,7 +4628,7 @@ enc_canonize(char_u *enc) } // "iso-8859n" -> "iso-8859-n" - if (STRNCMP(p, "iso-8859", 8) == 0 && isdigit(p[8])) + if (STRNCMP(p, "iso-8859", 8) == 0 && SAFE_isdigit(p[8])) { STRMOVE(p + 9, p + 8); p[8] = '-'; @@ -4705,7 +4705,7 @@ enc_locale_env(char *locale) if ((p = (char *)vim_strchr((char_u *)s, '.')) != NULL) { if (p > s + 2 && STRNICMP(p + 1, "EUC", 3) == 0 - && !isalnum((int)p[4]) && p[4] != '-' && p[-3] == '_') + && !SAFE_isalnum((int)p[4]) && p[4] != '-' && p[-3] == '_') { // copy "XY.EUC" to "euc-XY" to buf[10] STRCPY(buf + 10, "euc-"); @@ -4721,7 +4721,7 @@ enc_locale_env(char *locale) { if (s[i] == '_' || s[i] == '-') buf[i] = '-'; - else if (isalnum((int)s[i])) + else if (SAFE_isalnum(s[i])) buf[i] = TOLOWER_ASC(s[i]); else break; diff --git a/src/normal.c b/src/normal.c index 61a19c13a4..fd89b00fd4 100644 --- a/src/normal.c +++ b/src/normal.c @@ -4470,11 +4470,11 @@ nv_brackets(cmdarg_T *cap) return; find_pattern_in_path(ptr, 0, len, TRUE, - cap->count0 == 0 ? !isupper(cap->nchar) : FALSE, + cap->count0 == 0 ? !SAFE_isupper(cap->nchar) : FALSE, ((cap->nchar & 0xf) == ('d' & 0xf)) ? FIND_DEFINE : FIND_ANY, cap->count1, - isupper(cap->nchar) ? ACTION_SHOW_ALL : - islower(cap->nchar) ? ACTION_SHOW : ACTION_GOTO, + SAFE_isupper(cap->nchar) ? ACTION_SHOW_ALL : + SAFE_islower(cap->nchar) ? ACTION_SHOW : ACTION_GOTO, cap->cmdchar == ']' ? curwin->w_cursor.lnum + 1 : (linenr_T)1, (linenr_T)MAXLNUM); vim_free(ptr); @@ -5217,7 +5217,7 @@ v_visop(cmdarg_T *cap) // Uppercase means linewise, except in block mode, then "D" deletes till // the end of the line, and "C" replaces till EOL - if (isupper(cap->cmdchar)) + if (SAFE_isupper(cap->cmdchar)) { if (VIsual_mode != Ctrl_V) { diff --git a/src/ops.c b/src/ops.c index 46101a4359..f6d765bd71 100644 --- a/src/ops.c +++ b/src/ops.c @@ -2734,7 +2734,7 @@ do_addsub( { if (CharOrd(firstdigit) < Prenum1) { - if (isupper(firstdigit)) + if (SAFE_isupper(firstdigit)) firstdigit = 'A'; else firstdigit = 'a'; @@ -2746,7 +2746,7 @@ do_addsub( { if (26 - CharOrd(firstdigit) - 1 < Prenum1) { - if (isupper(firstdigit)) + if (SAFE_isupper(firstdigit)) firstdigit = 'Z'; else firstdigit = 'z'; @@ -2875,9 +2875,9 @@ do_addsub( save_pos = curwin->w_cursor; for (i = 0; i < todel; ++i) { - if (c < 0x100 && isalpha(c)) + if (c < 0x100 && SAFE_isalpha(c)) { - if (isupper(c)) + if (SAFE_isupper(c)) hexupper = TRUE; else hexupper = FALSE; diff --git a/src/option.c b/src/option.c index 4d12834f2e..7cac89e5cf 100644 --- a/src/option.c +++ b/src/option.c @@ -7697,7 +7697,7 @@ ExpandSettings( { for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) { - if (!isprint(str[0]) || !isprint(str[1])) + if (!SAFE_isprint(str[0]) || !SAFE_isprint(str[1])) continue; name_buf[0] = 't'; diff --git a/src/os_mswin.c b/src/os_mswin.c index 46f73752f9..21b7db31f3 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -675,7 +675,7 @@ display_errors(void) { // avoid putting up a message box with blanks only for (p = (char_u *)error_ga.ga_data; *p; ++p) - if (!isspace(*p)) + if (!SAFE_isspace(*p)) { // Only use a dialog when not using --gui-dialog-file: // write text to a file. @@ -759,7 +759,7 @@ mch_chdir(char *path) smsg("chdir(%s)", path); verbose_leave(); } - if (isalpha(path[0]) && path[1] == ':') // has a drive name + if (SAFE_isalpha(path[0]) && path[1] == ':') // has a drive name { // If we can change to the drive, skip that part of the path. If we // can't then the current directory may be invalid, try using chdir() @@ -1751,7 +1751,7 @@ is_reparse_point_included(LPCWSTR fname) WCHAR buf[MAX_PATH]; DWORD attr; - if (isalpha(p[0]) && p[1] == L':' && is_path_sep(p[2])) + if (SAFE_isalpha(p[0]) && p[1] == L':' && is_path_sep(p[2])) p += 3; else if (is_path_sep(p[0]) && is_path_sep(p[1])) p += 2; diff --git a/src/os_unix.c b/src/os_unix.c index 11448c5c62..af8f00604c 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -6171,7 +6171,7 @@ mch_signal_job(job_T *job, char_u *how) else if (STRCMP(how, "winch") == 0) sig = SIGWINCH; #endif - else if (isdigit(*how)) + else if (SAFE_isdigit(*how)) sig = atoi((char *)how); else return FAIL; diff --git a/src/os_win32.c b/src/os_win32.c index e5cfac7294..dbfc4eeca7 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -7443,7 +7443,7 @@ notsgr: { int l = 2; - if (isdigit(s[l])) + if (SAFE_isdigit(s[l])) l++; if (s[l] == ' ' && s[l + 1] == 'q') { diff --git a/src/spellfile.c b/src/spellfile.c index d3351ef23a..24df042b76 100644 --- a/src/spellfile.c +++ b/src/spellfile.c @@ -2890,7 +2890,7 @@ spell_read_aff(spellinfo_T *spin, char_u *fname) || is_aff_rule(items, itemcnt, "REPSAL", 2)) { // Ignore REP/REPSAL count - if (!isdigit(*items[1])) + if (!SAFE_isdigit(*items[1])) smsg(_("Expected REP(SAL) count in %s line %d"), fname, lnum); } @@ -2925,7 +2925,7 @@ spell_read_aff(spellinfo_T *spin, char_u *fname) { // First line contains the count. found_map = TRUE; - if (!isdigit(*items[1])) + if (!SAFE_isdigit(*items[1])) smsg(_("Expected MAP count in %s line %d"), fname, lnum); } diff --git a/src/tag.c b/src/tag.c index 8003156f0f..893415f699 100644 --- a/src/tag.c +++ b/src/tag.c @@ -1194,7 +1194,7 @@ add_llist_tags( // Get the line number or the search pattern used to locate // the tag. lnum = 0; - if (isdigit(*tagp.command)) + if (SAFE_isdigit(*tagp.command)) // Line number is used to locate the tag lnum = atol((char *)tagp.command); else diff --git a/src/term.c b/src/term.c index 0fdb33e6d7..dd59fdf65d 100644 --- a/src/term.c +++ b/src/term.c @@ -3434,7 +3434,7 @@ ttest(int pairs) #endif { env_colors = mch_getenv((char_u *)"COLORS"); - if (env_colors != NULL && isdigit(*env_colors)) + if (env_colors != NULL && SAFE_isdigit(*env_colors)) { int colors = atoi((char *)env_colors); @@ -5849,7 +5849,7 @@ handle_dcs(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen) // characters. for (i = j + 3; i < len; ++i) { - if (i - j == 3 && !isdigit(tp[i])) + if (i - j == 3 && !SAFE_isdigit(tp[i])) break; if (i - j == 4 && tp[i] != ' ') break; @@ -6083,7 +6083,7 @@ check_termcode( // The mouse termcode "ESC [" is also the prefix of // "ESC [ I" (focus gained) and other keys. Check some // more bytes to find out. - if (!isdigit(tp[2])) + if (!SAFE_isdigit(tp[2])) { // ESC [ without number following: Only use it when // there is no other match. @@ -6166,7 +6166,7 @@ check_termcode( // Skip over the digits, the final char must // follow. URXVT can use a negative value, thus // also accept '-'. - for (j = slen - 2; j < len && (isdigit(tp[j]) + for (j = slen - 2; j < len && (SAFE_isdigit(tp[j]) || tp[j] == '-' || tp[j] == ';'); ++j) ; ++j; diff --git a/src/terminal.c b/src/terminal.c index f79d102e8c..a641a850b0 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -853,13 +853,13 @@ ex_terminal(exarg_T *eap) else opt.jo_term_api = NULL; } - else if (OPTARG_HAS("rows") && ep != NULL && isdigit(ep[1])) + else if (OPTARG_HAS("rows") && ep != NULL && SAFE_isdigit(ep[1])) { opt.jo_set2 |= JO2_TERM_ROWS; opt.jo_term_rows = atoi((char *)ep + 1); p = skiptowhite(cmd); } - else if (OPTARG_HAS("cols") && ep != NULL && isdigit(ep[1])) + else if (OPTARG_HAS("cols") && ep != NULL && SAFE_isdigit(ep[1])) { opt.jo_set2 |= JO2_TERM_COLS; opt.jo_term_cols = atoi((char *)ep + 1); @@ -5463,11 +5463,11 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos) // use same attr as previous cell c = fgetc(fd); } - else if (isdigit(c)) + else if (SAFE_isdigit(c)) { // get the decimal attribute attr = 0; - while (isdigit(c)) + while (SAFE_isdigit(c)) { attr = attr * 10 + (c - '0'); c = fgetc(fd); @@ -5499,9 +5499,9 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos) c = fgetc(fd); blue = (blue << 4) + hex2nr(c); c = fgetc(fd); - if (!isdigit(c)) + if (!SAFE_isdigit(c)) dump_is_corrupt(&ga_text); - while (isdigit(c)) + while (SAFE_isdigit(c)) { index = index * 10 + (c - '0'); c = fgetc(fd); @@ -5565,7 +5565,7 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos) for (;;) { c = fgetc(fd); - if (!isdigit(c)) + if (!SAFE_isdigit(c)) break; count = count * 10 + (c - '0'); } diff --git a/src/typval.c b/src/typval.c index 35c9e24eb8..af96b3170b 100644 --- a/src/typval.c +++ b/src/typval.c @@ -2425,7 +2425,7 @@ eval_string(char_u **arg, typval_T *rettv, int evaluate, int interpolate) if (vim_isxdigit(p[1])) { int n, nr; - int c = toupper(*p); + int c = SAFE_toupper(*p); if (c == 'X') n = 2; diff --git a/src/uninstall.c b/src/uninstall.c index 78b2b7d3cf..907ed37976 100644 --- a/src/uninstall.c +++ b/src/uninstall.c @@ -29,7 +29,7 @@ confirm(void) char answer[10]; fflush(stdout); - return (scanf(" %c", answer) == 1 && toupper(answer[0]) == 'Y'); + return (scanf(" %c", answer) == 1 && toupper((unsigned char)answer[0]) == 'Y'); } static int diff --git a/src/userfunc.c b/src/userfunc.c index c0a2487b46..64761ecdb7 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -77,7 +77,7 @@ one_function_arg( while (ASCII_ISALNUM(*p) || *p == '_') ++p; - if (arg == p || isdigit(*arg) + if (arg == p || SAFE_isdigit(*arg) || (argtypes == NULL && ((p - arg == 9 && STRNCMP(arg, "firstline", 9) == 0) || (p - arg == 8 && STRNCMP(arg, "lastline", 8) == 0)))) @@ -2272,7 +2272,7 @@ func_requires_g_prefix(ufunc_T *ufunc) return ufunc->uf_name[0] != K_SPECIAL && (ufunc->uf_flags & FC_LAMBDA) == 0 && vim_strchr(ufunc->uf_name, AUTOLOAD_CHAR) == NULL - && !isdigit(ufunc->uf_name[0]); + && !SAFE_isdigit(ufunc->uf_name[0]); } /* @@ -2448,8 +2448,8 @@ cleanup_function_call(funccall_T *fc) static int numbered_function(char_u *name) { - return isdigit(*name) - || (name[0] == 'g' && name[1] == ':' && isdigit(name[2])); + return SAFE_isdigit(*name) + || (name[0] == 'g' && name[1] == ':' && SAFE_isdigit(name[2])); } /* @@ -4653,7 +4653,7 @@ list_functions(regmatch_T *regmatch) && (regmatch == NULL ? !message_filtered(fp->uf_name) && !func_name_refcount(fp->uf_name) - : !isdigit(*fp->uf_name) + : !SAFE_isdigit(*fp->uf_name) && vim_regexec(regmatch, fp->uf_name, 0))) { if (list_func_head(fp, FALSE) == FAIL) diff --git a/src/version.c b/src/version.c index 42d58897e5..3dc537d180 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 6, /**/ 5, /**/ @@ -1328,9 +1330,9 @@ do_intro_line( if (highest_patch()) { // Check for 9.9x or 9.9xx, alpha/beta version - if (isalpha((int)vers[3])) + if (SAFE_isalpha((int)vers[3])) { - int len = (isalpha((int)vers[4])) ? 5 : 4; + int len = (SAFE_isalpha((int)vers[4])) ? 5 : 4; sprintf((char *)vers + len, ".%d%s", highest_patch(), mediumVersion + len); } diff --git a/src/vim9compile.c b/src/vim9compile.c index ad1f6b4aa8..d6faa7bb97 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -3159,7 +3159,7 @@ get_cmd_count(char_u *line, exarg_T *eap) // skip over colons and white space for (p = line; *p == ':' || VIM_ISWHITE(*p); ++p) ; - if (!isdigit(*p)) + if (!SAFE_isdigit(*p)) { // The command or modifiers must be following. Assume a lower case // character means there is a modifier. diff --git a/src/vim9expr.c b/src/vim9expr.c index 31fa824a7b..38a65d4424 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -1950,7 +1950,7 @@ get_compare_type(char_u *p, int *len, int *type_is) if (p[2] == 'n' && p[3] == 'o' && p[4] == 't') *len = 5; i = p[*len]; - if (!isalnum(i) && i != '_') + if (!SAFE_isalnum(i) && i != '_') { type = *len == 2 ? EXPR_IS : EXPR_ISNOT; *type_is = TRUE; diff --git a/src/viminfo.c b/src/viminfo.c index 58bf419194..540422c8ca 100644 --- a/src/viminfo.c +++ b/src/viminfo.c @@ -1068,7 +1068,7 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values) } } - if (isdigit(*p)) + if (SAFE_isdigit(*p)) { value->bv_type = BVAL_NR; value->bv_nr = getdigits(&p); @@ -2485,7 +2485,7 @@ read_viminfo_filemark(vir_T *virp, int force) str = virp->vir_line + 1; if (*str <= 127 && ((*virp->vir_line == '\'' - && (VIM_ISDIGIT(*str) || isupper(*str))) + && (VIM_ISDIGIT(*str) || SAFE_isupper(*str))) || (*virp->vir_line == '-' && *str == '\''))) { if (*str == '\'') diff --git a/src/xxd/xxd.c b/src/xxd/xxd.c index c90bc027e8..26f8d8365d 100644 --- a/src/xxd/xxd.c +++ b/src/xxd/xxd.c @@ -96,8 +96,8 @@ # include #endif #include -#include /* for strncmp() */ -#include /* for isalnum() */ +#include +#include #include #if __MWERKS__ && !defined(BEBOX) # include /* for fdopen() on MAC */ @@ -208,7 +208,7 @@ char hexxa[] = "0123456789abcdef0123456789ABCDEF", *hexx = hexxa; #define HEX_BITS 3 /* not hex a dump, but bits: 01111001 */ #define HEX_LITTLEENDIAN 4 -#define CONDITIONAL_CAPITALIZE(c) (capitalize ? toupper((int)c) : c) +#define CONDITIONAL_CAPITALIZE(c) (capitalize ? toupper((unsigned char)(c)) : (c)) #define COLOR_PROLOGUE \ l[c++] = '\033'; \ @@ -952,9 +952,9 @@ main(int argc, char *argv[]) if (varname != NULL) { - FPRINTF_OR_DIE((fpo, "unsigned char %s", isdigit((int)varname[0]) ? "__" : "")); + FPRINTF_OR_DIE((fpo, "unsigned char %s", isdigit((unsigned char)varname[0]) ? "__" : "")); for (e = 0; (c = varname[e]) != 0; e++) - putc_or_die(isalnum(c) ? CONDITIONAL_CAPITALIZE(c) : '_', fpo); + putc_or_die(isalnum((unsigned char)c) ? CONDITIONAL_CAPITALIZE(c) : '_', fpo); fputs_or_die("[] = {\n", fpo); } @@ -972,9 +972,9 @@ main(int argc, char *argv[]) if (varname != NULL) { fputs_or_die("};\n", fpo); - FPRINTF_OR_DIE((fpo, "unsigned int %s", isdigit((int)varname[0]) ? "__" : "")); + FPRINTF_OR_DIE((fpo, "unsigned int %s", isdigit((unsigned char)varname[0]) ? "__" : "")); for (e = 0; (c = varname[e]) != 0; e++) - putc_or_die(isalnum(c) ? CONDITIONAL_CAPITALIZE(c) : '_', fpo); + putc_or_die(isalnum((unsigned char)c) ? CONDITIONAL_CAPITALIZE(c) : '_', fpo); FPRINTF_OR_DIE((fpo, "_%s = %d;\n", capitalize ? "LEN" : "len", p)); } From ad4d7f446dc6754bde212234d46f4849b520b6e0 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Thu, 4 Jan 2024 21:43:36 +0100 Subject: [PATCH 012/143] patch 9.1.0007: can select empty inner text blocks Problem: can select empty inner text blocks (laurentalacoque) Solution: make selecting empty inner text blocks an error textobjects: Make selecting inner empty blocks an error fixes: #13514 closes: #13523 Signed-off-by: Christian Brabandt --- runtime/doc/motion.txt | 14 ++-- src/testdir/test_textobjects.vim | 114 ++++++++++++++++++++++++++++++- src/textobject.c | 5 ++ src/version.c | 2 + 4 files changed, 127 insertions(+), 8 deletions(-) diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt index 448b68bce5..8c07fbf53e 100644 --- a/runtime/doc/motion.txt +++ b/runtime/doc/motion.txt @@ -600,7 +600,8 @@ i] *v_i]* *v_i[* *i]* *i[* i[ "inner [] block", select [count] '[' ']' blocks. This goes backwards to the [count] unclosed '[', and finds the matching ']'. The enclosed text is selected, - excluding the '[' and ']'. The |cpo-M| option flag + excluding the '[' and ']'. It's an error to select an + empty inner block like "[]". The |cpo-M| option flag is used to handle escaped brackets. When used in Visual mode it is made characterwise. @@ -618,7 +619,8 @@ i( *vib* *v_ib* *v_i(* *ib* ib "inner block", select [count] blocks, from "[count] [(" to the matching ')', excluding the '(' and ')' (see |[(|). If the cursor is not inside a () block, then - find the next "(". The |cpo-M| option flag + find the next "(". It's an error to select an empty + inner block like "()". The |cpo-M| option flag is used to handle escaped parenthesis. When used in Visual mode it is made characterwise. @@ -632,8 +634,9 @@ a< "a <> block", select [count] <> blocks, from the i> *v_i>* *v_i<* *i>* *i<* i< "inner <> block", select [count] <> blocks, from the [count]'th unmatched '<' backwards to the matching - '>', excluding the '<' and '>'. The |cpo-M| option flag - is used to handle escaped '<' and '>'. + '>', excluding the '<' and '>'. It's an error to + select an empty inner block like "<>". The |cpo-M| + option flag is used to handle escaped '<' and '>'. When used in Visual mode it is made characterwise. *v_at* *at* @@ -663,7 +666,8 @@ i} *v_i}* *i}* *i{* i{ *v_iB* *v_i{* *iB* iB "inner Block", select [count] Blocks, from "[count] [{" to the matching '}', excluding the '{' and '}' (see - |[{|). The |cpo-M| option flag is used to handle + |[{|). It's an error to select an empty inner block + like "{}". The |cpo-M| option flag is used to handle escaped braces. When used in Visual mode it is made characterwise. diff --git a/src/testdir/test_textobjects.vim b/src/testdir/test_textobjects.vim index 746b3268b2..89e741c715 100644 --- a/src/testdir/test_textobjects.vim +++ b/src/testdir/test_textobjects.vim @@ -400,7 +400,7 @@ func Test_paragraph() call assert_beeps("normal Vipip") exe "normal \" - close! + bw! endfunc " Tests for text object aw @@ -606,7 +606,7 @@ func Test_textobj_quote() normal $hhyi" call assert_equal('bar', @") - close! + bw! endfunc " Test for i(, i<, etc. when cursor is in front of a block @@ -638,7 +638,115 @@ func Test_textobj_find_paren_forward() normal 0di) call assert_equal('foo ()', getline(1)) - close! + bw! +endfunc + +func Test_inner_block_empty_paren() + new + call setline(1, ["(text)()", "", "(text)(", ")", "", "()()"]) + + " Example 1 + call cursor(1, 1) + let @" = '' + call assert_beeps(':call feedkeys("0f(viby","xt")') + call assert_equal(7, getpos('.')[2]) + call assert_equal('(', @") + + " Example 2 + call cursor(3, 1) + let @" = '' + call assert_beeps('call feedkeys("0f(viby", "xt")') + call assert_equal(7, getpos('.')[2]) + call assert_equal('(', @") + + " Example 3 + call cursor(6, 1) + let @" = '' + call assert_beeps('call feedkeys("0f(viby", "xt")') + call assert_equal(3, getpos('.')[2]) + call assert_equal('(', @") + bwipe! +endfunc + +func Test_inner_block_empty_bracket() + new + call setline(1, ["[text][]", "", "[text][", "]", "", "[][]"]) + + " Example 1 + call cursor(1, 1) + let @" = '' + call assert_beeps(':call feedkeys("0f[viby","xt")') + call assert_equal(7, getpos('.')[2]) + call assert_equal('[', @") + + " Example 2 + call cursor(3, 1) + let @" = '' + call assert_beeps('call feedkeys("0f[viby", "xt")') + call assert_equal(7, getpos('.')[2]) + call assert_equal('[', @") + + " Example 3 + call cursor(6, 1) + let @" = '' + call assert_beeps('call feedkeys("0f[viby", "xt")') + call assert_equal(3, getpos('.')[2]) + call assert_equal('[', @") + bwipe! +endfunc + +func Test_inner_block_empty_brace() + new + call setline(1, ["{text}{}", "", "{text}{", "}", "", "{}{}"]) + + " Example 1 + call cursor(1, 1) + let @" = '' + call assert_beeps(':call feedkeys("0f{viby","xt")') + call assert_equal(7, getpos('.')[2]) + call assert_equal('{', @") + + " Example 2 + call cursor(3, 1) + let @" = '' + call assert_beeps('call feedkeys("0f{viby", "xt")') + call assert_equal(7, getpos('.')[2]) + call assert_equal('{', @") + + " Example 3 + call cursor(6, 1) + let @" = '' + call assert_beeps('call feedkeys("0f{viby", "xt")') + call assert_equal(3, getpos('.')[2]) + call assert_equal('{', @") + bwipe! +endfunc + +func Test_inner_block_empty_lessthan() + new + call setline(1, ["<>", "", "<", ">", "", "<><>"]) + + " Example 1 + call cursor(1, 1) + let @" = '' + call assert_beeps(':call feedkeys("0f Date: Thu, 4 Jan 2024 22:14:28 +0100 Subject: [PATCH 013/143] patch 9.1.0008: NSIS installer includes syntax testdir Problem: NSIS installer includes syntax test dumps (Yegappan Lakshmanan) Solution: Exclude syntax/testdir when creating the NSIS installer fixes: vim/vim-win32-installer#328 closes: #13814 Signed-off-by: Christian Brabandt --- nsis/gvim.nsi | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nsis/gvim.nsi b/nsis/gvim.nsi index 3a6dc29856..adb38a4a11 100644 --- a/nsis/gvim.nsi +++ b/nsis/gvim.nsi @@ -416,7 +416,7 @@ Section "$(str_section_exe)" id_section_exe File ${VIMSRC}\vim.ico SetOutPath $0\syntax - File /r ${VIMRT}\syntax\*.* + File /r /x testdir ${VIMRT}\syntax\*.* SetOutPath $0\spell File ${VIMRT}\spell\*.txt diff --git a/src/version.c b/src/version.c index d00e80276c..3839d9c359 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 8, /**/ 7, /**/ From f93b1c881a99fa847a1bafa71877d7e16f18e6ef Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Thu, 4 Jan 2024 22:28:46 +0100 Subject: [PATCH 014/143] patch 9.1.0009: Cannot easily get the list of matches Problem: Cannot easily get the list of matches Solution: Add the matchstrlist() and matchbufline() Vim script functions (Yegappan Lakshmanan) closes: #13766 Signed-off-by: Yegappan Lakshmanan Signed-off-by: Christian Brabandt --- runtime/doc/builtin.txt | 83 +++++++++++ runtime/doc/tags | 2 + runtime/doc/usr_41.txt | 3 + src/errors.h | 4 +- src/evalfunc.c | 264 +++++++++++++++++++++++++++++++++ src/testdir/test_functions.vim | 186 +++++++++++++++++++++++ src/version.c | 2 + 7 files changed, 543 insertions(+), 1 deletion(-) diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 084c76edfb..8f79d2001d 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -370,6 +370,8 @@ matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]]) matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) Number highlight positions with {group} matcharg({nr}) List arguments of |:match| +matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}) + List all the {pat} matches in buffer {buf} matchdelete({id} [, {win}]) Number delete match identified by {id} matchend({expr}, {pat} [, {start} [, {count}]]) Number position where {pat} ends in {expr} @@ -381,6 +383,8 @@ matchlist({expr}, {pat} [, {start} [, {count}]]) List match and submatches of {pat} in {expr} matchstr({expr}, {pat} [, {start} [, {count}]]) String {count}'th match of {pat} in {expr} +matchstrlist({list}, {pat} [, {dict}) + List all the {pat} matches in {list} matchstrpos({expr}, {pat} [, {start} [, {count}]]) List {count}'th match of {pat} in {expr} max({expr}) Number maximum value of items in {expr} @@ -6054,6 +6058,51 @@ matcharg({nr}) *matcharg()* Can also be used as a |method|: > GetMatch()->matcharg() +< + *matchbufline()* +matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}]) + Returns the |List| of matches in lines from {lnum} to {end} in + buffer {buf} where {pat} matches. + + {lnum} and {end} can either be a line number or the string "$" + to refer to the last line in {buf}. + + The {dict} argument supports following items: + submatches include submatch information (|/\(|) + + For each match, a |Dict| with the following items is returned: + byteidx starting byte index of the match +    lnum line number where there is a match +    text matched string + Note that there can be multiple matches in a single line. + + This function works only for loaded buffers. First call + |bufload()| if needed. + + When {buf} is not a valid buffer, the buffer is not loaded or + {lnum} or {end} is not valid then an error is given and an + empty |List| is returned. + + Examples: > +    " Assuming line 3 in buffer 5 contains "a" +    :echo matchbufline(5, '\<\k\+\>', 3, 3) +    [{'lnum': 3, 'byteidx': 0, 'text': 'a'}] +    " Assuming line 4 in buffer 10 contains "tik tok" +    :echo matchbufline(10, '\<\k\+\>', 1, 4) +    [{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}] +< + If {submatch} is present and is v:true, then submatches like + "\1", "\2", etc. are also returned.  Example: > +    " Assuming line 2 in buffer 2 contains "acd" +    :echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2 + \ {'submatches': v:true}) +    [{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}] +< The "submatches" List always contains 9 items. If a submatch + is not found, then an empty string is returned for that + submatch. + + Can also be used as a |method|: > + GetBuffer()->matchbufline('mypat', 1, '$') matchdelete({id} [, {win}) *matchdelete()* *E802* *E803* Deletes a match with ID {id} previously defined by |matchadd()| @@ -6187,6 +6236,40 @@ matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()* Can also be used as a |method|: > GetText()->matchlist('word') +< + *matchstrlist()* +matchstrlist({list}, {pat} [, {dict}]) + Returns the |List| of matches in {list} where {pat} matches. + {list} is a |List| of strings. {pat} is matched against each + string in {list}. + + The {dict} argument supports following items: + submatches include submatch information (|/\(|) + + For each match, a |Dict| with the following items is returned: + byteidx starting byte index of the match. + idx index in {list} of the match. + text matched string + submatches a List of submatches. Present only if + "submatches" is set to v:true in {dict}. + + Example: > +    :echo matchstrlist(['tik tok'], '\<\k\+\>') +    [{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}] +    :echo matchstrlist(['a', 'b'], '\<\k\+\>') +    [{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}] +< + If "submatches" is present and is v:true, then submatches like + "\1", "\2", etc. are also returned. Example: > + :echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)', + \ #{submatches: v:true}) + [{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}] +< The "submatches" List always contains 9 items. If a submatch + is not found, then an empty string is returned for that + submatch. + + Can also be used as a |method|: > + GetListOfStrings()->matchstrlist('mypat') matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()* Same as |match()|, but return the matched string. Example: > diff --git a/runtime/doc/tags b/runtime/doc/tags index e8ac2bc191..9af1ac0f64 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -8594,6 +8594,7 @@ match-parens tips.txt /*match-parens* matchadd() builtin.txt /*matchadd()* matchaddpos() builtin.txt /*matchaddpos()* matcharg() builtin.txt /*matcharg()* +matchbufline() builtin.txt /*matchbufline()* matchdelete() builtin.txt /*matchdelete()* matchend() builtin.txt /*matchend()* matchfuzzy() builtin.txt /*matchfuzzy()* @@ -8602,6 +8603,7 @@ matchit-install usr_05.txt /*matchit-install* matchlist() builtin.txt /*matchlist()* matchparen pi_paren.txt /*matchparen* matchstr() builtin.txt /*matchstr()* +matchstrlist() builtin.txt /*matchstrlist()* matchstrpos() builtin.txt /*matchstrpos()* matlab-indent indent.txt /*matlab-indent* matlab-indenting indent.txt /*matlab-indenting* diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index c4f2a8c4b8..2286d48516 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -743,10 +743,13 @@ String manipulation: *string-functions* toupper() turn a string to uppercase charclass() class of a character match() position where a pattern matches in a string + matchbufline() all the matches of a pattern in a buffer matchend() position where a pattern match ends in a string matchfuzzy() fuzzy matches a string in a list of strings matchfuzzypos() fuzzy matches a string in a list of strings matchstr() match of a pattern in a string + matchstrlist() all the matches of a pattern in a List of + strings matchstrpos() match and positions of a pattern in a string matchlist() like matchstr() and also return submatches stridx() first index of a short string in a long string diff --git a/src/errors.h b/src/errors.h index 828e8de249..dfb6ce644d 100644 --- a/src/errors.h +++ b/src/errors.h @@ -1749,9 +1749,11 @@ EXTERN char e_recursive_loop_loading_syncolor_vim[] #endif EXTERN char e_buffer_nr_invalid_buffer_number[] INIT(= N_("E680: : invalid buffer number")); -#ifdef FEAT_QUICKFIX +#if defined(FEAT_QUICKFIX) || defined(FEAT_EVAL) EXTERN char e_buffer_is_not_loaded[] INIT(= N_("E681: Buffer is not loaded")); +#endif +#ifdef FEAT_QUICKFIX EXTERN char e_invalid_search_pattern_or_delimiter[] INIT(= N_("E682: Invalid search pattern or delimiter")); EXTERN char e_file_name_missing_or_invalid_pattern[] diff --git a/src/evalfunc.c b/src/evalfunc.c index 513ddccdbe..e37b3a412a 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -100,9 +100,11 @@ static void f_line2byte(typval_T *argvars, typval_T *rettv); static void f_luaeval(typval_T *argvars, typval_T *rettv); #endif static void f_match(typval_T *argvars, typval_T *rettv); +static void f_matchbufline(typval_T *argvars, typval_T *rettv); static void f_matchend(typval_T *argvars, typval_T *rettv); static void f_matchlist(typval_T *argvars, typval_T *rettv); static void f_matchstr(typval_T *argvars, typval_T *rettv); +static void f_matchstrlist(typval_T *argvars, typval_T *rettv); static void f_matchstrpos(typval_T *argvars, typval_T *rettv); static void f_max(typval_T *argvars, typval_T *rettv); static void f_min(typval_T *argvars, typval_T *rettv); @@ -1176,6 +1178,8 @@ static argcheck_T arg2_map[] = {arg_list_or_dict_or_blob_or_string_mod, arg_map_ static argcheck_T arg2_mapnew[] = {arg_list_or_dict_or_blob_or_string, arg_any}; static argcheck_T arg25_matchadd[] = {arg_string, arg_string, arg_number, arg_number, arg_dict_any}; static argcheck_T arg25_matchaddpos[] = {arg_string, arg_list_any, arg_number, arg_number, arg_dict_any}; +static argcheck_T arg23_matchstrlist[] = {arg_list_string, arg_string, arg_dict_any}; +static argcheck_T arg45_matchbufline[] = {arg_buffer, arg_string, arg_lnum, arg_lnum, arg_dict_any}; static argcheck_T arg119_printf[] = {arg_string_or_nr, arg_any, arg_any, arg_any, arg_any, arg_any, arg_any, arg_any, arg_any, arg_any, arg_any, arg_any, arg_any, arg_any, arg_any, arg_any, arg_any, arg_any, arg_any}; static argcheck_T arg23_reduce[] = {arg_string_list_or_blob, arg_any, arg_any}; static argcheck_T arg24_remote_expr[] = {arg_string, arg_string, arg_string, arg_number}; @@ -2285,6 +2289,8 @@ static funcentry_T global_functions[] = ret_number, f_matchaddpos}, {"matcharg", 1, 1, FEARG_1, arg1_number, ret_list_string, f_matcharg}, + {"matchbufline", 4, 5, FEARG_1, arg45_matchbufline, + ret_list_any, f_matchbufline}, {"matchdelete", 1, 2, FEARG_1, arg2_number, ret_number_bool, f_matchdelete}, {"matchend", 2, 4, FEARG_1, arg24_match_func, @@ -2297,6 +2303,8 @@ static funcentry_T global_functions[] = ret_list_string, f_matchlist}, {"matchstr", 2, 4, FEARG_1, arg24_match_func, ret_string, f_matchstr}, + {"matchstrlist", 2, 3, FEARG_1, arg23_matchstrlist, + ret_list_any, f_matchstrlist}, {"matchstrpos", 2, 4, FEARG_1, arg24_match_func, ret_list_any, f_matchstrpos}, {"max", 1, 1, FEARG_1, arg1_list_or_dict, @@ -8023,6 +8031,183 @@ theend: p_cpo = save_cpo; } +/* + * Return all the matches in string "str" for pattern "rmp". + * The matches are returned in the List "mlist". + * If "submatches" is TRUE, then submatch information is also returned. + * "matchbuf" is TRUE when called for matchbufline(). + */ + static int +get_matches_in_str( + char_u *str, + regmatch_T *rmp, + list_T *mlist, + int idx, + int submatches, + int matchbuf) +{ + long len = (long)STRLEN(str); + int match = 0; + colnr_T startidx = 0; + + for (;;) + { + match = vim_regexec_nl(rmp, str, startidx); + if (!match) + break; + + dict_T *d = dict_alloc(); + if (d == NULL) + return FAIL; + if (list_append_dict(mlist, d) == FAIL) + return FAIL;; + + if (dict_add_number(d, matchbuf ? "lnum" : "idx", idx) == FAIL) + return FAIL; + + if (dict_add_number(d, "byteidx", + (colnr_T)(rmp->startp[0] - str)) == FAIL) + return FAIL; + + if (dict_add_string_len(d, "text", rmp->startp[0], + (int)(rmp->endp[0] - rmp->startp[0])) == FAIL) + return FAIL; + + if (submatches) + { + list_T *sml = list_alloc(); + if (sml == NULL) + return FAIL; + + if (dict_add_list(d, "submatches", sml) == FAIL) + return FAIL; + + // return a list with the submatches + for (int i = 1; i < NSUBEXP; ++i) + { + if (rmp->endp[i] == NULL) + { + if (list_append_string(sml, (char_u *)"", 0) == FAIL) + return FAIL; + } + else if (list_append_string(sml, rmp->startp[i], + (int)(rmp->endp[i] - rmp->startp[i])) == FAIL) + return FAIL; + } + } + startidx = (colnr_T)(rmp->endp[0] - str); + if (startidx >= (colnr_T)len || str + startidx <= rmp->startp[0]) + break; + } + + return OK; +} + +/* + * "matchbufline()" function + */ + static void +f_matchbufline(typval_T *argvars, typval_T *rettv) +{ + list_T *retlist = NULL; + char_u *save_cpo; + char_u patbuf[NUMBUFLEN]; + regmatch_T regmatch; + + rettv->vval.v_number = -1; + if (rettv_list_alloc(rettv) != OK) + return; + retlist = rettv->vval.v_list; + + if (check_for_buffer_arg(argvars, 0) == FAIL + || check_for_string_arg(argvars, 1) == FAIL + || check_for_lnum_arg(argvars, 2) == FAIL + || check_for_lnum_arg(argvars, 3) == FAIL + || check_for_opt_dict_arg(argvars, 4) == FAIL) + return; + + int prev_did_emsg = did_emsg; + buf_T *buf = tv_get_buf(&argvars[0], FALSE); + if (buf == NULL) + { + if (did_emsg == prev_did_emsg) + semsg(_(e_invalid_buffer_name_str), tv_get_string(&argvars[0])); + return; + } + if (buf->b_ml.ml_mfp == NULL) + { + emsg(_(e_buffer_is_not_loaded)); + return; + } + + char_u *pat = tv_get_string_buf(&argvars[1], patbuf); + + int did_emsg_before = did_emsg; + linenr_T slnum = tv_get_lnum_buf(&argvars[2], buf); + if (did_emsg > did_emsg_before) + return; + if (slnum < 1) + { + semsg(_(e_invalid_value_for_argument_str), "lnum"); + return; + } + + linenr_T elnum = tv_get_lnum_buf(&argvars[3], buf); + if (did_emsg > did_emsg_before) + return; + if (elnum < 1 || elnum < slnum) + { + semsg(_(e_invalid_value_for_argument_str), "end_lnum"); + return; + } + + if (elnum > buf->b_ml.ml_line_count) + elnum = buf->b_ml.ml_line_count; + + int submatches = FALSE; + if (argvars[4].v_type != VAR_UNKNOWN) + { + dict_T *d = argvars[4].vval.v_dict; + if (d != NULL) + { + dictitem_T *di = dict_find(d, (char_u *)"submatches", -1); + if (di != NULL) + { + if (di->di_tv.v_type != VAR_BOOL) + { + semsg(_(e_invalid_value_for_argument_str), "submatches"); + return; + } + submatches = tv_get_bool(&di->di_tv); + } + } + } + + // Make 'cpoptions' empty, the 'l' flag should not be used here. + save_cpo = p_cpo; + p_cpo = empty_option; + + regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); + if (regmatch.regprog == NULL) + goto theend; + regmatch.rm_ic = p_ic; + + while (slnum <= elnum) + { + char_u *str = ml_get_buf(buf, slnum, FALSE); + if (get_matches_in_str(str, ®match, retlist, slnum, submatches, + TRUE) == FAIL) + goto cleanup; + slnum++; + } + +cleanup: + vim_regfree(regmatch.regprog); + +theend: + p_cpo = save_cpo; +} + /* * "match()" function */ @@ -8059,6 +8244,85 @@ f_matchstr(typval_T *argvars, typval_T *rettv) find_some_match(argvars, rettv, MATCH_STR); } +/* + * "matchstrlist()" function + */ + static void +f_matchstrlist(typval_T *argvars, typval_T *rettv) +{ + list_T *retlist = NULL; + char_u *save_cpo; + list_T *l = NULL; + listitem_T *li = NULL; + char_u patbuf[NUMBUFLEN]; + regmatch_T regmatch; + + rettv->vval.v_number = -1; + if (rettv_list_alloc(rettv) != OK) + return; + retlist = rettv->vval.v_list; + + if (check_for_list_arg(argvars, 0) == FAIL + || check_for_string_arg(argvars, 1) == FAIL + || check_for_opt_dict_arg(argvars, 2) == FAIL) + return; + + if ((l = argvars[0].vval.v_list) == NULL) + return; + + char_u *pat = tv_get_string_buf_chk(&argvars[1], patbuf); + if (pat == NULL) + return; + + // Make 'cpoptions' empty, the 'l' flag should not be used here. + save_cpo = p_cpo; + p_cpo = empty_option; + + regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); + if (regmatch.regprog == NULL) + goto theend; + regmatch.rm_ic = p_ic; + + int submatches = FALSE; + if (argvars[2].v_type != VAR_UNKNOWN) + { + dict_T *d = argvars[2].vval.v_dict; + if (d != NULL) + { + dictitem_T *di = dict_find(d, (char_u *)"submatches", -1); + if (di != NULL) + { + if (di->di_tv.v_type != VAR_BOOL) + { + semsg(_(e_invalid_value_for_argument_str), "submatches"); + goto cleanup; + } + submatches = tv_get_bool(&di->di_tv); + } + } + } + + int idx = 0; + CHECK_LIST_MATERIALIZE(l); + FOR_ALL_LIST_ITEMS(l, li) + { + if (li->li_tv.v_type == VAR_STRING && li->li_tv.vval.v_string != NULL) + { + char_u *str = li->li_tv.vval.v_string; + if (get_matches_in_str(str, ®match, retlist, idx, submatches, + FALSE) == FAIL) + goto cleanup; + } + idx++; + } + +cleanup: + vim_regfree(regmatch.regprog); + +theend: + p_cpo = save_cpo; +} + /* * "matchstrpos()" function */ diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index 7bfe7fa750..85ccc78b8f 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -1172,6 +1172,192 @@ func Test_matchstrpos() call assert_equal(['', -1, -1], matchstrpos(test_null_list(), '\a')) endfunc +" Test for matchstrlist() +func Test_matchstrlist() + let lines =<< trim END + #" Basic match + call assert_equal([{'idx': 0, 'byteidx': 1, 'text': 'bout'}, + \ {'idx': 1, 'byteidx': 1, 'text': 'bove'}], + \ matchstrlist(['about', 'above'], 'bo.*')) + #" no match + call assert_equal([], matchstrlist(['about', 'above'], 'xy.*')) + #" empty string + call assert_equal([], matchstrlist([''], '.')) + #" empty pattern + call assert_equal([{'idx': 0, 'byteidx': 0, 'text': ''}], matchstrlist(['abc'], '')) + #" method call + call assert_equal([{'idx': 0, 'byteidx': 2, 'text': 'it'}], ['editor']->matchstrlist('ed\zsit\zeor')) + #" single character matches + call assert_equal([{'idx': 0, 'byteidx': 5, 'text': 'r'}], + \ ['editor']->matchstrlist('r')) + call assert_equal([{'idx': 0, 'byteidx': 0, 'text': 'a'}], ['a']->matchstrlist('a')) + call assert_equal([{'idx': 0, 'byteidx': 0, 'text': ''}], + \ matchstrlist(['foobar'], '\zs')) + #" string with tabs + call assert_equal([{'idx': 0, 'byteidx': 1, 'text': 'foo'}], + \ matchstrlist(["\tfoobar"], 'foo')) + #" string with multibyte characters + call assert_equal([{'idx': 0, 'byteidx': 2, 'text': '😊😊'}], + \ matchstrlist(["\t\t😊😊"], '\k\+')) + + #" null string + call assert_equal([], matchstrlist(test_null_list(), 'abc')) + call assert_equal([], matchstrlist([test_null_string()], 'abc')) + call assert_equal([{'idx': 0, 'byteidx': 0, 'text': ''}], + \ matchstrlist(['abc'], test_null_string())) + + #" sub matches + call assert_equal([{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}], matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)', {'submatches': v:true})) + + #" null dict argument + call assert_equal([{'idx': 0, 'byteidx': 0, 'text': 'vim'}], + \ matchstrlist(['vim'], '\w\+', test_null_dict())) + + #" Error cases + call assert_fails("echo matchstrlist('abc', 'a')", 'E1211: List required for argument 1') + call assert_fails("echo matchstrlist(['abc'], {})", 'E1174: String required for argument 2') + call assert_fails("echo matchstrlist(['abc'], '.', [])", 'E1206: Dictionary required for argument 3') + call assert_fails("echo matchstrlist(['abc'], 'a', {'submatches': []})", 'E475: Invalid value for argument submatches') + call assert_fails("echo matchstrlist(['abc'], '\\@=')", 'E866: (NFA regexp) Misplaced @') + END + call v9.CheckLegacyAndVim9Success(lines) + + let lines =<< trim END + vim9script + # non string items + matchstrlist([0z10, {'a': 'x'}], 'x') + END + call v9.CheckSourceSuccess(lines) + + let lines =<< trim END + vim9script + def Foo() + # non string items + assert_equal([], matchstrlist([0z10, {'a': 'x'}], 'x')) + enddef + Foo() + END + call v9.CheckSourceFailure(lines, 'E1013: Argument 1: type mismatch, expected list but got list', 2) +endfunc + +" Test for matchbufline() +func Test_matchbufline() + let lines =<< trim END + #" Basic match + new + call setline(1, ['about', 'above', 'below']) + VAR bnr = bufnr() + wincmd w + call assert_equal([{'lnum': 1, 'byteidx': 1, 'text': 'bout'}, + \ {'lnum': 2, 'byteidx': 1, 'text': 'bove'}], + \ matchbufline(bnr, 'bo.*', 1, '$')) + #" multiple matches in a line + call setbufline(bnr, 1, ['about about', 'above above', 'below']) + call assert_equal([{'lnum': 1, 'byteidx': 1, 'text': 'bout'}, + \ {'lnum': 1, 'byteidx': 7, 'text': 'bout'}, + \ {'lnum': 2, 'byteidx': 1, 'text': 'bove'}, + \ {'lnum': 2, 'byteidx': 7, 'text': 'bove'}], + \ matchbufline(bnr, 'bo\k\+', 1, '$')) + #" no match + call assert_equal([], matchbufline(bnr, 'xy.*', 1, '$')) + #" match on a particular line + call assert_equal([{'lnum': 2, 'byteidx': 7, 'text': 'bove'}], + \ matchbufline(bnr, 'bo\k\+$', 2, 2)) + #" match on a particular line + call assert_equal([], matchbufline(bnr, 'bo.*', 3, 3)) + #" empty string + call deletebufline(bnr, 1, '$') + call assert_equal([], matchbufline(bnr, '.', 1, '$')) + #" empty pattern + call setbufline(bnr, 1, 'abc') + call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': ''}], + \ matchbufline(bnr, '', 1, '$')) + #" method call + call setbufline(bnr, 1, 'editor') + call assert_equal([{'lnum': 1, 'byteidx': 2, 'text': 'it'}], + \ bnr->matchbufline('ed\zsit\zeor', 1, 1)) + #" single character matches + call assert_equal([{'lnum': 1, 'byteidx': 5, 'text': 'r'}], + \ matchbufline(bnr, 'r', 1, '$')) + call setbufline(bnr, 1, 'a') + call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': 'a'}], + \ matchbufline(bnr, 'a', 1, '$')) + #" zero-width match + call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': ''}], + \ matchbufline(bnr, '\zs', 1, '$')) + #" string with tabs + call setbufline(bnr, 1, "\tfoobar") + call assert_equal([{'lnum': 1, 'byteidx': 1, 'text': 'foo'}], + \ matchbufline(bnr, 'foo', 1, '$')) + #" string with multibyte characters + call setbufline(bnr, 1, "\t\t😊😊") + call assert_equal([{'lnum': 1, 'byteidx': 2, 'text': '😊😊'}], + \ matchbufline(bnr, '\k\+', 1, '$')) + #" empty buffer + call deletebufline(bnr, 1, '$') + call assert_equal([], matchbufline(bnr, 'abc', 1, '$')) + + #" Non existing buffer + call setbufline(bnr, 1, 'abc') + call assert_fails("echo matchbufline(5000, 'abc', 1, 1)", 'E158: Invalid buffer name: 5000') + #" null string + call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': ''}], + \ matchbufline(bnr, test_null_string(), 1, 1)) + #" invalid starting line number + call assert_equal([], matchbufline(bnr, 'abc', 100, 100)) + #" ending line number greater than the last line + call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': 'abc'}], + \ matchbufline(bnr, 'abc', 1, 100)) + #" ending line number greater than the starting line number + call setbufline(bnr, 1, ['one', 'two']) + call assert_fails($"echo matchbufline({bnr}, 'abc', 2, 1)", 'E475: Invalid value for argument end_lnum') + + #" sub matches + call deletebufline(bnr, 1, '$') + call setbufline(bnr, 1, 'acd') + call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}], + \ matchbufline(bnr, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 1, '$', {'submatches': v:true})) + + #" null dict argument + call assert_equal([{'lnum': 1, 'byteidx': 0, 'text': 'acd'}], + \ matchbufline(bnr, '\w\+', '$', '$', test_null_dict())) + + #" Error cases + call assert_fails("echo matchbufline([1], 'abc', 1, 1)", 'E1220: String or Number required for argument 1') + call assert_fails("echo matchbufline(1, {}, 1, 1)", 'E1174: String required for argument 2') + call assert_fails("echo matchbufline(1, 'abc', {}, 1)", 'E1220: String or Number required for argument 3') + call assert_fails("echo matchbufline(1, 'abc', 1, {})", 'E1220: String or Number required for argument 4') + call assert_fails($"echo matchbufline({bnr}, 'abc', -1, '$')", 'E475: Invalid value for argument lnum') + call assert_fails($"echo matchbufline({bnr}, 'abc', 1, -1)", 'E475: Invalid value for argument end_lnum') + call assert_fails($"echo matchbufline({bnr}, '\\@=', 1, 1)", 'E866: (NFA regexp) Misplaced @') + call assert_fails($"echo matchbufline({bnr}, 'abc', 1, 1, {{'submatches': []}})", 'E475: Invalid value for argument submatches') + :%bdelete! + call assert_fails($"echo matchbufline({bnr}, 'abc', 1, '$'))", 'E681: Buffer is not loaded') + END + call v9.CheckLegacyAndVim9Success(lines) + + call assert_fails($"echo matchbufline('', 'abc', 'abc', 1)", 'E475: Invalid value for argument lnum') + call assert_fails($"echo matchbufline('', 'abc', 1, 'abc')", 'E475: Invalid value for argument end_lnum') + + let lines =<< trim END + vim9script + def Foo() + echo matchbufline('', 'abc', 'abc', 1) + enddef + Foo() + END + call v9.CheckSourceFailure(lines, 'E1030: Using a String as a Number: "abc"', 1) + + let lines =<< trim END + vim9script + def Foo() + echo matchbufline('', 'abc', 1, 'abc') + enddef + Foo() + END + call v9.CheckSourceFailure(lines, 'E1030: Using a String as a Number: "abc"', 1) +endfunc + func Test_nextnonblank_prevnonblank() new insert diff --git a/src/version.c b/src/version.c index 3839d9c359..2e7f2871ea 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 9, /**/ 8, /**/ From 81642d9d6ff5cd6a90a012b1b98632ce51eeb1a8 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Thu, 4 Jan 2024 22:37:44 +0100 Subject: [PATCH 015/143] patch 9.1.0010: Keymap completion is not available Problem: Keymap completion is not available Solution: Add keymap completion (Doug Kearns) Add keymap completion to the 'keymap' option, user commands and builtin completion functions. closes: #13692 Signed-off-by: Doug Kearns Signed-off-by: Christian Brabandt --- runtime/doc/builtin.txt | 3 ++- runtime/doc/map.txt | 3 ++- src/cmdexpand.c | 9 +++++++++ src/option.c | 7 +++++++ src/testdir/test_cmdline.vim | 7 +++++++ src/testdir/test_options.vim | 8 ++++++++ src/usercmd.c | 3 +++ src/version.c | 2 ++ src/vim.h | 1 + 9 files changed, 41 insertions(+), 2 deletions(-) diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 8f79d2001d..94fcdf70c6 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1,4 +1,4 @@ -*builtin.txt* For Vim version 9.1. Last change: 2023 Dec 24 +*builtin.txt* For Vim version 9.1. Last change: 2024 Jan 04 VIM REFERENCE MANUAL by Bram Moolenaar @@ -3570,6 +3570,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()* help help subjects highlight highlight groups history |:history| suboptions + keymap keyboard mappings locale locale names (as output of locale -a) mapclear buffer argument mapping mapping name diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index d458aa661a..7d4d53048d 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -1,4 +1,4 @@ -*map.txt* For Vim version 9.1. Last change: 2023 December 31 +*map.txt* For Vim version 9.1. Last change: 2024 Jan 04 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1631,6 +1631,7 @@ completion can be enabled: -complete=help help subjects -complete=highlight highlight groups -complete=history :history suboptions + -complete=keymap keyboard mappings -complete=locale locale names (as output of locale -a) -complete=mapclear buffer argument -complete=mapping mapping name diff --git a/src/cmdexpand.c b/src/cmdexpand.c index 8bccaa3bb0..1008bf97e5 100644 --- a/src/cmdexpand.c +++ b/src/cmdexpand.c @@ -50,6 +50,7 @@ cmdline_fuzzy_completion_supported(expand_T *xp) && xp->xp_context != EXPAND_FILES_IN_PATH && xp->xp_context != EXPAND_FILETYPE && xp->xp_context != EXPAND_HELP + && xp->xp_context != EXPAND_KEYMAP && xp->xp_context != EXPAND_OLD_SETTING && xp->xp_context != EXPAND_STRING_SETTING && xp->xp_context != EXPAND_SETTING_SUBTRACT @@ -1394,6 +1395,7 @@ addstar( || context == EXPAND_COMPILER || context == EXPAND_OWNSYNTAX || context == EXPAND_FILETYPE + || context == EXPAND_KEYMAP || context == EXPAND_PACKADD || context == EXPAND_RUNTIME || ((context == EXPAND_TAGS_LISTFILES @@ -3131,6 +3133,13 @@ ExpandFromContext( char *directories[] = {"syntax", "indent", "ftplugin", NULL}; return ExpandRTDir(pat, 0, numMatches, matches, directories); } +#ifdef FEAT_KEYMAP + if (xp->xp_context == EXPAND_KEYMAP) + { + char *directories[] = {"keymap", NULL}; + return ExpandRTDir(pat, 0, numMatches, matches, directories); + } +#endif #if defined(FEAT_EVAL) if (xp->xp_context == EXPAND_USER_LIST) return ExpandUserList(xp, matches, numMatches); diff --git a/src/option.c b/src/option.c index 7cac89e5cf..2372c1aa9b 100644 --- a/src/option.c +++ b/src/option.c @@ -7412,6 +7412,13 @@ set_context_in_set_cmd( xp->xp_context = EXPAND_FILETYPE; return; } +#ifdef FEAT_KEYMAP + if (options[opt_idx].var == (char_u *)&p_keymap) + { + xp->xp_context = EXPAND_KEYMAP; + return; + } +#endif // Now pick. If the option has a custom expander, use that. Otherwise, just // fill with the existing option value. diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index 33ff606424..4554712670 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -545,6 +545,13 @@ func Test_getcompletion() let l = getcompletion('horse', 'filetype') call assert_equal([], l) + if has('keymap') + let l = getcompletion('acc', 'keymap') + call assert_true(index(l, 'accents') >= 0) + let l = getcompletion('nullkeymap', 'keymap') + call assert_equal([], l) + endif + let l = getcompletion('z', 'syntax') call assert_true(index(l, 'zimbu') >= 0) let l = getcompletion('emacs', 'syntax') diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim index 8c336abf7d..37dc20187e 100644 --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -435,6 +435,14 @@ func Test_set_completion() call assert_equal('"set syntax=sshdconfig', @:) call feedkeys(":set syntax=a\\\"\", 'xt') call assert_equal('"set syntax=' .. getcompletion('a*', 'syntax')->join(), @:) + + if has('keymap') + " Expand values for 'keymap' + call feedkeys(":set keymap=acc\\\"\", 'xt') + call assert_equal('"set keymap=accents', @:) + call feedkeys(":set keymap=a\\\"\", 'xt') + call assert_equal('"set keymap=' .. getcompletion('a*', 'keymap')->join(), @:) + endif endfunc " Test handling of expanding individual string option values diff --git a/src/usercmd.c b/src/usercmd.c index 04b341933a..e2c0114ca3 100644 --- a/src/usercmd.c +++ b/src/usercmd.c @@ -73,6 +73,9 @@ static struct {EXPAND_HELP, "help"}, {EXPAND_HIGHLIGHT, "highlight"}, {EXPAND_HISTORY, "history"}, +#if defined(FEAT_KEYMAP) + {EXPAND_KEYMAP, "keymap"}, +#endif #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) {EXPAND_LOCALES, "locale"}, #endif diff --git a/src/version.c b/src/version.c index 2e7f2871ea..c31fbf6358 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 10, /**/ 9, /**/ diff --git a/src/vim.h b/src/vim.h index 3aa04f5548..e41dfef01b 100644 --- a/src/vim.h +++ b/src/vim.h @@ -841,6 +841,7 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring); #define EXPAND_SETTING_SUBTRACT 55 #define EXPAND_ARGOPT 56 #define EXPAND_TERMINALOPT 57 +#define EXPAND_KEYMAP 58 // Values for exmode_active (0 is no exmode) #define EXMODE_NORMAL 1 From d2cc51f9a1a5a30ef5d2e732f49d7f495cae24cf Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Thu, 4 Jan 2024 22:54:08 +0100 Subject: [PATCH 016/143] patch 9.1.0011: regexp cannot match combining chars in collection Problem: regexp cannot match combining chars in collection Solution: Check for combining characters in regex collections for the NFA and BT Regex Engine Also, while at it, make debug mode work again. fixes #10286 closes: #12871 Signed-off-by: Christian Brabandt --- src/regexp.c | 10 ++- src/regexp.h | 4 +- src/regexp_bt.c | 39 +++++++++-- src/regexp_nfa.c | 111 ++++++++++++++++++++++++++++++- src/testdir/test_regexp_utf8.vim | 11 +++ src/version.c | 2 + 6 files changed, 166 insertions(+), 11 deletions(-) diff --git a/src/regexp.c b/src/regexp.c index a64672856c..c3bc4966c7 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -2686,7 +2686,10 @@ static regengine_T bt_regengine = bt_regcomp, bt_regfree, bt_regexec_nl, - bt_regexec_multi, + bt_regexec_multi +#ifdef DEBUG + ,(char_u *)"" +#endif }; #include "regexp_nfa.c" @@ -2696,7 +2699,10 @@ static regengine_T nfa_regengine = nfa_regcomp, nfa_regfree, nfa_regexec_nl, - nfa_regexec_multi, + nfa_regexec_multi +#ifdef DEBUG + ,(char_u *)"" +#endif }; // Which regexp engine to use? Needed for vim_regcomp(). diff --git a/src/regexp.h b/src/regexp.h index d6c8f48c7b..1ff2e1b6ef 100644 --- a/src/regexp.h +++ b/src/regexp.h @@ -178,7 +178,9 @@ struct regengine int (*regexec_nl)(regmatch_T *, char_u *, colnr_T, int); // bt_regexec_mult or nfa_regexec_mult long (*regexec_multi)(regmmatch_T *, win_T *, buf_T *, linenr_T, colnr_T, int *); - //char_u *expr; +#ifdef DEBUG + char_u *expr; +#endif }; // Flags used by vim_regsub() and vim_regsub_both() diff --git a/src/regexp_bt.c b/src/regexp_bt.c index 522cf37e2d..198946e0dc 100644 --- a/src/regexp_bt.c +++ b/src/regexp_bt.c @@ -3743,13 +3743,38 @@ regmatch( case ANYOF: case ANYBUT: - if (c == NUL) - status = RA_NOMATCH; - else if ((cstrchr(OPERAND(scan), c) == NULL) == (op == ANYOF)) - status = RA_NOMATCH; - else - ADVANCE_REGINPUT(); - break; + { + char_u *q = OPERAND(scan); + + if (c == NUL) + status = RA_NOMATCH; + else if ((cstrchr(q, c) == NULL) == (op == ANYOF)) + status = RA_NOMATCH; + else + { + // Check following combining characters + int len = 0; + int i; + + if (enc_utf8) + len = utfc_ptr2len(q) - utf_ptr2len(q); + + MB_CPTR_ADV(rex.input); + MB_CPTR_ADV(q); + + if (!enc_utf8 || len == 0) + break; + + for (i = 0; i < len; ++i) + if (q[i] != rex.input[i]) + { + status = RA_NOMATCH; + break; + } + rex.input += len; + } + break; + } case MULTIBYTECODE: if (has_mbyte) diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index d724d527b6..ff54348905 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -1764,6 +1764,7 @@ collection: endp = skip_anyof(p); if (*endp == ']') { + int plen; /* * Try to reverse engineer character classes. For example, * recognize that [0-9] stands for \d and [A-Za-z_] for \h, @@ -2033,13 +2034,43 @@ collection: else { if (got_coll_char == TRUE && startc == 0) + { EMIT(0x0a); + EMIT(NFA_CONCAT); + } else + { EMIT(startc); - EMIT(NFA_CONCAT); + if (!(enc_utf8 && (utf_ptr2len(regparse) != (plen = utfc_ptr2len(regparse))))) + { + EMIT(NFA_CONCAT); + } + } } } + if (enc_utf8 && (utf_ptr2len(regparse) != (plen = utfc_ptr2len(regparse)))) + { + int i = utf_ptr2len(regparse); + + c = utf_ptr2char(regparse + i); + + // Add composing characters + for (;;) + { + if (c == 0) + // \x00 is translated to \x0a, start at \x01. + EMIT(1); + else + EMIT(c); + EMIT(NFA_CONCAT); + if ((i += utf_char2len(c)) >= plen) + break; + c = utf_ptr2char(regparse + i); + } + EMIT(NFA_COMPOSING); + EMIT(NFA_CONCAT); + } MB_PTR_ADV(regparse); } // while (p < endp) @@ -6418,6 +6449,84 @@ nfa_regmatch( result_if_matched = (t->state->c == NFA_START_COLL); for (;;) { + if (state->c == NFA_COMPOSING) + { + int mc = curc; + int len = 0; + nfa_state_T *end; + nfa_state_T *sta; + int cchars[MAX_MCO]; + int ccount = 0; + int j; + + sta = t->state->out->out; + len = 0; + if (utf_iscomposing(sta->c)) + { + // Only match composing character(s), ignore base + // character. Used for ".{composing}" and "{composing}" + // (no preceding character). + len += mb_char2len(mc); + } + if (rex.reg_icombine && len == 0) + { + // If \Z was present, then ignore composing characters. + // When ignoring the base character this always matches. + if (sta->c != curc) + result = FAIL; + else + result = OK; + while (sta->c != NFA_END_COMPOSING) + sta = sta->out; + } + // Check base character matches first, unless ignored. + else if (len > 0 || mc == sta->c) +// if (len > 0 || mc == sta->c) + { + if (len == 0) + { + len += mb_char2len(mc); + sta = sta->out; + } + + // We don't care about the order of composing characters. + // Get them into cchars[] first. + while (len < clen) + { + mc = mb_ptr2char(rex.input + len); + cchars[ccount++] = mc; + len += mb_char2len(mc); + if (ccount == MAX_MCO) + break; + } + + // Check that each composing char in the pattern matches a + // composing char in the text. We do not check if all + // composing chars are matched. + result = OK; + while (sta->c != NFA_END_COMPOSING) + { + for (j = 0; j < ccount; ++j) + if (cchars[j] == sta->c) + break; + if (j == ccount) + { + result = FAIL; + break; + } + sta = sta->out; + } + } + else + result = FAIL; + + if (t->state->out->out1->c == NFA_END_COMPOSING) + { + end = t->state->out->out1; + ADD_STATE_IF_MATCH(end); + } + break; + } if (state->c == NFA_END_COLL) { result = !result_if_matched; diff --git a/src/testdir/test_regexp_utf8.vim b/src/testdir/test_regexp_utf8.vim index b591aedbb7..6669dee57e 100644 --- a/src/testdir/test_regexp_utf8.vim +++ b/src/testdir/test_regexp_utf8.vim @@ -575,5 +575,16 @@ func Test_match_too_complicated() set regexpengine=0 endfunc +func Test_combining_chars_in_collection() + new + for i in range(0,2) + exe "set re=".i + put =['ɔ̃', 'É”', '̃ ã', 'abcd'] + :%s/[ɔ̃]// + call assert_equal(['', '', 'É”', '̃ ã', 'abcd'], getline(1,'$')) + %d + endfor + bw! +endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index c31fbf6358..d45181d9d7 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 11, /**/ 10, /**/ From c79646dfb10126f4ef22734d8713f2352197435e Mon Sep 17 00:00:00 2001 From: dkearns Date: Fri, 5 Jan 2024 08:58:48 +1100 Subject: [PATCH 017/143] runtime(vim): Update syntax file (#13671) Support multiline :syntax commands. Match :syn-cchar option in :syn-{keyword,region}. Signed-off-by: Doug Kearns Signed-off-by: Christian Brabandt --- .../syntax/testdir/dumps/vim_syntax_00.dump | 20 +++++ .../syntax/testdir/dumps/vim_syntax_01.dump | 20 +++++ .../syntax/testdir/dumps/vim_syntax_02.dump | 20 +++++ .../syntax/testdir/dumps/vim_syntax_03.dump | 20 +++++ .../syntax/testdir/dumps/vim_syntax_99.dump | 20 +++++ .../testdir/dumps/vim_variables_03.dump | 6 +- .../testdir/dumps/vim_variables_05.dump | 4 +- runtime/syntax/testdir/input/vim_syntax.vim | 75 +++++++++++++++++++ runtime/syntax/vim.vim | 43 ++++++----- 9 files changed, 205 insertions(+), 23 deletions(-) create mode 100644 runtime/syntax/testdir/dumps/vim_syntax_00.dump create mode 100644 runtime/syntax/testdir/dumps/vim_syntax_01.dump create mode 100644 runtime/syntax/testdir/dumps/vim_syntax_02.dump create mode 100644 runtime/syntax/testdir/dumps/vim_syntax_03.dump create mode 100644 runtime/syntax/testdir/dumps/vim_syntax_99.dump create mode 100644 runtime/syntax/testdir/input/vim_syntax.vim diff --git a/runtime/syntax/testdir/dumps/vim_syntax_00.dump b/runtime/syntax/testdir/dumps/vim_syntax_00.dump new file mode 100644 index 0000000000..db529678e5 --- /dev/null +++ b/runtime/syntax/testdir/dumps/vim_syntax_00.dump @@ -0,0 +1,20 @@ +>"+0#0000e05#ffffff0| |V|i|m| |:|s|y|n|t|a|x| |h|i|g|h|l|i|g|h|t|i|n|g| +0#0000000&@48 +@75 +|s+0#af5f00255&|y|n| +0#0000000&|k+0#00e0003&|e|y|w|o|r|d| +0#0000000&|t+0#00e0003&|e|s|t|K|e|y|w|o|r|d| +0#0000000&@51 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|c|e|a|l| +0#0000000&@59 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&@1|h|a|r|=|&+0#e000002&| +0#0000000&@59 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|t|a|i|n|e|d| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|t|a|i|n|e|d|i|n|=|t+0#0000000&|e|s|t|C|o|n|t|a|i|n|e|r| @41 +@6|\+0#e000e06&| +0#0000000&|n+0#e000e06&|e|x|t|g|r|o|u|p|=|t+0#0000000&|e|s|t|N|e|x|t|,|@|t|e|s|t|C|l|u|s|t|e|r| @35 +@6|\+0#e000e06&| +0#0000000&|t+0#e000e06&|r|a|n|s|p|a|r|e|n|t| +0#0000000&@55 +@6|\+0#e000e06&| +0#0000000&|s+0#e000e06&|k|i|p|w|h|i|t|e| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|s+0#e000e06&|k|i|p|e|m|p|t|y| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|s+0#e000e06&|k|i|p|n|l| +0#0000000&@60 +@6|\+0#e000e06&| +0#0000000&|k|e|y|w|o|r|d|1| @58 +@6|\+0#e000e06&| +0#0000000&|k|e|y|w|o|r|d|2| @58 +@6|\+0#e000e06&| +0#0000000&|k|e|y|w|o|r|d|3| @58 +@75 +|s+0#af5f00255&|y|n| +0#0000000&|m+0#00e0003&|a|t|c|h| +0#0000000&|t+0#00e0003&|e|s|t|M|a|t|c|h| +0#0000000&@55 +@6|\+0#e000e06&| +0#0000000&|"+0#e000002&|p|a|t@1|e|r|n|"| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|c|e|a|l| +0#0000000&@59 +|"|i|n|p|u|t|/|v|i|m|_|s|y|n|t|a|x|.|v|i|m|"| |7|5|L|,| |1|5|0|2|B| @23|1|,|1| @10|T|o|p| diff --git a/runtime/syntax/testdir/dumps/vim_syntax_01.dump b/runtime/syntax/testdir/dumps/vim_syntax_01.dump new file mode 100644 index 0000000000..e09801dff0 --- /dev/null +++ b/runtime/syntax/testdir/dumps/vim_syntax_01.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@5|\+0#e000e06&| +0#0000000&|k|e|y|w|o|r|d|2| @58 +@6|\+0#e000e06&| +0#0000000&|k|e|y|w|o|r|d|3| @58 +@75 +|s+0#af5f00255&|y|n| +0#0000000&|m+0#00e0003&|a|t|c|h| +0#0000000&|t+0#00e0003&|e|s|t|M|a|t|c|h| +0#0000000&@55 +@6|\+0#e000e06&| +0#0000000&|"+0#e000002&|p|a|t@1|e|r|n|"| +0#0000000&@57 +@6>\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|c|e|a|l| +0#0000000&@59 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&@1|h|a|r|=|&+0#e000002&| +0#0000000&@59 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|t|a|i|n|e|d| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|t|a|i|n|e|d|i|n|=|t+0#0000000&|e|s|t|C|o|n|t|a|i|n|e|r| @41 +@6|\+0#e000e06&| +0#0000000&|n+0#e000e06&|e|x|t|g|r|o|u|p|=|t+0#0000000&|e|s|t|N|e|x|t|,|@|t|e|s|t|C|l|u|s|t|e|r| @35 +@6|\+0#e000e06&| +0#0000000&|t+0#e000e06&|r|a|n|s|p|a|r|e|n|t| +0#0000000&@55 +@6|\+0#e000e06&| +0#0000000&|s+0#e000e06&|k|i|p|w|h|i|t|e| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|s+0#e000e06&|k|i|p|e|m|p|t|y| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|s+0#e000e06&|k|i|p|n|l| +0#0000000&@60 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|t|a|i|n|s|=|t+0#0000000&|e|s|t|C|o|n|t|a|i|n|e|d|1|,|t|e|s|t|C|o|n|t|a|i|n|e|d|2| @28 +@6|\+0#e000e06&| +0#0000000&|f+0#e000e06&|o|l|d| +0#0000000&@62 +@6|\+0#e000e06&| +0#0000000&|d+0#e000e06&|i|s|p|l|a|y| +0#0000000&@59 +@6|\+0#e000e06&| +0#0000000&|e+0#e000e06&|x|t|e|n|d| +0#0000000&@60 +@6|\+0#e000e06&| +0#0000000&|e+0#e000e06&|x|c|l|u|d|e|n|l| +0#0000000&@57 +@57|1|9|,|7| @9|2|3|%| diff --git a/runtime/syntax/testdir/dumps/vim_syntax_02.dump b/runtime/syntax/testdir/dumps/vim_syntax_02.dump new file mode 100644 index 0000000000..063a33b767 --- /dev/null +++ b/runtime/syntax/testdir/dumps/vim_syntax_02.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@5|\+0#e000e06&| +0#0000000&|e+0#e000e06&|x|c|l|u|d|e|n|l| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|k+0#e000e06&|e@1|p|e|n|d| +0#0000000&@59 +@75 +|s+0#af5f00255&|y|n| +0#0000000&|r+0#00e0003&|e|g|i|o|n| +0#0000000&|t+0#00e0003&|e|s|t|R|e|g|i|o|n| +0#0000000&@53 +@6|\+0#e000e06&| +0#0000000&|s+0#00e0003&|t|a|r|t|=+0#0000000&|"+0#e000002&|s|t|a|r|t|-|p|a|t@1|e|r|n|"| +0#0000000&@45 +@6>\+0#e000e06&| +0#0000000&|e+0#00e0003&|n|d|=+0#0000000&|"+0#e000002&|e|n|d|-|p|a|t@1|e|r|n|"| +0#0000000&@49 +@6|\+0#e000e06&| +0#0000000&|s+0#00e0003&|k|i|p|=+0#0000000&|"+0#e000002&|s|k|i|p|-|p|a|t@1|e|r|n|"| +0#0000000&@47 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|t|a|i|n|e|d| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|c|e|a|l| +0#0000000&@59 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&@1|h|a|r|=|&+0#e000002&| +0#0000000&@59 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|t|a|i|n|e|d| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|t|a|i|n|e|d|i|n|=|t+0#0000000&|e|s|t|C|o|n|t|a|i|n|e|r| @41 +@6|\+0#e000e06&| +0#0000000&|n+0#e000e06&|e|x|t|g|r|o|u|p|=|t+0#0000000&|e|s|t|N|e|x|t|,|@|t|e|s|t|C|l|u|s|t|e|r| @35 +@6|\+0#e000e06&| +0#0000000&|t+0#e000e06&|r|a|n|s|p|a|r|e|n|t| +0#0000000&@55 +@6|\+0#e000e06&| +0#0000000&|s+0#e000e06&|k|i|p|w|h|i|t|e| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|s+0#e000e06&|k|i|p|e|m|p|t|y| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|s+0#e000e06&|k|i|p|n|l| +0#0000000&@60 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|t|a|i|n|s|=|t+0#0000000&|e|s|t|C|o|n|t|a|i|n|e|d|1|,|t|e|s|t|C|o|n|t|a|i|n|e|d|2| @28 +@6|\+0#e000e06&| +0#0000000&|o+0#e000e06&|n|e|l|i|n|e| +0#0000000&@59 +@57|3|7|,|7| @9|5@1|%| diff --git a/runtime/syntax/testdir/dumps/vim_syntax_03.dump b/runtime/syntax/testdir/dumps/vim_syntax_03.dump new file mode 100644 index 0000000000..b3a23ddc72 --- /dev/null +++ b/runtime/syntax/testdir/dumps/vim_syntax_03.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@5|\+0#e000e06&| +0#0000000&|o+0#e000e06&|n|e|l|i|n|e| +0#0000000&@59 +@6|\+0#e000e06&| +0#0000000&|f+0#e000e06&|o|l|d| +0#0000000&@62 +@6|\+0#e000e06&| +0#0000000&|d+0#e000e06&|i|s|p|l|a|y| +0#0000000&@59 +@6|\+0#e000e06&| +0#0000000&|e+0#e000e06&|x|t|e|n|d| +0#0000000&@60 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|c|e|a|l|e|n|d|s| +0#0000000&@55 +@6>\+0#e000e06&| +0#0000000&|e+0#e000e06&|x|c|l|u|d|e|n|l| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|k+0#e000e06&|e@1|p|e|n|d| +0#0000000&@59 +@75 +|s+0#af5f00255&|y|n| +0#0000000&|c+0#00e0003&|l|u|s|t|e|r| +0#0000000&|t+0#00e0003&|e|s|t|C|l|u|s|t|e|r| +0#0000000&@51 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|t|a|i|n|s|=|t+0#0000000&|e|s|t|C|o|n|t|a|i|n|e|d|1|,|t|e|s|t|C|o|n|t|a|i|n|e|d|2|,|t|e|s|t|C|o|n|t|a|i|n|e|d|3| @13 +@75 +|s+0#af5f00255&|y|n| +0#0000000&|c+0#00e0003&|l|u|s|t|e|r| +0#0000000&|t+0#00e0003&|e|s|t|C|l|u|s|t|e|r| +0#0000000&@51 +@6|\+0#e000e06&| +0#0000000&|a+0#e000e06&|d@1|=|t+0#0000000&|e|s|t|A|d@1| @55 +@6|\+0#e000e06&| +0#0000000&|r+0#e000e06&|e|m|o|v|e|=|t+0#0000000&|e|s|t|R|e|m|o|v|e| @49 +@75 +@75 +|"+0#0000e05&| |c|h|e|c|k| |m|u|l|t|i|l|i|n|e| |g|r|o|u|p| |l|i|s|t| +0#0000000&@46 +|s+0#af5f00255&|y|n| +0#0000000&|k+0#00e0003&|e|y|w|o|r|d| +0#0000000&|t+0#00e0003&|e|s|t|K|e|y|w|o|r|d| +0#0000000&@51 +@6|\+0#e000e06&| +0#0000000&|n+0#e000e06&|e|x|t|g|r|o|u|p|=| +0#0000000&@56 +@57|5@1|,|7| @9|8|7|%| diff --git a/runtime/syntax/testdir/dumps/vim_syntax_99.dump b/runtime/syntax/testdir/dumps/vim_syntax_99.dump new file mode 100644 index 0000000000..c50589d579 --- /dev/null +++ b/runtime/syntax/testdir/dumps/vim_syntax_99.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@74 +|s+0#af5f00255&|y|n| +0#0000000&|c+0#00e0003&|l|u|s|t|e|r| +0#0000000&|t+0#00e0003&|e|s|t|C|l|u|s|t|e|r| +0#0000000&@51 +@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|t|a|i|n|s|=|t+0#0000000&|e|s|t|C|o|n|t|a|i|n|e|d|1|,|t|e|s|t|C|o|n|t|a|i|n|e|d|2|,|t|e|s|t|C|o|n|t|a|i|n|e|d|3| @13 +@75 +|s+0#af5f00255&|y|n| +0#0000000&|c+0#00e0003&|l|u|s|t|e|r| +0#0000000&|t+0#00e0003&|e|s|t|C|l|u|s|t|e|r| +0#0000000&@51 +@6|\+0#e000e06&| +0#0000000&|a+0#e000e06&|d@1|=|t+0#0000000&|e|s|t|A|d@1| @55 +@6|\+0#e000e06&| +0#0000000&|r+0#e000e06&|e|m|o|v|e|=|t+0#0000000&|e|s|t|R|e|m|o|v|e| @49 +@75 +@75 +|"+0#0000e05&| |c|h|e|c|k| |m|u|l|t|i|l|i|n|e| |g|r|o|u|p| |l|i|s|t| +0#0000000&@46 +|s+0#af5f00255&|y|n| +0#0000000&|k+0#00e0003&|e|y|w|o|r|d| +0#0000000&|t+0#00e0003&|e|s|t|K|e|y|w|o|r|d| +0#0000000&@51 +@6|\+0#e000e06&| +0#0000000&|n+0#e000e06&|e|x|t|g|r|o|u|p|=| +0#0000000&@56 +@6|\+0#e000e06&| +0#0000000&|t|e|s|t|N|e|x|t| |,| @56 +@6|\+0#e000e06&| +0#0000000&|t|e|s|t|N|e|x|t|2| |,| @55 +@6|\+0#e000e06&| +0#0000000&|@|t|e|s|t|C|l|u|s|t|e|r| @54 +@6|\+0#e000e06&| +0#0000000&|s+0#e000e06&|k|i|p|w|h|i|t|e| +0#0000000&@57 +@6|\+0#e000e06&| +0#0000000&|k|e|y|w|o|r|d|4| @58 +@6|\+0#e000e06&| +0#0000000&|k|e|y|w|o|r|d|5| @58 +@6>\+0#e000e06&| +0#0000000&|k|e|y|w|o|r|d|6| @58 +@57|7|5|,|7| @9|B|o|t| diff --git a/runtime/syntax/testdir/dumps/vim_variables_03.dump b/runtime/syntax/testdir/dumps/vim_variables_03.dump index 3260c374b1..3e8d21cb84 100644 --- a/runtime/syntax/testdir/dumps/vim_variables_03.dump +++ b/runtime/syntax/testdir/dumps/vim_variables_03.dump @@ -1,5 +1,5 @@ |l+0#af5f00255#ffffff0|e|t| +0#0000000&|[|f+0#00e0e07&|o@1|,+0#0000000&| @65 -| +0#e000e06&@5|\| +0#0000000&|b+0#00e0e07&|a|r|]+0#0000000&| |=+0#af5f00255&| +0#0000000&|e|x|p|r| @55 +@6|\+0#e000e06&| +0#0000000&|b+0#00e0e07&|a|r|]+0#0000000&| |=+0#af5f00255&| +0#0000000&|e|x|p|r| @55 @75 |l+0#af5f00255&|e|t| +0#0000000&|[|f+0#00e0e07&|o@1|,+0#0000000&| |b+0#00e0e07&|a|r|]+0#0000000&| |.+0#af5f00255&|=| +0#0000000&|e|x|p|r| @52 |l+0#af5f00255&|e|t| +0#0000000&|[|f+0#00e0e07&|o@1|,+0#0000000&| |b+0#00e0e07&|a|r|]+0#0000000&| |++0#af5f00255&|=| +0#0000000&|e|x|p|r| @52 @@ -7,8 +7,8 @@ @75 |l+0#af5f00255&|e|t| +0#0000000&|[|f+0#00e0e07&|o@1|,+0#0000000&| |b+0#00e0e07&|a|r|;+0#0000000&| |b+0#00e0e07&|a|z|]+0#0000000&| |=+0#af5f00255&| +0#0000000&|e|x|p|r| @48 |l+0#af5f00255&|e|t| +0#0000000&|[|f+0#00e0e07&|o@1|,+0#0000000&| @65 -| +0#e000e06&@5|\| +0#0000000&|b+0#00e0e07&|a|r|;+0#0000000&| @62 -| +0#e000e06&@5|\| +0#0000000&|b+0#00e0e07&|a|z|]+0#0000000&| |=+0#af5f00255&| +0#0000000&|e|x|p|r| @55 +@6|\+0#e000e06&| +0#0000000&|b+0#00e0e07&|a|r|;+0#0000000&| @62 +@6|\+0#e000e06&| +0#0000000&|b+0#00e0e07&|a|z|]+0#0000000&| |=+0#af5f00255&| +0#0000000&|e|x|p|r| @55 @75 |l+0#af5f00255&|e|t| +0#0000000&|[|f+0#00e0e07&|o@1|,+0#0000000&| |b+0#00e0e07&|a|r|;+0#0000000&| |b+0#00e0e07&|a|z|]+0#0000000&| |.+0#af5f00255&|=| +0#0000000&|e|x|p|r| @47 |l+0#af5f00255&|e|t| +0#0000000&|[|f+0#00e0e07&|o@1|,+0#0000000&| |b+0#00e0e07&|a|r|;+0#0000000&| |b+0#00e0e07&|a|z|]+0#0000000&| |++0#af5f00255&|=| +0#0000000&|e|x|p|r| @47 diff --git a/runtime/syntax/testdir/dumps/vim_variables_05.dump b/runtime/syntax/testdir/dumps/vim_variables_05.dump index 7a932601b9..8254fbe481 100644 --- a/runtime/syntax/testdir/dumps/vim_variables_05.dump +++ b/runtime/syntax/testdir/dumps/vim_variables_05.dump @@ -2,12 +2,12 @@ |u+0#af5f00255&|n|l|e|t| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&@65 |u+0#af5f00255&|n|l|e|t| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&|b+0#00e0e07&|a|r| +0#0000000&@61 |u+0#af5f00255&|n|l|e|t| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&@65 -| +0#e000e06&@5|\| +0#0000000&|b+0#00e0e07&|a|r| +0#0000000&@63 +@6|\+0#e000e06&| +0#0000000&|b+0#00e0e07&|a|r| +0#0000000&@63 > @74 |u+0#af5f00255&|n|l|e|t|!| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&@64 |u+0#af5f00255&|n|l|e|t|!| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&|b+0#00e0e07&|a|r| +0#0000000&@60 |u+0#af5f00255&|n|l|e|t|!| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&@64 -| +0#e000e06&@5|\| +0#0000000&|b+0#00e0e07&|a|r| +0#0000000&@63 +@6|\+0#e000e06&| +0#0000000&|b+0#00e0e07&|a|r| +0#0000000&@63 @75 |u+0#af5f00255&|n|l|e|t| +0#0000000&|$+0#e000e06&|F|O@1| +0#0000000&@64 |u+0#af5f00255&|n|l|e|t|!| +0#0000000&|$+0#e000e06&|F|O@1| +0#0000000&@63 diff --git a/runtime/syntax/testdir/input/vim_syntax.vim b/runtime/syntax/testdir/input/vim_syntax.vim new file mode 100644 index 0000000000..e8c112cea8 --- /dev/null +++ b/runtime/syntax/testdir/input/vim_syntax.vim @@ -0,0 +1,75 @@ +" Vim :syntax highlighting + +syn keyword testKeyword + \ conceal + \ cchar=& + \ contained + \ containedin=testContainer + \ nextgroup=testNext,@testCluster + \ transparent + \ skipwhite + \ skipempty + \ skipnl + \ keyword1 + \ keyword2 + \ keyword3 + +syn match testMatch + \ "pattern" + \ conceal + \ cchar=& + \ contained + \ containedin=testContainer + \ nextgroup=testNext,@testCluster + \ transparent + \ skipwhite + \ skipempty + \ skipnl + \ contains=testContained1,testContained2 + \ fold + \ display + \ extend + \ excludenl + \ keepend + +syn region testRegion + \ start="start-pattern" + \ end="end-pattern" + \ skip="skip-pattern" + \ contained + \ conceal + \ cchar=& + \ contained + \ containedin=testContainer + \ nextgroup=testNext,@testCluster + \ transparent + \ skipwhite + \ skipempty + \ skipnl + \ contains=testContained1,testContained2 + \ oneline + \ fold + \ display + \ extend + \ concealends + \ excludenl + \ keepend + +syn cluster testCluster + \ contains=testContained1,testContained2,testContained3 + +syn cluster testCluster + \ add=testAdd + \ remove=testRemove + + +" check multiline group list +syn keyword testKeyword + \ nextgroup= + \ testNext , + \ testNext2 , + \ @testCluster + \ skipwhite + \ keyword4 + \ keyword5 + \ keyword6 diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index d697538db6..edfef438c3 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -7,6 +7,7 @@ " 2023 Dec 06 by Vim Project (add missing assignment operators) " 2023 Dec 10 by Vim Project (improve variable matching) " 2023 Dec 21 by Vim Project (improve ex command matching) +" 2023 Dec 30 by Vim Project (:syntax improvements) " Version: 9.0-25 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_VIM " Automatically generated keyword lists: {{{1 @@ -525,16 +526,22 @@ syn match vimNormCmds contained ".*$" " Syntax: {{{2 "======= -syn match vimGroupList contained "@\=[^ \t,]*" contains=vimGroupSpecial,vimPatSep -syn match vimGroupList contained "@\=[^ \t,]*," nextgroup=vimGroupList contains=vimGroupSpecial,vimPatSep -syn keyword vimGroupSpecial contained ALL ALLBUT CONTAINED TOP +syn match vimGroupList contained "@\=[^[:space:],]\+" nextgroup=vimGroupListComma skipwhite skipnl +syn match vimGroupListContinue contained "\\" nextgroup=vimGroupList skipwhite +syn match vimGroupListComma contained "," nextgroup=vimGroupList,vimGroupListContinue skipwhite skipnl +syn keyword vimGroupSpecial contained ALL ALLBUT CONTAINED TOP if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimsynerror") syn match vimSynError contained "\i\+" syn match vimSynError contained "\i\+=" nextgroup=vimGroupList endif -syn match vimSynContains contained "\" contains=vimCommand skipwhite nextgroup=vimSynType,vimComment,vim9Comment syn match vimAuSyntax contained "\s+sy\%[ntax]" contains=vimCommand skipwhite nextgroup=vimSynType,vimComment,vim9Comment @@ -552,7 +559,7 @@ syn keyword vimSynType contained clear skipwhite nextgroup=vimGroupList " Syntax: cluster {{{2 syn keyword vimSynType contained cluster skipwhite nextgroup=vimClusterName -syn region vimClusterName contained matchgroup=vimGroupName start="\h\w*" skip="\\\\\|\\|" matchgroup=vimSep end="$\||" contains=vimGroupAdd,vimGroupRem,vimSynContains,vimSynError +syn region vimClusterName contained matchgroup=vimGroupName start="\h\w*" skip="\\\\\|\\\|\n\s*\\" matchgroup=vimSep end="$\||" contains=vimContinue,vimGroupAdd,vimGroupRem,vimSynContains,vimSynError syn match vimGroupAdd contained "add=" nextgroup=vimGroupList syn match vimGroupRem contained "remove=" nextgroup=vimGroupList syn cluster vimFuncBodyList add=vimSynType,vimGroupAdd,vimGroupRem @@ -574,21 +581,17 @@ syn keyword vimSynType contained include skipwhite nextgroup=vimGroupList syn cluster vimFuncBodyList add=vimSynType " Syntax: keyword {{{2 -syn cluster vimSynKeyGroup contains=vimSynNextgroup,vimSynKeyOpt,vimSynKeyContainedin +syn cluster vimSynKeyGroup contains=vimContinue,vimSynCchar,vimSynNextgroup,vimSynKeyOpt,vimSynKeyContainedin syn keyword vimSynType contained keyword skipwhite nextgroup=vimSynKeyRegion -syn region vimSynKeyRegion contained oneline keepend matchgroup=vimGroupName start="\h\w*" skip="\\\\\|\\|" matchgroup=vimSep end="|\|$" contains=@vimSynKeyGroup +syn region vimSynKeyRegion contained keepend matchgroup=vimGroupName start="\h\w*" skip="\\\\\|\\|\|\n\s*\\" matchgroup=vimSep end="|\|$" contains=@vimSynKeyGroup syn match vimSynKeyOpt contained "\%#=1\<\(conceal\|contained\|transparent\|skipempty\|skipwhite\|skipnl\)\>" syn cluster vimFuncBodyList add=vimSynType " Syntax: match {{{2 -syn cluster vimSynMtchGroup contains=vimMtchComment,vimSynContains,vimSynError,vimSynMtchOpt,vimSynNextgroup,vimSynRegPat,vimNotation,vim9Comment +syn cluster vimSynMtchGroup contains=vimContinue,vimMtchComment,vimSynCchar,vimSynContains,vimSynError,vimSynMtchOpt,vimSynNextgroup,vimSynRegPat,vimNotation,vim9Comment syn keyword vimSynType contained match skipwhite nextgroup=vimSynMatchRegion -syn region vimSynMatchRegion contained keepend matchgroup=vimGroupName start="\h\w*" matchgroup=vimSep end="|\|$" contains=@vimSynMtchGroup +syn region vimSynMatchRegion contained keepend matchgroup=vimGroupName start="\h\w*" skip="\n\s*\\" matchgroup=vimSep end="|\|$" contains=@vimSynMtchGroup syn match vimSynMtchOpt contained "\%#=1\<\(conceal\|transparent\|contained\|excludenl\|keepend\|skipempty\|skipwhite\|display\|extend\|skipnl\|fold\)\>" -if has("conceal") - syn match vimSynMtchOpt contained "\" syn match vimSynReg contained "\(start\|skip\|end\)="he=e-1 nextgroup=vimSynRegPat syn match vimSynMtchGrp contained "matchgroup=" nextgroup=vimGroup,vimHLGroup -syn region vimSynRegPat contained extend start="\z([-`~!@#$%^&*_=+;:'",./?]\)" skip="\\\\\|\\\z1" end="\z1" contains=@vimSynRegPatGroup skipwhite nextgroup=vimSynPatMod,vimSynReg +syn region vimSynRegPat contained extend start="\z([-`~!@#$%^&*_=+;:'",./?]\)" skip="\\\\\|\\\z1\|\n\s*\\" end="\z1" contains=@vimSynRegPatGroup skipwhite nextgroup=vimSynPatMod,vimSynReg syn match vimSynPatMod contained "\%#=1\(hs\|ms\|me\|hs\|he\|rs\|re\)=[se]\([-+]\d\+\)\=" syn match vimSynPatMod contained "\%#=1\(hs\|ms\|me\|hs\|he\|rs\|re\)=[se]\([-+]\d\+\)\=," nextgroup=vimSynPatMod syn match vimSynPatMod contained "lc=\d\+" @@ -694,7 +697,8 @@ syn match vimLineComment +^[ \t:]*".*$+ contains=@vimCommentGroup,vimCommentStri syn match vimLineComment +^[ \t:]*"\("[^"]*"\|[^"]\)*$+ contains=@vimCommentGroup,vimCommentString,vimCommentTitle syn match vim9LineComment +^[ \t:]\+#.*$+ contains=@vimCommentGroup,vimCommentString,vimCommentTitle syn match vimCommentTitle '"\s*\%([sS]:\|\h\w*#\)\=\u\w*\(\s\+\u\w*\)*:'hs=s+1 contained contains=vimCommentTitleLeader,vimTodo,@vimCommentGroup -syn match vimContinue "^\s*\\" +" Note: Look-behind to work around nextgroup skipnl consuming leading whitespace and preventing a match +syn match vimContinue "\%(^\s*\)\@32<=\\" syn region vimString start="^\s*\\\z(['"]\)" skip='\\\\\|\\\z1' end="\z1" oneline keepend contains=@vimStringGroup,vimContinue syn match vimCommentTitleLeader '"\s\+'ms=s+1 contained @@ -955,6 +959,7 @@ if !exists("skip_vim_syntax_inits") hi def link vimFuncSID Special hi def link vimFuncVar Identifier hi def link vimGroupAdd vimSynOption + hi def link vimGroupListContinue vimContinue hi def link vimGroupName vimGroup hi def link vimGroupRem vimSynOption hi def link vimGroupSpecial Special @@ -1050,6 +1055,8 @@ if !exists("skip_vim_syntax_inits") hi def link vimSynFoldMethod Type hi def link vimSynKeyContainedin vimSynContains hi def link vimSynKeyOpt vimSynOption + hi def link vimSynCchar vimSynOption + hi def link vimSynCcharValue Character hi def link vimSynMtchGrp vimSynOption hi def link vimSynMtchOpt vimSynOption hi def link vimSynNextgroup vimSynOption From 963fd7d6e5c71d7d76b515891dc8ee32310ebe9f Mon Sep 17 00:00:00 2001 From: Lifepillar Date: Fri, 5 Jan 2024 17:44:57 +0100 Subject: [PATCH 018/143] runtime(doc): Fix typos in reltime() help. (#13818) Signed-off-by: Lifepillar Signed-off-by: Christian Brabandt --- runtime/doc/builtin.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 94fcdf70c6..9ac79c611b 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1,4 +1,4 @@ -*builtin.txt* For Vim version 9.1. Last change: 2024 Jan 04 +*builtin.txt* For Vim version 9.1. Last change: 2024 Jan 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -7388,9 +7388,9 @@ reltime({start}, {end}) *reltime()* echo startTime->reltime()->reltimestr() < Without an argument reltime() returns the current time (the - representation is system-dependent, it can not be used as the + representation is system-dependent, it cannot be used as the wall-clock time, see |localtime()| for that). - With one argument is returns the time passed since the time + With one argument it returns the time passed since the time specified in the argument. With two arguments it returns the time passed between {start} and {end}. From 7b7672d5caa1dd6861ed9263d80d70d922bdcd06 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Sat, 6 Jan 2024 01:47:01 +0900 Subject: [PATCH 019/143] runtime(doc): Fix typos in version9.txt (#13817) Signed-off-by: Ken Takata Signed-off-by: Christian Brabandt --- runtime/doc/version9.txt | 88 ++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt index 0f4400a3f5..697fd79844 100644 --- a/runtime/doc/version9.txt +++ b/runtime/doc/version9.txt @@ -1,4 +1,4 @@ -*version9.txt* For Vim version 9.1. Last change: 2024 Jan 01 +*version9.txt* For Vim version 9.1. Last change: 2024 Jan 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -12957,7 +12957,7 @@ Files: src/fileio.c Patch 8.2.2056 Problem: Configure fails when building with the "implicit-function-declaration" error enabled, specifically on Mac. -Solution: Declear the functions like in the source code. (suggestion by +Solution: Declare the functions like in the source code. (suggestion by Clemens Lang, closes #7380) Files: src/configure.ac, src/auto/configure @@ -18862,7 +18862,7 @@ Solution: Do not handle text properties when deleting a line for splitting a Files: src/structs.h, src/memline.c, src/testdir/test_textprop.vim Patch 8.2.3063 -Problem: Crash when switching 'cryptmethod' to xchaha20 with an existing +Problem: Crash when switching 'cryptmethod' to xchacha20 with an existing undo file. (Martin Tournoij) Solution: Disable reading undo file when decoding can't be done inplace. (issue #8467) @@ -19819,7 +19819,7 @@ Solution: Add missing changes. Files: src/globals.h Patch 8.2.3218 -Problem: When using xchaha20 crypt undo file is not removed. +Problem: When using xchacha20 crypt undo file is not removed. Solution: Reset 'undofile' and delete the file. (Christian Brabandt, closes #8630, closes #8467) Files: src/bufwrite.c, src/crypt.c, src/proto/undo.pro, @@ -29043,7 +29043,7 @@ Files: src/testdir/test_autocmd.vim Patch 8.2.4729 Problem: HEEx and Surface templates do not need a separate filetype. -Solution: Use Eelixir for the similar filetypes. (Aaron Tinio, closes #10124) +Solution: Use Elixir for the similar filetypes. (Aaron Tinio, closes #10124) Files: runtime/filetype.vim, src/testdir/test_filetype.vim Patch 8.2.4730 @@ -31688,7 +31688,7 @@ Files: runtime/makemenu.vim VERSION 9.1 *version-9.1* *version9.1* *vim-9.1* This section is about improvements made between version 9.0 and 9.1. -The release 9.1 is dedicated to Vims Benevolent dictator for life +The release 9.1 is dedicated to Vim's Benevolent dictator for life |Bram-Moolenaar|. This release has hundreds of bug fixes, there are a few new features and there @@ -31774,7 +31774,7 @@ Other improvements *new-other-9.1* - Support "**" for filename expansion with bash using globstar setting. - Add quadruple prime digraph using 4'. - Better high dpi support on Windows. -- Varous fixes for unsafe memory access, memory leaks, buffer overflows +- Various fixes for unsafe memory access, memory leaks, buffer overflows and potential crashes. - Termdebug: Support for the variables window (|termdebug_variables_window|), moving up/down the stack frames (|termdebug-frames|) and setting temporary @@ -32098,7 +32098,7 @@ Problem: Split else-of is confusing. Solution: Join the lines. (closes #10696) Patch 9.0.0051 -Problem: Using CTRL-C wih :append may hang Vim. +Problem: Using CTRL-C with :append may hang Vim. Solution: Reset got_int. (closes #10729, closes #10728) Patch 9.0.0052 @@ -32487,7 +32487,7 @@ Solution: pass the command modifier in sticky_cmdmod_flags. (Kota Kato, closes #10845) Patch 9.0.0141 -Problem: "delmenu" does not remove autocmmands. Running menu test function +Problem: "delmenu" does not remove autocommands. Running menu test function alone fails. Solution: Delete autocommands Make sure there is at least one menu. (closes #10848) @@ -32663,7 +32663,7 @@ Solution: Remove ch_logfile() calls. Patch 9.0.0181 Problem: Textprop test with line2byte() fails on MS-Windows. -Solution: Fix updating chuncks in ml_delete_int(). +Solution: Fix updating chunks in ml_delete_int(). Patch 9.0.0182 Problem: Quarto files are not recognized. @@ -32901,7 +32901,7 @@ Problem: Cannot make difference between the end of :normal and a character Solution: Add the "typebuf_was_empty" flag. (closes #10950) Patch 9.0.0235 -Problem: 'autoshelldir' does not work with chunked respose. +Problem: 'autoshelldir' does not work with chunked response. Solution: Collect chunks before parsing OSC 7. (closes #10949) Patch 9.0.0236 @@ -32991,7 +32991,7 @@ Solution: Add #ifdef. Patch 9.0.0256 Problem: Compiler warning for uninitialized variables. -Solution: Initilize the variables. +Solution: Initialize the variables. Patch 9.0.0257 Problem: "->" in ":scriptnames" output not tested yet. @@ -33101,7 +33101,7 @@ Problem: Build failure without the +eval feature. Solution: Add #ifdef. Patch 9.0.0282 -Problem: A nested timout stops the previous timeout. +Problem: A nested timeout stops the previous timeout. Solution: Ignore any nested timeout. Patch 9.0.0283 @@ -33542,7 +33542,7 @@ Problem: Coverity complains about unused value. Solution: Use the value. Patch 9.0.0384 -Problem: Covertity still complains about using return value of getc(). +Problem: Coverity still complains about using return value of getc(). Solution: Check for EOF. Patch 9.0.0385 @@ -34271,7 +34271,7 @@ Problem: Crash when using NUL in buffer that uses :source. Solution: Don't get a next line when skipping over NL. Patch 9.0.0553 -Problem: No error for "|" after "{" in lamda. +Problem: No error for "|" after "{" in lambda. Solution: Check for invalid "|". (closes #11199) Patch 9.0.0554 @@ -34310,7 +34310,7 @@ Solution: Set a timeout of 30 seconds. Patch 9.0.0562 Problem: HSL playlist files are not recognized. -Solution: Add a pattern to recognize HSL palylist files. (Benoît Ryder, +Solution: Add a pattern to recognize HSL playlist files. (Benoît Ryder, closes #11204) Patch 9.0.0563 @@ -34400,7 +34400,7 @@ Solution: Also remove /private from the expected directory. Patch 9.0.0583 Problem: Only recognizing .m3u8 files is inconsistent. -Solution: Also matc .m3u files. (issue #11204) +Solution: Also match .m3u files. (issue #11204) Patch 9.0.0584 Problem: Cscope test with wrong executable name fails. @@ -34678,7 +34678,7 @@ Solution: Stop at line 1 when 'smoothscroll' is not set. (closes #11261) Patch 9.0.0646 Problem: with 'smoothscroll' set CTRL-E does not work properly when 'foldmethod' is set to "indent". (Yee Cheng Chin) -Solution: Merge the code for scroling with folds and 'smoothscroll'. +Solution: Merge the code for scrolling with folds and 'smoothscroll'. (closes #11262) Patch 9.0.0647 @@ -34770,7 +34770,7 @@ Patch 9.0.0666 Problem: Spacing-combining characters handled as composing, causing text to take more space than expected. Solution: Handle characters marked with "Mc" not as composing. - (closes #11282 + (closes #11282) Patch 9.0.0667 Problem: ml_get error when 'splitkeep' is "screen". (Marius Gedminas) @@ -34858,7 +34858,7 @@ Solution: Use a pointer to the first char. (Yee Cheng Chin, closes #11302) Patch 9.0.0686 Problem: The right ALT key does not work on some MS-Windows keyboards. -Solution: Adjust the modifiers based on GetKeyState(). (Anoton Sharonov, +Solution: Adjust the modifiers based on GetKeyState(). (Anton Sharonov, closes #11300) Patch 9.0.0687 @@ -35139,7 +35139,7 @@ Solution: Adjust expected result to slightly different behavior. Correct Patch 9.0.0747 Problem: Too many #ifdefs. -Solution: Gradudate the +cmdline_info feature. (Martin Tournoij, +Solution: Graduate the +cmdline_info feature. (Martin Tournoij, closes #11330) Patch 9.0.0748 @@ -35305,7 +35305,7 @@ Solution: Free the allocated memory when bailing out. Patch 9.0.0786 Problem: User command does not get number from :tab modifier. -Solution: Include the number. (closes #11393, closes #6801) +Solution: Include the number. (closes #11393, closes #6901) Patch 9.0.0787 Problem: MS-Windows: mouse scrolling in terminal misbehaves without dll. @@ -35372,8 +35372,8 @@ Solution: Remove one typedef. Patch 9.0.0801 Problem: The modifyOtherKeys flag is set when it should not. -Solution: Do not handle special key codes with a modifer value above 16 as a - modifyOtherKeys value. (issue #11403) +Solution: Do not handle special key codes with a modifier value above 16 as + a modifyOtherKeys value. (issue #11403) Patch 9.0.0802 Problem: MS-Windows: cannot map console mouse scroll events. @@ -35385,7 +35385,7 @@ Problem: readblob() cannot read from character device. Solution: Use S_ISCHR() to not check the size. (Ken Takata, closes #11407) Patch 9.0.0804 -Problem: Crash when trying to divice the largest negative number by -1. +Problem: Crash when trying to divide the largest negative number by -1. Solution: Handle this case specifically. Patch 9.0.0805 @@ -35974,7 +35974,7 @@ Solution: Improve code formatting. Patch 9.0.0935 Problem: When using dash it may not be recognize as filetype "sh". -Solution: Add checks for "dash". (Eisuke Kawashima,closes #11600) +Solution: Add checks for "dash". (Eisuke Kawashima, closes #11600) Patch 9.0.0936 Problem: Wrong type for "isunnamed" returned by getreginfo(). @@ -36465,7 +36465,7 @@ Solution: When setting "curwin" also set "curbuf". (closes #11687) Patch 9.0.1045 Problem: In a class object members cannot be initialized. -Solution: Support initializing object members. Make "dissassemble" work on +Solution: Support initializing object members. Make "disassemble" work on an object method. Patch 9.0.1046 @@ -36668,7 +36668,7 @@ Problem: Clang warns for unused variable. Solution: Adjust #ifdef. (John Marriott) Patch 9.0.1089 -Problem: unnessary assignment +Problem: unnecessary assignment Solution: Remove the assignment. (Luuk van Baal, closes #1136) Patch 9.0.1090 @@ -36886,11 +36886,11 @@ Solution: Only use the member when the type is a list. (closes #11774) Patch 9.0.1139 Problem: Cannot create a new object in a compiled function. -Solution: Compile the instructins to create a new object. +Solution: Compile the instructions to create a new object. Patch 9.0.1140 Problem: Cannot call an object method in a compiled function. -Solution: Compile the instructins to invoke an object method. +Solution: Compile the instructions to invoke an object method. Patch 9.0.1141 Problem: 'cursorcolumn' and 'colorcolumn' wrong after concealing and @@ -37031,7 +37031,7 @@ Solution: Redraw the screen when the cell widths have changed. (Yasuhiro Patch 9.0.1172 Problem: When 'selection' is "exclusive" then "1v" is one char short. -Solution: Add one character when 'selection' is "exclusive. (closes #11791) +Solution: Add one character when 'selection' is "exclusive". (closes #11791) Patch 9.0.1173 Problem: Compiler warning for unused variable on non-Unix systems. @@ -37264,7 +37264,7 @@ Problem: Reading past the end of a line when formatting text. Solution: Check for not going over the end of the line. Patch 9.0.1226 -Problem: Spurious empty line when using text propertie and virtual text. +Problem: Spurious empty line when using text properties and virtual text. Solution: Do not set "text_prop_follows" when the other text property is not virtual text. (closes #11846) @@ -37504,7 +37504,7 @@ Problem: Display shows lines scrolled down erroneously. (Yishai Lerner) Solution: Do not change "wl_lnum" at index zero. (closes #11938) Patch 9.0.1280 -Problem: Inssufficient testing for what 9.0.1265 fixes. +Problem: Insufficient testing for what 9.0.1265 fixes. Solution: Add a couple of test cases. (issue #11885) Patch 9.0.1281 @@ -37533,7 +37533,7 @@ Problem: Coverity warns for using a NULL pointer. Solution: Bail out whan "varp" is NULL. Patch 9.0.1287 -Problem: With the Kitty key protocl Esc with NumLock cannot be mapped. +Problem: With the Kitty key protocol Esc with NumLock cannot be mapped. Solution: Also use K_ESC when there is a modifier. (closes #11811) Patch 9.0.1288 @@ -37706,7 +37706,7 @@ Solution: Use the same code as used for "j"/"k" to go to the next/previous Patch 9.0.1325 Problem: 'colorcolumn' highlight wrong with virtual text above. -Solution: Adjust column of 'colorcolumn' for text propertly. (closes #12004) +Solution: Adjust column of 'colorcolumn' for text property. (closes #12004) Patch 9.0.1326 Problem: Relative line number not updated with virtual text above. @@ -37965,8 +37965,8 @@ Problem: xxd: combination of little endian and cols fails. (Aapo Solution: Round up the space taken by the hex output. (closes #12097) Patch 9.0.1384 -Problem: Setting HOMEBREW_NO_AUTO_UPDATE is not needed with Homebew version - 4. +Problem: Setting HOMEBREW_NO_AUTO_UPDATE is not needed with Homebrew + version 4. Solution: Remove setting HOMEBREW_NO_AUTO_UPDATE. (closes #12008) Patch 9.0.1385 @@ -38413,7 +38413,7 @@ Solution: Add entry for Xchacha, even though it is not used. Patch 9.0.1485 Problem: no functions for converting from/to UTF-16 index. -Solution: Add UTF-16 flag to existing funtions and add strutf16len() and +Solution: Add UTF-16 flag to existing functions and add strutf16len() and utf16idx(). (Yegappan Lakshmanan, closes #12216) Patch 9.0.1486 @@ -38427,7 +38427,7 @@ Solution: Use "vscode-jsonrpc" instead of "vim-jsonrpc". (Yegappan Patch 9.0.1488 Problem: xchacha20v2 crypt header is platform dependent. -Solution: Avoid using "size_t". (Ozaki Kiichi, closses #12296) +Solution: Avoid using "size_t". (Ozaki Kiichi, closes #12296) Patch 9.0.1489 Problem: Crypt with libsodium is not tested on CI. @@ -39720,7 +39720,7 @@ Solution: Add a few more tests for operator pending mode and register Patch 9.0.1780 Problem: Vim9 type not defined during object creation Solution: Define type during object creation and not during class - definition, parse mulit-line member initializers, fix lock + definition, parse multi-line member initializers, fix lock initialization Patch 9.0.1781 @@ -39786,7 +39786,7 @@ Problem: obsolete macros in configure script Solution: Remove those and start moving to autoconf 2.71 Patch 9.0.1794 -Problem: autoconf: not correctly detecing include dirs +Problem: autoconf: not correctly detecting include dirs Solution: make use of python3 to generate includedirs Patch 9.0.1795 @@ -40117,7 +40117,7 @@ Problem: Coverity warns about uninitialized var Solution: initialize it Patch 9.0.1870 -Problem: Vim9: disassamble does not show static +Problem: Vim9: disassemble does not show static Solution: Show static flag Patch 9.0.1871 @@ -40860,7 +40860,7 @@ Solution: Fix cmdline completion fuzzy/Ctrl-E/Ctrl-Y/options when not Patch 9.0.2038 Problem: Vim9: object method funcref not cleaned up after use Solution: Clean up type stack after using object method funcref, - remove now longer used ISN_DEFEROBJ instrunction + remove now longer used ISN_DEFEROBJ instruction Patch 9.0.2039 Problem: completion shows current word after completion restart @@ -40883,7 +40883,7 @@ Problem: Vim9: issue with funcref assignment and varargs Solution: Fix funcref type checking Patch 9.0.2044 -Problem: Vim9: exceptions confuse defered functions +Problem: Vim9: exceptions confuse deferred functions Solution: save and restore exception state when calling deferred functions From 3779516988f14f2070d827514c79383334a0946b Mon Sep 17 00:00:00 2001 From: Maxim Kim Date: Fri, 5 Jan 2024 17:52:49 +0100 Subject: [PATCH 020/143] patch 9.1.0012: regression with empty inner blocks introduced Problem: regression with empty inner blocks introduced (after v9.1.0007) Solution: Set correct cursor position, Check for visual mode being active (Maxim Kim) relates: #13514 closes: #13819 Signed-off-by: Maxim Kim Signed-off-by: Christian Brabandt --- src/testdir/test_textobjects.vim | 24 +++++++++++++++++++++--- src/textobject.c | 11 ++++++++--- src/version.c | 2 ++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/testdir/test_textobjects.vim b/src/testdir/test_textobjects.vim index 89e741c715..d5e772db50 100644 --- a/src/testdir/test_textobjects.vim +++ b/src/testdir/test_textobjects.vim @@ -643,7 +643,7 @@ endfunc func Test_inner_block_empty_paren() new - call setline(1, ["(text)()", "", "(text)(", ")", "", "()()"]) + call setline(1, ["(text)()", "", "(text)(", ")", "", "()()", "", "text()"]) " Example 1 call cursor(1, 1) @@ -665,12 +665,18 @@ func Test_inner_block_empty_paren() call assert_beeps('call feedkeys("0f(viby", "xt")') call assert_equal(3, getpos('.')[2]) call assert_equal('(', @") + + " Change empty inner block + call cursor(8, 1) + call feedkeys("0cibtext", "xt") + call assert_equal("text(text)", getline('.')) + bwipe! endfunc func Test_inner_block_empty_bracket() new - call setline(1, ["[text][]", "", "[text][", "]", "", "[][]"]) + call setline(1, ["[text][]", "", "[text][", "]", "", "[][]", "", "text[]"]) " Example 1 call cursor(1, 1) @@ -692,12 +698,18 @@ func Test_inner_block_empty_bracket() call assert_beeps('call feedkeys("0f[viby", "xt")') call assert_equal(3, getpos('.')[2]) call assert_equal('[', @") + + " Change empty inner block + call cursor(8, 1) + call feedkeys("0ci[text", "xt") + call assert_equal("text[text]", getline('.')) + bwipe! endfunc func Test_inner_block_empty_brace() new - call setline(1, ["{text}{}", "", "{text}{", "}", "", "{}{}"]) + call setline(1, ["{text}{}", "", "{text}{", "}", "", "{}{}", "", "text{}"]) " Example 1 call cursor(1, 1) @@ -719,6 +731,12 @@ func Test_inner_block_empty_brace() call assert_beeps('call feedkeys("0f{viby", "xt")') call assert_equal(3, getpos('.')[2]) call assert_equal('{', @") + + " Change empty inner block + call cursor(8, 1) + call feedkeys("0ciBtext", "xt") + call assert_equal("text{text}", getline('.')) + bwipe! endfunc diff --git a/src/textobject.c b/src/textobject.c index af94d06bc8..015b33bbf5 100644 --- a/src/textobject.c +++ b/src/textobject.c @@ -1131,10 +1131,15 @@ current_block( break; } - if (EQUAL_POS(start_pos, *end_pos)) - // empty block like this: () - // there is no inner block to select, abort + /* + * In Visual mode, when resulting area is empty + * i.e. there is no inner block to select, abort. + */ + if (EQUAL_POS(start_pos, *end_pos) && VIsual_active) + { + curwin->w_cursor = old_pos; return FAIL; + } /* * In Visual mode, when the resulting area is not bigger than what we diff --git a/src/version.c b/src/version.c index d45181d9d7..35865d696f 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 12, /**/ 11, /**/ From 68a89470693c7687d4e736ca056c05de632e3ac7 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 5 Jan 2024 17:59:04 +0100 Subject: [PATCH 021/143] patch 9.1.0013: Modula2 filetype support lacking Problem: Modula2 filetype support lacking Solution: Improve the Modula-2 runtime support, add additional modula2 dialects, add compiler plugin, update syntax highlighting, include syntax tests, update Makefiles (Doug Kearns) closes: #6796 closes: #8115 Signed-off-by: Doug Kearns Signed-off-by: Benjamin Kowarsch Signed-off-by: Christian Brabandt --- .github/CODEOWNERS | 7 + Filelist | 1 + runtime/autoload/dist/ft.vim | 60 ++- runtime/autoload/modula2.vim | 31 ++ runtime/compiler/gm2.vim | 26 + runtime/doc/filetype.txt | 3 +- runtime/doc/syntax.txt | 50 ++ runtime/doc/tags | 9 + runtime/filetype.vim | 11 +- runtime/ftplugin/modula2.vim | 35 +- runtime/makemenu.vim | 6 +- runtime/synmenu.vim | 48 +- runtime/syntax/modula2.vim | 71 +-- runtime/syntax/modula2/opt/iso.vim | 380 +++++++++++++++ runtime/syntax/modula2/opt/pim.vim | 377 +++++++++++++++ runtime/syntax/modula2/opt/r10.vim | 452 ++++++++++++++++++ .../syntax/testdir/dumps/modula2_iso_00.dump | 20 + .../syntax/testdir/dumps/modula2_iso_01.dump | 20 + .../syntax/testdir/dumps/modula2_iso_02.dump | 20 + .../syntax/testdir/dumps/modula2_iso_03.dump | 20 + .../syntax/testdir/dumps/modula2_iso_04.dump | 20 + .../syntax/testdir/dumps/modula2_iso_05.dump | 20 + .../syntax/testdir/dumps/modula2_iso_06.dump | 20 + .../syntax/testdir/dumps/modula2_iso_99.dump | 20 + .../syntax/testdir/dumps/modula2_pim_00.dump | 20 + .../syntax/testdir/dumps/modula2_pim_01.dump | 20 + .../syntax/testdir/dumps/modula2_pim_02.dump | 20 + .../syntax/testdir/dumps/modula2_pim_03.dump | 20 + .../syntax/testdir/dumps/modula2_pim_04.dump | 20 + .../syntax/testdir/dumps/modula2_pim_05.dump | 20 + .../syntax/testdir/dumps/modula2_pim_99.dump | 20 + .../syntax/testdir/dumps/modula2_r10_00.dump | 20 + .../syntax/testdir/dumps/modula2_r10_01.dump | 20 + .../syntax/testdir/dumps/modula2_r10_02.dump | 20 + .../syntax/testdir/dumps/modula2_r10_03.dump | 20 + .../syntax/testdir/dumps/modula2_r10_04.dump | 20 + .../syntax/testdir/dumps/modula2_r10_05.dump | 20 + .../syntax/testdir/dumps/modula2_r10_06.dump | 20 + .../syntax/testdir/dumps/modula2_r10_07.dump | 20 + .../syntax/testdir/dumps/modula2_r10_99.dump | 20 + runtime/syntax/testdir/input/modula2_iso.def | 114 +++++ runtime/syntax/testdir/input/modula2_pim.def | 111 +++++ runtime/syntax/testdir/input/modula2_r10.def | 146 ++++++ src/Makefile | 8 +- src/testdir/test_filetype.vim | 38 +- src/version.c | 2 + 46 files changed, 2354 insertions(+), 112 deletions(-) create mode 100644 runtime/autoload/modula2.vim create mode 100644 runtime/compiler/gm2.vim create mode 100644 runtime/syntax/modula2/opt/iso.vim create mode 100644 runtime/syntax/modula2/opt/pim.vim create mode 100644 runtime/syntax/modula2/opt/r10.vim create mode 100644 runtime/syntax/testdir/dumps/modula2_iso_00.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_iso_01.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_iso_02.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_iso_03.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_iso_04.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_iso_05.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_iso_06.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_iso_99.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_pim_00.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_pim_01.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_pim_02.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_pim_03.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_pim_04.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_pim_05.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_pim_99.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_r10_00.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_r10_01.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_r10_02.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_r10_03.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_r10_04.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_r10_05.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_r10_06.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_r10_07.dump create mode 100644 runtime/syntax/testdir/dumps/modula2_r10_99.dump create mode 100644 runtime/syntax/testdir/input/modula2_iso.def create mode 100644 runtime/syntax/testdir/input/modula2_pim.def create mode 100644 runtime/syntax/testdir/input/modula2_r10.def diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index af32d6a3ab..6ebaeda19e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -13,6 +13,7 @@ runtime/autoload/freebasic.vim @dkearns runtime/autoload/getscript.vim @cecamp runtime/autoload/haskell.vim @alx741 runtime/autoload/javascript.vim @jsit +runtime/autoload/modula2.vim @dkearns runtime/autoload/netrw.vim @cecamp runtime/autoload/netrwFileHandlers.vim @cecamp runtime/autoload/netrwSettings.vim @cecamp @@ -65,6 +66,7 @@ runtime/compiler/eruby.vim @dkearns runtime/compiler/fbc.vim @dkearns runtime/compiler/gawk.vim @dkearns runtime/compiler/gjs.vim @dkearns +runtime/compiler/gm2.vim @dkearns runtime/compiler/go.vim @dbarnett runtime/compiler/haml.vim @tpope runtime/compiler/hare.vim @rsaihe @@ -182,6 +184,7 @@ runtime/ftplugin/m3quake.vim @dkearns runtime/ftplugin/markdown.vim @tpope runtime/ftplugin/matlab.vim @cecamp runtime/ftplugin/meson.vim @Liambeguin +runtime/ftplugin/modula2.vim @dkearns runtime/ftplugin/modula3.vim @dkearns runtime/ftplugin/nginx.vim @chr4 runtime/ftplugin/nroff.vim @a-vrma @@ -442,6 +445,10 @@ runtime/syntax/maple.vim @cecamp runtime/syntax/markdown.vim @tpope runtime/syntax/mason.vim @petdance runtime/syntax/meson.vim @Liambeguin +runtime/syntax/modula2.vim @dkearns +runtime/syntax/modula2/opt/iso.vim @trijezdci +runtime/syntax/modula2/opt/pim.vim @trijezdci +runtime/syntax/modula2/opt/r10.vim @trijezdci runtime/syntax/modula3.vim @dkearns runtime/syntax/n1ql.vim @pr3d4t0r runtime/syntax/netrw.vim @cecamp diff --git a/Filelist b/Filelist index df188e8a5e..d4fbca342e 100644 --- a/Filelist +++ b/Filelist @@ -818,6 +818,7 @@ RT_SCRIPTS = \ runtime/plugin/README.txt \ runtime/syntax/*.vim \ runtime/syntax/README.txt \ + runtime/syntax/modula2/opt/*.vim \ runtime/syntax/shared/*.vim \ runtime/syntax/shared/README.txt \ runtime/syntax/Makefile \ diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 2423fd4469..9d0f2ee7af 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -2,8 +2,8 @@ vim9script # Vim functions for file type detection # -# Maintainer: The Vim Project -# Last Change: 2023 Aug 10 +# Maintainer: The Vim Project +# Last Change: 2024 Jan 05 # Former Maintainer: Bram Moolenaar # These functions are moved here from runtime/filetype.vim to make startup @@ -279,6 +279,19 @@ export def DtraceCheck() endif enddef +export def FTdef() + if get(g:, "filetype_def", "") == "modula2" || IsModula2() + SetFiletypeModula2() + return + endif + + if exists("g:filetype_def") + exe "setf " .. g:filetype_def + else + setf def + endif +enddef + export def FTe() if exists('g:filetype_euphoria') exe 'setf ' .. g:filetype_euphoria @@ -517,16 +530,53 @@ def IsLProlog(): bool return getline(lnum) =~ '\= 0 + dialect = matches[1] + endif + if index(KNOWN_EXTENSIONS, matches[2]) >= 0 + extension = matches[2] + endif + break + endif + endfor + + modula2#SetDialect(dialect, extension) + + setf modula2 +enddef + # Determine if *.mod is ABB RAPID, LambdaProlog, Modula-2, Modsim III or go.mod export def FTmod() + if get(g:, "filetype_mod", "") == "modula2" || IsModula2() + SetFiletypeModula2() + return + endif + if exists("g:filetype_mod") exe "setf " .. g:filetype_mod elseif expand("") =~ '\ +" Last Change: 2024 Jan 04 + +" Dialect can be one of pim, iso, r10 +function modula2#GetDialect() abort + + if exists("b:modula2.dialect") + return b:modula2.dialect + endif + + if exists("g:modula2_default_dialect") + let dialect = g:modula2_default_dialect + else + let dialect = "pim" + endif + + return dialect +endfunction + +function modula2#SetDialect(dialect, extension = "") abort + if exists("b:modula2") + unlockvar! b:modula2 + endif + + let b:modula2 = #{ dialect: a:dialect, extension: a:extension } + lockvar! b:modula2 +endfunction + +" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: diff --git a/runtime/compiler/gm2.vim b/runtime/compiler/gm2.vim new file mode 100644 index 0000000000..5053912200 --- /dev/null +++ b/runtime/compiler/gm2.vim @@ -0,0 +1,26 @@ +" Vim compiler file +" Compiler: GNU Modula-2 Compiler +" Maintainer: Doug Kearns +" Last Change: 2024 Jan 04 + +if exists("current_compiler") + finish +endif +let current_compiler = "gm2" + +if exists(":CompilerSet") != 2 " older Vim always used :setlocal + command -nargs=* CompilerSet setlocal +endif + +let s:cpo_save = &cpo +set cpo&vim + +CompilerSet makeprg=gm2 +CompilerSet errorformat=%-G%f:%l:%c:\ error:\ compilation\ failed, + \%f:%l:%c:\ %trror:\ %m, + \%f:%l:%c:\ %tarning:\ %m, + \%f:%l:%c:\ %tote:\ %m, + \%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt index e8445db541..4876e3d754 100644 --- a/runtime/doc/filetype.txt +++ b/runtime/doc/filetype.txt @@ -1,4 +1,4 @@ -*filetype.txt* For Vim version 9.1. Last change: 2024 Jan 01 +*filetype.txt* For Vim version 9.1. Last change: 2024 Jan 04 VIM REFERENCE MANUAL by Bram Moolenaar @@ -148,6 +148,7 @@ variables can be used to overrule the filetype used for certain extensions: *.cls g:filetype_cls *.csh g:filetype_csh |ft-csh-syntax| *.dat g:filetype_dat + *.def g:filetype_def *.f g:filetype_f |ft-forth-syntax| *.frm g:filetype_frm |ft-form-syntax| *.fs g:filetype_fs |ft-forth-syntax| diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index e3cac2e248..cc293a5979 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -2251,6 +2251,56 @@ have the following in your .vimrc: > let filetype_m = "mma" +MODULA2 *modula2.vim* *ft-modula2-syntax* + +Vim will recognise comments with dialect tags to automatically select a given +dialect. + +The syntax for a dialect tag comment is: > + + taggedComment := + '(*!' dialectTag '*)' + ; + + dialectTag := + m2pim | m2iso | m2r10 + ; + + reserved words + m2pim = 'm2pim', m2iso = 'm2iso', m2r10 = 'm2r10' + +A dialect tag comment is recognised by Vim if it occurs within the first 200 +lines of the source file. Only the very first such comment is recognised, any +additional dialect tag comments are ignored. + +Example: > + + DEFINITION MODULE FooLib; (*!m2pim*) + ... + +Variable g:modula2_default_dialect sets the default Modula-2 dialect when the +dialect cannot be determined from the contents of the Modula-2 file: if +defined and set to 'm2pim', the default dialect is PIM. + +Example: > + + let g:modula2_default_dialect = 'm2pim' + + +Highlighting is further configurable for each dialect via the following +variables. + +Variable Highlight ~ +*modula2_iso_allow_lowline* allow low line in identifiers +*modula2_iso_disallow_octals* disallow octal integer literals +*modula2_iso_disallow_synonyms* disallow "@", "&" and "~" synonyms + +*modula2_pim_allow_lowline* allow low line in identifiers +*modula2_pim_disallow_octals* disallow octal integer literals +*modula2_pim_disallow_synonyms* disallow "&" and "~" synonyms + +*modula2_r10_allow_lowline* allow low line in identifiers + MOO *moo.vim* *ft-moo-syntax* If you use C-style comments inside expressions and find it mangles your diff --git a/runtime/doc/tags b/runtime/doc/tags index 9af1ac0f64..5b9e5a9b64 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -7270,6 +7270,7 @@ ft-metapost-intro ft_mp.txt /*ft-metapost-intro* ft-metapost-mappings ft_mp.txt /*ft-metapost-mappings* ft-metapost-settings ft_mp.txt /*ft-metapost-settings* ft-mma-syntax syntax.txt /*ft-mma-syntax* +ft-modula2-syntax syntax.txt /*ft-modula2-syntax* ft-moo-syntax syntax.txt /*ft-moo-syntax* ft-msql-syntax syntax.txt /*ft-msql-syntax* ft-n1ql-syntax syntax.txt /*ft-n1ql-syntax* @@ -8659,6 +8660,14 @@ modeline options.txt /*modeline* modeline-local options.txt /*modeline-local* modeline-version options.txt /*modeline-version* modifyOtherKeys map.txt /*modifyOtherKeys* +modula2.vim syntax.txt /*modula2.vim* +modula2_iso_allow_lowline syntax.txt /*modula2_iso_allow_lowline* +modula2_iso_disallow_octals syntax.txt /*modula2_iso_disallow_octals* +modula2_iso_disallow_synonyms syntax.txt /*modula2_iso_disallow_synonyms* +modula2_pim_allow_lowline syntax.txt /*modula2_pim_allow_lowline* +modula2_pim_disallow_octals syntax.txt /*modula2_pim_disallow_octals* +modula2_pim_disallow_synonyms syntax.txt /*modula2_pim_disallow_synonyms* +modula2_r10_allow_lowline syntax.txt /*modula2_r10_allow_lowline* moo.vim syntax.txt /*moo.vim* more-compatible version5.txt /*more-compatible* more-prompt message.txt /*more-prompt* diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 30f8a1e16d..0c2869a017 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -619,8 +619,12 @@ au BufNewFile,BufRead *.intr setf dylanintr " Dylan au BufNewFile,BufRead *.dylan setf dylan -" Microsoft Module Definition -au BufNewFile,BufRead *.def setf def +" Microsoft Module Definition or Modula-2 +au BufNewFile,BufRead *.def call dist#ft#FTdef() + +if has("fname_case") + au BufNewFile,BufRead *.DEF setf modula2 +endif " Dracula au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe setf dracula @@ -1339,9 +1343,6 @@ au BufNewFile,BufRead *.mmp setf mmp " ABB Rapid, Modula-2, Modsim III or LambdaProlog au BufNewFile,BufRead *.mod\c call dist#ft#FTmod() -" Modula-2 (.md removed in favor of Markdown, see dist#ft#FTmod for *.MOD) -au BufNewFile,BufRead *.m2,*.DEF,*.mi setf modula2 - " Modula-3 (.m3, .i3, .mg, .ig) au BufNewFile,BufRead *.[mi][3g] setf modula3 diff --git a/runtime/ftplugin/modula2.vim b/runtime/ftplugin/modula2.vim index 1d0e81ee70..e230636acc 100644 --- a/runtime/ftplugin/modula2.vim +++ b/runtime/ftplugin/modula2.vim @@ -11,28 +11,39 @@ let b:did_ftplugin = 1 let s:cpo_save = &cpo set cpo&vim -setlocal comments=s0:(*,mb:\ ,ex:*) -setlocal commentstring=(*%s*) +let s:dialect = modula2#GetDialect() + +if s:dialect ==# "r10" + setlocal comments=s:(*,m:\ ,e:*),:! + setlocal commentstring=!\ %s +else + setlocal commentstring=(*%s*) + setlocal comments=s:(*,m:\ ,e:*) +endif setlocal formatoptions-=t formatoptions+=croql +let b:undo_ftplugin = "setl com< cms< fo<" + if exists("loaded_matchit") && !exists("b:match_words") - " The second branch of the middle pattern is intended to match CASE labels + let b:match_ignorecase = 0 + " the second branch of the middle pattern is intended to match CASE labels let b:match_words = '\:\,' .. - \ '\<\%(BEGIN\|CASE\|FOR\|IF\|LOOP\|WHILE\|WITH\)\>' .. - \ ':' .. - \ '\<\%(ELSIF\|ELSE\)\>\|\%(^\s*\)\@<=\w\+\%(\s*\,\s*\w\+\)\=\s*\:=\@!' .. - \ ':' .. - \ '\' + \ '\<\%(BEGIN\|CASE\|FOR\|IF\|LOOP\|WHILE\|WITH\|RECORD\)\>' .. + \ ':' .. + \ '\<\%(ELSIF\|ELSE\)\>\|\%(^\s*\)\@<=\w\+\%(\s*\,\s*\w\+\)\=\s*\:=\@!' .. + \ ':' .. + \ '\,' .. + \ '(\*:\*),<\*:\*>' + let b:match_skip = 's:Comment\|Pragma' + let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_skip b:match_words" endif if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:browsefilter = "Modula-2 Source Files (*.def *.mod)\t*.def;*.mod\n" .. - \ "All Files (*.*)\t*.*\n" + \ "All Files (*.*)\t*.*\n" + let b:undo_ftplugin ..= " | unlet! b:browsefilter" endif -let b:undo_ftplugin = "setl com< cms< fo< " .. - \ "| unlet! b:browsefilter b:match_words" - let &cpo = s:cpo_save unlet s:cpo_save diff --git a/runtime/makemenu.vim b/runtime/makemenu.vim index 16af2035e3..6707f2b6a6 100644 --- a/runtime/makemenu.vim +++ b/runtime/makemenu.vim @@ -384,8 +384,10 @@ SynMenu M.MMIX:mmix SynMenu M.Modconf:modconf SynMenu M.Model:model SynMenu M.Modsim\ III:modsim3 -SynMenu M.Modula\ 2:modula2 -SynMenu M.Modula\ 3:modula3 +SynMenu M.Modula-2.R10\ (2010):modula2:r10 +SynMenu M.Modula-2.ISO\ (1994):modula2:iso +SynMenu M.Modula-2.PIM\ (1985):modula2:pim +SynMenu M.Modula-3:modula3 SynMenu M.Monk:monk SynMenu M.Motorola\ S-Record:srec SynMenu M.Mplayer\ config:mplayerconf diff --git a/runtime/synmenu.vim b/runtime/synmenu.vim index eeede5f7ce..23c1c7b95b 100644 --- a/runtime/synmenu.vim +++ b/runtime/synmenu.vim @@ -1,8 +1,8 @@ " Vim support file to define the syntax selection menu " This file is normally sourced from menu.vim. " -" Maintainer: The Vim Project -" Last Change: 2023 Aug 10 +" Maintainer: The Vim Project +" Last Change: 2024 Jan 04 " Former Maintainer: Bram Moolenaar " Define the SetSyn function, used for the Syntax menu entries. @@ -13,6 +13,10 @@ def SetSyn(name: string) g:use_fvwm_1 = name == "fvwm1" g:use_fvwm_2 = name == "fvwm2" filetype = "fvwm" + elseif name =~ '^modula2:\w\+$' + var dialect: string + [filetype, dialect] = split(name, ":") + modula2#SetDialect(dialect) endif if name == "whitespace" # do not replace the filetype but add whitespace on top @@ -359,25 +363,27 @@ an 50.70.340 &Syntax.M.MMIX :cal SetSyn("mmix") an 50.70.350 &Syntax.M.Modconf :cal SetSyn("modconf") an 50.70.360 &Syntax.M.Model :cal SetSyn("model") an 50.70.370 &Syntax.M.Modsim\ III :cal SetSyn("modsim3") -an 50.70.380 &Syntax.M.Modula\ 2 :cal SetSyn("modula2") -an 50.70.390 &Syntax.M.Modula\ 3 :cal SetSyn("modula3") -an 50.70.400 &Syntax.M.Monk :cal SetSyn("monk") -an 50.70.410 &Syntax.M.Motorola\ S-Record :cal SetSyn("srec") -an 50.70.420 &Syntax.M.Mplayer\ config :cal SetSyn("mplayerconf") -an 50.70.430 &Syntax.M.MOO :cal SetSyn("moo") -an 50.70.440 &Syntax.M.Mrxvtrc :cal SetSyn("mrxvtrc") -an 50.70.450 &Syntax.M.MS-DOS/Windows.4DOS\ \.bat\ file :cal SetSyn("btm") -an 50.70.460 &Syntax.M.MS-DOS/Windows.\.bat\/\.cmd\ file :cal SetSyn("dosbatch") -an 50.70.470 &Syntax.M.MS-DOS/Windows.\.ini\ file :cal SetSyn("dosini") -an 50.70.480 &Syntax.M.MS-DOS/Windows.Message\ text :cal SetSyn("msmessages") -an 50.70.490 &Syntax.M.MS-DOS/Windows.Module\ Definition :cal SetSyn("def") -an 50.70.500 &Syntax.M.MS-DOS/Windows.Registry :cal SetSyn("registry") -an 50.70.510 &Syntax.M.MS-DOS/Windows.Resource\ file :cal SetSyn("rc") -an 50.70.520 &Syntax.M.Msql :cal SetSyn("msql") -an 50.70.530 &Syntax.M.MuPAD :cal SetSyn("mupad") -an 50.70.540 &Syntax.M.Murphi :cal SetSyn("murphi") -an 50.70.550 &Syntax.M.MUSHcode :cal SetSyn("mush") -an 50.70.560 &Syntax.M.Muttrc :cal SetSyn("muttrc") +an 50.70.380 &Syntax.M.Modula-2.R10\ (2010) :cal SetSyn("modula2:r10") +an 50.70.390 &Syntax.M.Modula-2.ISO\ (1994) :cal SetSyn("modula2:iso") +an 50.70.400 &Syntax.M.Modula-2.PIM\ (1985) :cal SetSyn("modula2:pim") +an 50.70.410 &Syntax.M.Modula-3 :cal SetSyn("modula3") +an 50.70.420 &Syntax.M.Monk :cal SetSyn("monk") +an 50.70.430 &Syntax.M.Motorola\ S-Record :cal SetSyn("srec") +an 50.70.440 &Syntax.M.Mplayer\ config :cal SetSyn("mplayerconf") +an 50.70.450 &Syntax.M.MOO :cal SetSyn("moo") +an 50.70.460 &Syntax.M.Mrxvtrc :cal SetSyn("mrxvtrc") +an 50.70.470 &Syntax.M.MS-DOS/Windows.4DOS\ \.bat\ file :cal SetSyn("btm") +an 50.70.480 &Syntax.M.MS-DOS/Windows.\.bat\/\.cmd\ file :cal SetSyn("dosbatch") +an 50.70.490 &Syntax.M.MS-DOS/Windows.\.ini\ file :cal SetSyn("dosini") +an 50.70.500 &Syntax.M.MS-DOS/Windows.Message\ text :cal SetSyn("msmessages") +an 50.70.510 &Syntax.M.MS-DOS/Windows.Module\ Definition :cal SetSyn("def") +an 50.70.520 &Syntax.M.MS-DOS/Windows.Registry :cal SetSyn("registry") +an 50.70.530 &Syntax.M.MS-DOS/Windows.Resource\ file :cal SetSyn("rc") +an 50.70.540 &Syntax.M.Msql :cal SetSyn("msql") +an 50.70.550 &Syntax.M.MuPAD :cal SetSyn("mupad") +an 50.70.560 &Syntax.M.Murphi :cal SetSyn("murphi") +an 50.70.570 &Syntax.M.MUSHcode :cal SetSyn("mush") +an 50.70.580 &Syntax.M.Muttrc :cal SetSyn("muttrc") an 50.80.100 &Syntax.NO.N1QL :cal SetSyn("n1ql") an 50.80.110 &Syntax.NO.Nanorc :cal SetSyn("nanorc") an 50.80.120 &Syntax.NO.Nastran\ input/DMAP :cal SetSyn("nastran") diff --git a/runtime/syntax/modula2.vim b/runtime/syntax/modula2.vim index 4a14cf1f6f..6a9f4af6aa 100644 --- a/runtime/syntax/modula2.vim +++ b/runtime/syntax/modula2.vim @@ -1,73 +1,16 @@ " Vim syntax file -" Language: Modula 2 -" Maintainer: pf@artcom0.north.de (Peter Funk) -" based on original work of Bram Moolenaar -" Last Change: 2001 May 09 +" Language: Modula-2 +" Maintainer: Doug Kearns +" Previous Maintainer: pf@artcom0.north.de (Peter Funk) +" Last Change: 2024 Jan 04 -" quit when a syntax file was already loaded if exists("b:current_syntax") finish endif -" Don't ignore case (Modula-2 is case significant). This is the default in vim - -" Especially emphasize headers of procedures and modules: -syn region modula2Header matchgroup=modula2Header start="PROCEDURE " end="(" contains=modula2Ident oneline -syn region modula2Header matchgroup=modula2Header start="MODULE " end=";" contains=modula2Ident oneline -syn region modula2Header matchgroup=modula2Header start="BEGIN (\*" end="\*)" contains=modula2Ident oneline -syn region modula2Header matchgroup=modula2Header start="END " end=";" contains=modula2Ident oneline -syn region modula2Keyword start="END" end=";" contains=ALLBUT,modula2Ident oneline - -" Some very important keywords which should be emphasized more than others: -syn keyword modula2AttKeyword CONST EXIT HALT RETURN TYPE VAR -" All other keywords in alphabetical order: -syn keyword modula2Keyword AND ARRAY BY CASE DEFINITION DIV DO ELSE -syn keyword modula2Keyword ELSIF EXPORT FOR FROM IF IMPLEMENTATION IMPORT -syn keyword modula2Keyword IN LOOP MOD NOT OF OR POINTER QUALIFIED RECORD -syn keyword modula2Keyword SET THEN TO UNTIL WHILE WITH - -syn keyword modula2Type ADDRESS BITSET BOOLEAN CARDINAL CHAR INTEGER REAL WORD -syn keyword modula2StdFunc ABS CAP CHR DEC EXCL INC INCL ORD SIZE TSIZE VAL -syn keyword modula2StdConst FALSE NIL TRUE -" The following may be discussed, since NEW and DISPOSE are some kind of -" special builtin macro functions: -syn keyword modula2StdFunc NEW DISPOSE -" The following types are added later on and may be missing from older -" Modula-2 Compilers (they are at least missing from the original report -" by N.Wirth from March 1980 ;-) Highlighting should apply nevertheless: -syn keyword modula2Type BYTE LONGCARD LONGINT LONGREAL PROC SHORTCARD SHORTINT -" same note applies to min and max, which were also added later to m2: -syn keyword modula2StdFunc MAX MIN -" The underscore was originally disallowed in m2 ids, it was also added later: -syn match modula2Ident " [A-Z,a-z][A-Z,a-z,0-9,_]*" contained - -" Comments may be nested in Modula-2: -syn region modula2Comment start="(\*" end="\*)" contains=modula2Comment,modula2Todo -syn keyword modula2Todo contained TODO FIXME XXX - -" Strings -syn region modula2String start=+"+ end=+"+ -syn region modula2String start="'" end="'" -syn region modula2Set start="{" end="}" - -" Define the default highlighting. -" Only when an item doesn't have highlighting yet - -hi def link modula2Ident Identifier -hi def link modula2StdConst Boolean -hi def link modula2Type Identifier -hi def link modula2StdFunc Identifier -hi def link modula2Header Type -hi def link modula2Keyword Statement -hi def link modula2AttKeyword PreProc -hi def link modula2Comment Comment -" The following is just a matter of taste (you want to try this instead): -" hi modula2Comment term=bold ctermfg=DarkBlue guifg=Blue gui=bold -hi def link modula2Todo Todo -hi def link modula2String String -hi def link modula2Set String - +let dialect = modula2#GetDialect() +exe "runtime! syntax/modula2/opt/" .. dialect .. ".vim" let b:current_syntax = "modula2" -" vim: ts=8 +" vim: nowrap sw=2 sts=2 ts=8 noet: diff --git a/runtime/syntax/modula2/opt/iso.vim b/runtime/syntax/modula2/opt/iso.vim new file mode 100644 index 0000000000..5bd24f6885 --- /dev/null +++ b/runtime/syntax/modula2/opt/iso.vim @@ -0,0 +1,380 @@ +" Vim syntax file +" Language: Modula-2 (ISO) +" Maintainer: B.Kowarsch +" Last Change: 2016 August 22 + +" ---------------------------------------------------- +" THIS FILE IS LICENSED UNDER THE VIM LICENSE +" see https://github.com/vim/vim/blob/master/LICENSE +" ---------------------------------------------------- + +" Remarks: +" Vim Syntax files are available for the following Modula-2 dialects: +" * for the PIM dialect : m2pim.vim +" * for the ISO dialect : m2iso.vim (this file) +" * for the R10 dialect : m2r10.vim + +" ----------------------------------------------------------------------------- +" This syntax description follows ISO standard IS-10514 (aka ISO Modula-2) +" with the addition of the following language extensions: +" * non-standard types LONGCARD and LONGBITSET +" * non-nesting code disabling tags ?< and >? at the start of a line +" ----------------------------------------------------------------------------- + +" Parameters: +" +" Vim's filetype script recognises Modula-2 dialect tags within the first 200 +" lines of Modula-2 .def and .mod input files. The script sets filetype and +" dialect automatically when a valid dialect tag is found in the input file. +" The dialect tag for the ISO dialect is (*!m2iso*). It is recommended to put +" the tag immediately after the module header in the Modula-2 input file. +" +" Example: +" DEFINITION MODULE Foolib; (*!m2iso*) +" +" Variable g:modula2_default_dialect sets the default Modula-2 dialect when the +" dialect cannot be determined from the contents of the Modula-2 input file: +" if defined and set to 'm2iso', the default dialect is ISO. +" +" Variable g:modula2_iso_allow_lowline controls support for lowline in identifiers: +" if defined and set to a non-zero value, they are recognised, otherwise not +" +" Variable g:modula2_iso_disallow_octals controls the rendering of octal literals: +" if defined and set to a non-zero value, they are rendered as errors. +" +" Variable g:modula2_iso_disallow_synonyms controls the rendering of @, & and ~: +" if defined and set to a non-zero value, they are rendered as errors. +" +" Variables may be defined in Vim startup file .vimrc +" +" Examples: +" let g:modula2_default_dialect = 'm2iso' +" let g:modula2_iso_allow_lowline = 1 +" let g:modula2_iso_disallow_octals = 1 +" let g:modula2_iso_disallow_synonyms = 1 + + +if exists("b:current_syntax") + finish +endif + +" Modula-2 is case sensitive +syn case match + + +" ----------------------------------------------------------------------------- +" Reserved Words +" ----------------------------------------------------------------------------- +syn keyword modula2Resword AND ARRAY BEGIN BY CASE CONST DEFINITION DIV DO ELSE +syn keyword modula2Resword ELSIF EXCEPT EXIT EXPORT FINALLY FOR FORWARD FROM IF +syn keyword modula2Resword IMPLEMENTATION IMPORT IN LOOP MOD NOT OF OR PACKEDSET +syn keyword modula2Resword POINTER QUALIFIED RECORD REPEAT REM RETRY RETURN SET +syn keyword modula2Resword THEN TO TYPE UNTIL VAR WHILE WITH + + +" ----------------------------------------------------------------------------- +" Builtin Constant Identifiers +" ----------------------------------------------------------------------------- +syn keyword modula2ConstIdent FALSE NIL TRUE INTERRUPTIBLE UNINTERRUPTIBLE + + +" ----------------------------------------------------------------------------- +" Builtin Type Identifiers +" ----------------------------------------------------------------------------- +syn keyword modula2TypeIdent BITSET BOOLEAN CHAR PROC +syn keyword modula2TypeIdent CARDINAL INTEGER LONGINT REAL LONGREAL +syn keyword modula2TypeIdent COMPLEX LONGCOMPLEX PROTECTION + + +" ----------------------------------------------------------------------------- +" Builtin Procedure and Function Identifiers +" ----------------------------------------------------------------------------- +syn keyword modula2ProcIdent CAP DEC EXCL HALT INC INCL +syn keyword modula2FuncIdent ABS CHR CMPLX FLOAT HIGH IM INT LENGTH LFLOAT MAX MIN +syn keyword modula2FuncIdent ODD ORD RE SIZE TRUNC VAL + + +" ----------------------------------------------------------------------------- +" Wirthian Macro Identifiers +" ----------------------------------------------------------------------------- +syn keyword modula2MacroIdent NEW DISPOSE + + +" ----------------------------------------------------------------------------- +" Unsafe Facilities via Pseudo-Module SYSTEM +" ----------------------------------------------------------------------------- +syn keyword modula2UnsafeIdent ADDRESS BYTE LOC WORD +syn keyword modula2UnsafeIdent ADR CAST TSIZE SYSTEM +syn keyword modula2UnsafeIdent MAKEADR ADDADR SUBADR DIFADR ROTATE SHIFT + + +" ----------------------------------------------------------------------------- +" Non-Portable Language Extensions +" ----------------------------------------------------------------------------- +syn keyword modula2NonPortableIdent LONGCARD LONGBITSET + + +" ----------------------------------------------------------------------------- +" User Defined Identifiers +" ----------------------------------------------------------------------------- +syn match modula2Ident "[a-zA-Z][a-zA-Z0-9]*\(_\)\@!" +syn match modula2LowLineIdent "[a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)\+" + + +" ----------------------------------------------------------------------------- +" String Literals +" ----------------------------------------------------------------------------- +syn region modula2String start=/"/ end=/"/ oneline +syn region modula2String start=/'/ end=/'/ oneline + + +" ----------------------------------------------------------------------------- +" Numeric Literals +" ----------------------------------------------------------------------------- +syn match modula2Num + \ "\(\([0-7]\+\)[BC]\@!\|[89]\)[0-9]*\(\.[0-9]\+\([eE][+-]\?[0-9]\+\)\?\)\?" +syn match modula2Num "[0-9A-F]\+H" +syn match modula2Octal "[0-7]\+[BC]" + + +" ----------------------------------------------------------------------------- +" Punctuation +" ----------------------------------------------------------------------------- +syn match modula2Punctuation + \ "\.\|[,:;]\|\*\|[/+-]\|\#\|[=<>]\|\^\|\[\|\]\|(\(\*\)\@!\|[){}]" +syn match modula2Synonym "[@&~]" + + +" ----------------------------------------------------------------------------- +" Pragmas +" ----------------------------------------------------------------------------- +syn region modula2Pragma start="<\*" end="\*>" +syn match modula2DialectTag "(\*!m2iso\(+[a-z0-9]\+\)\?\*)" + +" ----------------------------------------------------------------------------- +" Block Comments +" ----------------------------------------------------------------------------- +syn region modula2Comment start="(\*\(!m2iso\(+[a-z0-9]\+\)\?\*)\)\@!" end="\*)" + \ contains = modula2Comment, modula2CommentKey, modula2TechDebtMarker +syn match modula2CommentKey "[Aa]uthor[s]\?\|[Cc]opyright\|[Ll]icense\|[Ss]ynopsis" +syn match modula2CommentKey "\([Pp]re\|[Pp]ost\|[Ee]rror\)\-condition[s]\?:" + + +" ----------------------------------------------------------------------------- +" Technical Debt Markers +" ----------------------------------------------------------------------------- +syn keyword modula2TechDebtMarker contained DEPRECATED FIXME +syn match modula2TechDebtMarker "TODO[:]\?" contained + +" ----------------------------------------------------------------------------- +" Disabled Code Sections +" ----------------------------------------------------------------------------- +syn region modula2DisabledCode start="^?<" end="^>?" + + +" ----------------------------------------------------------------------------- +" Headers +" ----------------------------------------------------------------------------- +" !!! this section must be second last !!! + +" new module header +syn match modula2ModuleHeader + \ "MODULE\( [A-Z][a-zA-Z0-9]*\)\?" + \ contains = modula2ReswordModule, modula2ModuleIdent + +syn match modula2ModuleIdent + \ "[A-Z][a-zA-Z0-9]*" contained + +syn match modula2ModuleTail + \ "END [A-Z][a-zA-Z0-9]*\.$" + \ contains = modula2ReswordEnd, modula2ModuleIdent, modula2Punctuation + +" new procedure header +syn match modula2ProcedureHeader + \ "PROCEDURE\( [a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)*\)\?" + \ contains = modula2ReswordProcedure, + \ modula2ProcedureIdent, modula2ProcedureLowlineIdent, modula2IllegalChar, modula2IllegalIdent + +syn match modula2ProcedureIdent + \ "\([a-zA-Z]\)\([a-zA-Z0-9]*\)" contained + +syn match modula2ProcedureLowlineIdent + \ "[a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)\+" contained + +syn match modula2ProcedureTail + \ "END\( \([a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)*\)[.;]$\)\?" + \ contains = modula2ReswordEnd, + \ modula2ProcedureIdent, modula2ProcedureLowLineIdent, + \ modula2Punctuation, modula2IllegalChar, modula2IllegalIdent + +syn keyword modula2ReswordModule contained MODULE +syn keyword modula2ReswordProcedure contained PROCEDURE +syn keyword modula2ReswordEnd contained END + + +" ----------------------------------------------------------------------------- +" Illegal Symbols +" ----------------------------------------------------------------------------- +" !!! this section must be last !!! + +" any '`' '!' '$' '%' or '\' +syn match modula2IllegalChar "[`!$%\\]" + +" any solitary sequence of '_' +syn match modula2IllegalChar "\<_\+\>" + +" any '?' at start of line if not followed by '<' +syn match modula2IllegalChar "^?\(<\)\@!" + +" any '?' not following '>' at start of line +syn match modula2IllegalChar "\(\(^>\)\|\(^\)\)\@" + + +" ----------------------------------------------------------------------------- +" Define Rendering Styles +" ----------------------------------------------------------------------------- + +" highlight default link modula2PredefIdentStyle Keyword +" highlight default link modula2ConstIdentStyle modula2PredefIdentStyle +" highlight default link modula2TypeIdentStyle modula2PredefIdentStyle +" highlight default link modula2ProcIdentStyle modula2PredefIdentStyle +" highlight default link modula2FuncIdentStyle modula2PredefIdentStyle +" highlight default link modula2MacroIdentStyle modula2PredefIdentStyle + +highlight default link modula2ConstIdentStyle Constant +highlight default link modula2TypeIdentStyle Type +highlight default link modula2ProcIdentStyle Function +highlight default link modula2FuncIdentStyle Function +highlight default link modula2MacroIdentStyle Function +highlight default link modula2UnsafeIdentStyle Question +highlight default link modula2NonPortableIdentStyle Question +highlight default link modula2StringLiteralStyle String +highlight default link modula2CommentStyle Comment +highlight default link modula2PragmaStyle PreProc +highlight default link modula2DialectTagStyle SpecialComment +highlight default link modula2TechDebtMarkerStyle SpecialComment +highlight default link modula2ReswordStyle Keyword +highlight default link modula2HeaderIdentStyle Function +highlight default link modula2UserDefIdentStyle Normal +highlight default link modula2NumericLiteralStyle Number +highlight default link modula2PunctuationStyle Delimiter +highlight default link modula2CommentKeyStyle SpecialComment +highlight default link modula2DisabledCodeStyle NonText + +" ----------------------------------------------------------------------------- +" Assign Rendering Styles +" ----------------------------------------------------------------------------- + +" headers +highlight default link modula2ModuleIdent modula2HeaderIdentStyle +highlight default link modula2ProcedureIdent modula2HeaderIdentStyle +highlight default link modula2ModuleHeader Normal +highlight default link modula2ModuleTail Normal +highlight default link modula2ProcedureHeader Normal +highlight default link modula2ProcedureTail Normal + +" lowline identifiers are rendered as errors if g:modula2_iso_allow_lowline is unset +if exists("g:modula2_iso_allow_lowline") + if g:modula2_iso_allow_lowline != 0 + highlight default link modula2ProcedureLowlineIdent modula2HeaderIdentStyle + else + highlight default link modula2ProcedureLowlineIdent Error + endif +else + highlight default link modula2ProcedureLowlineIdent modula2HeaderIdentStyle +endif + +" reserved words +highlight default link modula2Resword modula2ReswordStyle +highlight default link modula2ReswordModule modula2ReswordStyle +highlight default link modula2ReswordProcedure modula2ReswordStyle +highlight default link modula2ReswordEnd modula2ReswordStyle + +" predefined identifiers +highlight default link modula2ConstIdent modula2ConstIdentStyle +highlight default link modula2TypeIdent modula2TypeIdentStyle +highlight default link modula2ProcIdent modula2ProcIdentStyle +highlight default link modula2FuncIdent modula2FuncIdentStyle +highlight default link modula2MacroIdent modula2MacroIdentStyle + +" unsafe and non-portable identifiers +highlight default link modula2UnsafeIdent modula2UnsafeIdentStyle +highlight default link modula2NonPortableIdent modula2NonPortableIdentStyle + +" user defined identifiers +highlight default link modula2Ident modula2UserDefIdentStyle + +" lowline identifiers are rendered as errors if g:modula2_iso_allow_lowline is unset +if exists("g:modula2_iso_allow_lowline") + if g:modula2_iso_allow_lowline != 0 + highlight default link modula2LowLineIdent modula2UserDefIdentStyle + else + highlight default link modula2LowLineIdent Error + endif +else + highlight default link modula2LowLineIdent modula2UserDefIdentStyle +endif + +" literals +highlight default link modula2String modula2StringLiteralStyle +highlight default link modula2Num modula2NumericLiteralStyle + +" octal literals are rendered as errors if g:modula2_iso_disallow_octals is set +if exists("g:modula2_iso_disallow_octals") + if g:modula2_iso_disallow_octals != 0 + highlight default link modula2Octal Error + else + highlight default link modula2Octal modula2NumericLiteralStyle + endif +else + highlight default link modula2Octal modula2NumericLiteralStyle +endif + +" punctuation +highlight default link modula2Punctuation modula2PunctuationStyle + +" synonyms & and ~ are rendered as errors if g:modula2_iso_disallow_synonyms is set +if exists("g:modula2_iso_disallow_synonyms") + if g:modula2_iso_disallow_synonyms != 0 + highlight default link modula2Synonym Error + else + highlight default link modula2Synonym modula2PunctuationStyle + endif +else + highlight default link modula2Synonym modula2PunctuationStyle +endif + +" pragmas +highlight default link modula2Pragma modula2PragmaStyle +highlight default link modula2DialectTag modula2DialectTagStyle + +" comments +highlight default link modula2Comment modula2CommentStyle +highlight default link modula2CommentKey modula2CommentKeyStyle + +" technical debt markers +highlight default link modula2TechDebtMarker modula2TechDebtMarkerStyle + +" disabled code +highlight default link modula2DisabledCode modula2DisabledCodeStyle + +" illegal symbols +highlight default link modula2IllegalChar Error +highlight default link modula2IllegalIdent Error + + +let b:current_syntax = "modula2" + +" vim: ts=4 + +" END OF FILE diff --git a/runtime/syntax/modula2/opt/pim.vim b/runtime/syntax/modula2/opt/pim.vim new file mode 100644 index 0000000000..1626db91cf --- /dev/null +++ b/runtime/syntax/modula2/opt/pim.vim @@ -0,0 +1,377 @@ +" Vim syntax file +" Language: Modula-2 (PIM) +" Maintainer: B.Kowarsch +" Last Change: 2016 August 22 + +" ---------------------------------------------------- +" THIS FILE IS LICENSED UNDER THE VIM LICENSE +" see https://github.com/vim/vim/blob/master/LICENSE +" ---------------------------------------------------- + +" Remarks: +" Vim Syntax files are available for the following Modula-2 dialects: +" * for the PIM dialect : m2pim.vim (this file) +" * for the ISO dialect : m2iso.vim +" * for the R10 dialect : m2r10.vim + +" ----------------------------------------------------------------------------- +" This syntax description follows the 3rd and 4th editions of N.Wirth's Book +" Programming in Modula-2 (aka PIM) plus the following language extensions: +" * non-leading, non-trailing, non-consecutive lowlines _ in identifiers +" * widely supported non-standard types BYTE, LONGCARD and LONGBITSET +" * non-nesting code disabling tags ?< and >? at the start of a line +" ----------------------------------------------------------------------------- + +" Parameters: +" +" Vim's filetype script recognises Modula-2 dialect tags within the first 200 +" lines of Modula-2 .def and .mod input files. The script sets filetype and +" dialect automatically when a valid dialect tag is found in the input file. +" The dialect tag for the PIM dialect is (*!m2pim*). It is recommended to put +" the tag immediately after the module header in the Modula-2 input file. +" +" Example: +" DEFINITION MODULE Foolib; (*!m2pim*) +" +" Variable g:modula2_default_dialect sets the default Modula-2 dialect when the +" dialect cannot be determined from the contents of the Modula-2 input file: +" if defined and set to 'm2pim', the default dialect is PIM. +" +" Variable g:modula2_pim_allow_lowline controls support for lowline in identifiers: +" if defined and set to a non-zero value, they are recognised, otherwise not +" +" Variable g:modula2_pim_disallow_octals controls the rendering of octal literals: +" if defined and set to a non-zero value, they are rendered as errors. +" +" Variable g:modula2_pim_disallow_synonyms controls the rendering of & and ~: +" if defined and set to a non-zero value, they are rendered as errors. +" +" Variables may be defined in Vim startup file .vimrc +" +" Examples: +" let g:modula2_default_dialect = 'm2pim' +" let g:modula2_pim_allow_lowline = 1 +" let g:modula2_pim_disallow_octals = 1 +" let g:modula2_pim_disallow_synonyms = 1 + + +if exists("b:current_syntax") + finish +endif + +" Modula-2 is case sensitive +syn case match + + +" ----------------------------------------------------------------------------- +" Reserved Words +" ----------------------------------------------------------------------------- +syn keyword modula2Resword AND ARRAY BEGIN BY CASE CONST DEFINITION DIV DO ELSE +syn keyword modula2Resword ELSIF EXIT EXPORT FOR FROM IF IMPLEMENTATION IMPORT +syn keyword modula2Resword IN LOOP MOD NOT OF OR POINTER QUALIFIED RECORD REPEAT +syn keyword modula2Resword RETURN SET THEN TO TYPE UNTIL VAR WHILE WITH + + +" ----------------------------------------------------------------------------- +" Builtin Constant Identifiers +" ----------------------------------------------------------------------------- +syn keyword modula2ConstIdent FALSE NIL TRUE + + +" ----------------------------------------------------------------------------- +" Builtin Type Identifiers +" ----------------------------------------------------------------------------- +syn keyword modula2TypeIdent BITSET BOOLEAN CHAR PROC +syn keyword modula2TypeIdent CARDINAL INTEGER LONGINT REAL LONGREAL + + +" ----------------------------------------------------------------------------- +" Builtin Procedure and Function Identifiers +" ----------------------------------------------------------------------------- +syn keyword modula2ProcIdent CAP DEC EXCL HALT INC INCL +syn keyword modula2FuncIdent ABS CHR FLOAT HIGH MAX MIN ODD ORD SIZE TRUNC VAL + + +" ----------------------------------------------------------------------------- +" Wirthian Macro Identifiers +" ----------------------------------------------------------------------------- +syn keyword modula2MacroIdent NEW DISPOSE + + +" ----------------------------------------------------------------------------- +" Unsafe Facilities via Pseudo-Module SYSTEM +" ----------------------------------------------------------------------------- +syn keyword modula2UnsafeIdent ADDRESS PROCESS WORD +syn keyword modula2UnsafeIdent ADR TSIZE NEWPROCESS TRANSFER SYSTEM + + +" ----------------------------------------------------------------------------- +" Non-Portable Language Extensions +" ----------------------------------------------------------------------------- +syn keyword modula2NonPortableIdent BYTE LONGCARD LONGBITSET + + +" ----------------------------------------------------------------------------- +" User Defined Identifiers +" ----------------------------------------------------------------------------- +syn match modula2Ident "[a-zA-Z][a-zA-Z0-9]*\(_\)\@!" +syn match modula2LowLineIdent "[a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)\+" + + +" ----------------------------------------------------------------------------- +" String Literals +" ----------------------------------------------------------------------------- +syn region modula2String start=/"/ end=/"/ oneline +syn region modula2String start=/'/ end=/'/ oneline + + +" ----------------------------------------------------------------------------- +" Numeric Literals +" ----------------------------------------------------------------------------- +syn match modula2Num + \ "\(\([0-7]\+\)[BC]\@!\|[89]\)[0-9]*\(\.[0-9]\+\([eE][+-]\?[0-9]\+\)\?\)\?" +syn match modula2Num "[0-9A-F]\+H" +syn match modula2Octal "[0-7]\+[BC]" + + +" ----------------------------------------------------------------------------- +" Punctuation +" ----------------------------------------------------------------------------- +syn match modula2Punctuation + \ "\.\|[,:;]\|\*\|[/+-]\|\#\|[=<>]\|\^\|\[\|\]\|(\(\*\)\@!\|[){}]" +syn match modula2Synonym "[&~]" + + +" ----------------------------------------------------------------------------- +" Pragmas +" ----------------------------------------------------------------------------- +syn region modula2Pragma start="(\*\$" end="\*)" +syn match modula2DialectTag "(\*!m2pim\(+[a-z0-9]\+\)\?\*)" + +" ----------------------------------------------------------------------------- +" Block Comments +" ----------------------------------------------------------------------------- +syn region modula2Comment start="(\*\(\$\|!m2pim\(+[a-z0-9]\+\)\?\*)\)\@!" end="\*)" + \ contains = modula2Comment, modula2CommentKey, modula2TechDebtMarker +syn match modula2CommentKey "[Aa]uthor[s]\?\|[Cc]opyright\|[Ll]icense\|[Ss]ynopsis" +syn match modula2CommentKey "\([Pp]re\|[Pp]ost\|[Ee]rror\)\-condition[s]\?:" + + +" ----------------------------------------------------------------------------- +" Technical Debt Markers +" ----------------------------------------------------------------------------- +syn keyword modula2TechDebtMarker contained DEPRECATED FIXME +syn match modula2TechDebtMarker "TODO[:]\?" contained + +" ----------------------------------------------------------------------------- +" Disabled Code Sections +" ----------------------------------------------------------------------------- +syn region modula2DisabledCode start="^?<" end="^>?" + + +" ----------------------------------------------------------------------------- +" Headers +" ----------------------------------------------------------------------------- +" !!! this section must be second last !!! + +" new module header +syn match modula2ModuleHeader + \ "MODULE\( [A-Z][a-zA-Z0-9]*\)\?" + \ contains = modula2ReswordModule, modula2ModuleIdent + +syn match modula2ModuleIdent + \ "[A-Z][a-zA-Z0-9]*" contained + +syn match modula2ModuleTail + \ "END [A-Z][a-zA-Z0-9]*\.$" + \ contains = modula2ReswordEnd, modula2ModuleIdent, modula2Punctuation + +" new procedure header +syn match modula2ProcedureHeader + \ "PROCEDURE\( [a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)*\)\?" + \ contains = modula2ReswordProcedure, + \ modula2ProcedureIdent, modula2ProcedureLowlineIdent, modula2IllegalChar, modula2IllegalIdent + +syn match modula2ProcedureIdent + \ "\([a-zA-Z]\)\([a-zA-Z0-9]*\)" contained + +syn match modula2ProcedureLowlineIdent + \ "[a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)\+" contained + +syn match modula2ProcedureTail + \ "END\( \([a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)*\)[.;]$\)\?" + \ contains = modula2ReswordEnd, + \ modula2ProcedureIdent, modula2ProcedureLowLineIdent, + \ modula2Punctuation, modula2IllegalChar, modula2IllegalIdent + +syn keyword modula2ReswordModule contained MODULE +syn keyword modula2ReswordProcedure contained PROCEDURE +syn keyword modula2ReswordEnd contained END + + +" ----------------------------------------------------------------------------- +" Illegal Symbols +" ----------------------------------------------------------------------------- +" !!! this section must be last !!! + +" any '`' '!' '@ ''$' '%' or '\' +syn match modula2IllegalChar "[`!@$%\\]" + +" any solitary sequence of '_' +syn match modula2IllegalChar "\<_\+\>" + +" any '?' at start of line if not followed by '<' +syn match modula2IllegalChar "^?\(<\)\@!" + +" any '?' not following '>' at start of line +syn match modula2IllegalChar "\(\(^>\)\|\(^\)\)\@" + + +" ----------------------------------------------------------------------------- +" Define Rendering Styles +" ----------------------------------------------------------------------------- + +" highlight default link modula2PredefIdentStyle Keyword +" highlight default link modula2ConstIdentStyle modula2PredefIdentStyle +" highlight default link modula2TypeIdentStyle modula2PredefIdentStyle +" highlight default link modula2ProcIdentStyle modula2PredefIdentStyle +" highlight default link modula2FuncIdentStyle modula2PredefIdentStyle +" highlight default link modula2MacroIdentStyle modula2PredefIdentStyle + +highlight default link modula2ConstIdentStyle Constant +highlight default link modula2TypeIdentStyle Type +highlight default link modula2ProcIdentStyle Function +highlight default link modula2FuncIdentStyle Function +highlight default link modula2MacroIdentStyle Function +highlight default link modula2UnsafeIdentStyle Question +highlight default link modula2NonPortableIdentStyle Question +highlight default link modula2StringLiteralStyle String +highlight default link modula2CommentStyle Comment +highlight default link modula2PragmaStyle PreProc +highlight default link modula2DialectTagStyle SpecialComment +highlight default link modula2TechDebtMarkerStyle SpecialComment +highlight default link modula2ReswordStyle Keyword +highlight default link modula2HeaderIdentStyle Function +highlight default link modula2UserDefIdentStyle Normal +highlight default link modula2NumericLiteralStyle Number +highlight default link modula2PunctuationStyle Delimiter +highlight default link modula2CommentKeyStyle SpecialComment +highlight default link modula2DisabledCodeStyle NonText + +" ----------------------------------------------------------------------------- +" Assign Rendering Styles +" ----------------------------------------------------------------------------- + +" headers +highlight default link modula2ModuleIdent modula2HeaderIdentStyle +highlight default link modula2ProcedureIdent modula2HeaderIdentStyle +highlight default link modula2ModuleHeader Normal +highlight default link modula2ModuleTail Normal +highlight default link modula2ProcedureHeader Normal +highlight default link modula2ProcedureTail Normal + +" lowline identifiers are rendered as errors if g:modula2_pim_allow_lowline is unset +if exists("g:modula2_pim_allow_lowline") + if g:modula2_pim_allow_lowline != 0 + highlight default link modula2ProcedureLowlineIdent modula2HeaderIdentStyle + else + highlight default link modula2ProcedureLowlineIdent Error + endif +else + highlight default link modula2ProcedureLowlineIdent Error +endif + +" reserved words +highlight default link modula2Resword modula2ReswordStyle +highlight default link modula2ReswordModule modula2ReswordStyle +highlight default link modula2ReswordProcedure modula2ReswordStyle +highlight default link modula2ReswordEnd modula2ReswordStyle + +" predefined identifiers +highlight default link modula2ConstIdent modula2ConstIdentStyle +highlight default link modula2TypeIdent modula2TypeIdentStyle +highlight default link modula2ProcIdent modula2ProcIdentStyle +highlight default link modula2FuncIdent modula2FuncIdentStyle +highlight default link modula2MacroIdent modula2MacroIdentStyle + +" unsafe and non-portable identifiers +highlight default link modula2UnsafeIdent modula2UnsafeIdentStyle +highlight default link modula2NonPortableIdent modula2NonPortableIdentStyle + +" user defined identifiers +highlight default link modula2Ident modula2UserDefIdentStyle + +" lowline identifiers are rendered as errors if g:modula2_pim_allow_lowline is unset +if exists("g:modula2_pim_allow_lowline") + if g:modula2_pim_allow_lowline != 0 + highlight default link modula2LowLineIdent modula2UserDefIdentStyle + else + highlight default link modula2LowLineIdent Error + endif +else + highlight default link modula2LowLineIdent Error +endif + +" literals +highlight default link modula2String modula2StringLiteralStyle +highlight default link modula2Num modula2NumericLiteralStyle + +" octal literals are rendered as errors if g:modula2_pim_disallow_octals is set +if exists("g:modula2_pim_disallow_octals") + if g:modula2_pim_disallow_octals != 0 + highlight default link modula2Octal Error + else + highlight default link modula2Octal modula2NumericLiteralStyle + endif +else + highlight default link modula2Octal modula2NumericLiteralStyle +endif + +" punctuation +highlight default link modula2Punctuation modula2PunctuationStyle + +" synonyms & and ~ are rendered as errors if g:modula2_pim_disallow_synonyms is set +if exists("g:modula2_pim_disallow_synonyms") + if g:modula2_pim_disallow_synonyms != 0 + highlight default link modula2Synonym Error + else + highlight default link modula2Synonym modula2PunctuationStyle + endif +else + highlight default link modula2Synonym modula2PunctuationStyle +endif + +" pragmas +highlight default link modula2Pragma modula2PragmaStyle +highlight default link modula2DialectTag modula2DialectTagStyle + +" comments +highlight default link modula2Comment modula2CommentStyle +highlight default link modula2CommentKey modula2CommentKeyStyle + +" technical debt markers +highlight default link modula2TechDebtMarker modula2TechDebtMarkerStyle + +" disabled code +highlight default link modula2DisabledCode modula2DisabledCodeStyle + +" illegal symbols +highlight default link modula2IllegalChar Error +highlight default link modula2IllegalIdent Error + + +let b:current_syntax = "modula2" + +" vim: ts=4 + +" END OF FILE diff --git a/runtime/syntax/modula2/opt/r10.vim b/runtime/syntax/modula2/opt/r10.vim new file mode 100644 index 0000000000..775f498dfb --- /dev/null +++ b/runtime/syntax/modula2/opt/r10.vim @@ -0,0 +1,452 @@ +" Vim syntax file +" Language: Modula-2 (R10) +" Maintainer: B.Kowarsch +" Last Change: 2020 June 18 (moved repository from bb to github) + +" ---------------------------------------------------- +" THIS FILE IS LICENSED UNDER THE VIM LICENSE +" see https://github.com/vim/vim/blob/master/LICENSE +" ---------------------------------------------------- + +" Remarks: +" Vim Syntax files are available for the following Modula-2 dialects: +" * for the PIM dialect : m2pim.vim +" * for the ISO dialect : m2iso.vim +" * for the R10 dialect : m2r10.vim (this file) + +" ----------------------------------------------------------------------------- +" This syntax description follows the Modula-2 Revision 2010 language report +" (Kowarsch and Sutcliffe, 2015) available at http://modula-2.info/m2r10. +" ----------------------------------------------------------------------------- + +" Parameters: +" +" Vim's filetype script recognises Modula-2 dialect tags within the first 200 +" lines of Modula-2 .def and .mod input files. The script sets filetype and +" dialect automatically when a valid dialect tag is found in the input file. +" The dialect tag for the R10 dialect is (*!m2r10*). It is recommended to put +" the tag immediately after the module header in the Modula-2 input file. +" +" Example: +" DEFINITION MODULE Foolib; (*!m2r10*) +" +" Variable g:modula2_default_dialect sets the default Modula-2 dialect when the +" dialect cannot be determined from the contents of the Modula-2 input file: +" if defined and set to 'm2r10', the default dialect is R10. +" +" Variable g:modula2_r10_allow_lowline controls support for lowline in identifiers: +" if defined and set to a non-zero value, they are recognised, otherwise not +" +" Variables may be defined in Vim startup file .vimrc +" +" Examples: +" let g:modula2_default_dialect = 'm2r10' +" let g:modula2_r10_allow_lowline = 1 + + +if exists("b:current_syntax") + finish +endif + +" Modula-2 is case sensitive +syn case match + + +" ----------------------------------------------------------------------------- +" Reserved Words +" ----------------------------------------------------------------------------- +" Note: MODULE, PROCEDURE and END are defined separately further below +syn keyword modula2Resword ALIAS AND ARGLIST ARRAY BEGIN CASE CONST COPY DEFINITION +syn keyword modula2Resword DIV DO ELSE ELSIF EXIT FOR FROM GENLIB IF IMPLEMENTATION +syn keyword modula2Resword IMPORT IN LOOP MOD NEW NOT OF OPAQUE OR POINTER READ +syn keyword modula2Resword RECORD RELEASE REPEAT RETAIN RETURN SET THEN TO TYPE +syn keyword modula2Resword UNTIL VAR WHILE WRITE YIELD + + +" ----------------------------------------------------------------------------- +" Schroedinger's Tokens +" ----------------------------------------------------------------------------- +syn keyword modula2SchroedToken CAPACITY COROUTINE LITERAL + + +" ----------------------------------------------------------------------------- +" Builtin Constant Identifiers +" ----------------------------------------------------------------------------- +syn keyword modula2ConstIdent NIL FALSE TRUE + + +" ----------------------------------------------------------------------------- +" Builtin Type Identifiers +" ----------------------------------------------------------------------------- +syn keyword modula2TypeIdent BOOLEAN CHAR UNICHAR OCTET +syn keyword modula2TypeIdent CARDINAL LONGCARD INTEGER LONGINT REAL LONGREAL + + +" ----------------------------------------------------------------------------- +" Builtin Procedure and Function Identifiers +" ----------------------------------------------------------------------------- +syn keyword modula2ProcIdent APPEND INSERT REMOVE SORT SORTNEW +syn keyword modula2FuncIdent CHR ORD ODD ABS SGN MIN MAX LOG2 POW2 ENTIER +syn keyword modula2FuncIdent PRED SUCC PTR COUNT LENGTH + + +" ----------------------------------------------------------------------------- +" Builtin Macro Identifiers +" ----------------------------------------------------------------------------- +syn keyword modula2MacroIdent NOP TMIN TMAX TSIZE TLIMIT + + +" ----------------------------------------------------------------------------- +" Builtin Primitives +" ----------------------------------------------------------------------------- +syn keyword modula2PrimitiveIdent SXF VAL STORE VALUE SEEK SUBSET + + +" ----------------------------------------------------------------------------- +" Unsafe Facilities via Pseudo-Module UNSAFE +" ----------------------------------------------------------------------------- +syn keyword modula2UnsafeIdent UNSAFE BYTE WORD LONGWORD OCTETSEQ +syn keyword modula2UnsafeIdent ADD SUB INC DEC SETBIT HALT +syn keyword modula2UnsafeIdent ADR CAST BIT SHL SHR BWNOT BWAND BWOR + + +" ----------------------------------------------------------------------------- +" Non-Portable Language Extensions +" ----------------------------------------------------------------------------- +syn keyword modula2NonPortableIdent ASSEMBLER ASM REG + + +" ----------------------------------------------------------------------------- +" User Defined Identifiers +" ----------------------------------------------------------------------------- +syn match modula2Ident "[a-zA-Z][a-zA-Z0-9]*\(_\)\@!" +syn match modula2LowLineIdent "[a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)\+" + +syn match modula2ReswordDo "\(TO\)\@&#,]\|\[\)\@<='" end=/'/ oneline + + +" ----------------------------------------------------------------------------- +" Numeric Literals +" ----------------------------------------------------------------------------- +syn match modula2Base2Num "0b[01]\+\('[01]\+\)*" +syn match modula2Base16Num "0[ux][0-9A-F]\+\('[0-9A-F]\+\)*" + +"| *** VMSCRIPT BUG ALERT *** +"| The regular expression below causes errors when split into separate strings +"| +"| syn match modula2Base10Num +"| \ "\(\(0[bux]\@!\|[1-9]\)[0-9]*\('[0-9]\+\)*\)" . +"| \ "\(\.[0-9]\+\('[0-9]\+\)*\(e[+-]\?[0-9]\+\('[0-9]\+\)*\)\?\)\?" +"| +"| E475: Invalid argument: modula2Base10Num "\(\(0[bux]\@!\|[1-9]\)[0-9]*\('[0-9]\+\)*\)" +"| . "\(\.[0-9]\+\('[0-9]\+\)*\(e[+-]\?[0-9]\+\('[0-9]\+\)*\)\?\)\?" +"| +"| However, the same regular expression works just fine as a sole string. +"| +"| As a consequence, we have no choice but to put it all into a single line +"| which greatly diminishes readability and thereby increases the opportunity +"| for error during maintenance. Ideally, regular expressions should be split +"| into small human readable pieces with interleaved comments that explain +"| precisely what each piece is doing. Vimscript imposes poor design. :-( + +syn match modula2Base10Num + \ "\(\(0[bux]\@!\|[1-9]\)[0-9]*\('[0-9]\+\)*\)\(\.[0-9]\+\('[0-9]\+\)*\(e[+-]\?[0-9]\+\('[0-9]\+\)*\)\?\)\?" + + +" ----------------------------------------------------------------------------- +" Punctuation +" ----------------------------------------------------------------------------- +syn match modula2Punctuation + \ "\.\|[,:;]\|\*\|[/+-]\|\#\|[=<>&]\|\^\|\[\|\]\|(\(\*\)\@!\|[){}]" + + +" ----------------------------------------------------------------------------- +" Pragmas +" ----------------------------------------------------------------------------- +syn region modula2Pragma start="<\*" end="\*>" + \ contains = modula2PragmaKey, modula2TechDebtPragma +syn keyword modula2PragmaKey contained MSG IF ELSIF ELSE END INLINE NOINLINE OUT +syn keyword modula2PragmaKey contained GENERATED ENCODING ALIGN PADBITS NORETURN +syn keyword modula2PragmaKey contained PURITY SINGLEASSIGN LOWLATENCY VOLATILE +syn keyword modula2PragmaKey contained FORWARD ADDR FFI FFIDENT + +syn match modula2DialectTag "(\*!m2r10\(+[a-z0-9]\+\)\?\*)" + + +" ----------------------------------------------------------------------------- +" Line Comments +" ----------------------------------------------------------------------------- +syn region modula2Comment start=/^!/ end=/$/ oneline + + +" ----------------------------------------------------------------------------- +" Block Comments +" ----------------------------------------------------------------------------- +syn region modula2Comment + \ start="\(END\s\)\@?" + + +" ----------------------------------------------------------------------------- +" Headers +" ----------------------------------------------------------------------------- +" !!! this section must be second last !!! + +" module header +syn match modula2ModuleHeader + \ "\(MODULE\|BLUEPRINT\)\( [A-Z][a-zA-Z0-9]*\)\?" + \ contains = modula2ReswordModule, modula2ReswordBlueprint, modula2ModuleIdent + +syn match modula2ModuleIdent + \ "[A-Z][a-zA-Z0-9]*" contained + +syn match modula2ModuleTail + \ "END [A-Z][a-zA-Z0-9]*\.$" + \ contains = modula2ReswordEnd, modula2ModuleIdent, modula2Punctuation + +" procedure, sole occurrence +syn match modula2ProcedureHeader + \ "PROCEDURE\(\s\[\|\s[a-zA-Z]\)\@!" contains = modula2ReswordProcedure + +" procedure header +syn match modula2ProcedureHeader + \ "PROCEDURE [a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)*" + \ contains = modula2ReswordProcedure, + \ modula2ProcedureIdent, modula2ProcedureLowlineIdent, modula2IllegalChar, modula2IllegalIdent + +" procedure binding to operator +syn match modula2ProcedureHeader + \ "PROCEDURE \[[+-\*/\\=<>]\] [a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)*" + \ contains = modula2ReswordProcedure, modula2Punctuation, + \ modula2ProcedureIdent, modula2ProcedureLowlineIdent, modula2IllegalChar, modula2IllegalIdent + +" procedure binding to builtin +syn match modula2ProcedureHeader + \ "PROCEDURE \[[A-Z]\+\(:\([#\*,]\|++\|--\)\?\)\?\] [a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)*" + \ contains = modula2ReswordProcedure, + \ modula2Punctuation, modula2Resword, modula2SchroedToken, + \ modula2ProcIdent, modula2FuncIdent, modula2PrimitiveIdent, + \ modula2ProcedureIdent, modula2ProcedureLowlineIdent, modula2IllegalChar, modula2IllegalIdent + +syn match modula2ProcedureIdent + \ "\([a-zA-Z]\)\([a-zA-Z0-9]*\)" contained + +syn match modula2ProcedureLowlineIdent + \ "[a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)\+" contained + +syn match modula2ProcedureTail + \ "END [a-zA-Z][a-zA-Z0-9]*\(_[a-zA-Z0-9]\+\)*;$" + \ contains = modula2ReswordEnd, + \ modula2ProcedureIdent, modula2ProcedureLowLineIdent, + \ modula2Punctuation, modula2IllegalChar, modula2IllegalIdent + +syn keyword modula2ReswordModule contained MODULE +syn keyword modula2ReswordBlueprint contained BLUEPRINT +syn keyword modula2ReswordProcedure contained PROCEDURE +syn keyword modula2ReswordEnd contained END + + +" ----------------------------------------------------------------------------- +" Illegal Symbols +" ----------------------------------------------------------------------------- +" !!! this section must be last !!! + +" any '`' '~' '@' '$' '%' +syn match modula2IllegalChar "[`~@$%]" + +" any solitary sequence of '_' +syn match modula2IllegalChar "\<_\+\>" + +" any '?' at start of line if not followed by '<' +syn match modula2IllegalChar "^?\(<\)\@!" + +" any '?' not following '>' at start of line +syn match modula2IllegalChar "\(\(^>\)\|\(^\)\)\@" + + +" ----------------------------------------------------------------------------- +" Define Rendering Styles +" ----------------------------------------------------------------------------- + +" highlight default link modula2PredefIdentStyle Keyword +" highlight default link modula2ConstIdentStyle modula2PredefIdentStyle +" highlight default link modula2TypeIdentStyle modula2PredefIdentStyle +" highlight default link modula2ProcIdentStyle modula2PredefIdentStyle +" highlight default link modula2FuncIdentStyle modula2PredefIdentStyle +" highlight default link modula2MacroIdentStyle modula2PredefIdentStyle + +highlight default link modula2ConstIdentStyle Constant +highlight default link modula2TypeIdentStyle Type +highlight default link modula2ProcIdentStyle Function +highlight default link modula2FuncIdentStyle Function +highlight default link modula2MacroIdentStyle Function +highlight default link modula2PrimitiveIdentStyle Function +highlight default link modula2UnsafeIdentStyle Question +highlight default link modula2NonPortableIdentStyle Question +highlight default link modula2StringLiteralStyle String +highlight default link modula2CommentStyle Comment +highlight default link modula2PragmaStyle PreProc +highlight default link modula2PragmaKeyStyle PreProc +highlight default link modula2DialectTagStyle SpecialComment +highlight default link modula2TechDebtMarkerStyle SpecialComment +highlight default link modula2ReswordStyle Keyword +highlight default link modula2HeaderIdentStyle Function +highlight default link modula2UserDefIdentStyle Normal +highlight default link modula2NumericLiteralStyle Number +highlight default link modula2PunctuationStyle Delimiter +highlight default link modula2CommentKeyStyle SpecialComment +highlight default link modula2DisabledCodeStyle NonText + + +" ----------------------------------------------------------------------------- +" Assign Rendering Styles +" ----------------------------------------------------------------------------- + +" headers +highlight default link modula2ModuleIdent modula2HeaderIdentStyle +highlight default link modula2ProcedureIdent modula2HeaderIdentStyle +highlight default link modula2ModuleHeader modula2HeaderIdentStyle +highlight default link modula2ModuleTail Normal +highlight default link modula2ProcedureHeader Normal +highlight default link modula2ProcedureTail Normal + +" lowline identifiers are rendered as errors if g:modula2_r10_allow_lowline is unset +if exists("g:modula2_r10_allow_lowline") + if g:modula2_r10_allow_lowline != 0 + highlight default link modula2ProcedureLowlineIdent modula2HeaderIdentStyle + else + highlight default link modula2ProcedureLowlineIdent Error + endif +else + highlight default link modula2ProcedureLowlineIdent modula2HeaderIdentStyle +endif + +" reserved words +highlight default link modula2Resword modula2ReswordStyle +highlight default link modula2ReswordModule modula2ReswordStyle +highlight default link modula2ReswordProcedure modula2ReswordStyle +highlight default link modula2ReswordEnd modula2ReswordStyle +highlight default link modula2ReswordDo modula2ReswordStyle +highlight default link modula2ReswordTo modula2ReswordStyle +highlight default link modula2SchroedToken modula2ReswordStyle + +" predefined identifiers +highlight default link modula2ConstIdent modula2ConstIdentStyle +highlight default link modula2TypeIdent modula2TypeIdentStyle +highlight default link modula2ProcIdent modula2ProcIdentStyle +highlight default link modula2FuncIdent modula2FuncIdentStyle +highlight default link modula2MacroIdent modula2MacroIdentStyle +highlight default link modula2PrimitiveIdent modula2PrimitiveIdentStyle + +" unsafe and non-portable identifiers +highlight default link modula2UnsafeIdent modula2UnsafeIdentStyle +highlight default link modula2NonPortableIdent modula2NonPortableIdentStyle + +" user defined identifiers +highlight default link modula2Ident modula2UserDefIdentStyle + +" lowline identifiers are rendered as errors if g:modula2_r10_allow_lowline is unset +if exists("g:modula2_r10_allow_lowline") + if g:modula2_r10_allow_lowline != 0 + highlight default link modula2LowLineIdent modula2UserDefIdentStyle + else + highlight default link modula2LowLineIdent Error + endif +else + highlight default link modula2LowLineIdent modula2UserDefIdentStyle +endif + +" literals +highlight default link modula2String modula2StringLiteralStyle +highlight default link modula2Base2Num modula2NumericLiteralStyle +highlight default link modula2Base10Num modula2NumericLiteralStyle +highlight default link modula2Base16Num modula2NumericLiteralStyle + +" punctuation +highlight default link modula2Punctuation modula2PunctuationStyle + +" pragmas +highlight default link modula2Pragma modula2PragmaStyle +highlight default link modula2PragmaKey modula2PragmaKeyStyle +highlight default link modula2DialectTag modula2DialectTagStyle + +" comments +highlight default link modula2Comment modula2CommentStyle +highlight default link modula2CommentKey modula2CommentKeyStyle +highlight default link modula2ToDoTailComment modula2CommentStyle +highlight default link modula2StmtTailComment modula2CommentStyle + +" technical debt markers +highlight default link modula2ToDoHeader modula2TechDebtMarkerStyle +highlight default link modula2ToDoTail modula2TechDebtMarkerStyle +highlight default link modula2TechDebtPragma modula2TechDebtMarkerStyle + +" disabled code +highlight default link modula2DisabledCode modula2DisabledCodeStyle + +" illegal symbols +highlight default link modula2IllegalChar Error +highlight default link modula2IllegalIdent Error + + +let b:current_syntax = "modula2" + +" vim: ts=4 + +" END OF FILE diff --git a/runtime/syntax/testdir/dumps/modula2_iso_00.dump b/runtime/syntax/testdir/dumps/modula2_iso_00.dump new file mode 100644 index 0000000000..797376fc1d --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_iso_00.dump @@ -0,0 +1,20 @@ +>(+0#0000e05#ffffff0|*| |M|o|d|u|l|a|-|2| |I|S|O| |T|e|s|t| |F|i|l|e| |f|o|r| |V|i|m| |S|y|n|t|a|x| |C|o|l|o|u|r|i|n|g| |*|)| +0#0000000&@21 +@75 +|(+0#0000e05&|*| |-@49| +0#0000000&@21 +| +0#0000e05&|*| |T|H|I|S| |F|I|L|E| |I|S| |L|I|C|E|N|S|E|D| |U|N|D|E|R| |T|H|E| |V|I|M| |L|I|C|E|N|S|E| +0#0000000&@28 +| +0#0000e05&|*| |s|e@1| |h|t@1|p|s|:|/@1|g|i|t|h|u|b|.|c|o|m|/|v|i|m|/|v|i|m|/|b|l|o|b|/|m|a|s|t|e|r|/|L|I|C|E|N|S|E| +0#0000000&@21 +| +0#0000e05&|*| |-@49| |*|)| +0#0000000&@18 +@75 +@75 +|D+0#af5f00255&|E|F|I|N|I|T|I|O|N| +0#0000000&|M+0#af5f00255&|O|D|U|L|E| +0#0000000&|F+0#00e0e07&|o@1|b|a|r|;+0#e000e06&| +0#0000000&|(+0#e000e06&|*|!|m|2|i|s|o|*|)| +0#0000000&@38 +@75 +|F+0#af5f00255&|R|O|M| +0#0000000&|S+0#00e0003&|Y|S|T|E|M| +0#0000000&|I+0#af5f00255&|M|P|O|R|T| +0#0000000&|L+0#00e0003&|O|C|,+0#e000e06&| +0#0000000&|W+0#00e0003&|O|R|D|,+0#e000e06&| +0#0000000&|A+0#00e0003&|D@1|R|E|S@1|;+0#e000e06&| +0#0000000&@36 +@75 +|C+0#af5f00255&|O|N|S|T| +0#0000000&|M|a|x|F|o@1| |=+0#e000e06&| +0#0000000&|1+0#e000002&|.|0|;+0#e000e06&| +0#0000000&|L|F| |=+0#e000e06&| +0#0000000&|C+0#00e0e07&|H|R|(+0#e000e06&|1+0#e000002&|0|)+0#e000e06&|;| +0#0000000&@41 +@75 +|T+0#af5f00255&|Y|P|E| +0#0000000&|F|o@1| |=+0#e000e06&| +0#0000000&|P+0#af5f00255&|O|I|N|T|E|R| +0#0000000&|T+0#af5f00255&|O| +0#0000000&|B|a|r|;+0#e000e06&| +0#0000000&@48 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |c|o|n|s|t|a|n|t|s| |*|)| +0#0000000&@48 +|F+0#e000002&|A|L|S|E| +0#0000000&|N+0#e000002&|I|L| +0#0000000&|T+0#e000002&|R|U|E| +0#0000000&|I+0#e000002&|N|T|E|R@1|U|P|T|I|B|L|E| +0#0000000&|U+0#e000002&|N|I|N|T|E|R@1|U|P|T|I|B|L|E| +0#0000000&@30 +@75 +|"|i|n|p|u|t|/|m|o|d|u|l|a|2|_|i|s|o|.|d|e|f|"| |1@1|4|L|,| |2|3|1|8|B| @21|1|,|1| @10|T|o|p| diff --git a/runtime/syntax/testdir/dumps/modula2_iso_01.dump b/runtime/syntax/testdir/dumps/modula2_iso_01.dump new file mode 100644 index 0000000000..8b7d2f2570 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_iso_01.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@74 +|T+0#af5f00255&|Y|P|E| +0#0000000&|F|o@1| |=+0#e000e06&| +0#0000000&|P+0#af5f00255&|O|I|N|T|E|R| +0#0000000&|T+0#af5f00255&|O| +0#0000000&|B|a|r|;+0#e000e06&| +0#0000000&@48 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |c|o|n|s|t|a|n|t|s| |*|)| +0#0000000&@48 +|F+0#e000002&|A|L|S|E| +0#0000000&|N+0#e000002&|I|L| +0#0000000&|T+0#e000002&|R|U|E| +0#0000000&|I+0#e000002&|N|T|E|R@1|U|P|T|I|B|L|E| +0#0000000&|U+0#e000002&|N|I|N|T|E|R@1|U|P|T|I|B|L|E| +0#0000000&@30 +> @74 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |t|y|p|e|s| |*|)| +0#0000000&@52 +|B+0#00e0003&|I|T|S|E|T| +0#0000000&|B+0#00e0003&|O@1|L|E|A|N| +0#0000000&|C+0#00e0003&|H|A|R| +0#0000000&|P+0#00e0003&|R|O|C| +0#0000000&|C+0#00e0003&|A|R|D|I|N|A|L| +0#0000000&|I+0#00e0003&|N|T|E|G|E|R| +0#0000000&|L+0#00e0003&|O|N|G|I|N|T| +0#0000000&|R+0#00e0003&|E|A|L| +0#0000000&|L+0#00e0003&|O|N|G|R|E|A|L| +0#0000000&@11 +|C+0#00e0003&|O|M|P|L|E|X| +0#0000000&|L+0#00e0003&|O|N|G|C|O|M|P|L|E|X| +0#0000000&|P+0#00e0003&|R|O|T|E|C|T|I|O|N| +0#0000000&@44 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |p|r|o|c|e|d|u|r|e|s| |*|)| +0#0000000&@47 +|C+0#00e0e07&|A|P| +0#0000000&|D+0#00e0e07&|E|C| +0#0000000&|E+0#00e0e07&|X|C|L| +0#0000000&|H+0#00e0e07&|A|L|T| +0#0000000&|I+0#00e0e07&|N|C| +0#0000000&|I+0#00e0e07&|N|C|L| +0#0000000&@48 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |f|u|n|c|t|i|o|n|s| |*|)| +0#0000000&@48 +|A+0#00e0e07&|B|S| +0#0000000&|C+0#00e0e07&|H|R| +0#0000000&|C+0#00e0e07&|M|P|L|X| +0#0000000&|F+0#00e0e07&|L|O|A|T| +0#0000000&|H+0#00e0e07&|I|G|H| +0#0000000&|I+0#00e0e07&|M| +0#0000000&|I+0#00e0e07&|N|T| +0#0000000&|L+0#00e0e07&|E|N|G|T|H| +0#0000000&|L+0#00e0e07&|F|L|O|A|T| +0#0000000&|M+0#00e0e07&|A|X| +0#0000000&|M+0#00e0e07&|I|N| +0#0000000&|O+0#00e0e07&|D@1| +0#0000000&|O+0#00e0e07&|R|D| +0#0000000&|R+0#00e0e07&|E| +0#0000000&|S+0#00e0e07&|I|Z|E| +0#0000000&|T+0#00e0e07&|R|U|N|C +| +0#0000000&|V+0#00e0e07&|A|L| +0#0000000&@70 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |m|a|c|r|o|s| |*|)| +0#0000000&@51 +|N+0#00e0e07&|E|W| +0#0000000&|D+0#00e0e07&|I|S|P|O|S|E| +0#0000000&@63 +@57|1|9|,|0|-|1| @7|1|3|%| diff --git a/runtime/syntax/testdir/dumps/modula2_iso_02.dump b/runtime/syntax/testdir/dumps/modula2_iso_02.dump new file mode 100644 index 0000000000..6d6023307a --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_iso_02.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@74 +|(+0#0000e05&|*| |u|n|s|a|f|e| |b|u|i|l|t|i|n|s| |*|)| +0#0000000&@53 +|A+0#00e0003&|D@1|R|E|S@1| +0#0000000&|B+0#00e0003&|Y|T|E| +0#0000000&|L+0#00e0003&|O|C| +0#0000000&|W+0#00e0003&|O|R|D| +0#0000000&|A+0#00e0003&|D|R| +0#0000000&|C+0#00e0003&|A|S|T| +0#0000000&|T+0#00e0003&|S|I|Z|E| +0#0000000&|S+0#00e0003&|Y|S|T|E|M| +0#0000000&@31 +|M+0#00e0003&|A|K|E|A|D|R| +0#0000000&|A+0#00e0003&|D@1|A|D|R| +0#0000000&|S+0#00e0003&|U|B|A|D|R| +0#0000000&|D+0#00e0003&|I|F|A|D|R| +0#0000000&|R+0#00e0003&|O|T|A|T|E| +0#0000000&|S+0#00e0003&|H|I|F|T| +0#0000000&@33 +@75 +>(+0#0000e05&|*| |n|o|n|-|s|t|a|n|d|a|r|d| |l|a|n|g|u|a|g|e| |e|x|t|e|n|s|i|o|n|s| |*|)| +0#0000000&@36 +|L+0#00e0003&|O|N|G|C|A|R|D| +0#0000000&|L+0#00e0003&|O|N|G|B|I|T|S|E|T| +0#0000000&@55 +@75 +|(+0#0000e05&|*| |u|s|e|r| |d|e|f|i|n|e|d| |i|d|e|n|t|i|f|i|e|r|s| |*|)| +0#0000000&@44 +|f|o@1|b|a|r| |F|o@1|b|a|r| |F|o@1|B|a|r| |f|o@1|1|2|3| |f|o@1|_|b|a|r| @39 +@75 +|(+0#0000e05&|*| |s|t|r|i|n|g| |l|i|t|e|r|a|l|s| |*|)| +0#0000000&@53 +|s|t|r| |:+0#e000e06&|=| +0#0000000&|"+0#e000002&|f|o@1| |'|b|a|r|'| |b|a|z|"|;+0#e000e06&| +0#0000000&@51 +|s|t|r| |:+0#e000e06&|=| +0#0000000&|'+0#e000002&|f|o@1| |"|b|a|r|"| |b|a|z|'|;+0#e000e06&| +0#0000000&@51 +@75 +|(+0#0000e05&|*| |n|u|m|e|r|i|c| |l|i|t|e|r|a|l|s| |*|)| +0#0000000&@52 +|0+0#e000002&|F@2|H|,+0#e000e06&| +0#0000000&|1+0#e000002&|.|2|3|,+0#e000e06&| +0#0000000&|1+0#e000002&|.|2|3|e|-|4|5|,+0#e000e06&| +0#0000000&|1+0#e000002&|0@2| +0#0000000&@47 +@75 +|(+0#0000e05&|*| |o|c|t|a|l| |l|i|t|e|r|a|l|s| |*|)| +0#0000000&@54 +@57|3|7|,|1| @9|3|2|%| diff --git a/runtime/syntax/testdir/dumps/modula2_iso_03.dump b/runtime/syntax/testdir/dumps/modula2_iso_03.dump new file mode 100644 index 0000000000..b9406daf27 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_iso_03.dump @@ -0,0 +1,20 @@ +|(+0#0000e05#ffffff0|*| |o|c|t|a|l| |l|i|t|e|r|a|l|s| |*|)| +0#0000000&@54 +|n| |:+0#e000e06&|=| +0#0000000&|0+0#e000002&|3|7@1|B|;+0#e000e06&| +0#0000000&|c|h| |:+0#e000e06&|=| +0#0000000&|0+0#e000002&|3|7@1|C|;+0#e000e06&| +0#0000000&@50 +@75 +|(+0#0000e05&|*| |p|r|a|g|m|a|s| |*|)| +0#0000000&@61 +|<+0#e000e06&|*|$|f|o@1|*|>| +0#0000000&@66 +> @74 +|(+0#0000e05&|*| |b|l|o|c|k| |c|o|m@1|e|n|t|s| |w|i|t|h| |e|m|p|h|a|s|i|s| |*|)| +0#0000000&@40 +|(+0#0000e05&|*| |c+0#e000e06&|o|p|y|r|i|g|h|t| +0#0000e05&|(|c|)| |J|u|r@1|a|s|i|c| |I|n|c|.| +0#0000000&@44 +| +0#0000e05&@2|a+0#e000e06&|u|t|h|o|r| +0#0000e05&|F|r|e|d| |F|l|i|n|t|s|t|o|n|e| |S|r|.| +0#0000000&@45 +| +0#0000e05&@2|l+0#e000e06&|i|c|e|n|s|e| +0#0000e05&|s|e@1| |L|I|C|E|N|S|E| |f|i|l|e|.| |*|)| +0#0000000&@43 +@75 +|(+0#0000e05&|*| |p+0#e000e06&|r|e|-|c|o|n|d|i|t|i|o|n|s|:| +0#0000e05&|f|o@1| |b|a|r| |b|a|z| |b|a|m| |b|o@1| |d|o@1|d|l|e| |w|a|h|.| +0#0000000&@24 +| +0#0000e05&@2|p+0#e000e06&|o|s|t|-|c|o|n|d|i|t|i|o|n|s|:| +0#0000e05&|f|o@1|d|l|e| |b|a|b@1|l|e| |b|o|z|o| |b|i|m| |b|a|m| |d|a|n|g|.| +0#0000000&@22 +| +0#0000e05&@2|e+0#e000e06&|r@1|o|r|-|c|o|n|d|i|t|i|o|n|s|:| +0#0000e05&|d|a|d|a| |j|i|n|g|l|e| |j|u|n|g|l|e| |b|o|g@1|l|e| |d|e@1| |b|o@1|.| |*|)| +0#0000000&@16 +@75 +|(+0#0000e05&|*| |t|e|c|h|n|i|c|a|l| |d|e|b|t| |m|a|r|k|e|r|s| |*|)| +0#0000000&@46 +|(+0#0000e05&|*| |T+0#e000e06&|O|D|O|:| +0#0000e05&|.@2| |*|)| +0#0000000&@59 +|(+0#0000e05&|*| |F+0#e000e06&|I|X|M|E| +0#0000e05&|*|)| +0#0000000&@63 +|(+0#0000e05&|*| |D+0#e000e06&|E|P|R|E|C|A|T|E|D| +0#0000e05&|*|)| +0#0000000&@58 +@57|5@1|,|0|-|1| @7|5|1|%| diff --git a/runtime/syntax/testdir/dumps/modula2_iso_04.dump b/runtime/syntax/testdir/dumps/modula2_iso_04.dump new file mode 100644 index 0000000000..98fdc23676 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_iso_04.dump @@ -0,0 +1,20 @@ +|(+0#0000e05#ffffff0|*| |D+0#e000e06&|E|P|R|E|C|A|T|E|D| +0#0000e05&|*|)| +0#0000000&@58 +@75 +|(+0#0000e05&|*| |p|r|o|c|e|d|u|r|e|s| |*|)| +0#0000000&@58 +|P+0#af5f00255&|R|O|C|E|D|U|R|E| +0#0000000&|N+0#00e0e07&|e|w|F|o@1|W|i|t|h|B|a|r| +0#0000000&|(+0#e000e06&| +0#0000000&|V+0#af5f00255&|A|R| +0#0000000&|f|o@1|:+0#e000e06&| +0#0000000&|F|o@1|;+0#e000e06&| +0#0000000&|b|a|r| |:+0#e000e06&| +0#0000000&|I+0#00e0003&|N|T|E|G|E|R| +0#0000000&|)+0#e000e06&|;| +0#0000000&@18 +|B+0#af5f00255&|E|G|I|N| +0#0000000&@69 +@2>N+0#00e0e07&|E|W|(+0#e000e06&|f+0#0000000&|o@1|)+0#e000e06&|;| +0#0000000&@63 +@2|f|o@1|^+0#e000e06&|.|b+0#0000000&|a|r| |:+0#e000e06&|=| +0#0000000&|b|a|r|;+0#e000e06&| +0#0000000&@56 +@2|R+0#af5f00255&|E|T|U|R|N| +0#0000000&@66 +|E+0#af5f00255&|N|D| +0#0000000&|S+0#00e0e07&|e|t|B|a|r|;+0#e000e06&| +0#0000000&@63 +@75 +|(+0#0000e05&|*| |f|u|n|c|t|i|o|n|s| |*|)| +0#0000000&@59 +|P+0#af5f00255&|R|O|C|E|D|U|R|E| +0#0000000&|b+0#00e0e07&|a|r| +0#0000000&|(+0#e000e06&| +0#0000000&|f|o@1| |:+0#e000e06&| +0#0000000&|F|o@1| |)+0#e000e06&| +0#0000000&|:+0#e000e06&| +0#0000000&|I+0#00e0003&|N|T|E|G|E|R|;+0#e000e06&| +0#0000000&@36 +|B+0#af5f00255&|E|G|I|N| +0#0000000&@69 +@2|I+0#af5f00255&|F| +0#0000000&|f|o@1| |=+0#e000e06&| +0#0000000&|N+0#e000002&|I|L| +0#0000000&|T+0#af5f00255&|H|E|N| +0#0000000&@55 +@4|H+0#00e0e07&|A|L|T| +0#0000000&@66 +@2|E+0#af5f00255&|L|S|E| +0#0000000&@68 +@4|R+0#af5f00255&|E|T|U|R|N| +0#0000000&|f|o@1|^+0#e000e06&|.|b+0#0000000&|a|r| @55 +@2|E+0#af5f00255&|N|D| +0#0000000&|(+0#0000e05&|*| |I|F| |*|)| +0#0000000&@60 +|E+0#af5f00255&|N|D| +0#0000000&|b+0#00e0e07&|a|r|;+0#e000e06&| +0#0000000&@66 +@57|7|3|,|3| @9|7|0|%| diff --git a/runtime/syntax/testdir/dumps/modula2_iso_05.dump b/runtime/syntax/testdir/dumps/modula2_iso_05.dump new file mode 100644 index 0000000000..eca4631a27 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_iso_05.dump @@ -0,0 +1,20 @@ +|E+0#af5f00255#ffffff0|N|D| +0#0000000&|b+0#00e0e07&|a|r|;+0#e000e06&| +0#0000000&@66 +@75 +|(+0#0000e05&|*| |d|i|s|a|b|l|e|d| |c|o|d|e| |*|)| +0#0000000&@55 +|?+0#4040ff13&|<| +0#0000000&@72 +|W+0#4040ff13&|H|I|L|E| |f|o@1| |=| |b|a|r| |D|O| +0#0000000&@56 +| +0#4040ff13&@1>b|a|z|(|b|a|m|,| |b|o@1|)| +0#0000000&@59 +|E+0#4040ff13&|N|D| |(|*| |W|H|I|L|E| |*|)|;| +0#0000000&@58 +|>+0#4040ff13&|?| +0#0000000&@72 +@75 +|(+0#0000e05&|*| |s|y|n|o|n|y|m|s| |*|)| +0#0000000&@60 +|@+0#e000e06&| +0#0000000&@1|&+0#e000e06&| +0#0000000&@1|~+0#e000e06&| +0#0000000&@67 +@75 +|(+0#0000e05&|*| |i|l@1|e|g|a|l| |c|h|a|r|a|c|t|e|r|s| |*|)| +0#0000000&@50 +|`+0#ffffff16#ff404010| +0#0000000#ffffff0@1|!+0#ffffff16#ff404010| +0#0000000#ffffff0@1|$+0#ffffff16#ff404010| +0#0000000#ffffff0@1|%+0#ffffff16#ff404010| +0#0000000#ffffff0@1|\+0#ffffff16#ff404010| +0#0000000#ffffff0@1|?+0#ffffff16#ff404010| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010| +0#0000000#ffffff0@55 +@75 +|(+0#0000e05&|*| |i|l@1|e|g|a|l| |i|d|e|n|t|i|f|i|e|r|s| |*|)| +0#0000000&@49 +@75 +|_+0#ffffff16#ff404010|b|a|r| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z|_@1|b|a|m| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1| +0#0000000#ffffff0@26 +@75 +@57|9|1|,|3| @9|8|9|%| diff --git a/runtime/syntax/testdir/dumps/modula2_iso_06.dump b/runtime/syntax/testdir/dumps/modula2_iso_06.dump new file mode 100644 index 0000000000..4074a0113a --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_iso_06.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@74 +|b+0#ffffff16#ff404010|a|r|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1|_| +0#0000000#ffffff0@26 +@75 +|_+0#ffffff16#ff404010@1|b|a|r| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1|b|a|m| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1| +0#0000000#ffffff0@22 +@75 +>b+0#ffffff16#ff404010|a|r|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1|_@1| +0#0000000#ffffff0@22 +@75 +|b+0#ffffff16#ff404010|a|r|_@1|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_@1|b|a|z|_@1| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1| +0#0000000#ffffff0@35 +@75 +@75 +|E+0#af5f00255&|N|D| +0#0000000&|F+0#00e0e07&|o@1|b|a|r|.+0#e000e06&| +0#0000000&@63 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +| +0#0000000&@56|1|0|9|,|1| @8|B|o|t| diff --git a/runtime/syntax/testdir/dumps/modula2_iso_99.dump b/runtime/syntax/testdir/dumps/modula2_iso_99.dump new file mode 100644 index 0000000000..e23fb290b0 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_iso_99.dump @@ -0,0 +1,20 @@ +|@+0#e000e06#ffffff0| +0#0000000&@1|&+0#e000e06&| +0#0000000&@1|~+0#e000e06&| +0#0000000&@67 +@75 +|(+0#0000e05&|*| |i|l@1|e|g|a|l| |c|h|a|r|a|c|t|e|r|s| |*|)| +0#0000000&@50 +|`+0#ffffff16#ff404010| +0#0000000#ffffff0@1|!+0#ffffff16#ff404010| +0#0000000#ffffff0@1|$+0#ffffff16#ff404010| +0#0000000#ffffff0@1|%+0#ffffff16#ff404010| +0#0000000#ffffff0@1|\+0#ffffff16#ff404010| +0#0000000#ffffff0@1|?+0#ffffff16#ff404010| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010| +0#0000000#ffffff0@55 +@75 +|(+0#0000e05&|*| |i|l@1|e|g|a|l| |i|d|e|n|t|i|f|i|e|r|s| |*|)| +0#0000000&@49 +@75 +|_+0#ffffff16#ff404010|b|a|r| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z|_@1|b|a|m| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1| +0#0000000#ffffff0@26 +@75 +|b+0#ffffff16#ff404010|a|r|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1|_| +0#0000000#ffffff0@26 +@75 +|_+0#ffffff16#ff404010@1|b|a|r| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1|b|a|m| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1| +0#0000000#ffffff0@22 +@75 +|b+0#ffffff16#ff404010|a|r|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1|_@1| +0#0000000#ffffff0@22 +@75 +|b+0#ffffff16#ff404010|a|r|_@1|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_@1|b|a|z|_@1| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1| +0#0000000#ffffff0@35 +@75 +@75 +>E+0#af5f00255&|N|D| +0#0000000&|F+0#00e0e07&|o@1|b|a|r|.+0#e000e06&| +0#0000000&@63 +@57|1@1|4|,|1| @8|B|o|t| diff --git a/runtime/syntax/testdir/dumps/modula2_pim_00.dump b/runtime/syntax/testdir/dumps/modula2_pim_00.dump new file mode 100644 index 0000000000..5e85b7aa80 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_pim_00.dump @@ -0,0 +1,20 @@ +>(+0#0000e05#ffffff0|*| |M|o|d|u|l|a|-|2| |P|I|M| |T|e|s|t| |F|i|l|e| |f|o|r| |V|i|m| |S|y|n|t|a|x| |C|o|l|o|u|r|i|n|g| |*|)| +0#0000000&@21 +@75 +|(+0#0000e05&|*| |-@49| +0#0000000&@21 +| +0#0000e05&|*| |T|H|I|S| |F|I|L|E| |I|S| |L|I|C|E|N|S|E|D| |U|N|D|E|R| |T|H|E| |V|I|M| |L|I|C|E|N|S|E| +0#0000000&@28 +| +0#0000e05&|*| |s|e@1| |h|t@1|p|s|:|/@1|g|i|t|h|u|b|.|c|o|m|/|v|i|m|/|v|i|m|/|b|l|o|b|/|m|a|s|t|e|r|/|L|I|C|E|N|S|E| +0#0000000&@21 +| +0#0000e05&|*| |-@49| |*|)| +0#0000000&@18 +@75 +|D+0#af5f00255&|E|F|I|N|I|T|I|O|N| +0#0000000&|M+0#af5f00255&|O|D|U|L|E| +0#0000000&|F+0#00e0e07&|o@1|b|a|r|;+0#e000e06&| +0#0000000&|(+0#e000e06&|*|!|m|2|p|i|m|*|)| +0#0000000&@38 +@75 +|F+0#af5f00255&|R|O|M| +0#0000000&|S+0#00e0003&|Y|S|T|E|M| +0#0000000&|I+0#af5f00255&|M|P|O|R|T| +0#0000000&|W+0#00e0003&|O|R|D|,+0#e000e06&| +0#0000000&|A+0#00e0003&|D@1|R|E|S@1|;+0#e000e06&| +0#0000000&@41 +@75 +|C+0#af5f00255&|O|N|S|T| +0#0000000&|M|a|x|F|o@1| |=+0#e000e06&| +0#0000000&|1+0#e000002&|.|0|;+0#e000e06&| +0#0000000&|L|F| |=+0#e000e06&| +0#0000000&|C+0#00e0e07&|H|R|(+0#e000e06&|1+0#e000002&|0|)+0#e000e06&|;| +0#0000000&@41 +@75 +|T+0#af5f00255&|Y|P|E| +0#0000000&|F|o@1| |=+0#e000e06&| +0#0000000&|P+0#af5f00255&|O|I|N|T|E|R| +0#0000000&|T+0#af5f00255&|O| +0#0000000&|B|a|r|;+0#e000e06&| +0#0000000&@48 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |c|o|n|s|t|a|n|t|s| |*|)| +0#0000000&@48 +|F+0#e000002&|A|L|S|E| +0#0000000&|N+0#e000002&|I|L| +0#0000000&|T+0#e000002&|R|U|E| +0#0000000&@60 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |t|y|p|e|s| |*|)| +0#0000000&@52 +|"|i|n|p|u|t|/|m|o|d|u|l|a|2|_|p|i|m|.|d|e|f|"| |1@2|L|,| |2|1|9|7|B| @21|1|,|1| @10|T|o|p| diff --git a/runtime/syntax/testdir/dumps/modula2_pim_01.dump b/runtime/syntax/testdir/dumps/modula2_pim_01.dump new file mode 100644 index 0000000000..8b93e0f617 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_pim_01.dump @@ -0,0 +1,20 @@ +|T+0#af5f00255#ffffff0|Y|P|E| +0#0000000&|F|o@1| |=+0#e000e06&| +0#0000000&|P+0#af5f00255&|O|I|N|T|E|R| +0#0000000&|T+0#af5f00255&|O| +0#0000000&|B|a|r|;+0#e000e06&| +0#0000000&@48 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |c|o|n|s|t|a|n|t|s| |*|)| +0#0000000&@48 +|F+0#e000002&|A|L|S|E| +0#0000000&|N+0#e000002&|I|L| +0#0000000&|T+0#e000002&|R|U|E| +0#0000000&@60 +@75 +>(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |t|y|p|e|s| |*|)| +0#0000000&@52 +|B+0#00e0003&|I|T|S|E|T| +0#0000000&|B+0#00e0003&|O@1|L|E|A|N| +0#0000000&|C+0#00e0003&|H|A|R| +0#0000000&|P+0#00e0003&|R|O|C| +0#0000000&|C+0#00e0003&|A|R|D|I|N|A|L| +0#0000000&|I+0#00e0003&|N|T|E|G|E|R| +0#0000000&|L+0#00e0003&|O|N|G|I|N|T| +0#0000000&|R+0#00e0003&|E|A|L| +0#0000000&|L+0#00e0003&|O|N|G|R|E|A|L| +0#0000000&@11 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |p|r|o|c|e|d|u|r|e|s| |*|)| +0#0000000&@47 +|C+0#00e0e07&|A|P| +0#0000000&|D+0#00e0e07&|E|C| +0#0000000&|E+0#00e0e07&|X|C|L| +0#0000000&|H+0#00e0e07&|A|L|T| +0#0000000&|I+0#00e0e07&|N|C| +0#0000000&|I+0#00e0e07&|N|C|L| +0#0000000&@48 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |f|u|n|c|t|i|o|n|s| |*|)| +0#0000000&@48 +|A+0#00e0e07&|B|S| +0#0000000&|C+0#00e0e07&|H|R| +0#0000000&|F+0#00e0e07&|L|O|A|T| +0#0000000&|H+0#00e0e07&|I|G|H| +0#0000000&|M+0#00e0e07&|A|X| +0#0000000&|M+0#00e0e07&|I|N| +0#0000000&|O+0#00e0e07&|D@1| +0#0000000&|O+0#00e0e07&|R|D| +0#0000000&|S+0#00e0e07&|I|Z|E| +0#0000000&|T+0#00e0e07&|R|U|N|C| +0#0000000&|V+0#00e0e07&|A|L| +0#0000000&@25 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |m|a|c|r|o|s| |*|)| +0#0000000&@51 +|N+0#00e0e07&|E|W| +0#0000000&|D+0#00e0e07&|I|S|P|O|S|E| +0#0000000&@63 +@75 +|(+0#0000e05&|*| |u|n|s|a|f|e| |b|u|i|l|t|i|n|s| |*|)| +0#0000000&@53 +|A+0#00e0003&|D@1|R|E|S@1| +0#0000000&|P+0#00e0003&|R|O|C|E|S@1| +0#0000000&|W+0#00e0003&|O|R|D| +0#0000000&|A+0#00e0003&|D|R| +0#0000000&|T+0#00e0003&|S|I|Z|E| +0#0000000&|N+0#00e0003&|E|W|P|R|O|C|E|S@1| +0#0000000&|T+0#00e0003&|R|A|N|S|F|E|R| +0#0000000&|S+0#00e0003&|Y|S|T|E|M| +0#0000000&@17 +@57|1|9|,|1| @9|1|4|%| diff --git a/runtime/syntax/testdir/dumps/modula2_pim_02.dump b/runtime/syntax/testdir/dumps/modula2_pim_02.dump new file mode 100644 index 0000000000..c417f8420e --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_pim_02.dump @@ -0,0 +1,20 @@ +|A+0#00e0003#ffffff0|D@1|R|E|S@1| +0#0000000&|P+0#00e0003&|R|O|C|E|S@1| +0#0000000&|W+0#00e0003&|O|R|D| +0#0000000&|A+0#00e0003&|D|R| +0#0000000&|T+0#00e0003&|S|I|Z|E| +0#0000000&|N+0#00e0003&|E|W|P|R|O|C|E|S@1| +0#0000000&|T+0#00e0003&|R|A|N|S|F|E|R| +0#0000000&|S+0#00e0003&|Y|S|T|E|M| +0#0000000&@17 +@75 +|(+0#0000e05&|*| |n|o|n|-|s|t|a|n|d|a|r|d| |l|a|n|g|u|a|g|e| |e|x|t|e|n|s|i|o|n|s| |*|)| +0#0000000&@36 +|B+0#00e0003&|Y|T|E| +0#0000000&|L+0#00e0003&|O|N|G|C|A|R|D| +0#0000000&|L+0#00e0003&|O|N|G|B|I|T|S|E|T| +0#0000000&@50 +@75 +>(+0#0000e05&|*| |u|s|e|r| |d|e|f|i|n|e|d| |i|d|e|n|t|i|f|i|e|r|s| |*|)| +0#0000000&@44 +|f|o@1|b|a|r| |F|o@1|b|a|r| |F|o@1|B|a|r| |f|o@1|1|2|3| |f+0#ffffff16#ff404010|o@1|_|b|a|r| +0#0000000#ffffff0@39 +@75 +|(+0#0000e05&|*| |s|t|r|i|n|g| |l|i|t|e|r|a|l|s| |*|)| +0#0000000&@53 +|s|t|r| |:+0#e000e06&|=| +0#0000000&|"+0#e000002&|f|o@1| |'|b|a|r|'| |b|a|z|"|;+0#e000e06&| +0#0000000&@51 +|s|t|r| |:+0#e000e06&|=| +0#0000000&|'+0#e000002&|f|o@1| |"|b|a|r|"| |b|a|z|'|;+0#e000e06&| +0#0000000&@51 +@75 +|(+0#0000e05&|*| |n|u|m|e|r|i|c| |l|i|t|e|r|a|l|s| |*|)| +0#0000000&@52 +|0+0#e000002&|F@2|H|,+0#e000e06&| +0#0000000&|1+0#e000002&|.|2|3|,+0#e000e06&| +0#0000000&|1+0#e000002&|.|2|3|e|-|4|5|,+0#e000e06&| +0#0000000&|1+0#e000002&|0@2| +0#0000000&@47 +@75 +|(+0#0000e05&|*| |o|c|t|a|l| |l|i|t|e|r|a|l|s| |*|)| +0#0000000&@54 +|n| |:+0#e000e06&|=| +0#0000000&|0+0#e000002&|3|7@1|B|;+0#e000e06&| +0#0000000&|c|h| |:+0#e000e06&|=| +0#0000000&|0+0#e000002&|3|7@1|C|;+0#e000e06&| +0#0000000&@50 +@75 +|(+0#0000e05&|*| |p|r|a|g|m|a|s| |*|)| +0#0000000&@61 +@57|3|7|,|1| @9|3@1|%| diff --git a/runtime/syntax/testdir/dumps/modula2_pim_03.dump b/runtime/syntax/testdir/dumps/modula2_pim_03.dump new file mode 100644 index 0000000000..d811245103 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_pim_03.dump @@ -0,0 +1,20 @@ +|(+0#0000e05#ffffff0|*| |p|r|a|g|m|a|s| |*|)| +0#0000000&@61 +|(+0#e000e06&|*|$|f|o@1|*|)| +0#0000000&@66 +@75 +|(+0#0000e05&|*| |b|l|o|c|k| |c|o|m@1|e|n|t|s| |w|i|t|h| |e|m|p|h|a|s|i|s| |*|)| +0#0000000&@40 +|(+0#0000e05&|*| |c+0#e000e06&|o|p|y|r|i|g|h|t| +0#0000e05&|(|c|)| |J|u|r@1|a|s|i|c| |I|n|c|.| +0#0000000&@44 +| +0#0000e05&@2>a+0#e000e06&|u|t|h|o|r| +0#0000e05&|F|r|e|d| |F|l|i|n|t|s|t|o|n|e| |S|r|.| +0#0000000&@45 +| +0#0000e05&@2|l+0#e000e06&|i|c|e|n|s|e| +0#0000e05&|s|e@1| |L|I|C|E|N|S|E| |f|i|l|e|.| |*|)| +0#0000000&@43 +@75 +|(+0#0000e05&|*| |p+0#e000e06&|r|e|-|c|o|n|d|i|t|i|o|n|s|:| +0#0000e05&|f|o@1| |b|a|r| |b|a|z| |b|a|m| |b|o@1| |d|o@1|d|l|e| |w|a|h|.| +0#0000000&@24 +| +0#0000e05&@2|p+0#e000e06&|o|s|t|-|c|o|n|d|i|t|i|o|n|s|:| +0#0000e05&|f|o@1|d|l|e| |b|a|b@1|l|e| |b|o|z|o| |b|i|m| |b|a|m| |d|a|n|g|.| +0#0000000&@22 +| +0#0000e05&@2|e+0#e000e06&|r@1|o|r|-|c|o|n|d|i|t|i|o|n|s|:| +0#0000e05&|d|a|d|a| |j|i|n|g|l|e| |j|u|n|g|l|e| |b|o|g@1|l|e| |d|e@1| |b|o@1|.| |*|)| +0#0000000&@16 +@75 +|(+0#0000e05&|*| |t|e|c|h|n|i|c|a|l| |d|e|b|t| |m|a|r|k|e|r|s| |*|)| +0#0000000&@46 +|(+0#0000e05&|*| |T+0#e000e06&|O|D|O|:| +0#0000e05&|.@2| |*|)| +0#0000000&@59 +|(+0#0000e05&|*| |F+0#e000e06&|I|X|M|E| +0#0000e05&|*|)| +0#0000000&@63 +|(+0#0000e05&|*| |D+0#e000e06&|E|P|R|E|C|A|T|E|D| +0#0000e05&|*|)| +0#0000000&@58 +@75 +|(+0#0000e05&|*| |p|r|o|c|e|d|u|r|e|s| |*|)| +0#0000000&@58 +|P+0#af5f00255&|R|O|C|E|D|U|R|E| +0#0000000&|N+0#00e0e07&|e|w|F|o@1|W|i|t|h|B|a|r| +0#0000000&|(+0#e000e06&| +0#0000000&|V+0#af5f00255&|A|R| +0#0000000&|f|o@1|:+0#e000e06&| +0#0000000&|F|o@1|;+0#e000e06&| +0#0000000&|b|a|r| |:+0#e000e06&| +0#0000000&|I+0#00e0003&|N|T|E|G|E|R| +0#0000000&|)+0#e000e06&|;| +0#0000000&@18 +@57|5@1|,|4| @9|5|3|%| diff --git a/runtime/syntax/testdir/dumps/modula2_pim_04.dump b/runtime/syntax/testdir/dumps/modula2_pim_04.dump new file mode 100644 index 0000000000..7dc8514570 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_pim_04.dump @@ -0,0 +1,20 @@ +|P+0#af5f00255#ffffff0|R|O|C|E|D|U|R|E| +0#0000000&|N+0#00e0e07&|e|w|F|o@1|W|i|t|h|B|a|r| +0#0000000&|(+0#e000e06&| +0#0000000&|V+0#af5f00255&|A|R| +0#0000000&|f|o@1|:+0#e000e06&| +0#0000000&|F|o@1|;+0#e000e06&| +0#0000000&|b|a|r| |:+0#e000e06&| +0#0000000&|I+0#00e0003&|N|T|E|G|E|R| +0#0000000&|)+0#e000e06&|;| +0#0000000&@18 +|B+0#af5f00255&|E|G|I|N| +0#0000000&@69 +@2|N+0#00e0e07&|E|W|(+0#e000e06&|f+0#0000000&|o@1|)+0#e000e06&|;| +0#0000000&@63 +@2|f|o@1|^+0#e000e06&|.|b+0#0000000&|a|r| |:+0#e000e06&|=| +0#0000000&|b|a|r|;+0#e000e06&| +0#0000000&@56 +@2|R+0#af5f00255&|E|T|U|R|N| +0#0000000&@66 +>E+0#af5f00255&|N|D| +0#0000000&|S+0#00e0e07&|e|t|B|a|r|;+0#e000e06&| +0#0000000&@63 +@75 +|(+0#0000e05&|*| |f|u|n|c|t|i|o|n|s| |*|)| +0#0000000&@59 +|P+0#af5f00255&|R|O|C|E|D|U|R|E| +0#0000000&|b+0#00e0e07&|a|r| +0#0000000&|(+0#e000e06&| +0#0000000&|f|o@1| |:+0#e000e06&| +0#0000000&|F|o@1| |)+0#e000e06&| +0#0000000&|:+0#e000e06&| +0#0000000&|I+0#00e0003&|N|T|E|G|E|R|;+0#e000e06&| +0#0000000&@36 +|B+0#af5f00255&|E|G|I|N| +0#0000000&@69 +@2|I+0#af5f00255&|F| +0#0000000&|f|o@1| |=+0#e000e06&| +0#0000000&|N+0#e000002&|I|L| +0#0000000&|T+0#af5f00255&|H|E|N| +0#0000000&@55 +@4|H+0#00e0e07&|A|L|T| +0#0000000&@66 +@2|E+0#af5f00255&|L|S|E| +0#0000000&@68 +@4|R+0#af5f00255&|E|T|U|R|N| +0#0000000&|f|o@1|^+0#e000e06&|.|b+0#0000000&|a|r| @55 +@2|E+0#af5f00255&|N|D| +0#0000000&|(+0#0000e05&|*| |I|F| |*|)| +0#0000000&@60 +|E+0#af5f00255&|N|D| +0#0000000&|b+0#00e0e07&|a|r|;+0#e000e06&| +0#0000000&@66 +@75 +|(+0#0000e05&|*| |d|i|s|a|b|l|e|d| |c|o|d|e| |*|)| +0#0000000&@55 +|?+0#4040ff13&|<| +0#0000000&@72 +@57|7|3|,|1| @9|7|2|%| diff --git a/runtime/syntax/testdir/dumps/modula2_pim_05.dump b/runtime/syntax/testdir/dumps/modula2_pim_05.dump new file mode 100644 index 0000000000..fd5adb4df4 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_pim_05.dump @@ -0,0 +1,20 @@ +|?+0#4040ff13#ffffff0|<| +0#0000000&@72 +|W+0#4040ff13&|H|I|L|E| |f|o@1| |=| |b|a|r| |D|O| +0#0000000&@56 +| +0#4040ff13&@1|b|a|z|(|b|a|m|,| |b|o@1|)| +0#0000000&@59 +|E+0#4040ff13&|N|D| |(|*| |W|H|I|L|E| |*|)|;| +0#0000000&@58 +|>+0#4040ff13&|?| +0#0000000&@72 +> @74 +|(+0#0000e05&|*| |s|y|n|o|n|y|m|s| |*|)| +0#0000000&@60 +|&+0#e000e06&| +0#0000000&@1|~+0#e000e06&| +0#0000000&@70 +@75 +|(+0#0000e05&|*| |i|l@1|e|g|a|l| |c|h|a|r|a|c|t|e|r|s| |*|)| +0#0000000&@50 +|`+0#ffffff16#ff404010| +0#0000000#ffffff0@1|!+0#ffffff16#ff404010| +0#0000000#ffffff0@1|@+0#ffffff16#ff404010| +0#0000000#ffffff0@1|$+0#ffffff16#ff404010| +0#0000000#ffffff0@1|%+0#ffffff16#ff404010| +0#0000000#ffffff0@1|\+0#ffffff16#ff404010| +0#0000000#ffffff0@1|?+0#ffffff16#ff404010| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010| +0#0000000#ffffff0@52 +@75 +|(+0#0000e05&|*| |i|l@1|e|g|a|l| |i|d|e|n|t|i|f|i|e|r|s| |*|)| +0#0000000&@49 +@75 +|_+0#ffffff16#ff404010|b|a|r| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z|_@1|b|a|m| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1| +0#0000000#ffffff0@26 +@75 +|b+0#ffffff16#ff404010|a|r|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1|_| +0#0000000#ffffff0@26 +@75 +|_+0#ffffff16#ff404010@1|b|a|r| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1|b|a|m| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1| +0#0000000#ffffff0@22 +@57|9|1|,|0|-|1| @7|9|2|%| diff --git a/runtime/syntax/testdir/dumps/modula2_pim_99.dump b/runtime/syntax/testdir/dumps/modula2_pim_99.dump new file mode 100644 index 0000000000..7e096a2aa2 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_pim_99.dump @@ -0,0 +1,20 @@ +|&+0#e000e06#ffffff0| +0#0000000&@1|~+0#e000e06&| +0#0000000&@70 +@75 +|(+0#0000e05&|*| |i|l@1|e|g|a|l| |c|h|a|r|a|c|t|e|r|s| |*|)| +0#0000000&@50 +|`+0#ffffff16#ff404010| +0#0000000#ffffff0@1|!+0#ffffff16#ff404010| +0#0000000#ffffff0@1|@+0#ffffff16#ff404010| +0#0000000#ffffff0@1|$+0#ffffff16#ff404010| +0#0000000#ffffff0@1|%+0#ffffff16#ff404010| +0#0000000#ffffff0@1|\+0#ffffff16#ff404010| +0#0000000#ffffff0@1|?+0#ffffff16#ff404010| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010| +0#0000000#ffffff0@52 +@75 +|(+0#0000e05&|*| |i|l@1|e|g|a|l| |i|d|e|n|t|i|f|i|e|r|s| |*|)| +0#0000000&@49 +@75 +|_+0#ffffff16#ff404010|b|a|r| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z|_@1|b|a|m| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1| +0#0000000#ffffff0@26 +@75 +|b+0#ffffff16#ff404010|a|r|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1|_| +0#0000000#ffffff0@26 +@75 +|_+0#ffffff16#ff404010@1|b|a|r| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1|b|a|m| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1| +0#0000000#ffffff0@22 +@75 +|b+0#ffffff16#ff404010|a|r|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1|_@1| +0#0000000#ffffff0@22 +@75 +|b+0#ffffff16#ff404010|a|r|_@1|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_@1|b|a|z|_@1| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1| +0#0000000#ffffff0@35 +@75 +@75 +>E+0#af5f00255&|N|D| +0#0000000&|F+0#00e0e07&|o@1|b|a|r|.+0#e000e06&| +0#0000000&@63 +@57|1@2|,|1| @8|B|o|t| diff --git a/runtime/syntax/testdir/dumps/modula2_r10_00.dump b/runtime/syntax/testdir/dumps/modula2_r10_00.dump new file mode 100644 index 0000000000..ab4167abf5 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_r10_00.dump @@ -0,0 +1,20 @@ +>(+0#0000e05#ffffff0|*| |M|o|d|u|l|a|-|2| |R|1|0| |T|e|s|t| |F|i|l|e| |f|o|r| |V|i|m| |S|y|n|t|a|x| |C|o|l|o|u|r|i|n|g| |*|)| +0#0000000&@21 +@75 +|(+0#0000e05&|*| |-@49| +0#0000000&@21 +| +0#0000e05&|*| |T|H|I|S| |F|I|L|E| |I|S| |L|I|C|E|N|S|E|D| |U|N|D|E|R| |T|H|E| |V|I|M| |L|I|C|E|N|S|E| +0#0000000&@28 +| +0#0000e05&|*| |s|e@1| |h|t@1|p|s|:|/@1|g|i|t|h|u|b|.|c|o|m|/|v|i|m|/|v|i|m|/|b|l|o|b|/|m|a|s|t|e|r|/|L|I|C|E|N|S|E| +0#0000000&@21 +| +0#0000e05&|*| |-@49| |*|)| +0#0000000&@18 +@75 +|D+0#af5f00255&|E|F|I|N|I|T|I|O|N| +0#0000000&|M+0#af5f00255&|O|D|U|L|E| +0#00e0e07&|F|o@1|b|a|r|;+0#e000e06&| +0#0000000&|(+0#e000e06&|*|!|m|2|r|1|0|*|)| +0#0000000&@38 +@75 +|I+0#af5f00255&|M|P|O|R|T| +0#0000000&|U+0#00e0003&|N|S|A|F|E| +0#0000000&|A+0#af5f00255&|L|I|A|S| +0#0000000&|B+0#00e0003&|Y|T|E|,+0#e000e06&| +0#0000000&|W+0#00e0003&|O|R|D|,+0#e000e06&| +0#0000000&|A|D@1|R|E|S@1|;+0#e000e06&| +0#0000000&@34 +@75 +|C+0#af5f00255&|O|N|S|T| +0#0000000&|M|a|x|F|o@1| |=+0#e000e06&| +0#0000000&|1+0#e000002&|.|0|;+0#e000e06&| +0#0000000&@55 +@75 +|T+0#af5f00255&|Y|P|E| +0#0000000&|F|o@1| |=+0#e000e06&| +0#0000000&|A+0#af5f00255&|L|I|A|S| +0#0000000&|O+0#af5f00255&|F| +0#0000000&|B|a|r|;+0#e000e06&| +0#0000000&@50 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |c|o|n|s|t|a|n|t|s| |*|)| +0#0000000&@48 +|N+0#e000002&|I|L| +0#0000000&|F+0#e000002&|A|L|S|E| +0#0000000&|T+0#e000002&|R|U|E| +0#0000000&@60 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |t|y|p|e|s| |*|)| +0#0000000&@52 +|"|i|n|p|u|t|/|m|o|d|u|l|a|2|_|r|1|0|.|d|e|f|"| |1|4|6|L|,| |2|9|8|3|B| @21|1|,|1| @10|T|o|p| diff --git a/runtime/syntax/testdir/dumps/modula2_r10_01.dump b/runtime/syntax/testdir/dumps/modula2_r10_01.dump new file mode 100644 index 0000000000..417ad883d4 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_r10_01.dump @@ -0,0 +1,20 @@ +|T+0#af5f00255#ffffff0|Y|P|E| +0#0000000&|F|o@1| |=+0#e000e06&| +0#0000000&|A+0#af5f00255&|L|I|A|S| +0#0000000&|O+0#af5f00255&|F| +0#0000000&|B|a|r|;+0#e000e06&| +0#0000000&@50 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |c|o|n|s|t|a|n|t|s| |*|)| +0#0000000&@48 +|N+0#e000002&|I|L| +0#0000000&|F+0#e000002&|A|L|S|E| +0#0000000&|T+0#e000002&|R|U|E| +0#0000000&@60 +@75 +>(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |t|y|p|e|s| |*|)| +0#0000000&@52 +|B+0#00e0003&|O@1|L|E|A|N| +0#0000000&|C+0#00e0003&|H|A|R| +0#0000000&|U+0#00e0003&|N|I|C|H|A|R| +0#0000000&|O+0#00e0003&|C|T|E|T| +0#0000000&|C+0#00e0003&|A|R|D|I|N|A|L| +0#0000000&|L+0#00e0003&|O|N|G|C|A|R|D| +0#0000000&|I+0#00e0003&|N|T|E|G|E|R| +0#0000000&|L+0#00e0003&|O|N|G|I|N|T| +0#0000000&|R+0#00e0003&|E|A|L| +0#0000000&|L+0#00e0003&|O|N|G|R|E|A|L| +0#0000000& +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |p|r|o|c|e|d|u|r|e|s| |*|)| +0#0000000&@47 +|A+0#00e0e07&|P@1|E|N|D| +0#0000000&|I+0#00e0e07&|N|S|E|R|T| +0#0000000&|R+0#00e0e07&|E|M|O|V|E| +0#0000000&|S+0#00e0e07&|O|R|T| +0#0000000&|S+0#00e0e07&|O|R|T|N|E|W| +0#0000000&@41 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |f|u|n|c|t|i|o|n|s| |*|)| +0#0000000&@48 +|C+0#00e0e07&|H|R| +0#0000000&|O+0#00e0e07&|R|D| +0#0000000&|O+0#00e0e07&|D@1| +0#0000000&|A+0#00e0e07&|B|S| +0#0000000&|S+0#00e0e07&|G|N| +0#0000000&|M+0#00e0e07&|I|N| +0#0000000&|M+0#00e0e07&|A|X| +0#0000000&|L+0#00e0e07&|O|G|2| +0#0000000&|P+0#00e0e07&|O|W|2| +0#0000000&|E+0#00e0e07&|N|T|I|E|R| +0#0000000&|P+0#00e0e07&|R|E|D| +0#0000000&|S+0#00e0e07&|U|C@1| +0#0000000&|P+0#00e0e07&|T|R| +0#0000000&|C+0#af5f00255&|A|P|A|C|I|T|Y| +0#0000000&|C+0#00e0e07&|O|U|N|T| +0#0000000&|L+0#00e0e07& +|E|N|G|T|H| +0#0000000&@69 +@75 +|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |m|a|c|r|o|s| |*|)| +0#0000000&@51 +|N+0#00e0e07&|O|P| +0#0000000&|T+0#00e0e07&|M|I|N| +0#0000000&|T+0#00e0e07&|M|A|X| +0#0000000&|T+0#00e0e07&|S|I|Z|E| +0#0000000&|T+0#00e0e07&|L|I|M|I|T| +0#0000000&@48 +@75 +|(+0#0000e05&|*| |u|n|s|a|f|e| |b|u|i|l|t|i|n|s| |*|)| +0#0000000&@53 +@57|1|9|,|1| @9|1|0|%| diff --git a/runtime/syntax/testdir/dumps/modula2_r10_02.dump b/runtime/syntax/testdir/dumps/modula2_r10_02.dump new file mode 100644 index 0000000000..408872aa8b --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_r10_02.dump @@ -0,0 +1,20 @@ +|U+0#00e0003#ffffff0|N|S|A|F|E| +0#0000000&@68 +@75 +|(+0#0000e05&|*| |u|n|s|a|f|e| |b|u|i|l|t|i|n| |t|y|p|e|s| |*|)| +0#0000000&@48 +|B+0#00e0003&|Y|T|E| +0#0000000&|W+0#00e0003&|O|R|D| +0#0000000&|L+0#00e0003&|O|N|G|W|O|R|D| +0#0000000&|A|D@1|R|E|S@1| |O+0#00e0003&|C|T|E|T|S|E|Q| +0#0000000&@39 +@75 +>(+0#0000e05&|*| |u|n|s|a|f|e| |b|u|i|l|t|i|n| |p|r|o|c|e|d|u|r|e|s| |*|)| +0#0000000&@43 +|A+0#00e0003&|D@1| +0#0000000&|S+0#00e0003&|U|B| +0#0000000&|D+0#00e0003&|E|C| +0#0000000&|I+0#00e0003&|N|C| +0#0000000&|S+0#00e0003&|E|T|B|I|T| +0#0000000&|H+0#00e0003&|A|L|T| +0#0000000&@47 +@75 +|(+0#0000e05&|*| |u|n|s|a|f|e| |b|u|i|l|t|i|n| |f|u|n|c|t|i|o|n|s| |*|)| +0#0000000&@44 +|A+0#00e0003&|D|R| +0#0000000&|C+0#00e0003&|A|S|T| +0#0000000&|B+0#00e0003&|I|T| +0#0000000&|S+0#00e0003&|H|L| +0#0000000&|S+0#00e0003&|H|R| +0#0000000&|B+0#00e0003&|W|N|O|T| +0#0000000&|B+0#00e0003&|W|A|N|D| +0#0000000&|B+0#00e0003&|W|O|R| +0#0000000&@37 +@75 +|(+0#0000e05&|*| |n|o|n|-|p|o|r|t|a|b|l|e| |l|a|n|g|u|a|g|e| |e|x|t|e|n|s|i|o|n|s| |*|)| +0#0000000&@36 +|A+0#00e0003&|S@1|E|M|B|L|E|R| +0#0000000&|A+0#00e0003&|S|M| +0#0000000&|R+0#00e0003&|E|G| +0#0000000&@57 +@75 +|(+0#0000e05&|*| |u|s|e|r| |d|e|f|i|n|e|d| |i|d|e|n|t|i|f|i|e|r|s| |*|)| +0#0000000&@44 +|f|o@1|b|a|r| |F|o@1|b|a|r| |F|o@1|B|a|r| |f|o@1|_|b|a|r| |f|o@1|0| @41 +@75 +@75 +|(+0#0000e05&|*| |s|t|r|i|n|g| |l|i|t|e|r|a|l|s| |*|)| +0#0000000&@53 +@57|3|7|,|1| @9|2|4|%| diff --git a/runtime/syntax/testdir/dumps/modula2_r10_03.dump b/runtime/syntax/testdir/dumps/modula2_r10_03.dump new file mode 100644 index 0000000000..b35c8b095b --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_r10_03.dump @@ -0,0 +1,20 @@ +|(+0#0000e05#ffffff0|*| |s|t|r|i|n|g| |l|i|t|e|r|a|l|s| |*|)| +0#0000000&@53 +|s|t|r| |:+0#e000e06&|=| +0#0000000&|"+0#e000002&|f|o@1| |'|b|a|r|'| |b|a|z|"|;+0#e000e06&| +0#0000000&@51 +|s|t|r| |:+0#e000e06&|=| +0#0000000&|'+0#e000002&|f|o@1| |"|b|a|r|"| |b|a|z|'|;+0#e000e06&| +0#0000000&@51 +@75 +|(+0#0000e05&|*| |n|u|m|e|r|i|c| |l|i|t|e|r|a|l|s| |*|)| +0#0000000&@52 +>0+0#e000002&|b|0|1@1|0|'|0@1|1@1|'|0|1@1|0|'|0@3|,+0#e000e06&| +0#0000000&|0+0#e000002&|u|0|A|,+0#e000e06&| +0#0000000&|0+0#e000002&|x|0|1|2|3|,+0#e000e06&| +0#0000000&|0+0#e000002&|x|C|A|F|E|'|D|0@1|D| +0#0000000&@26 +|1+0#e000002&|'|0@2|'|0@2|.|0@1|,+0#e000e06&| +0#0000000&|1+0#e000002&|.|2|3|,+0#e000e06&| +0#0000000&|1+0#e000002&|.|2|3|e|+|1|0|,+0#e000e06&| +0#0000000&|1+0#e000002&|.|2|3|4|'|5|6|7|'|8|9|0|e|-|1|'|0@2| +0#0000000&@24 +@75 +@75 +|(+0#0000e05&|*| |l|a|n|g|u|a|g|e| |d|e|f|i|n|e|d| |p|r|a|g|m|a|s| |*|)| +0#0000000&@44 +|<+0#e000e06&|*|M|S|G|=|I|N|F|O|:|"|f|o@1|b|a|r|"|*|>| +0#0000000&|<+0#e000e06&|*|E|N|C|O|D|I|N|G|=|"|U|T|F|8|"|*|>| +0#0000000&|<+0#e000e06&|*|I|N|L|I|N|E|*|>| +0#0000000&|<+0#e000e06&|*|N|O|I|N|L|I|N|E|*|>| +0#0000000&|<+0#e000e06&|*|F@1|I|=|"|C|" +|*|>| +0#0000000&@72 +@75 +|(+0#0000e05&|*| |i|m|p|l|e|m|e|n|t|a|t|i|o|n| |d|e|f|i|n|e|d| |p|r|a|g|m|a|s| |*|)| +0#0000000&@38 +|<+0#e000e06&|*|G|M|2|.|F|o@1|b|a|r|||W|=|B|a|z|b|a|m|*|>| +0#0000000&@51 +@75 +@75 +|(+0#0000e05&|*| |s|i|n|g|l|e| |l|i|n|e| |c|o|m@1|e|n|t| |*|)| +0#0000000&@49 +|!+0#0000e05&| |f|o@1| |b|a|r| |b|a|z| |b|a|m| |b|o@1| | +0#0000000&@52 +@57|5@1|,|1| @9|3|8|%| diff --git a/runtime/syntax/testdir/dumps/modula2_r10_04.dump b/runtime/syntax/testdir/dumps/modula2_r10_04.dump new file mode 100644 index 0000000000..cd6436c370 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_r10_04.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@74 +|(+0#0000e05&|*| |b|l|o|c|k| |c|o|m@1|e|n|t|s| |w|i|t|h| |e|m|p|h|a|s|i|s| |*|)| +0#0000000&@40 +|(+0#0000e05&|*| |c+0#e000e06&|o|p|y|r|i|g|h|t| +0#0000e05&|(|c|)| |2|0|1|6| |M|o|d|u|l|a|-|2| |F|o|u|n|d|a|t|i|o|n|.| +0#0000000&@32 +| +0#0000e05&@2|a+0#e000e06&|u|t|h|o|r|s| +0#0000e05&|B|.|K|o|w|a|r|s|c|h| |a|n|d| |R|.|S|u|t|c|l|i|f@1|e| +0#0000000&@37 +| +0#0000e05&@2|l+0#e000e06&|i|c|e|n|s|e| +0#0000e05&|s|e@1| |L|I|C|E|N|S|E| |*|)| +0#0000000&@49 +> @74 +|(+0#0000e05&|*| |p+0#e000e06&|r|e|-|c|o|n|d|i|t|i|o|n|s|:| +0#0000e05&|f|o@1| |b|a|r| |b|a|z| |b|a|m| |b|o@1| |d|o@1|d|l|e| |w|a|h|.| +0#0000000&@24 +| +0#0000e05&@2|p+0#e000e06&|o|s|t|-|c|o|n|d|i|t|i|o|n|s|:| +0#0000e05&|f|o@1|d|l|e| |b|a|b@1|l|e| |b|o|z|o| |b|i|m| |b|a|m| |d|a|n|g|.| +0#0000000&@22 +| +0#0000e05&@2|e+0#e000e06&|r@1|o|r|-|c|o|n|d|i|t|i|o|n|s|:| +0#0000e05&|d|a|d|a| |j|i|n|g|l|e| |j|u|n|g|l|e| |b|o|g@1|l|e| |d|e@1| |b|o@1|.| |*|)| +0#0000000&@16 +@75 +|(+0#0000e05&|*| |(|*| |*|)| |*|)| +0#0000000&@63 +@75 +|(+0#0000e05&|*| |b|i|n|d|i|n|g|s| |*|)| +0#0000000&@60 +|P+0#af5f00255&|R|O|C|E|D|U|R|E| +0#0000000&|[+0#e000e06&|+|]| +0#0000000&|s+0#00e0e07&|u|m| +0#0000000&|(+0#e000e06&| +0#0000000&|a|,+0#e000e06&| +0#0000000&|b| |:+0#e000e06&| +0#0000000&|B|C|D| |)+0#e000e06&| +0#0000000&|:+0#e000e06&| +0#0000000&|B|C|D|;+0#e000e06&| +0#0000000&@35 +@75 +|P+0#af5f00255&|R|O|C|E|D|U|R|E| +0#0000000&|[+0#e000e06&|M+0#af5f00255&|O|D|]+0#e000e06&| +0#0000000&|m+0#00e0e07&|o|d|u|l|u|s| +0#0000000&|(+0#e000e06&| +0#0000000&|n|,+0#e000e06&| +0#0000000&|m| |:+0#e000e06&| +0#0000000&|I|N|T|6|4| |)+0#e000e06&| +0#0000000&|:+0#e000e06&| +0#0000000&|I|N|T|6|4|;+0#e000e06&| +0#0000000&@25 +@75 +|P+0#af5f00255&|R|O|C|E|D|U|R|E| +0#0000000&|[+0#e000e06&|R+0#af5f00255&|E|T|A|I|N|]+0#e000e06&| +0#0000000&|R+0#00e0e07&|e|t|a|i|n| +0#0000000&|(+0#e000e06&| +0#0000000&|f|o@1| |:+0#e000e06&| +0#0000000&|F|o@1| |)+0#e000e06&|;| +0#0000000&@34 +@75 +@57|7|3|,|0|-|1| @7|5|2|%| diff --git a/runtime/syntax/testdir/dumps/modula2_r10_05.dump b/runtime/syntax/testdir/dumps/modula2_r10_05.dump new file mode 100644 index 0000000000..2a8ae0c680 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_r10_05.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@74 +|P+0#af5f00255&|R|O|C|E|D|U|R|E| +0#0000000&|[+0#e000e06&|L+0#00e0e07&|E|N|G|T|H|]+0#e000e06&| +0#0000000&|l+0#00e0e07&|e|n|g|t|h| +0#0000000&|(+0#e000e06&| +0#0000000&|s|t|r| |:+0#e000e06&| +0#0000000&|S|t|r|i|n|g| |)+0#e000e06&| +0#0000000&|:+0#e000e06&| +0#0000000&|L+0#00e0003&|O|N|G|C|A|R|D|;+0#e000e06&| +0#0000000&@20 +@75 +@75 +|(+0#0000e05&|*| |p|r|o|c|e|d|u|r|e|s| |*|)| +0#0000000&@58 +>P+0#af5f00255&|R|O|C|E|D|U|R|E| +0#0000000&|N+0#00e0e07&|e|w|F|o@1|W|i|t|h|B|a|r| +0#0000000&|(+0#e000e06&| +0#0000000&|V+0#af5f00255&|A|R| +0#0000000&|f|o@1|:+0#e000e06&| +0#0000000&|F|o@1|;+0#e000e06&| +0#0000000&|b|a|r| |:+0#e000e06&| +0#0000000&|I+0#00e0003&|N|T|E|G|E|R| +0#0000000&|)+0#e000e06&|;| +0#0000000&@18 +|B+0#af5f00255&|E|G|I|N| +0#0000000&@69 +@2|N+0#af5f00255&|E|W|(+0#e000e06&|f+0#0000000&|o@1|)+0#e000e06&|;| +0#0000000&@63 +@2|f|o@1|^+0#e000e06&|.|b+0#0000000&|a|r| |:+0#e000e06&|=| +0#0000000&|b|a|r|;+0#e000e06&| +0#0000000&@56 +@2|R+0#af5f00255&|E|T|U|R|N| +0#0000000&@66 +|E+0#af5f00255&|N|D| +0#0000000&|N+0#00e0e07&|e|w|F|o@1|W|i|t|h|B|a|r|;+0#e000e06&| +0#0000000&@56 +@75 +|E+0#af5f00255&|N|D| +0#0000000&|E+0#af5f00255&|N|D|;+0#e000e06&| +0#0000000&@66 +@75 +|(+0#0000e05&|*| |f|u|n|c|t|i|o|n|s| |*|)| +0#0000000&@59 +|P+0#af5f00255&|R|O|C|E|D|U|R|E| +0#0000000&|b+0#00e0e07&|a|r| +0#0000000&|(+0#e000e06&| +0#0000000&|f|o@1| |:+0#e000e06&| +0#0000000&|F|o@1| |)+0#e000e06&| +0#0000000&|:+0#e000e06&| +0#0000000&|I+0#00e0003&|N|T|E|G|E|R|;+0#e000e06&| +0#0000000&@36 +|B+0#af5f00255&|E|G|I|N| +0#0000000&@69 +@2|I+0#af5f00255&|F| +0#0000000&|f|o@1| |=+0#e000e06&| +0#0000000&|N+0#e000002&|I|L| +0#0000000&|T+0#af5f00255&|H|E|N| +0#0000000&@55 +@4|U+0#00e0003&|N|S|A|F|E|.+0#e000e06&|H+0#00e0003&|A|L|T| +0#0000000&@59 +@57|9|1|,|1| @9|6@1|%| diff --git a/runtime/syntax/testdir/dumps/modula2_r10_06.dump b/runtime/syntax/testdir/dumps/modula2_r10_06.dump new file mode 100644 index 0000000000..68af55cb09 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_r10_06.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@3|U+0#00e0003&|N|S|A|F|E|.+0#e000e06&|H+0#00e0003&|A|L|T| +0#0000000&@59 +@2|E+0#af5f00255&|L|S|E| +0#0000000&@68 +@4|R+0#af5f00255&|E|T|U|R|N| +0#0000000&|f|o@1|^+0#e000e06&|.|b+0#0000000&|a|r| @55 +@2|E+0#af5f00255&|N|D| +0#0000000&|(+0#0000e05&|*| |I|F| |*|)| +0#0000000&@60 +|E+0#af5f00255&|N|D| +0#0000000&|b+0#00e0e07&|a|r|;+0#e000e06&| +0#0000000&@66 +> @74 +@75 +|(+0#0000e05&|*| |t|e|c|h|n|i|c|a|l| |d|e|b|t| |*|)| +0#0000000&@54 +|T+0#af5f00255&|O| +0#0000000&|D+0#af5f00255&|O| +0#0000000&|(+0#e000e06&| +0#0000000&|1+0#e000002&|2|3|4|,+0#e000e06&| +0#0000000&|W|e|i|g|h|t|.+0#e000e06&|M+0#0000000&|a|j|o|r| |)+0#e000e06&| +0#0000000&|(+0#0000e05&|*| |f|o@1| |*|)| +0#0000000&@36 +@2|"+0#e000002&|r|e|d|e|s|i|g|n| |f|o@1|"|,+0#e000e06&| +0#0000000&|2+0#e000002&|d+0#0000000&|;+0#e000e06&| +0#0000000&@53 +@2|"+0#e000002&|r|e|p|l|a|c|e| |f|o@1|"|,+0#e000e06&| +0#0000000&|2+0#e000002&|d+0#0000000&|;+0#e000e06&| +0#0000000&@54 +@2|"+0#e000002&|t|e|s|t| |n|e|w| |f|o@1|"|,+0#e000e06&| +0#0000000&|1+0#e000002&|d+0#0000000&| @54 +|E+0#e000e06&|N|D| +0#0000000&|(+0#0000e05&|*| |T|O| |D|O| |*|)|;+0#e000e06&| +0#0000000&@58 +@75 +|P+0#af5f00255&|R|O|C|E|D|U|R|E| +0#0000000&|S+0#00e0e07&|e|t|B|a|b|a| +0#0000000&|<+0#e000e06&|*|D|E|P|R|E|C|A|T|E|D|*|>| +0#0000000&|(+0#e000e06&| +0#0000000&|n| |:+0#e000e06&| +0#0000000&|C+0#00e0003&|A|R|D|I|N|A|L| +0#0000000&|)+0#e000e06&|;| +0#0000000&@24 +@75 +@75 +|(+0#0000e05&|*| |d|i|s|a|b|l|e|d| |c|o|d|e| |*|)| +0#0000000&@55 +|?+0#4040ff13&|<| +0#0000000&@72 +@57|1|0|9|,|0|-|1| @6|8|1|%| diff --git a/runtime/syntax/testdir/dumps/modula2_r10_07.dump b/runtime/syntax/testdir/dumps/modula2_r10_07.dump new file mode 100644 index 0000000000..8f061fdb94 --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_r10_07.dump @@ -0,0 +1,20 @@ +|?+0#4040ff13#ffffff0|<| +0#0000000&@72 +|W+0#4040ff13&|H|I|L|E| |f|o@1| |=| |b|a|r| |D|O| +0#0000000&@56 +| +0#4040ff13&@1|b|a|z|(|b|a|m|,| |b|o@1|)| +0#0000000&@59 +|E+0#4040ff13&|N|D| |(|*| |W|H|I|L|E| |*|)|;| +0#0000000&@58 +|>+0#4040ff13&|?| +0#0000000&@72 +> @74 +@75 +|(+0#0000e05&|*| |i|l@1|e|g|a|l| |c|h|a|r|a|c|t|e|r|s| |*|)| +0#0000000&@50 +|`+0#ffffff16#ff404010| +0#0000000#ffffff0@1|~+0#ffffff16#ff404010| +0#0000000#ffffff0@1|$+0#ffffff16#ff404010| +0#0000000#ffffff0@1|%+0#ffffff16#ff404010| +0#0000000#ffffff0@1|?+0#ffffff16#ff404010| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010| +0#0000000#ffffff0@58 +@75 +|(+0#0000e05&|*| |i|l@1|e|g|a|l| |i|d|e|n|t|i|f|i|e|r|s| |*|)| +0#0000000&@49 +@75 +|_+0#ffffff16#ff404010|b|a|r| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z|_@1|b|a|m| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1| +0#0000000#ffffff0@26 +@75 +|b+0#ffffff16#ff404010|a|r|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1|_| +0#0000000#ffffff0@26 +@75 +|_+0#ffffff16#ff404010@1|b|a|r| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1|b|a|m| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1| +0#0000000#ffffff0@22 +@75 +|b+0#ffffff16#ff404010|a|r|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1|_@1| +0#0000000#ffffff0@22 +@57|1|2|7|,|0|-|1| @6|9|5|%| diff --git a/runtime/syntax/testdir/dumps/modula2_r10_99.dump b/runtime/syntax/testdir/dumps/modula2_r10_99.dump new file mode 100644 index 0000000000..067fb47dad --- /dev/null +++ b/runtime/syntax/testdir/dumps/modula2_r10_99.dump @@ -0,0 +1,20 @@ +| +0&#ffffff0@74 +|(+0#0000e05&|*| |i|l@1|e|g|a|l| |c|h|a|r|a|c|t|e|r|s| |*|)| +0#0000000&@50 +|`+0#ffffff16#ff404010| +0#0000000#ffffff0@1|~+0#ffffff16#ff404010| +0#0000000#ffffff0@1|$+0#ffffff16#ff404010| +0#0000000#ffffff0@1|%+0#ffffff16#ff404010| +0#0000000#ffffff0@1|?+0#ffffff16#ff404010| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010| +0#0000000#ffffff0@58 +@75 +|(+0#0000e05&|*| |i|l@1|e|g|a|l| |i|d|e|n|t|i|f|i|e|r|s| |*|)| +0#0000000&@49 +@75 +|_+0#ffffff16#ff404010|b|a|r| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z|_@1|b|a|m| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010|b|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1| +0#0000000#ffffff0@26 +@75 +|b+0#ffffff16#ff404010|a|r|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1|_| +0#0000000#ffffff0@26 +@75 +|_+0#ffffff16#ff404010@1|b|a|r| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1|b|a|m| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1| +0#0000000#ffffff0@22 +@75 +|b+0#ffffff16#ff404010|a|r|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_@1| +0#0000000#ffffff0@1|b+0#ffffff16#ff404010|a|r|_|b|a|z|_@1|b|a|m|_|b|o@1|_@1| +0#0000000#ffffff0@22 +@75 +|b+0#ffffff16#ff404010|a|r|_@1|b|a|z| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_|b|a|z|_@1| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1|b|a|r|_@1|b|a|z|_@1| +0#0000000#ffffff0@1|_+0#ffffff16#ff404010@1| +0#0000000#ffffff0@35 +@75 +@75 +|(+0#0000e05&|*| |m|o|d|u|l|e| |e|n|d| |*|)| +0#0000000&@58 +>E+0#af5f00255&|N|D| +0#0000000&|F+0#00e0e07&|o@1|b|a|r|.+0#e000e06&| +0#0000000&@63 +@57|1|4|6|,|1| @8|B|o|t| diff --git a/runtime/syntax/testdir/input/modula2_iso.def b/runtime/syntax/testdir/input/modula2_iso.def new file mode 100644 index 0000000000..b979ccf70c --- /dev/null +++ b/runtime/syntax/testdir/input/modula2_iso.def @@ -0,0 +1,114 @@ +(* Modula-2 ISO Test File for Vim Syntax Colouring *) + +(* -------------------------------------------------- + * THIS FILE IS LICENSED UNDER THE VIM LICENSE + * see https://github.com/vim/vim/blob/master/LICENSE + * -------------------------------------------------- *) + + +DEFINITION MODULE Foobar; (*!m2iso*) + +FROM SYSTEM IMPORT LOC, WORD, ADDRESS; + +CONST MaxFoo = 1.0; LF = CHR(10); + +TYPE Foo = POINTER TO Bar; + +(* predefined constants *) +FALSE NIL TRUE INTERRUPTIBLE UNINTERRUPTIBLE + +(* predefined types *) +BITSET BOOLEAN CHAR PROC CARDINAL INTEGER LONGINT REAL LONGREAL +COMPLEX LONGCOMPLEX PROTECTION + +(* predefined procedures *) +CAP DEC EXCL HALT INC INCL + +(* predefined functions *) +ABS CHR CMPLX FLOAT HIGH IM INT LENGTH LFLOAT MAX MIN ODD ORD RE SIZE TRUNC VAL + +(* predefined macros *) +NEW DISPOSE + +(* unsafe builtins *) +ADDRESS BYTE LOC WORD ADR CAST TSIZE SYSTEM +MAKEADR ADDADR SUBADR DIFADR ROTATE SHIFT + +(* non-standard language extensions *) +LONGCARD LONGBITSET + +(* user defined identifiers *) +foobar Foobar FooBar foo123 foo_bar + +(* string literals *) +str := "foo 'bar' baz"; +str := 'foo "bar" baz'; + +(* numeric literals *) +0FFFH, 1.23, 1.23e-45, 1000 + +(* octal literals *) +n := 0377B; ch := 0377C; + +(* pragmas *) +<*$foo*> + +(* block comments with emphasis *) +(* copyright (c) Jurrasic Inc. + author Fred Flintstone Sr. + license see LICENSE file. *) + +(* pre-conditions: foo bar baz bam boo doodle wah. + post-conditions: foodle babble bozo bim bam dang. + error-conditions: dada jingle jungle boggle dee boo. *) + +(* technical debt markers *) +(* TODO: ... *) +(* FIXME *) +(* DEPRECATED *) + +(* procedures *) +PROCEDURE NewFooWithBar ( VAR foo: Foo; bar : INTEGER ); +BEGIN + NEW(foo); + foo^.bar := bar; + RETURN +END SetBar; + +(* functions *) +PROCEDURE bar ( foo : Foo ) : INTEGER; +BEGIN + IF foo = NIL THEN + HALT + ELSE + RETURN foo^.bar + END (* IF *) +END bar; + +(* disabled code *) +?< +WHILE foo = bar DO + baz(bam, boo) +END (* WHILE *); +>? + +(* synonyms *) +@ & ~ + +(* illegal characters *) +` ! $ % \ ? _ + +(* illegal identifiers *) + +_bar _bar_baz _bar_baz__bam _bar_baz__bam_boo + +bar_ bar_baz_ bar_baz__bam_ bar_baz__bam_boo_ + +__bar __bar_baz __bar_baz__bam __bar_baz__bam_boo + +bar__ bar_baz__ bar_baz__bam__ bar_baz__bam_boo__ + +bar__baz __bar_baz__ __bar__baz__ __ + + +END Foobar. diff --git a/runtime/syntax/testdir/input/modula2_pim.def b/runtime/syntax/testdir/input/modula2_pim.def new file mode 100644 index 0000000000..e008160d34 --- /dev/null +++ b/runtime/syntax/testdir/input/modula2_pim.def @@ -0,0 +1,111 @@ +(* Modula-2 PIM Test File for Vim Syntax Colouring *) + +(* -------------------------------------------------- + * THIS FILE IS LICENSED UNDER THE VIM LICENSE + * see https://github.com/vim/vim/blob/master/LICENSE + * -------------------------------------------------- *) + +DEFINITION MODULE Foobar; (*!m2pim*) + +FROM SYSTEM IMPORT WORD, ADDRESS; + +CONST MaxFoo = 1.0; LF = CHR(10); + +TYPE Foo = POINTER TO Bar; + +(* predefined constants *) +FALSE NIL TRUE + +(* predefined types *) +BITSET BOOLEAN CHAR PROC CARDINAL INTEGER LONGINT REAL LONGREAL + +(* predefined procedures *) +CAP DEC EXCL HALT INC INCL + +(* predefined functions *) +ABS CHR FLOAT HIGH MAX MIN ODD ORD SIZE TRUNC VAL + +(* predefined macros *) +NEW DISPOSE + +(* unsafe builtins *) +ADDRESS PROCESS WORD ADR TSIZE NEWPROCESS TRANSFER SYSTEM + +(* non-standard language extensions *) +BYTE LONGCARD LONGBITSET + +(* user defined identifiers *) +foobar Foobar FooBar foo123 foo_bar + +(* string literals *) +str := "foo 'bar' baz"; +str := 'foo "bar" baz'; + +(* numeric literals *) +0FFFH, 1.23, 1.23e-45, 1000 + +(* octal literals *) +n := 0377B; ch := 0377C; + +(* pragmas *) +(*$foo*) + +(* block comments with emphasis *) +(* copyright (c) Jurrasic Inc. + author Fred Flintstone Sr. + license see LICENSE file. *) + +(* pre-conditions: foo bar baz bam boo doodle wah. + post-conditions: foodle babble bozo bim bam dang. + error-conditions: dada jingle jungle boggle dee boo. *) + +(* technical debt markers *) +(* TODO: ... *) +(* FIXME *) +(* DEPRECATED *) + +(* procedures *) +PROCEDURE NewFooWithBar ( VAR foo: Foo; bar : INTEGER ); +BEGIN + NEW(foo); + foo^.bar := bar; + RETURN +END SetBar; + +(* functions *) +PROCEDURE bar ( foo : Foo ) : INTEGER; +BEGIN + IF foo = NIL THEN + HALT + ELSE + RETURN foo^.bar + END (* IF *) +END bar; + +(* disabled code *) +?< +WHILE foo = bar DO + baz(bam, boo) +END (* WHILE *); +>? + +(* synonyms *) +& ~ + +(* illegal characters *) +` ! @ $ % \ ? _ + +(* illegal identifiers *) + +_bar _bar_baz _bar_baz__bam _bar_baz__bam_boo + +bar_ bar_baz_ bar_baz__bam_ bar_baz__bam_boo_ + +__bar __bar_baz __bar_baz__bam __bar_baz__bam_boo + +bar__ bar_baz__ bar_baz__bam__ bar_baz__bam_boo__ + +bar__baz __bar_baz__ __bar__baz__ __ + + +END Foobar. diff --git a/runtime/syntax/testdir/input/modula2_r10.def b/runtime/syntax/testdir/input/modula2_r10.def new file mode 100644 index 0000000000..0872d5dfb9 --- /dev/null +++ b/runtime/syntax/testdir/input/modula2_r10.def @@ -0,0 +1,146 @@ +(* Modula-2 R10 Test File for Vim Syntax Colouring *) + +(* -------------------------------------------------- + * THIS FILE IS LICENSED UNDER THE VIM LICENSE + * see https://github.com/vim/vim/blob/master/LICENSE + * -------------------------------------------------- *) + +DEFINITION MODULE Foobar; (*!m2r10*) + +IMPORT UNSAFE ALIAS BYTE, WORD, ADDRESS; + +CONST MaxFoo = 1.0; + +TYPE Foo = ALIAS OF Bar; + +(* predefined constants *) +NIL FALSE TRUE + +(* predefined types *) +BOOLEAN CHAR UNICHAR OCTET CARDINAL LONGCARD INTEGER LONGINT REAL LONGREAL + +(* predefined procedures *) +APPEND INSERT REMOVE SORT SORTNEW + +(* predefined functions *) +CHR ORD ODD ABS SGN MIN MAX LOG2 POW2 ENTIER PRED SUCC PTR CAPACITY COUNT LENGTH + +(* predefined macros *) +NOP TMIN TMAX TSIZE TLIMIT + +(* unsafe builtins *) +UNSAFE + +(* unsafe builtin types *) +BYTE WORD LONGWORD ADDRESS OCTETSEQ + +(* unsafe builtin procedures *) +ADD SUB DEC INC SETBIT HALT + +(* unsafe builtin functions *) +ADR CAST BIT SHL SHR BWNOT BWAND BWOR + +(* non-portable language extensions *) +ASSEMBLER ASM REG + +(* user defined identifiers *) +foobar Foobar FooBar foo_bar foo0 + + +(* string literals *) +str := "foo 'bar' baz"; +str := 'foo "bar" baz'; + +(* numeric literals *) +0b0110'0011'0110'0000, 0u0A, 0x0123, 0xCAFE'D00D +1'000'000.00, 1.23, 1.23e+10, 1.234'567'890e-1'000 + + +(* language defined pragmas *) +<*MSG=INFO:"foobar"*> <*ENCODING="UTF8"*> <*INLINE*> <*NOINLINE*> <*FFI="C"*> + +(* implementation defined pragmas *) +<*GM2.Foobar|W=Bazbam*> + + +(* single line comment *) +! foo bar baz bam boo + +(* block comments with emphasis *) +(* copyright (c) 2016 Modula-2 Foundation. + authors B.Kowarsch and R.Sutcliffe + license see LICENSE *) + +(* pre-conditions: foo bar baz bam boo doodle wah. + post-conditions: foodle babble bozo bim bam dang. + error-conditions: dada jingle jungle boggle dee boo. *) + +(* (* *) *) + +(* bindings *) +PROCEDURE [+] sum ( a, b : BCD ) : BCD; + +PROCEDURE [MOD] modulus ( n, m : INT64 ) : INT64; + +PROCEDURE [RETAIN] Retain ( foo : Foo ); + +PROCEDURE [LENGTH] length ( str : String ) : LONGCARD; + + +(* procedures *) +PROCEDURE NewFooWithBar ( VAR foo: Foo; bar : INTEGER ); +BEGIN + NEW(foo); + foo^.bar := bar; + RETURN +END NewFooWithBar; + +END END; + +(* functions *) +PROCEDURE bar ( foo : Foo ) : INTEGER; +BEGIN + IF foo = NIL THEN + UNSAFE.HALT + ELSE + RETURN foo^.bar + END (* IF *) +END bar; + + +(* technical debt *) +TO DO ( 1234, Weight.Major ) (* foo *) + "redesign foo", 2d; + "replace foo", 2d; + "test new foo", 1d +END (* TO DO *); + +PROCEDURE SetBaba <*DEPRECATED*> ( n : CARDINAL ); + + +(* disabled code *) +?< +WHILE foo = bar DO + baz(bam, boo) +END (* WHILE *); +>? + + +(* illegal characters *) +` ~ $ % ? _ + +(* illegal identifiers *) + +_bar _bar_baz _bar_baz__bam _bar_baz__bam_boo + +bar_ bar_baz_ bar_baz__bam_ bar_baz__bam_boo_ + +__bar __bar_baz __bar_baz__bam __bar_baz__bam_boo + +bar__ bar_baz__ bar_baz__bam__ bar_baz__bam_boo__ + +bar__baz __bar_baz__ __bar__baz__ __ + + +(* module end *) +END Foobar. diff --git a/src/Makefile b/src/Makefile index 0d8f150f1d..59511d2b34 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2338,7 +2338,8 @@ installruntime: installrtbase installmacros installpack installtutor installspel # Also install most of the other runtime files. installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(VIMTARGET) $(DEST_RT) \ $(DEST_HELP) $(DEST_PRINT) $(DEST_COL) \ - $(DEST_SYN) $(DEST_SYN)/shared $(DEST_IND) $(DEST_FTP) \ + $(DEST_SYN) $(DEST_SYN)/modula2 $(DEST_SYN)/modula2/opt $(DEST_SYN)/shared \ + $(DEST_IND) $(DEST_FTP) \ $(DEST_AUTO) $(DEST_AUTO)/dist $(DEST_AUTO)/xml $(DEST_AUTO)/zig \ $(DEST_IMPORT) $(DEST_IMPORT)/dist \ $(DEST_PLUG) $(DEST_TUTOR) $(DEST_SPELL) $(DEST_COMP) @@ -2413,6 +2414,8 @@ installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(VIMTARGET) $(DEST_RT) \ cd $(DEST_SYN); chmod $(HELPMOD) *.vim README.txt cd $(SYNSOURCE)/shared; $(INSTALL_DATA) *.vim README.txt $(DEST_SYN)/shared cd $(DEST_SYN)/shared; chmod $(HELPMOD) *.vim README.txt + cd $(SYNSOURCE)/modula2/opt; $(INSTALL_DATA) *.vim $(DEST_SYN)/modula2/opt + cd $(DEST_SYN)/modula2/opt; chmod $(HELPMOD) *.vim # install the indent files cd $(INDSOURCE); $(INSTALL_DATA) *.vim README.txt $(DEST_IND) cd $(DEST_IND); chmod $(HELPMOD) *.vim README.txt @@ -2661,6 +2664,7 @@ $(HELPSOURCE)/vim.1 $(MACROSOURCE) $(TOOLSSOURCE): $(DESTDIR)$(exec_prefix) $(DEST_BIN) \ $(DEST_VIM) $(DEST_RT) $(DEST_HELP) \ $(DEST_PRINT) $(DEST_COL) $(DEST_SYN) $(DEST_SYN)/shared \ + $(DEST_SYN)/modula2 $(DEST_SYN)/modula2/opt \ $(DEST_IND) $(DEST_FTP) \ $(DEST_LANG) $(DEST_KMAP) $(DEST_COMP) $(DEST_MACRO) \ $(DEST_PACK) $(DEST_TOOLS) $(DEST_TUTOR) $(DEST_SPELL) \ @@ -2838,6 +2842,7 @@ uninstall_runtime: -rm -rf $(DEST_COL)/tools -rm -rf $(DEST_COL)/lists -rm -f $(DEST_SYN)/shared/*.vim $(DEST_SYN)/shared/README.txt + -rm -f $(DEST_SYN)/modula2/opt/*.vim -rm -f $(DEST_SYN)/*.vim $(DEST_SYN)/README.txt -rm -f $(DEST_IND)/*.vim $(DEST_IND)/README.txt -rm -rf $(DEST_MACRO) @@ -2850,6 +2855,7 @@ uninstall_runtime: -rm -rf $(DEST_COMP) -rm -f $(DEST_PRINT)/*.ps -rmdir $(DEST_HELP) $(DEST_PRINT) $(DEST_COL) $(DEST_SYN)/shared + -rmdir $(DEST_SYN)/modula2/opt $(DEST_SYN)/modula2 -rmdir $(DEST_SYN) $(DEST_IND) -rm -rf $(DEST_FTP)/*.vim $(DEST_FTP)/README.txt $(DEST_FTP)/logtalk.dict -rm -f $(DEST_AUTO)/*.vim $(DEST_AUTO)/README.txt diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index fe22069a53..6913eec57c 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -453,7 +453,6 @@ def s:GetFilenameChecks(): dict> mma: ['file.nb'], mmp: ['file.mmp'], modconf: ['/etc/modules.conf', '/etc/modules', '/etc/conf.modules', '/etc/modprobe.file', 'any/etc/conf.modules', 'any/etc/modprobe.file', 'any/etc/modules', 'any/etc/modules.conf'], - modula2: ['file.m2', 'file.mi'], modula3: ['file.m3', 'file.mg', 'file.i3', 'file.ig', 'file.lm3'], monk: ['file.isc', 'file.monk', 'file.ssc', 'file.tsc'], moo: ['file.moo'], @@ -1642,13 +1641,16 @@ func Test_mod_file() call writefile(['IMPLEMENTATION MODULE Module2Mod;'], 'modfile.MOD') split modfile.MOD call assert_equal('modula2', &filetype) + call assert_equal('pim', b:modula2.dialect) bwipe! " Modula-2 with comment and empty lines prior MODULE call writefile(['', '(* with', ' comment *)', '', 'MODULE Module2Mod;'], 'modfile.MOD') split modfile.MOD call assert_equal('modula2', &filetype) + call assert_equal('pim', b:modula2.dialect) bwipe! + call delete('modfile.MOD') " LambdaProlog module @@ -2376,4 +2378,38 @@ func Test_i_file() filetype off endfunc +func Test_def_file() + filetype on + + call writefile(['this is the fallback'], 'Xfile.def', 'D') + split Xfile.def + call assert_equal('def', &filetype) + bwipe! + + " Test dist#ft#FTdef() + + let g:filetype_def = 'modula2' + split Xfile.def + call assert_equal('modula2', &filetype) + call assert_equal('pim', b:modula2.dialect) + bwipe! + unlet g:filetype_def + + " Modula-2 + + call writefile(['(* a Modula-2 comment *)'], 'Xfile.def') + split Xfile.def + call assert_equal('modula2', &filetype) + call assert_equal('pim', b:modula2.dialect) + bwipe! + + call writefile(['IMPLEMENTATION MODULE Module2Mod;'], 'Xfile.def') + split Xfile.def + call assert_equal('modula2', &filetype) + call assert_equal('pim', b:modula2.dialect) + bwipe! + + filetype off +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 35865d696f..8f6446fd88 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 13, /**/ 12, /**/ From b1ed7ec9f7d1a0142d4f1c8c83bab9172bc92c7c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 5 Jan 2024 18:11:43 +0100 Subject: [PATCH 022/143] patch 9.1.0014: incorrect use of W_WINROW in edit.c Problem: incorrect use of W_WINROW in edit.c Solution: compare against curwin->w_height instead Remove incorrect use of W_WINROW In structs.h it is mentioned that w_wrow is relative to w_winrow, so using W_WINROW doesn't make sense when comparing with window height. This change won't lead to any observable behavior change: The condition intends to check if there are 'scrolloff' lines between the current cursor when the bottom of the window. When W_WINROW(curwin) is added to curwin->w_height - 1 - get_scrolloff_value(), the condition is instead satisfied when the cursor is on some screen line below that position. However, - If 'scrolloff' is smaller than half the window height, this condition can only be satisfied when W_WINROW(curwin) == 0. And if it is not satisfied, update_topline() does the actual scrolling. - If 'scrolloff' is larger than half the window height, update_topline() will put the cursor at the center of the window soon afterwards anyway, because set_topline() now unsets VALID_TOPLINE flag starting from https://github.com/vim/vim-history/commit/7db7bb45b0f919ff0615d463ebd4fde881c69d1f. To put it in another way, https://github.com/vim/vim-history/commit/7db7bb45b0f919ff0615d463ebd4fde881c69d1f makes the update_topline() just below correct the mistakes made in this block, so this incorrect use of W_WINROW() no longer affects observable behavior. closes: #12331 Signed-off-by: zeertzjq Signed-off-by: Christian Brabandt --- src/edit.c | 4 ++-- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/edit.c b/src/edit.c index f89d43eec6..cb6ae7ee9b 100644 --- a/src/edit.c +++ b/src/edit.c @@ -525,8 +525,8 @@ edit( #else (int)curwin->w_wcol < mincol - curbuf->b_p_ts #endif - && curwin->w_wrow == W_WINROW(curwin) - + curwin->w_height - 1 - get_scrolloff_value() + && curwin->w_wrow == + curwin->w_height - 1 - get_scrolloff_value() && (curwin->w_cursor.lnum != curwin->w_topline #ifdef FEAT_DIFF || curwin->w_topfill > 0 diff --git a/src/version.c b/src/version.c index 8f6446fd88..a6dae87b5b 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 14, /**/ 13, /**/ From 5d5cbb2b9ac526fb6fad2116e24a282affc45efe Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Fri, 5 Jan 2024 18:19:52 +0100 Subject: [PATCH 023/143] patch 9.1.0015: i_CTRL-R- no longer works in replace mode Problem: i_CTRL-R- no longer works in replace mode Solution: delete characters in replace mode before putting, add a test, add a bit warning into the documentation, that i_CTRL-R-P/O is not supported in Replace mode for now fixes: #13792 closes: #13816 Signed-off-by: Christian Brabandt --- runtime/doc/insert.txt | 6 +++--- src/register.c | 15 ++++++++++++++- src/testdir/test_normal.vim | 2 +- src/testdir/test_registers.vim | 20 ++++++++++++++++++++ src/version.c | 2 ++ 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index de8866fc64..6ebd83e3e7 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -1,4 +1,4 @@ -*insert.txt* For Vim version 9.1. Last change: 2022 Sep 30 +*insert.txt* For Vim version 9.1. Last change: 2024 Jan 04 VIM REFERENCE MANUAL by Bram Moolenaar @@ -168,22 +168,22 @@ CTRL-R CTRL-O {register} *i_CTRL-R_CTRL-O* auto-indent. Does the same as pasting with the mouse ||. When the register is linewise this will insert the text above the current line, like with `P`. - Does not replace characters! The '.' register (last inserted text) is still inserted as typed. After this command, the '.' register contains the command typed and not the text. I.e., the literals "^R^O" and not the text from the register. + Does not replace characters in |Replace-mode|! CTRL-R CTRL-P {register} *i_CTRL-R_CTRL-P* Insert the contents of a register literally and fix the indent, like |[|. - Does not replace characters! The '.' register (last inserted text) is still inserted as typed. After this command, the '.' register contains the command typed and not the text. I.e., the literals "^R^P" and not the text from the register. + Does not replace characters in |Replace-mode|! *i_CTRL-T* CTRL-T Insert one shiftwidth of indent at the start of the current diff --git a/src/register.c b/src/register.c index 1d0e46bd0b..f381e303be 100644 --- a/src/register.c +++ b/src/register.c @@ -828,9 +828,22 @@ insert_reg( { if (regname == '-') { + int dir = BACKWARD; + if ((State & REPLACE_FLAG) != 0) + { + pos_T curpos; + u_save_cursor(); + del_bytes((long)STRLEN(y_current->y_array[0]), TRUE, FALSE); + curpos = curwin->w_cursor; + if (oneright() == FAIL) + // hit end of line, need to put forward (after the current position) + dir = FORWARD; + curwin->w_cursor = curpos; + } + AppendCharToRedobuff(Ctrl_R); AppendCharToRedobuff(regname); - do_put(regname, NULL, BACKWARD, 1L, PUT_CURSEND); + do_put(regname, NULL, dir, 1L, PUT_CURSEND); } else stuffescaped(y_current->y_array[i], literally); diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index 90bedf1800..38ad8107b4 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -4181,4 +4181,4 @@ func Test_brace_single_line() bw! endfunc -" vim: shiftwidth=2 sts=2 expandtab +" vim: shiftwidth=2 sts=2 expandtab nofoldenable diff --git a/src/testdir/test_registers.vim b/src/testdir/test_registers.vim index f85e72735a..50f39107b4 100644 --- a/src/testdir/test_registers.vim +++ b/src/testdir/test_registers.vim @@ -946,4 +946,24 @@ func Test_register_y_append_reset() bwipe! endfunc +func Test_insert_small_delete_replace_mode() + new + call setline(1, ['foo', 'bar', 'foobar', 'bar']) + let @-='foo' + call cursor(2, 1) + exe ":norm! R\-\-" + call assert_equal('foofoo', getline(2)) + call cursor(3, 1) + norm! D + call assert_equal(['foo', 'foofoo', '', 'bar'], getline(1, 4)) + call cursor(4, 2) + exe ":norm! R\-ZZZZ" + call assert_equal(['foo', 'foofoo', '', 'bfoobarZZZZ'], getline(1, 4)) + call cursor(1, 1) + let @-='' + exe ":norm! R\-ZZZ" + call assert_equal(['ZZZ', 'foofoo', '', 'bfoobarZZZZ'], getline(1, 4)) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index a6dae87b5b..9a4106de49 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 15, /**/ 14, /**/ From b21499537fb9fd0ff407e6113ac60ebd82058e2a Mon Sep 17 00:00:00 2001 From: Aliaksei Budavei <32549825+zzzyxwvut@users.noreply.github.com> Date: Sun, 7 Jan 2024 17:52:10 +0300 Subject: [PATCH 024/143] runtime(doc): Improve the documentation for Vim9 classes (#13828) * Emend textual typos * Emend syntactic errors in examples * Acknowledge no support for abstract static methods * Acknowledge the non-ubiquity of instance qualification "This" was never allowed in method declarations, e.g.: class A def this.M() enddef endclass and, since patch 9.0.2167, "this" can no longer be used in field declarations, e.g.: class B var this.f: string endclass * Recognise abstract child classes * Reword an ambiguous turn of phrase Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com> Signed-off-by: Ernie Rael Signed-off-by: Yegappan Lakshmanan Signed-off-by: Christian Brabandt --- runtime/doc/vim9class.txt | 43 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/runtime/doc/vim9class.txt b/runtime/doc/vim9class.txt index ca9daffac5..6e94e84832 100644 --- a/runtime/doc/vim9class.txt +++ b/runtime/doc/vim9class.txt @@ -1,4 +1,4 @@ -*vim9class.txt* For Vim version 9.1. Last change: 2024 Jan 01 +*vim9class.txt* For Vim version 9.1. Last change: 2024 Jan 06 VIM REFERENCE MANUAL by Bram Moolenaar @@ -106,17 +106,17 @@ The object variables "lnum" and "col" can be accessed directly: > echo $'The text position is ({pos.lnum}, {pos.col})' < *E1317* *E1327* *:this* If you have been using other object-oriented languages you will notice that in -Vim, within a class definition, the object members are consistently referred -to with the "this." prefix. This is different from languages like Java and -TypeScript. The naming convention makes the object members easy to spot. -Also, when a variable does not have the "this." prefix you know it is not an -object variable. +Vim, within a class definition, the declared object members are consistently +referred to with the "this." prefix. This is different from languages like +Java and TypeScript. The naming convention makes the object members easy to +spot. Also, when a variable does not have the "this." prefix you know it is +not an object variable. *E1411* From outside the class definition, access an object's methods and variables by using the object name followed by a dot following by the member: > pos.lnum - pos.setCol(10) + pos.SetCol(10) < *E1405* *E1406* A class name cannot be used as an expression. A class name cannot be used in @@ -164,7 +164,7 @@ from outside the class or its sub-classes, you can make them protected. This is done by prefixing an underscore to the name: > var _lnum: number - var _col number + var _col: number Now you need to provide methods to get the value of the protected variables. These are commonly called getters. We recommend using a name that starts with @@ -174,7 +174,7 @@ These are commonly called getters. We recommend using a name that starts with return this._lnum enddef - def GetCol() number + def GetCol(): number return this._col enddef @@ -330,7 +330,8 @@ variables but they have no access to the object variables, they cannot use the Inside the class the class method can be called by name directly, outside the class the class name must be prefixed: `OtherThing.ClearTotalSize()`. To use -a super class method in a child class, the class name must be prefixed. +a class method from a parent class in a child class, the class name must be +prefixed. Just like object methods the access can be made protected by using an underscore as the first character in the method name: > @@ -492,17 +493,15 @@ prefix when defining the method: > abstract class Shape abstract def Draw() - abstract static def SetColor() endclass < A static method in an abstract class cannot be an abstract method. *E1373* -A class extending the abstract class must implement all the abstract methods. -The signature (arguments, argument types and return type) must be exactly the -same. If the return type of a method is a class, then that class or one of -its subclasses can be used in the extended method. Class methods in an -abstract class can also be abstract methods. +A non-abstract class extending the abstract class must implement all the +abstract methods. The signature (arguments, argument types and return type) +must be exactly the same. If the return type of a method is a class, then +that class or one of its subclasses can be used in the extended method. ============================================================================== @@ -610,7 +609,7 @@ once. They can appear in any order, although this order is recommended: > < *E1355* *E1369* Each variable and method name can be used only once. It is not possible to define a method with the same name and different type of arguments. It is not -possible to use a public and protected member variable with the same name. A +possible to use a public and protected member variable with the same name. An object variable name used in a super class cannot be reused in a child class. @@ -688,7 +687,7 @@ Inside a class, in between `:class` and `:endclass`, these items can appear: - A class variable declaration: > static var _protectedClassVariableName: memberType static var readonlyClassVariableName: memberType - static var public readwriteClassVariableName: memberType + public static var readwriteClassVariableName: memberType - A constructor method: > def new(arguments) def newName(arguments) @@ -747,7 +746,7 @@ null object ~ When a variable is declared to have the type of an object, but it is not initialized, the value is null. When trying to use this null object Vim often does not know what class was supposed to be used. Vim then cannot check if -a variable name is correct and you will get an "Using a null object" error, +a variable name is correct and you will get a "Using a null object" error, even when the variable name is invalid. *E1360* *E1362* @@ -787,7 +786,7 @@ the name, you can define the constructor like this: > < When using the default new() method, if the order of the object variables in the class is changed later, then all the callers of the default new() method -needs to change. To avoid this, the new() method can be explicitly defined +need to change. To avoid this, the new() method can be explicitly defined without any arguments. *E1328* @@ -993,7 +992,7 @@ in the body, while for other variables this is not needed and often omitted. This leads to a mix of variables with and without "this.", which is inconsistent. -For |Vim9| classes the "this." prefix is always used. Also for declaring the +For |Vim9| classes the "this." prefix is always used for declared methods and variables. Simple and consistent. When looking at the code inside a class it's also directly clear which variable references are object variables and which aren't. @@ -1029,7 +1028,7 @@ Following that Vim object variables could be declared like this: > endclass Some users pointed out that this looks more like an assignment than a -declaration. Adding "var" changes that: > +declaration. Adding "var" and omitting "this." changes that: > class Point var x: number var y = 0 From 124371c5a149a8c0c75c04b6c90ac11e71a0aa97 Mon Sep 17 00:00:00 2001 From: Romain Lafourcade Date: Sun, 7 Jan 2024 15:08:31 +0100 Subject: [PATCH 025/143] patch 9.1.0016: default diff highlighting is too noisy Problem: default diff highlighting is too noisy Solution: Link diff highlighting groups to new Added/Removed/Changed, revert previous change (Romain Lafourcade) Remove diff* links added in #13776 and doc added in commit b1392be The links added in #13776 are way too noisy for the contexts in which the `diff` syntax is applied (git commits, patches, etc.). This commit: - removes those links - adds new default highlighting groups Added, Changed and Removed - links the diff highlighting groups to those new defaults - removes the doc changes - adjusts the syntax_completion test for those newly added group names Note: Changes to the default color schemes will be handled separately, by adding links to those newly created Added/Removed/Changed highlighting groups. related: #13776 closes #13825 Signed-off-by: Romain Lafourcade Signed-off-by: Christian Brabandt --- runtime/doc/syntax.txt | 17 ++++++----------- runtime/doc/tags | 1 - runtime/syntax/diff.vim | 6 +++--- runtime/syntax/help.vim | 7 +++++++ runtime/syntax/syncolor.vim | 6 ++++++ src/testdir/test_syntax.vim | 6 +++--- src/version.c | 2 ++ 7 files changed, 27 insertions(+), 18 deletions(-) diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index cc293a5979..6715f655ba 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 9.1. Last change: 2024 Jan 03 +*syntax.txt* For Vim version 9.1. Last change: 2024 Jan 06 VIM REFERENCE MANUAL by Bram Moolenaar @@ -271,6 +271,10 @@ you can see the actual color, except for "Ignore"): *Todo anything that needs extra attention; mostly the keywords TODO FIXME and XXX + *Added added line in a diff + *Changed changed line in a diff + *Removed removed line in a diff + The names marked with * are the preferred groups; the others are minor groups. For the preferred groups, the "syntax.vim" file contains default highlighting. The minor groups are linked to the preferred groups, so they get the same @@ -1261,7 +1265,7 @@ To highlight KDE-reserved features, set > g:desktop_enable_kde follows g:desktop_enable_nonstd if not supplied -DIFF *diff.vim* *ft-diff-syntax* +DIFF *diff.vim* The diff highlighting normally finds translated headers. This can be slow if there are very long lines in the file. To disable translations: > @@ -1270,15 +1274,6 @@ there are very long lines in the file. To disable translations: > Also see |diff-slow|. -Since the Vim 9.1 release |version-9.1| the diff filetype links the diffAdded, -diffRemoved and diffChanged highlighting groups to |hl-DiffAdd|, -|hl-DiffDelete| and |hl-DiffChange| by default. If you do not want this, you -can change it to the previous groups like this in your |.vimrc| > - - hi link diffRemoved Special - hi link diffChanged PreProc - hi link diffAdded Identifier -< DIRCOLORS *dircolors.vim* *ft-dircolors-syntax* The dircolors utility highlighting definition has one option. It exists to diff --git a/runtime/doc/tags b/runtime/doc/tags index 5b9e5a9b64..1b55fa1943 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -7207,7 +7207,6 @@ ft-cynlib-syntax syntax.txt /*ft-cynlib-syntax* ft-dart-syntax syntax.txt /*ft-dart-syntax* ft-dash-syntax syntax.txt /*ft-dash-syntax* ft-desktop-syntax syntax.txt /*ft-desktop-syntax* -ft-diff-syntax syntax.txt /*ft-diff-syntax* ft-dircolors-syntax syntax.txt /*ft-dircolors-syntax* ft-docbk-syntax syntax.txt /*ft-docbk-syntax* ft-docbksgml-syntax syntax.txt /*ft-docbksgml-syntax* diff --git a/runtime/syntax/diff.vim b/runtime/syntax/diff.vim index b5c3f5ecbb..b0a8594def 100644 --- a/runtime/syntax/diff.vim +++ b/runtime/syntax/diff.vim @@ -378,9 +378,9 @@ hi def link diffBDiffer Constant hi def link diffIsA Constant hi def link diffNoEOL Constant hi def link diffCommon Constant -hi def link diffRemoved DiffDelete -hi def link diffChanged DiffChange -hi def link diffAdded DiffAdd +hi def link diffRemoved Removed +hi def link diffChanged Changed +hi def link diffAdded Added hi def link diffLine Statement hi def link diffSubname PreProc hi def link diffComment Comment diff --git a/runtime/syntax/help.vim b/runtime/syntax/help.vim index b734c2c4b0..2024d38398 100644 --- a/runtime/syntax/help.vim +++ b/runtime/syntax/help.vim @@ -141,6 +141,10 @@ syn match helpTodo "\t[* ]Todo\t\+[a-z].*" syn match helpURL `\v<(((https?|ftp|gopher)://|(mailto|file|news):)[^' <>"]+|(www|web|w3)[a-z0-9_-]*\.[a-z0-9._-]+\.[^' <>"]+)[a-zA-Z0-9/]` +syn match helpDiffAdded "\t[* ]Added\t\+[a-z].*" +syn match helpDiffChanged "\t[* ]Changed\t\+[a-z].*" +syn match helpDiffRemoved "\t[* ]Removed\t\+[a-z].*" + " Additionally load a language-specific syntax file "help_ab.vim". let s:i = match(expand("%"), '\.\a\ax$') if s:i > 0 @@ -216,6 +220,9 @@ hi def link helpUnderlined Underlined hi def link helpError Error hi def link helpTodo Todo hi def link helpURL String +hi def link helpDiffAdded Added +hi def link helpDiffChanged Changed +hi def link helpDiffRemoved Removed if has('textprop') && expand('%:p') =~ '[/\\]doc[/\\]syntax.txt' " highlight groups with their respective color diff --git a/runtime/syntax/syncolor.vim b/runtime/syntax/syncolor.vim index 6cf38cfa5d..52b3a0b60d 100644 --- a/runtime/syntax/syncolor.vim +++ b/runtime/syntax/syncolor.vim @@ -41,6 +41,9 @@ if &background == "dark" SynColor Type term=underline cterm=NONE ctermfg=LightGreen ctermbg=NONE gui=bold guifg=#60ff60 guibg=NONE SynColor Underlined term=underline cterm=underline ctermfg=LightBlue gui=underline guifg=#80a0ff SynColor Ignore term=NONE cterm=NONE ctermfg=black ctermbg=NONE gui=NONE guifg=bg guibg=NONE + SynColor Added term=NONE cterm=NONE ctermfg=Green ctermbg=NONE gui=NONE guifg=LimeGreen guibg=NONE + SynColor Changed term=NONE cterm=NONE ctermfg=Blue ctermbg=NONE gui=NONE guifg=DodgerBlue guibg=NONE + SynColor Removed term=NONE cterm=NONE ctermfg=Red ctermbg=NONE gui=NONE guifg=Red guibg=NONE else SynColor Comment term=bold cterm=NONE ctermfg=DarkBlue ctermbg=NONE gui=NONE guifg=Blue guibg=NONE SynColor Constant term=underline cterm=NONE ctermfg=DarkRed ctermbg=NONE gui=NONE guifg=Magenta guibg=NONE @@ -53,6 +56,9 @@ else SynColor Type term=underline cterm=NONE ctermfg=DarkGreen ctermbg=NONE gui=bold guifg=SeaGreen guibg=NONE SynColor Underlined term=underline cterm=underline ctermfg=DarkMagenta gui=underline guifg=SlateBlue SynColor Ignore term=NONE cterm=NONE ctermfg=white ctermbg=NONE gui=NONE guifg=bg guibg=NONE + SynColor Added term=NONE cterm=NONE ctermfg=DarkGreen ctermbg=NONE gui=NONE guifg=SeaGreen guibg=NONE + SynColor Changed term=NONE cterm=NONE ctermfg=Blue ctermbg=NONE gui=NONE guifg=DodgerBlue guibg=NONE + SynColor Removed term=NONE cterm=NONE ctermfg=Red ctermbg=NONE gui=NONE guifg=Red guibg=NONE endif SynColor Error term=reverse cterm=NONE ctermfg=White ctermbg=Red gui=NONE guifg=White guibg=Red SynColor Todo term=standout cterm=NONE ctermfg=Black ctermbg=Yellow gui=NONE guifg=Blue guibg=Yellow diff --git a/src/testdir/test_syntax.vim b/src/testdir/test_syntax.vim index 8c56730daf..aeb2c51c58 100644 --- a/src/testdir/test_syntax.vim +++ b/src/testdir/test_syntax.vim @@ -193,14 +193,14 @@ func Test_syntax_completion() " Check that clearing "Aap" avoids it showing up before Boolean. hi Aap ctermfg=blue call feedkeys(":syn list \\\"\", 'tx') - call assert_match('^"syn list Aap Boolean Character ', @:) + call assert_match('^"syn list Aap Added Boolean Changed Character ', @:) hi clear Aap call feedkeys(":syn list \\\"\", 'tx') - call assert_match('^"syn list Boolean Character ', @:) + call assert_match('^"syn list Added Boolean Changed Character ', @:) call feedkeys(":syn match \\\"\", 'tx') - call assert_match('^"syn match Boolean Character ', @:) + call assert_match('^"syn match Added Boolean Changed Character ', @:) syn cluster Aax contains=Aap call feedkeys(":syn list @A\\\"\", 'tx') diff --git a/src/version.c b/src/version.c index 9a4106de49..2e178f3bb3 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 16, /**/ 15, /**/ From ceed36873e922df9acfeabf65184fcf2b5ab1cb3 Mon Sep 17 00:00:00 2001 From: Maxim Kim Date: Tue, 9 Jan 2024 05:42:02 +1100 Subject: [PATCH 026/143] runtime(vim): accept dot in completionList for Vim9 syntax (#13832) if you have autoloaded command complete function in vim9script, it shouldn't be highlighted as Error: ``` import autoload "share.vim" command! -range=% -nargs=? -complete=custom,share.Complete Share share.Paste(, , ) ``` `share.Complete` is a valid complete function. Signed-off-by: Maxim Kim Signed-off-by: Christian Brabandt --- runtime/syntax/vim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index edfef438c3..165a809596 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -316,7 +316,7 @@ syn case ignore syn keyword vimUserAttrbKey contained bar ban[g] cou[nt] ra[nge] com[plete] n[args] re[gister] syn keyword vimUserAttrbCmplt contained augroup buffer behave color command compiler cscope dir environment event expression file file_in_path filetype function help highlight history locale mapping menu option packadd shellcmd sign syntax syntime tag tag_listfiles user var syn keyword vimUserAttrbCmplt contained custom customlist nextgroup=vimUserAttrbCmpltFunc,vimUserCmdError -syn match vimUserAttrbCmpltFunc contained ",\%([sS]:\|<[sS][iI][dD]>\)\=\%(\h\w*\%(#\h\w*\)\+\|\h\w*\)"hs=s+1 nextgroup=vimUserCmdError +syn match vimUserAttrbCmpltFunc contained ",\%([sS]:\|<[sS][iI][dD]>\)\=\%(\h\w*\%([.#]\h\w*\)\+\|\h\w*\)"hs=s+1 nextgroup=vimUserCmdError syn case match syn match vimUserAttrbCmplt contained "custom,\u\w*" From 3a5b3df7764daa058a3e779183e8f38a8418b164 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Mon, 8 Jan 2024 20:02:14 +0100 Subject: [PATCH 027/143] runtime(tar): fix a few problems with the tar plugin From: #138331: - Updating .tar.zst files was broken. Fixes #12639. - Extracting files from .tar.zst / .tzs files was also broken and works now. From: #12637: - Fixes variable assignment and typo From: #8109: - Rename .tzs to the more standard .tzst fixes: #12639 fixes: #8105 closes: #8109 closes: #12637 closes: #13831 Co-authored-by: Martin Rys Co-authored-by: Eisuke Kawashima Co-authored-by: Carlo Teubner Signed-off-by: Christian Brabandt --- runtime/autoload/tar.vim | 36 ++++++++++++++++++------------------ runtime/plugin/tarPlugin.vim | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim index adfc10c92b..3c4c9ccfb2 100644 --- a/runtime/autoload/tar.vim +++ b/runtime/autoload/tar.vim @@ -163,9 +163,9 @@ fun! tar#Browse(tarfile) " call Decho("1: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ") exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " - elseif tarfile =~# '\.\(tgz\)$' || tarfile =~# '\.\(tbz\)$' || tarfile =~# '\.\(txz\)$' || tarfile =~# '\.\(tzs\)$' + elseif tarfile =~# '\.\(tgz\)$' || tarfile =~# '\.\(tbz\)$' || tarfile =~# '\.\(txz\)$' || tarfile =~# '\.\(tzst\)$' if has("unix") && executable("file") - let filekind= system("file ".shellescape(tarfile,1)) =~ "bzip2" + let filekind= system("file ".shellescape(tarfile,1)) else let filekind= "" endif @@ -192,7 +192,7 @@ fun! tar#Browse(tarfile) elseif tarfile =~# '\.\(xz\|txz\)$' " call Decho("3: exe silent r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ") exe "sil! r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " - elseif tarfile =~# '\.\(zst\|tzs\)$' + elseif tarfile =~# '\.\(zst\|tzst\)$' exe "sil! r! zstd --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " else if tarfile =~ '^\s*-' @@ -230,7 +230,7 @@ fun! tar#Browse(tarfile) " set up maps supported for tar setlocal noma nomod ro noremap :call TarBrowseSelect() - noremap x :call tar#Extract() + noremap x :call tar#Extract() if &mouse != "" noremap :call TarBrowseSelect() endif @@ -468,9 +468,9 @@ fun! tar#Write(fname) let compress= "xz -- ".shellescape(tarfile,0) " call Decho("compress<".compress.">") elseif tarfile =~# '\.zst' - call system("zstd --decompress -- ".shellescape(tarfile,0)) + call system("zstd --decompress --rm -- ".shellescape(tarfile,0)) let tarfile = substitute(tarfile,'\.zst','','e') - let compress= "zstd -- ".shellescape(tarfile,0) + let compress= "zstd --rm -- ".shellescape(tarfile,0) elseif tarfile =~# '\.lzma' call system("lzma -d -- ".shellescape(tarfile,0)) let tarfile = substitute(tarfile,'\.lzma','','e') @@ -486,7 +486,7 @@ fun! tar#Write(fname) else " call Decho("tarfile<".tarfile."> fname<".fname.">") - + if fname =~ '/' let dirpath = substitute(fname,'/[^/]\+$','','e') if has("win32unix") && executable("cygpath") @@ -502,7 +502,7 @@ fun! tar#Write(fname) let tarfile = substitute(tarfile, '-', './-', '') endif " call Decho("tarfile<".tarfile."> fname<".fname.">") - + if exists("g:tar_secure") let tar_secure= " -- " else @@ -512,7 +512,7 @@ fun! tar#Write(fname) if has("win32unix") && executable("cygpath") let tarfile = substitute(system("cygpath ".shellescape(tarfile,0)),'\n','','e') endif - + " delete old file from tarfile " call Decho("system(".g:tar_cmd." ".g:tar_delfile." ".shellescape(tarfile,0)." -- ".shellescape(fname,0).")") call system(g:tar_cmd." ".g:tar_delfile." ".shellescape(tarfile,0).tar_secure.shellescape(fname,0)) @@ -521,8 +521,8 @@ fun! tar#Write(fname) " call Decho("***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname)) echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None else - - " update tarfile with new file + + " update tarfile with new file " call Decho(g:tar_cmd." -".g:tar_writeoptions." ".shellescape(tarfile,0).tar_secure.shellescape(fname,0)) call system(g:tar_cmd." -".g:tar_writeoptions." ".shellescape(tarfile,0).tar_secure.shellescape(fname,0)) if v:shell_error != 0 @@ -555,7 +555,7 @@ fun! tar#Write(fname) unlet s:tblfile_{winnr()} endif endif - + " cleanup and restore current directory cd .. call s:Rmdir("_ZIPVIM_") @@ -696,13 +696,13 @@ fun! tar#Extract() echo "***note*** successfully extracted ".fname endif - elseif filereadable(tarbase.".tzs") + elseif filereadable(tarbase.".tzst") let extractcmd= substitute(extractcmd,"-","--zstd","") -" call Decho("system(".extractcmd." ".shellescape(tarbase).".tzs ".shellescape(fname).")") - call system(extractcmd." ".shellescape(tarbase).".txz ".shellescape(fname)) +" call Decho("system(".extractcmd." ".shellescape(tarbase).".tzst ".shellescape(fname).")") + call system(extractcmd." ".shellescape(tarbase).".tzst ".shellescape(fname)) if v:shell_error != 0 - echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tzs ".fname.": failed!" | echohl NONE -" call Decho("***error*** ".extractcmd." ".tarbase.".tzs ".fname.": failed!") + echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tzst ".fname.": failed!" | echohl NONE +" call Decho("***error*** ".extractcmd." ".tarbase.".tzst ".fname.": failed!") else echo "***note*** successfully extracted ".fname endif @@ -710,7 +710,7 @@ fun! tar#Extract() elseif filereadable(tarbase.".tar.zst") let extractcmd= substitute(extractcmd,"-","--zstd","") " call Decho("system(".extractcmd." ".shellescape(tarbase).".tar.zst ".shellescape(fname).")") - call system(extractcmd." ".shellescape(tarbase).".tar.xz ".shellescape(fname)) + call system(extractcmd." ".shellescape(tarbase).".tar.zst ".shellescape(fname)) if v:shell_error != 0 echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tar.zst ".fname.": failed!" | echohl NONE " call Decho("***error*** ".extractcmd." ".tarbase.".tar.zst ".fname.": failed!") diff --git a/runtime/plugin/tarPlugin.vim b/runtime/plugin/tarPlugin.vim index d55492a93e..40d2242514 100644 --- a/runtime/plugin/tarPlugin.vim +++ b/runtime/plugin/tarPlugin.vim @@ -45,7 +45,7 @@ augroup tar au BufReadCmd *.tar.xz call tar#Browse(expand("")) au BufReadCmd *.txz call tar#Browse(expand("")) au BufReadCmd *.tar.zst call tar#Browse(expand("")) - au BufReadCmd *.tzs call tar#Browse(expand("")) + au BufReadCmd *.tzst call tar#Browse(expand("")) augroup END com! -nargs=? -complete=file Vimuntar call tar#Vimuntar() From 5f4cc8ea65e80efa35f84fe9a9985a42c3c96bae Mon Sep 17 00:00:00 2001 From: Maxim Kim Date: Tue, 9 Jan 2024 06:14:04 +1100 Subject: [PATCH 028/143] runtime(colorschemes): Add initial support for Added/Removed/Changed highlight groups (#13830) For some of the colorschemes where diffAdded and diffRemoved were explicitly set up. Signed-off-by: Maxim Kim Signed-off-by: Christian Brabandt --- runtime/colors/blue.vim | 18 ++++----- runtime/colors/darkblue.vim | 10 ++--- runtime/colors/evening.vim | 14 +++---- runtime/colors/habamax.vim | 22 ++++++----- runtime/colors/lunaperche.vim | 32 +++++++++------- runtime/colors/murphy.vim | 4 +- runtime/colors/wildcharm.vim | 70 +++++++++++++++++++---------------- 7 files changed, 94 insertions(+), 76 deletions(-) diff --git a/runtime/colors/blue.vim b/runtime/colors/blue.vim index c53f44f9d3..f95cf272aa 100644 --- a/runtime/colors/blue.vim +++ b/runtime/colors/blue.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer Steven Vertigan " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Fri 15 Dec 2023 20:05:33 +" Last Updated: Mon 08 Jan 2024 09:42:49 AM AEDT " Generated by Colortemplate v2.2.3 @@ -76,8 +76,8 @@ hi Underlined guifg=NONE guibg=NONE gui=underline ctermfg=NONE ctermbg=NONE cter hi Label guifg=#ffd700 guibg=NONE gui=NONE cterm=NONE hi! link Terminal Normal hi! link Debug Special -hi! link diffAdded String -hi! link diffRemoved WarningMsg +hi! link Added String +hi! link Removed WarningMsg hi! link diffOnly WarningMsg hi! link diffNoEOL WarningMsg hi! link diffIsA WarningMsg @@ -186,8 +186,8 @@ if s:t_Co >= 256 hi Label ctermfg=220 ctermbg=NONE cterm=NONE hi! link Terminal Normal hi! link Debug Special - hi! link diffAdded String - hi! link diffRemoved WarningMsg + hi! link Added String + hi! link Removed WarningMsg hi! link diffOnly WarningMsg hi! link diffNoEOL WarningMsg hi! link diffIsA WarningMsg @@ -299,8 +299,8 @@ if s:t_Co >= 16 hi Label ctermfg=yellow ctermbg=NONE cterm=NONE hi! link Terminal Normal hi! link Debug Special - hi! link diffAdded String - hi! link diffRemoved WarningMsg + hi! link Added String + hi! link Removed WarningMsg hi! link diffOnly WarningMsg hi! link diffNoEOL WarningMsg hi! link diffIsA WarningMsg @@ -411,8 +411,8 @@ if s:t_Co >= 8 hi Label ctermfg=yellow ctermbg=NONE cterm=NONE hi! link Terminal Normal hi! link Debug Special - hi! link diffAdded String - hi! link diffRemoved WarningMsg + hi! link Added String + hi! link Removed WarningMsg hi! link diffOnly WarningMsg hi! link diffNoEOL WarningMsg hi! link diffIsA WarningMsg diff --git a/runtime/colors/darkblue.vim b/runtime/colors/darkblue.vim index 207d1ea58f..b792b90fb2 100644 --- a/runtime/colors/darkblue.vim +++ b/runtime/colors/darkblue.vim @@ -4,7 +4,7 @@ " Maintainer: Original author Bohdan Vlasyuk " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Fri 15 Dec 2023 20:05:33 +" Last Updated: Mon 08 Jan 2024 09:43:03 AM AEDT " Generated by Colortemplate v2.2.3 @@ -54,8 +54,8 @@ hi! link Structure Type hi! link Tag Special hi! link Typedef Type hi! link Debug Special -hi! link diffAdded String -hi! link diffRemoved WarningMsg +hi! link Added String +hi! link Removed WarningMsg hi! link diffOnly WarningMsg hi! link diffNoEOL WarningMsg hi! link diffIsA WarningMsg @@ -162,8 +162,8 @@ if s:t_Co >= 256 hi! link Tag Special hi! link Typedef Type hi! link Debug Special - hi! link diffAdded String - hi! link diffRemoved WarningMsg + hi! link Added String + hi! link Removed WarningMsg hi! link diffOnly WarningMsg hi! link diffNoEOL WarningMsg hi! link diffIsA WarningMsg diff --git a/runtime/colors/evening.vim b/runtime/colors/evening.vim index 3ac3242dd1..2753daa440 100644 --- a/runtime/colors/evening.vim +++ b/runtime/colors/evening.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer Steven Vertigan " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Fri 15 Dec 2023 20:05:35 +" Last Updated: Mon 08 Jan 2024 09:43:27 AM AEDT " Generated by Colortemplate v2.2.3 @@ -28,8 +28,8 @@ hi! link CursorIM Cursor hi! link LineNrAbove LineNr hi! link LineNrBelow LineNr hi! link Debug Special -hi! link diffAdded String -hi! link diffRemoved WarningMsg +hi! link Added String +hi! link Removed WarningMsg hi! link diffOnly WarningMsg hi! link diffNoEOL WarningMsg hi! link diffIsA WarningMsg @@ -136,8 +136,8 @@ if s:t_Co >= 256 hi! link LineNrAbove LineNr hi! link LineNrBelow LineNr hi! link Debug Special - hi! link diffAdded String - hi! link diffRemoved WarningMsg + hi! link Added String + hi! link Removed WarningMsg hi! link diffOnly WarningMsg hi! link diffNoEOL WarningMsg hi! link diffIsA WarningMsg @@ -247,8 +247,8 @@ if s:t_Co >= 16 hi! link LineNrAbove LineNr hi! link LineNrBelow LineNr hi! link Debug Special - hi! link diffAdded String - hi! link diffRemoved WarningMsg + hi! link Added String + hi! link Removed WarningMsg hi! link diffOnly WarningMsg hi! link diffNoEOL WarningMsg hi! link diffIsA WarningMsg diff --git a/runtime/colors/habamax.vim b/runtime/colors/habamax.vim index 4880482417..f32a5494ac 100644 --- a/runtime/colors/habamax.vim +++ b/runtime/colors/habamax.vim @@ -4,7 +4,7 @@ " Maintainer: Maxim Kim " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Fri 15 Dec 2023 20:05:35 +" Last Updated: Mon 08 Jan 2024 09:39:53 AM AEDT " Generated by Colortemplate v2.2.3 @@ -106,8 +106,9 @@ hi Ignore guifg=NONE guibg=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE hi Debug guifg=#5f8787 guibg=NONE gui=NONE cterm=NONE hi DiffAdd guifg=#dadada guibg=#5f875f gui=NONE cterm=NONE hi DiffDelete guifg=#af875f guibg=NONE gui=NONE cterm=NONE -hi diffAdded guifg=#87af87 guibg=NONE gui=NONE cterm=NONE -hi diffRemoved guifg=#d75f5f guibg=NONE gui=NONE cterm=NONE +hi Added guifg=#87af87 guibg=NONE gui=NONE cterm=NONE +hi Changed guifg=#5f8787 guibg=NONE gui=NONE cterm=NONE +hi Removed guifg=#d75f5f guibg=NONE gui=NONE cterm=NONE hi diffSubname guifg=#af87af guibg=NONE gui=NONE cterm=NONE hi DiffText guifg=#dadada guibg=#878787 gui=NONE cterm=NONE hi DiffChange guifg=#bcbcbc guibg=#5f5f5f gui=NONE cterm=NONE @@ -199,8 +200,9 @@ if s:t_Co >= 256 hi Debug ctermfg=66 ctermbg=NONE cterm=NONE hi DiffAdd ctermfg=253 ctermbg=65 cterm=NONE hi DiffDelete ctermfg=137 ctermbg=NONE cterm=NONE - hi diffAdded ctermfg=108 ctermbg=NONE cterm=NONE - hi diffRemoved ctermfg=167 ctermbg=NONE cterm=NONE + hi Added ctermfg=108 ctermbg=NONE cterm=NONE + hi Changed ctermfg=66 ctermbg=NONE cterm=NONE + hi Removed ctermfg=167 ctermbg=NONE cterm=NONE hi diffSubname ctermfg=139 ctermbg=NONE cterm=NONE hi DiffText ctermfg=253 ctermbg=102 cterm=NONE hi DiffChange ctermfg=250 ctermbg=59 cterm=NONE @@ -277,8 +279,9 @@ if s:t_Co >= 16 hi Debug ctermfg=darkcyan ctermbg=NONE cterm=NONE hi DiffAdd ctermfg=white ctermbg=darkgreen cterm=NONE hi DiffDelete ctermfg=darkyellow ctermbg=NONE cterm=NONE - hi diffAdded ctermfg=darkgreen ctermbg=NONE cterm=NONE - hi diffRemoved ctermfg=darkred ctermbg=NONE cterm=NONE + hi Added ctermfg=darkgreen ctermbg=NONE cterm=NONE + hi Changed ctermfg=darkcyan ctermbg=NONE cterm=NONE + hi Removed ctermfg=darkred ctermbg=NONE cterm=NONE hi diffSubname ctermfg=darkmagenta ctermbg=NONE cterm=NONE hi DiffText ctermfg=white ctermbg=lightgrey cterm=NONE hi DiffChange ctermfg=white ctermbg=darkgray cterm=NONE @@ -355,8 +358,9 @@ if s:t_Co >= 8 hi Debug ctermfg=darkcyan ctermbg=NONE cterm=NONE hi DiffAdd ctermfg=white ctermbg=darkgreen cterm=NONE hi DiffDelete ctermfg=darkyellow ctermbg=NONE cterm=NONE - hi diffAdded ctermfg=darkgreen ctermbg=NONE cterm=NONE - hi diffRemoved ctermfg=darkred ctermbg=NONE cterm=NONE + hi Added ctermfg=darkgreen ctermbg=NONE cterm=NONE + hi Changed ctermfg=darkcyan ctermbg=NONE cterm=NONE + hi Removed ctermfg=darkred ctermbg=NONE cterm=NONE hi diffSubname ctermfg=darkmagenta ctermbg=NONE cterm=NONE hi DiffText ctermfg=white ctermbg=black cterm=bold,reverse hi DiffChange ctermfg=black ctermbg=white cterm=NONE diff --git a/runtime/colors/lunaperche.vim b/runtime/colors/lunaperche.vim index 4e4678e81a..3546710a3d 100644 --- a/runtime/colors/lunaperche.vim +++ b/runtime/colors/lunaperche.vim @@ -4,7 +4,7 @@ " Maintainer: Maxim Kim " Website: https://www.github.com/vim/colorschemes " License: Vim License (see `:help license`) -" Last Updated: Fri 15 Dec 2023 20:05:37 +" Last Updated: Mon 08 Jan 2024 09:41:03 AM AEDT " Generated by Colortemplate v2.2.3 @@ -164,8 +164,9 @@ if &background ==# 'dark' hi DiffChange guifg=#c6c6c6 guibg=#5f5f5f gui=NONE cterm=NONE hi DiffText guifg=#afffff guibg=#5f8787 gui=NONE cterm=NONE hi DiffDelete guifg=#d78787 guibg=NONE gui=NONE cterm=NONE - hi diffAdded guifg=#5fd75f guibg=NONE gui=NONE cterm=NONE - hi diffRemoved guifg=#d78787 guibg=NONE gui=NONE cterm=NONE + hi Added guifg=#5fd75f guibg=NONE gui=NONE cterm=NONE + hi Changed guifg=#5fafff guibg=NONE gui=NONE cterm=NONE + hi Removed guifg=#d78787 guibg=NONE gui=NONE cterm=NONE hi diffSubname guifg=#ff87ff guibg=NONE gui=NONE cterm=NONE hi dirType guifg=#d787d7 guibg=NONE gui=NONE cterm=NONE hi dirPermissionUser guifg=#5faf5f guibg=NONE gui=NONE cterm=NONE @@ -254,8 +255,9 @@ else hi DiffChange guifg=#000000 guibg=#d0d0d0 gui=NONE cterm=NONE hi DiffText guifg=#000000 guibg=#5fd7d7 gui=NONE cterm=NONE hi DiffDelete guifg=#870000 guibg=NONE gui=NONE cterm=NONE - hi diffAdded guifg=#008700 guibg=NONE gui=NONE cterm=NONE - hi diffRemoved guifg=#d70000 guibg=NONE gui=NONE cterm=NONE + hi Added guifg=#008700 guibg=NONE gui=NONE cterm=NONE + hi Changed guifg=#005fd7 guibg=NONE gui=NONE cterm=NONE + hi Removed guifg=#d70000 guibg=NONE gui=NONE cterm=NONE hi diffSubname guifg=#af00af guibg=NONE gui=NONE cterm=NONE hi dirType guifg=#005f5f guibg=NONE gui=NONE cterm=NONE hi dirPermissionUser guifg=#af5f00 guibg=NONE gui=NONE cterm=NONE @@ -421,8 +423,9 @@ if s:t_Co >= 256 hi DiffChange ctermfg=251 ctermbg=59 cterm=NONE hi DiffText ctermfg=159 ctermbg=66 cterm=NONE hi DiffDelete ctermfg=174 ctermbg=NONE cterm=NONE - hi diffAdded ctermfg=77 ctermbg=NONE cterm=NONE - hi diffRemoved ctermfg=174 ctermbg=NONE cterm=NONE + hi Added ctermfg=77 ctermbg=NONE cterm=NONE + hi Changed ctermfg=75 ctermbg=NONE cterm=NONE + hi Removed ctermfg=174 ctermbg=NONE cterm=NONE hi diffSubname ctermfg=213 ctermbg=NONE cterm=NONE hi dirType ctermfg=176 ctermbg=NONE cterm=NONE hi dirPermissionUser ctermfg=71 ctermbg=NONE cterm=NONE @@ -506,8 +509,9 @@ if s:t_Co >= 256 hi DiffChange ctermfg=16 ctermbg=252 cterm=NONE hi DiffText ctermfg=16 ctermbg=80 cterm=NONE hi DiffDelete ctermfg=88 ctermbg=NONE cterm=NONE - hi diffAdded ctermfg=28 ctermbg=NONE cterm=NONE - hi diffRemoved ctermfg=160 ctermbg=NONE cterm=NONE + hi Added ctermfg=28 ctermbg=NONE cterm=NONE + hi Changed ctermfg=26 ctermbg=NONE cterm=NONE + hi Removed ctermfg=160 ctermbg=NONE cterm=NONE hi diffSubname ctermfg=127 ctermbg=NONE cterm=NONE hi dirType ctermfg=23 ctermbg=NONE cterm=NONE hi dirPermissionUser ctermfg=130 ctermbg=NONE cterm=NONE @@ -596,8 +600,9 @@ if s:t_Co >= 16 hi DiffChange ctermfg=white ctermbg=darkgreen cterm=NONE hi DiffText ctermfg=black ctermbg=cyan cterm=NONE hi DiffDelete ctermfg=darkred ctermbg=NONE cterm=NONE - hi diffAdded ctermfg=green ctermbg=NONE cterm=NONE - hi diffRemoved ctermfg=darkred ctermbg=NONE cterm=NONE + hi Added ctermfg=green ctermbg=NONE cterm=NONE + hi Changed ctermfg=blue ctermbg=NONE cterm=NONE + hi Removed ctermfg=darkred ctermbg=NONE cterm=NONE hi diffSubname ctermfg=magenta ctermbg=NONE cterm=NONE hi dirType ctermfg=darkmagenta ctermbg=NONE cterm=NONE hi dirPermissionUser ctermfg=darkgreen ctermbg=NONE cterm=NONE @@ -681,8 +686,9 @@ if s:t_Co >= 16 hi DiffChange ctermfg=black ctermbg=lightgray cterm=NONE hi DiffText ctermfg=black ctermbg=cyan cterm=NONE hi DiffDelete ctermfg=darkred ctermbg=NONE cterm=NONE - hi diffAdded ctermfg=darkgreen ctermbg=NONE cterm=NONE - hi diffRemoved ctermfg=red ctermbg=NONE cterm=NONE + hi Added ctermfg=darkgreen ctermbg=NONE cterm=NONE + hi Changed ctermfg=darkblue ctermbg=NONE cterm=NONE + hi Removed ctermfg=red ctermbg=NONE cterm=NONE hi diffSubname ctermfg=darkmagenta ctermbg=NONE cterm=NONE hi dirType ctermfg=darkcyan ctermbg=NONE cterm=NONE hi dirPermissionUser ctermfg=darkyellow ctermbg=NONE cterm=NONE diff --git a/runtime/colors/murphy.vim b/runtime/colors/murphy.vim index b829d4975e..a6a08ed41a 100644 --- a/runtime/colors/murphy.vim +++ b/runtime/colors/murphy.vim @@ -4,7 +4,7 @@ " Maintainer: Original maintainer Ron Aaron . " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Fri 15 Dec 2023 20:05:38 +" Last Updated: Mon 08 Jan 2024 09:50:15 AM AEDT " Generated by Colortemplate v2.2.3 @@ -28,6 +28,7 @@ hi! link StatusLineTerm StatusLine hi! link StatusLineTermNC StatusLineNC hi! link MessageWindow Pmenu hi! link PopupNotification Todo +hi! link Added Constant hi Normal guifg=#87ff87 guibg=#000000 gui=NONE cterm=NONE hi EndOfBuffer guifg=#0000ff guibg=#000000 gui=NONE cterm=NONE hi StatusLine guifg=#ffffff guibg=#00008b gui=NONE cterm=NONE @@ -100,6 +101,7 @@ if s:t_Co >= 256 hi! link StatusLineTermNC StatusLineNC hi! link MessageWindow Pmenu hi! link PopupNotification Todo + hi! link Added Constant hi Normal ctermfg=120 ctermbg=16 cterm=NONE hi EndOfBuffer ctermfg=21 ctermbg=16 cterm=NONE hi StatusLine ctermfg=231 ctermbg=18 cterm=NONE diff --git a/runtime/colors/wildcharm.vim b/runtime/colors/wildcharm.vim index 31facfa918..ee1f37625c 100644 --- a/runtime/colors/wildcharm.vim +++ b/runtime/colors/wildcharm.vim @@ -4,7 +4,7 @@ " Maintainer: Maxim Kim " Website: https://github.com/vim/colorschemes " License: Same as Vim -" Last Updated: Fri 15 Dec 2023 20:05:43 +" Last Updated: Mon 08 Jan 2024 09:40:36 AM AEDT " Generated by Colortemplate v2.2.3 @@ -93,8 +93,9 @@ if &background ==# 'dark' hi DiffChange guifg=#d0d0d0 guibg=#5f5f5f gui=NONE cterm=NONE hi DiffText guifg=#afffff guibg=#5f8787 gui=NONE cterm=NONE hi DiffDelete guifg=#ffafaf guibg=#875f5f gui=NONE cterm=NONE - hi diffAdded guifg=#00af5f guibg=NONE gui=NONE cterm=NONE - hi diffRemoved guifg=#d7005f guibg=NONE gui=NONE cterm=NONE + hi Added guifg=#00af5f guibg=NONE gui=NONE cterm=NONE + hi Changed guifg=#0087d7 guibg=NONE gui=NONE cterm=NONE + hi Removed guifg=#d7005f guibg=NONE gui=NONE cterm=NONE else " Light background if (has('termguicolors') && &termguicolors) || has('gui_running') @@ -167,8 +168,9 @@ else hi DiffChange guifg=#262626 guibg=#dadada gui=NONE cterm=NONE hi DiffText guifg=#005f5f guibg=#afd7d7 gui=NONE cterm=NONE hi DiffDelete guifg=#875f5f guibg=#ffd7d7 gui=NONE cterm=NONE - hi diffAdded guifg=#008700 guibg=NONE gui=NONE cterm=NONE - hi diffRemoved guifg=#d70000 guibg=NONE gui=NONE cterm=NONE + hi Added guifg=#5faf5f guibg=NONE gui=NONE cterm=NONE + hi Changed guifg=#0087d7 guibg=NONE gui=NONE cterm=NONE + hi Removed guifg=#d70000 guibg=NONE gui=NONE cterm=NONE endif if s:t_Co >= 256 @@ -247,8 +249,9 @@ if s:t_Co >= 256 hi DiffChange ctermfg=252 ctermbg=59 cterm=NONE hi DiffText ctermfg=159 ctermbg=66 cterm=NONE hi DiffDelete ctermfg=217 ctermbg=95 cterm=NONE - hi diffAdded ctermfg=35 ctermbg=NONE cterm=NONE - hi diffRemoved ctermfg=161 ctermbg=NONE cterm=NONE + hi Added ctermfg=35 ctermbg=NONE cterm=NONE + hi Changed ctermfg=32 ctermbg=NONE cterm=NONE + hi Removed ctermfg=161 ctermbg=NONE cterm=NONE else " Light background hi Normal ctermfg=16 ctermbg=231 cterm=NONE @@ -316,8 +319,9 @@ if s:t_Co >= 256 hi DiffChange ctermfg=235 ctermbg=253 cterm=NONE hi DiffText ctermfg=23 ctermbg=152 cterm=NONE hi DiffDelete ctermfg=95 ctermbg=224 cterm=NONE - hi diffAdded ctermfg=28 ctermbg=NONE cterm=NONE - hi diffRemoved ctermfg=160 ctermbg=NONE cterm=NONE + hi Added ctermfg=71 ctermbg=NONE cterm=NONE + hi Changed ctermfg=32 ctermbg=NONE cterm=NONE + hi Removed ctermfg=160 ctermbg=NONE cterm=NONE endif unlet s:t_Co finish @@ -386,12 +390,13 @@ if s:t_Co >= 16 hi Directory ctermfg=blue ctermbg=NONE cterm=bold hi Conceal ctermfg=NONE ctermbg=NONE cterm=NONE hi Ignore ctermfg=NONE ctermbg=NONE cterm=NONE - hi DiffAdd ctermfg=black ctermbg=darkmagenta cterm=NONE + hi DiffAdd ctermfg=black ctermbg=darkgreen cterm=NONE hi DiffChange ctermfg=black ctermbg=lightgray cterm=NONE hi DiffText ctermfg=black ctermbg=cyan cterm=NONE hi DiffDelete ctermfg=black ctermbg=darkred cterm=NONE - hi diffAdded ctermfg=darkgreen ctermbg=NONE cterm=NONE - hi diffRemoved ctermfg=darkred ctermbg=NONE cterm=NONE + hi Added ctermfg=darkgreen ctermbg=NONE cterm=NONE + hi Changed ctermfg=darkblue ctermbg=NONE cterm=NONE + hi Removed ctermfg=darkred ctermbg=NONE cterm=NONE else " Light background hi Normal ctermfg=black ctermbg=white cterm=NONE @@ -455,12 +460,13 @@ if s:t_Co >= 16 hi Directory ctermfg=darkblue ctermbg=NONE cterm=bold hi Conceal ctermfg=NONE ctermbg=NONE cterm=NONE hi Ignore ctermfg=NONE ctermbg=NONE cterm=NONE - hi DiffAdd ctermfg=black ctermbg=darkmagenta cterm=NONE + hi DiffAdd ctermfg=black ctermbg=darkgreen cterm=NONE hi DiffChange ctermfg=black ctermbg=lightgray cterm=NONE hi DiffText ctermfg=black ctermbg=cyan cterm=NONE hi DiffDelete ctermfg=black ctermbg=darkred cterm=NONE - hi diffAdded ctermfg=darkgreen ctermbg=NONE cterm=NONE - hi diffRemoved ctermfg=red ctermbg=NONE cterm=NONE + hi Added ctermfg=green ctermbg=NONE cterm=NONE + hi Changed ctermfg=blue ctermbg=NONE cterm=NONE + hi Removed ctermfg=red ctermbg=NONE cterm=NONE endif unlet s:t_Co finish @@ -510,7 +516,7 @@ if s:t_Co >= 8 hi VisualNOS ctermfg=black ctermbg=darkblue cterm=NONE hi CursorLine ctermfg=NONE ctermbg=NONE cterm=underline hi CursorColumn ctermfg=black ctermbg=darkyellow cterm=NONE - hi Folded ctermfg=black ctermbg=NONE cterm=bold + hi Folded ctermfg=grey ctermbg=NONE cterm=bold hi ColorColumn ctermfg=black ctermbg=darkyellow cterm=NONE hi SpellBad ctermfg=darkred ctermbg=NONE cterm=reverse hi SpellCap ctermfg=darkcyan ctermbg=NONE cterm=reverse @@ -519,20 +525,20 @@ if s:t_Co >= 8 hi Comment ctermfg=NONE ctermbg=NONE cterm=bold hi Constant ctermfg=darkred ctermbg=NONE cterm=NONE hi String ctermfg=darkgreen ctermbg=NONE cterm=NONE - hi Identifier ctermfg=NONE ctermbg=NONE cterm=NONE - hi Statement ctermfg=darkblue ctermbg=NONE cterm=bold + hi Identifier ctermfg=darkmagenta ctermbg=NONE cterm=NONE + hi Statement ctermfg=darkblue ctermbg=NONE cterm=NONE hi Type ctermfg=darkyellow ctermbg=NONE cterm=NONE hi PreProc ctermfg=darkcyan ctermbg=NONE cterm=NONE - hi Special ctermfg=darkcyan ctermbg=NONE cterm=NONE + hi Special ctermfg=darkmagenta ctermbg=NONE cterm=NONE hi Underlined ctermfg=NONE ctermbg=NONE cterm=underline hi Title ctermfg=NONE ctermbg=NONE cterm=bold hi Directory ctermfg=darkblue ctermbg=NONE cterm=bold hi Conceal ctermfg=NONE ctermbg=NONE cterm=NONE hi Ignore ctermfg=NONE ctermbg=NONE cterm=NONE - hi DiffAdd ctermfg=black ctermbg=darkmagenta cterm=NONE - hi DiffChange ctermfg=black ctermbg=darkcyan cterm=NONE - hi DiffText ctermfg=black ctermbg=grey cterm=NONE - hi DiffDelete ctermfg=darkred ctermbg=NONE cterm=NONE + hi DiffAdd ctermfg=black ctermbg=darkgreen cterm=NONE + hi DiffChange ctermfg=black ctermbg=darkblue cterm=NONE + hi DiffText ctermfg=black ctermbg=darkmagenta cterm=NONE + hi DiffDelete ctermfg=black ctermbg=darkred cterm=NONE else " Light background hi Normal ctermfg=black ctermbg=grey cterm=NONE @@ -586,20 +592,20 @@ if s:t_Co >= 8 hi Comment ctermfg=NONE ctermbg=NONE cterm=bold hi Constant ctermfg=darkred ctermbg=NONE cterm=NONE hi String ctermfg=darkgreen ctermbg=NONE cterm=NONE - hi Identifier ctermfg=NONE ctermbg=NONE cterm=NONE - hi Statement ctermfg=darkblue ctermbg=NONE cterm=bold + hi Identifier ctermfg=darkmagenta ctermbg=NONE cterm=NONE + hi Statement ctermfg=darkblue ctermbg=NONE cterm=NONE hi Type ctermfg=darkyellow ctermbg=NONE cterm=NONE hi PreProc ctermfg=darkcyan ctermbg=NONE cterm=NONE - hi Special ctermfg=darkcyan ctermbg=NONE cterm=NONE + hi Special ctermfg=darkmagenta ctermbg=NONE cterm=NONE hi Underlined ctermfg=NONE ctermbg=NONE cterm=underline hi Title ctermfg=NONE ctermbg=NONE cterm=bold hi Directory ctermfg=darkblue ctermbg=NONE cterm=bold hi Conceal ctermfg=NONE ctermbg=NONE cterm=NONE hi Ignore ctermfg=NONE ctermbg=NONE cterm=NONE - hi DiffAdd ctermfg=black ctermbg=darkmagenta cterm=NONE - hi DiffChange ctermfg=black ctermbg=darkcyan cterm=NONE - hi DiffText ctermfg=grey ctermbg=black cterm=NONE - hi DiffDelete ctermfg=darkred ctermbg=NONE cterm=NONE + hi DiffAdd ctermfg=black ctermbg=darkgreen cterm=NONE + hi DiffChange ctermfg=black ctermbg=darkblue cterm=NONE + hi DiffText ctermfg=black ctermbg=darkmagenta cterm=NONE + hi DiffDelete ctermfg=black ctermbg=darkred cterm=NONE endif unlet s:t_Co finish @@ -700,7 +706,7 @@ endif " Color: colorlC #ff5fff 207 magenta " Color: colorDim #878787 102 grey " Color: colorMP #ff00af 199 magenta -" Color: diffAdd #5f875f 65 darkmagenta +" Color: diffAdd #5f875f 65 darkgreen " Color: diffAddFg #afffaf 157 black " Color: diffDelete #875f5f 95 darkred " Color: diffDeleteFg #ffafaf 217 black @@ -739,7 +745,7 @@ endif " Color: colorDim #626262 241 darkgrey " Color: colorSt #5f5f5f 59 darkgrey " Color: colorMP #ff00af 199 magenta -" Color: diffAdd #afd7af 151 darkmagenta +" Color: diffAdd #afd7af 151 darkgreen " Color: diffAddFg #005f00 22 black " Color: diffDelete #ffd7d7 224 darkred " Color: diffDeleteFg #875f5f 95 black From 71d0ba07a33a750e9834cd42b7acc619043dedb1 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Wed, 10 Jan 2024 03:21:05 +0900 Subject: [PATCH 029/143] runtime(netrw): Sync with netrw 174b (#13836) * Import netrw v174b * Revert unwanted changes * Fix indent * Revert some changes * Update tags * Break long line Signed-off-by: Ken Takata Signed-off-by: Christian Brabandt --- runtime/autoload/netrw.vim | 44 +++++++++++++++++++------------------- runtime/doc/pi_netrw.txt | 39 ++++++++++++++++----------------- runtime/doc/tags | 1 - 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 748ac22768..3af7ba0f1d 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -2121,9 +2121,9 @@ fun! netrw#NetRead(mode,...) let wholechoice = wholechoice . " " . choice let ichoice = ichoice + 1 if ichoice > a:0 - if !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",3) - endif + if !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",3) + endif " call Dret("netrw#NetRead :2 getcwd<".getcwd().">") return endif @@ -2544,9 +2544,9 @@ fun! netrw#NetWrite(...) range let wholechoice= wholechoice . " " . choice let ichoice = ichoice + 1 if choice > a:0 - if !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",13) - endif + if !exists("g:netrw_quiet") + call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",13) + endif " call Dret("netrw#NetWrite") return endif @@ -5003,12 +5003,12 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) if g:netrw_chgwin >= 1 " call Decho("edit-a-file: changing window to #".g:netrw_chgwin.": (due to g:netrw_chgwin)",'~'.expand("")) if winnr("$")+1 == g:netrw_chgwin - " if g:netrw_chgwin is set to one more than the last window, then - " vertically split the last window to make that window available. - let curwin= winnr() - exe "NetrwKeepj keepalt ".winnr("$")."wincmd w" - vs - exe "NetrwKeepj keepalt ".g:netrw_chgwin."wincmd ".curwin + " if g:netrw_chgwin is set to one more than the last window, then + " vertically split the last window to make that window available. + let curwin= winnr() + exe "NetrwKeepj keepalt ".winnr("$")."wincmd w" + vs + exe "NetrwKeepj keepalt ".g:netrw_chgwin."wincmd ".curwin endif exe "NetrwKeepj keepalt ".g:netrw_chgwin."wincmd w" endif @@ -6127,7 +6127,7 @@ fun! s:NetrwServerEdit(islocal,fname) " used something like . " call Decho("user must have closed server AND did not use ctrl-r",'~'.expand("")) if exists("g:netrw_browse_split") - unlet g:netrw_browse_split + unlet g:netrw_browse_split endif let g:netrw_browse_split= 0 if exists("s:netrw_browse_split_".winnr()) @@ -6161,7 +6161,7 @@ fun! s:NetrwServerEdit(islocal,fname) if !ctrlr " call Decho("server<".g:netrw_servername."> not available and ctrl-r not used",'~'.expand("")) if exists("g:netrw_browse_split") - unlet g:netrw_browse_split + unlet g:netrw_browse_split endif let g:netrw_browse_split= 0 call s:NetrwBrowse(islocal,s:NetrwBrowseChgDir(islocal,a:fname)) @@ -7506,7 +7506,7 @@ fun! s:NetrwMarkFileExe(islocal,enbloc) for fname in s:netrwmarkfilelist_{curbufnr} if a:islocal if g:netrw_keepdir - let fname= s:ShellEscape(netrw#WinPath(s:ComposePath(curdir,fname))) + let fname= s:ShellEscape(netrw#WinPath(s:ComposePath(curdir,fname))) endif else let fname= s:ShellEscape(netrw#WinPath(b:netrw_curdir.fname)) @@ -10685,7 +10685,7 @@ fun! s:NetrwRemoteRmFile(path,rmfile,all) let ret= system(netrw_rm_cmd) if v:shell_error != 0 if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && !g:netrw_keepdir - call netrw#ErrorMsg(s:ERROR,"remove failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-cd)",102) + call netrw#ErrorMsg(s:ERROR,"remove failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-cd)",102) else call netrw#ErrorMsg(s:WARNING,"cmd<".netrw_rm_cmd."> failed",60) endif @@ -11193,16 +11193,16 @@ fun! s:LocalListing() " call Decho("pfile <".pfile.">",'~'.expand("")) if w:netrw_liststyle == s:LONGLIST - let longfile= printf("%-".g:netrw_maxfilenamelen."S",pfile) - let sz = getfsize(filename) - let szlen = 15 - (strdisplaywidth(longfile) - g:netrw_maxfilenamelen) - let szlen = (szlen > 0) ? szlen : 0 + let longfile = printf("%-".g:netrw_maxfilenamelen."S",pfile) + let sz = getfsize(filename) + let szlen = 15 - (strdisplaywidth(longfile) - g:netrw_maxfilenamelen) + let szlen = (szlen > 0) ? szlen : 0 if g:netrw_sizestyle =~# "[hH]" let sz= s:NetrwHumanReadable(sz) endif let fsz = printf("%".szlen."S",sz) - let pfile = longfile." ".fsz." ".strftime(g:netrw_timefmt,getftime(filename)) + let pfile= longfile." ".fsz." ".strftime(g:netrw_timefmt,getftime(filename)) " call Decho("longlist support: sz=".sz." fsz=".fsz,'~'.expand("")) endif @@ -12222,7 +12222,7 @@ fun! s:NetrwLcd(newdir) if (has("win32") || has("win95") || has("win64") || has("win16")) && !g:netrw_cygwin if a:newdir =~ '^\\\\\w\+' || a:newdir =~ '^//\w\+' let dirname = '\' - exe 'NetrwKeepj sil lcd '.fnameescape(dirname) + exe 'NetrwKeepj sil lcd '.fnameescape(dirname) endif endif catch /^Vim\%((\a\+)\)\=:E472/ diff --git a/runtime/doc/pi_netrw.txt b/runtime/doc/pi_netrw.txt index 07d70c831d..90164e2996 100644 --- a/runtime/doc/pi_netrw.txt +++ b/runtime/doc/pi_netrw.txt @@ -1,4 +1,4 @@ -*pi_netrw.txt* For Vim version 9.1. Last change: 2023 May 14 +*pi_netrw.txt* For Vim version 9.1. Last change: 2023 Jun 19 ------------------------------------------------ NETRW REFERENCE MANUAL by Charles E. Campbell @@ -1625,10 +1625,8 @@ A further approach is to delete files which match a pattern. This will cause the matching files to be marked. Then, press "D". -If your vim has 7.4 with patch#1107, then |g:netrw_localrmdir| no longer -is used to remove directories; instead, vim's |delete()| is used with -the "d" option. Please note that only empty directories may be deleted -with the "D" mapping. Regular files are deleted with |delete()|, too. +Please note that only empty directories may be deleted with the "D" mapping. +Regular files are deleted with |delete()|, too. The |g:netrw_rm_cmd|, |g:netrw_rmf_cmd|, and |g:netrw_rmdir_cmd| variables are used to control the attempts to remove remote files and directories. The @@ -1647,8 +1645,7 @@ to remove it again using the g:netrw_rmf_cmd variable. Its default value is: |g:netrw_rmf_cmd|: ssh HOSTNAME rm -f Related topics: |netrw-d| -Associated setting variable: |g:netrw_localrmdir| |g:netrw_rm_cmd| - |g:netrw_rmdir_cmd| |g:netrw_ssh_cmd| +Associated setting variable: |g:netrw_rm_cmd| |g:netrw_ssh_cmd| *netrw-explore* *netrw-hexplore* *netrw-nexplore* *netrw-pexplore* @@ -1691,7 +1688,11 @@ DIRECTORY EXPLORATION COMMANDS {{{2 to 2; edits will thus preferentially be made in window#2. The [N] specifies a |g:netrw_winsize| just for the new :Lexplore - window. + window. That means that + if [N] < 0 : use |N| columns for the Lexplore window + if [N] = 0 : a normal split is made + if [N] > 0 : use N% of the current window will be used for the + new window Those who like this method often also like tree style displays; see |g:netrw_liststyle|. @@ -2863,14 +2864,6 @@ your browsing preferences. (see also: |netrw-settings|) =" /c move" Windows Options for |g:netrw_localmovecmd| - *g:netrw_localrmdir* ="rmdir" Linux/Unix/MacOS/Cygwin - =expand("$COMSPEC") Windows - Remove directory command (rmdir) - This variable is only used if your vim is - earlier than 7.4 or if your vim doesn't - have patch#1107. Otherwise, |delete()| - is used with the "d" option. - *g:netrw_maxfilenamelen* =32 by default, selected so as to make long listings fit on 80 column displays. If your screen is wider, and you have file @@ -3781,7 +3774,7 @@ Example: Clear netrw's marked file list via a mapping on gu > Netrw uses several system level commands to do things (see |g:netrw_localcopycmd|, |g:netrw_localmovecmd|, - |g:netrw_localrmdir|, |g:netrw_mkdir_cmd|). + |g:netrw_mkdir_cmd|). You may need to adjust the default commands for one or more of these commands by setting them properly in your .vimrc. Another @@ -3907,8 +3900,13 @@ netrw: ============================================================================== 12. History *netrw-history* {{{1 - v172: Apr 22, 2023 * removed g:netrw_localrmdiropt - removed g:netrw_localrmdir + v172: Sep 02, 2021 * (Bram Moolenaar) Changed "l:go" to "go" + * (Bram Moolenaar) no need for "b" in + netrw-safe guioptions + Nov 15, 2021 * removed netrw_localrm and netrw_localrmdir + references + Aug 18, 2022 * (Miguel Barro) improving compatability with + powershell v171: Oct 09, 2020 * included code in s:NetrwOptionsSafe() to allow |'bh'| to be set to delete when rather than hide when g:netrw_fastbrowse @@ -3996,7 +3994,6 @@ netrw: |g:netrw_localcopydircmdopt| |g:netrw_localmkdiropt| |g:netrw_localmovecmdopt| - g:netrw_localrmdiropt Nov 21, 2016 * (mattn) provided a patch for preview; swapped winwidth() with winheight() Nov 22, 2016 * (glacambre) reported that files containing @@ -4056,7 +4053,7 @@ netrw: refreshes. However, inside a |:map-|, tab and window changes are disallowed. Fixed. (affects netrw's s:LocalBrowseRefresh()) - * |g:netrw_localrmdir| not used any more, but + * g:netrw_localrmdir not used any more, but the relevant patch that causes |delete()| to take over was #1107 (not #1109). * |expand()| is now used on |g:netrw_home|; diff --git a/runtime/doc/tags b/runtime/doc/tags index 1b55fa1943..bab6b3bf58 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -7535,7 +7535,6 @@ g:netrw_localmkdir pi_netrw.txt /*g:netrw_localmkdir* g:netrw_localmkdiropt pi_netrw.txt /*g:netrw_localmkdiropt* g:netrw_localmovecmd pi_netrw.txt /*g:netrw_localmovecmd* g:netrw_localmovecmdopt pi_netrw.txt /*g:netrw_localmovecmdopt* -g:netrw_localrmdir pi_netrw.txt /*g:netrw_localrmdir* g:netrw_maxfilenamelen pi_netrw.txt /*g:netrw_maxfilenamelen* g:netrw_menu pi_netrw.txt /*g:netrw_menu* g:netrw_mkdir_cmd pi_netrw.txt /*g:netrw_mkdir_cmd* From 28d71b566a29ceea3a2d05bcee9264ed5d630d42 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Fri, 12 Jan 2024 17:21:55 +0100 Subject: [PATCH 030/143] patch 9.1.0017: [security]: use-after-free in eval1_emsg() Problem: use-after-free in eval1_emsg() when an empty line follows a lambda (by @yu3s) Solution: only set evalarg->eval_using_cmdline = FALSE when the *arg pointer is not null fixes: #13833 closes: #13841 Signed-off-by: Yegappan Lakshmanan Signed-off-by: Christian Brabandt --- src/eval.c | 11 +++++++++-- src/testdir/test_vim9_script.vim | 25 +++++++++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/eval.c b/src/eval.c index 815d13d42a..bf053dfb69 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2699,6 +2699,9 @@ eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext) /* * To be called after eval_next_non_blank() sets "getnext" to TRUE. * Only called for Vim9 script. + * + * If "arg" is not NULL, then the caller should assign the return value to + * "arg". */ char_u * eval_next_line(char_u *arg, evalarg_T *evalarg) @@ -2747,8 +2750,12 @@ eval_next_line(char_u *arg, evalarg_T *evalarg) } // Advanced to the next line, "arg" no longer points into the previous - // line. - evalarg->eval_using_cmdline = FALSE; + // line. The caller assigns the return value to "arg". + // If "arg" is NULL, then the return value is discarded. In that case, + // "arg" still points to the previous line. So don't reset + // "eval_using_cmdline". + if (arg != NULL) + evalarg->eval_using_cmdline = FALSE; return skipwhite(line); } diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 7ae4d553e3..77b8831d45 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -4906,6 +4906,31 @@ def Test_for_stmt_space_before_type() v9.CheckSourceFailure(lines, 'E1059: No white space allowed before colon: :number in range(10)', 2) enddef +" This test used to cause an use-after-free memory access +def Test_for_empty_line_after_lambda() + var lines =<< trim END + vim9script + echomsg range(0, 2)->map((_, v) => { + return 1 + }) + + assert_equal('[1, 1, 1]', v:statusmsg) + END + v9.CheckSourceSuccess(lines) + + lines =<< trim END + vim9script + echomsg range(0, 1)->map((_, v) => { + return 1 + }) range(0, 1)->map((_, v) => { + return 2 + }) # comment + + assert_equal('[1, 1] [2, 2]', v:statusmsg) + END + v9.CheckSourceSuccess(lines) +enddef + " Keep this last, it messes up highlighting. def Test_substitute_cmd() new diff --git a/src/version.c b/src/version.c index 2e178f3bb3..f440140a4b 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 17, /**/ 16, /**/ From 2357765304e4c55935b5cc853ffb98ae82d64a01 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Sat, 13 Jan 2024 01:30:01 +0900 Subject: [PATCH 031/143] runtime(netrw): Decode multibyte percent-encoding filename correctly (#13842) Use `printf("%c")` instead of `nr2char()` to handle '%xx' as a byte. Close #13787 Signed-off-by: Ken Takata Signed-off-by: Christian Brabandt --- runtime/autoload/netrw.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 3af7ba0f1d..bcb1f24751 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -11587,7 +11587,7 @@ endfun " netrw#RFC2396: converts %xx into characters {{{2 fun! netrw#RFC2396(fname) " call Dfunc("netrw#RFC2396(fname<".a:fname.">)") - let fname = escape(substitute(a:fname,'%\(\x\x\)','\=nr2char("0x".submatch(1))','ge')," \t") + let fname = escape(substitute(a:fname,'%\(\x\x\)','\=printf("%c","0x".submatch(1))','ge')," \t") " call Dret("netrw#RFC2396 ".fname) return fname endfun From b52600d5613316e5b6e89514a02df1f97e27a5ff Mon Sep 17 00:00:00 2001 From: Ken Takata Date: Fri, 12 Jan 2024 17:31:07 +0100 Subject: [PATCH 032/143] patch 9.1.0018: use of #if instead of #ifdef Problem: use of #if instead of #ifdef Solution: use correct form of #ifdef `#if FEAT_GUI_HAIKU` was used mistakenly. Use the correct form `#ifdef FEAT_GUI_HAIKU` instead. closes: #13843 Signed-off-by: Ken Takata Signed-off-by: Christian Brabandt --- src/gui.h | 2 +- src/structs.h | 2 +- src/version.c | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui.h b/src/gui.h index 0a1d274140..1882000f6b 100644 --- a/src/gui.h +++ b/src/gui.h @@ -176,7 +176,7 @@ typedef struct GuiScrollbar // to reduce the count. #endif -#if FEAT_GUI_HAIKU +#ifdef FEAT_GUI_HAIKU VimScrollBar *id; // Pointer to real scroll bar #endif #ifdef FEAT_GUI_PHOTON diff --git a/src/structs.h b/src/structs.h index 3b51e0c8f1..6d77deb454 100644 --- a/src/structs.h +++ b/src/structs.h @@ -4333,7 +4333,7 @@ struct VimMenu HMENU submenu_id; // If this is submenu, add children here HWND tearoff_handle; // hWnd of tearoff if created #endif -#if FEAT_GUI_HAIKU +#ifdef FEAT_GUI_HAIKU BMenuItem *id; // Id of menu item BMenu *submenu_id; // If this is submenu, add children here # ifdef FEAT_TOOLBAR diff --git a/src/version.c b/src/version.c index f440140a4b..675103fecd 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 18, /**/ 17, /**/ From 8610f74382039c9c54d6c4aeb978d252e762360a Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Fri, 12 Jan 2024 17:34:40 +0100 Subject: [PATCH 033/143] patch 9.1.0019: cmdline may disappear when changing 'cmdheight' Problem: cmdline may disappear when changing 'cmdheight' (after Patch 9.0.0190, @markonm) Solution: always re-calculate the old_p_ch value, not only when cmdline_row was higher than expected fixes: #13822 closes: #13826 Signed-off-by: Christian Brabandt --- src/testdir/test_cmdline.vim | 13 +++++++++++++ src/version.c | 2 ++ src/window.c | 8 ++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index 4554712670..ea95cbfce5 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -3742,4 +3742,17 @@ func Test_custom_completion_with_glob() delfunc TestGlobComplete endfunc +func Test_window_size_stays_same_after_changing_cmdheight() + set laststatus=2 + let expected = winheight(0) + function! Function_name() abort + call feedkeys(":"..repeat('x', &columns), 'x') + let &cmdheight=2 + let &cmdheight=1 + redraw + endfunction + call Function_name() + call assert_equal(expected, winheight(0)) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 675103fecd..627acd24d7 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 19, /**/ 18, /**/ diff --git a/src/window.c b/src/window.c index 54e17be2db..e53ac71584 100644 --- a/src/window.c +++ b/src/window.c @@ -7131,17 +7131,17 @@ command_height(void) // If the space for the command line is already more than 'cmdheight' there // is nothing to do (window size must have decreased). + // Note: this makes curtab->tp_ch_used unreliable if (p_ch > old_p_ch && cmdline_row <= Rows - p_ch) return; // Update cmdline_row to what it should be: just below the last window. cmdline_row = topframe->fr_height + tabline_height(); - // If cmdline_row is smaller than what it is supposed to be for 'cmdheight' - // then set old_p_ch to what it would be, so that the windows get resized + // old_p_ch may be unreliable, because of the early return above, so + // set old_p_ch to what it would be, so that the windows get resized // properly for the new value. - if (cmdline_row < Rows - p_ch) - old_p_ch = Rows - cmdline_row; + old_p_ch = Rows - cmdline_row; // Find bottom frame with width of screen. frp = lastwin->w_frame; From 4f32c83a775a195ae7e1545b2840fb773f93414f Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Fri, 12 Jan 2024 17:36:40 +0100 Subject: [PATCH 034/143] patch 9.1.0020: Vim9: cannot compile all methods in a class Problem: Vim9: cannot compile all methods in a class Solution: Support compiling all the methods in a class using :defcompile (Yegappan Lakshmanan) closes: #13844 Signed-off-by: Yegappan Lakshmanan Signed-off-by: Christian Brabandt --- runtime/doc/tags | 1 + runtime/doc/todo.txt | 2 - runtime/doc/vim9.txt | 12 ++-- runtime/doc/vim9class.txt | 9 ++- src/proto/userfunc.pro | 1 + src/proto/vim9class.pro | 3 + src/testdir/test_vim9_class.vim | 83 +++++++++++++++++++++++++ src/userfunc.c | 105 +++++++++++++++++++++----------- src/version.c | 2 + src/vim9class.c | 48 +++++++++++++++ 10 files changed, 224 insertions(+), 42 deletions(-) diff --git a/runtime/doc/tags b/runtime/doc/tags index bab6b3bf58..b3691bb93f 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -6428,6 +6428,7 @@ cino-{ indent.txt /*cino-{* cino-} indent.txt /*cino-}* cinoptions-values indent.txt /*cinoptions-values* class vim9class.txt /*class* +class-compile vim9class.txt /*class-compile* class-method vim9class.txt /*class-method* clear-undo undo.txt /*clear-undo* clearmatches() builtin.txt /*clearmatches()* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index 9847ff7d36..746488ecc4 100644 --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -130,8 +130,6 @@ Further Vim9 improvements: Issue #11822: any.Func() can be a dict or an object call, need to handle this at runtime. Also see #12198 for an example. Possibly issue #11981 can be fixed at the same time (has two examples). - - Make ":defcompile ClassName" compile all functions and methods in the - class. - Forward declaration of a class? E.g. for Clone() function. Email lifepillar 2023 Mar 26 - object empty(), len() - can class define a method to be used for them? diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt index b12b1cc998..b246fcbcec 100644 --- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -1,4 +1,4 @@ -*vim9.txt* For Vim version 9.1. Last change: 2023 Dec 24 +*vim9.txt* For Vim version 9.1. Last change: 2024 Jan 12 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1260,10 +1260,12 @@ Script-local variables in a |Vim9| script must be declared at the script level. They cannot be created in a function, also not in a legacy function. *:defc* *:defcompile* -:defc[ompile] Compile functions defined in the current script that - were not compiled yet. - This will report any errors found during compilation. - This excludes functions defined inside a class. +:defc[ompile] Compile functions and classes (|class-compile|) + defined in the current script that were not compiled + yet. This will report any errors found during + compilation. + +:defc[ompile] MyClass Compile all methods in a class |class-compile|. :defc[ompile] {func} :defc[ompile] debug {func} diff --git a/runtime/doc/vim9class.txt b/runtime/doc/vim9class.txt index 6e94e84832..ba821c1b29 100644 --- a/runtime/doc/vim9class.txt +++ b/runtime/doc/vim9class.txt @@ -1,4 +1,4 @@ -*vim9class.txt* For Vim version 9.1. Last change: 2024 Jan 06 +*vim9class.txt* For Vim version 9.1. Last change: 2024 Jan 12 VIM REFERENCE MANUAL by Bram Moolenaar @@ -830,7 +830,14 @@ Note that the method name must start with "new". If there is no method called "new()" then the default constructor is added, even though there are other constructor methods. +Compiling methods in a Class ~ + *class-compile* +The |:defcompile| command can be used to compile all the class and object +methods defined in a class: > + defcompile MyClass # Compile class "MyClass" + defcompile # Compile the classes in the current script +< ============================================================================== 7. Type definition *typealias* *Vim9-type* *:type* diff --git a/src/proto/userfunc.pro b/src/proto/userfunc.pro index e393c04707..9bb461663e 100644 --- a/src/proto/userfunc.pro +++ b/src/proto/userfunc.pro @@ -50,6 +50,7 @@ void list_functions(regmatch_T *regmatch); ufunc_T *define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free, int class_flags, ocmember_T *obj_members, int obj_member_count); void ex_function(exarg_T *eap); ufunc_T *find_func_by_name(char_u *name, compiletype_T *compile_type); +void defcompile_function(ufunc_T *ufunc, class_T *cl); void ex_defcompile(exarg_T *eap); int eval_fname_script(char_u *p); int translated_function_exists(char_u *name, int is_global); diff --git a/src/proto/vim9class.pro b/src/proto/vim9class.pro index f1b63602a7..a746eb7729 100644 --- a/src/proto/vim9class.pro +++ b/src/proto/vim9class.pro @@ -31,6 +31,9 @@ void object_free_items(int copyID); void emsg_var_cl_define(char *msg, char_u *name, size_t len, class_T *cl); void method_not_found_msg(class_T *cl, vartype_T v_type, char_u *name, size_t len); void member_not_found_msg(class_T *cl, vartype_T v_type, char_u *name, size_t len); +void defcompile_class(class_T *cl); +void defcompile_classes_in_script(void); +int is_class_name(char_u *name, typval_T *rettv); int class_instance_of(class_T *cl, class_T *other_cl); void f_instanceof(typval_T *argvars, typval_T *rettv); /* vim: set ft=c : */ diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim index b34d2ad12c..62a6d043d9 100644 --- a/src/testdir/test_vim9_class.vim +++ b/src/testdir/test_vim9_class.vim @@ -9686,4 +9686,87 @@ def Test_method_double_underscore_prefix() v9.CheckSourceFailure(lines, 'E1034: Cannot use reserved name __foo()', 3) enddef +" Test for compiling class/object methods using :defcompile +def Test_defcompile_class() + # defcompile all the classes in the current script + var lines =<< trim END + vim9script + class A + def Foo() + var i = 10 + enddef + endclass + class B + def Bar() + var i = 20 + xxx + enddef + endclass + defcompile + END + v9.CheckSourceFailure(lines, 'E476: Invalid command: xxx', 2) + + # defcompile a specific class + lines =<< trim END + vim9script + class A + def Foo() + xxx + enddef + endclass + class B + def Bar() + yyy + enddef + endclass + defcompile B + END + v9.CheckSourceFailure(lines, 'E476: Invalid command: yyy', 1) + + # defcompile a non-class + lines =<< trim END + vim9script + class A + def Foo() + enddef + endclass + var X: list = [] + defcompile X + END + v9.CheckSourceFailure(lines, 'E1061: Cannot find function X', 7) + + # defcompile a class twice + lines =<< trim END + vim9script + class A + def new() + enddef + endclass + defcompile A + defcompile A + assert_equal('Function A.new does not need compiling', v:statusmsg) + END + v9.CheckSourceSuccess(lines) + + # defcompile should not compile an imported class + lines =<< trim END + vim9script + export class A + def Foo() + xxx + enddef + endclass + END + writefile(lines, 'Xdefcompileimport.vim', 'D') + lines =<< trim END + vim9script + + import './Xdefcompileimport.vim' + class B + endclass + defcompile + END + v9.CheckScriptSuccess(lines) +enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker diff --git a/src/userfunc.c b/src/userfunc.c index 64761ecdb7..e39ce6e492 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -5545,6 +5545,60 @@ find_func_by_name(char_u *name, compiletype_T *compile_type) return ufunc; } +/* + * Compile the :def function "ufunc". If "cl" is not NULL, then compile the + * class or object method "ufunc" in "cl". + */ + void +defcompile_function(ufunc_T *ufunc, class_T *cl) +{ + compiletype_T compile_type = CT_NONE; + + if (func_needs_compiling(ufunc, compile_type)) + (void)compile_def_function(ufunc, FALSE, compile_type, NULL); + else + smsg(_("Function %s%s%s does not need compiling"), + cl != NULL ? cl->class_name : (char_u *)"", + cl != NULL ? (char_u *)"." : (char_u *)"", + ufunc->uf_name); +} + +/* + * Compile all the :def functions defined in the current script + */ + static void +defcompile_funcs_in_script(void) +{ + long todo = (long)func_hashtab.ht_used; + int changed = func_hashtab.ht_changed; + hashitem_T *hi; + + for (hi = func_hashtab.ht_array; todo > 0 && !got_int; ++hi) + { + if (!HASHITEM_EMPTY(hi)) + { + --todo; + ufunc_T *ufunc = HI2UF(hi); + if (ufunc->uf_script_ctx.sc_sid == current_sctx.sc_sid + && ufunc->uf_def_status == UF_TO_BE_COMPILED + && (ufunc->uf_flags & FC_DEAD) == 0) + { + (void)compile_def_function(ufunc, FALSE, CT_NONE, NULL); + + if (func_hashtab.ht_changed != changed) + { + // a function has been added or removed, need to start + // over + todo = (long)func_hashtab.ht_used; + changed = func_hashtab.ht_changed; + hi = func_hashtab.ht_array; + --hi; + } + } + } + } +} + /* * :defcompile - compile all :def functions in the current script that need to * be compiled or the one specified by the argument. @@ -5555,46 +5609,29 @@ ex_defcompile(exarg_T *eap) { if (*eap->arg != NUL) { - compiletype_T compile_type = CT_NONE; - ufunc_T *ufunc = find_func_by_name(eap->arg, &compile_type); - if (ufunc != NULL) + typval_T tv; + + if (is_class_name(eap->arg, &tv)) { - if (func_needs_compiling(ufunc, compile_type)) - (void)compile_def_function(ufunc, FALSE, compile_type, NULL); - else - smsg(_("Function %s does not need compiling"), eap->arg); + class_T *cl = tv.vval.v_class; + + if (cl != NULL) + defcompile_class(cl); + } + else + { + compiletype_T compile_type = CT_NONE; + ufunc_T *ufunc = find_func_by_name(eap->arg, &compile_type); + if (ufunc != NULL) + defcompile_function(ufunc, NULL); } } else { - long todo = (long)func_hashtab.ht_used; - int changed = func_hashtab.ht_changed; - hashitem_T *hi; + defcompile_funcs_in_script(); - for (hi = func_hashtab.ht_array; todo > 0 && !got_int; ++hi) - { - if (!HASHITEM_EMPTY(hi)) - { - --todo; - ufunc_T *ufunc = HI2UF(hi); - if (ufunc->uf_script_ctx.sc_sid == current_sctx.sc_sid - && ufunc->uf_def_status == UF_TO_BE_COMPILED - && (ufunc->uf_flags & FC_DEAD) == 0) - { - (void)compile_def_function(ufunc, FALSE, CT_NONE, NULL); - - if (func_hashtab.ht_changed != changed) - { - // a function has been added or removed, need to start - // over - todo = (long)func_hashtab.ht_used; - changed = func_hashtab.ht_changed; - hi = func_hashtab.ht_array; - --hi; - } - } - } - } + // compile all the class defined in the current script + defcompile_classes_in_script(); } } diff --git a/src/version.c b/src/version.c index 627acd24d7..76a7668b0e 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 20, /**/ 19, /**/ diff --git a/src/vim9class.c b/src/vim9class.c index e5d9aeb4ba..525f8d0389 100644 --- a/src/vim9class.c +++ b/src/vim9class.c @@ -3224,6 +3224,54 @@ member_not_found_msg(class_T *cl, vartype_T v_type, char_u *name, size_t len) vim_free(varname); } +/* + * Compile all the class and object methods in "cl". + */ + void +defcompile_class(class_T *cl) +{ + for (int loop = 1; loop <= 2; ++loop) + { + int func_count = loop == 1 ? cl->class_class_function_count + : cl->class_obj_method_count; + for (int i = 0; i < func_count; i++) + { + ufunc_T *ufunc = loop == 1 ? cl->class_class_functions[i] + : cl->class_obj_methods[i]; + defcompile_function(ufunc, cl); + } + } +} + +/* + * Compile all the classes defined in the current script + */ + void +defcompile_classes_in_script(void) +{ + for (class_T *cl = first_class; cl != NULL; cl = cl->class_next_used) + { + if (eval_variable(cl->class_name, 0, 0, NULL, NULL, + EVAL_VAR_NOAUTOLOAD | EVAL_VAR_NO_FUNC) != FAIL) + defcompile_class(cl); + } +} + +/* + * Returns TRUE if "name" is the name of a class. The typval for the class is + * returned in "rettv". + */ + int +is_class_name(char_u *name, typval_T *rettv) +{ + rettv->v_type = VAR_UNKNOWN; + + if (eval_variable(name, 0, 0, rettv, NULL, EVAL_VAR_NOAUTOLOAD | + EVAL_VAR_NO_FUNC) != FAIL) + return rettv->v_type == VAR_CLASS; + return FALSE; +} + /* * Return TRUE when the class "cl", its base class or one of the implemented * interfaces matches the class "other_cl". From 424ec1f235a53131042aed94d30f6e2528e551d9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 12 Jan 2024 17:43:05 +0100 Subject: [PATCH 035/143] patch 9.1.0021: i_CTRL-R- doesn't work for multibyte chars in Replace mode Problem: i_CTRL-R- doesn't work for multibyte chars in Replace mode, Coverity complains missing return value for u_save_cursor() Solution: Use mb_charlen() and del_chars() instead, handle failure mode for u_save_cursor() correctly (@zeertzjq) closes: #13846 Signed-off-by: zeertzjq Signed-off-by: Christian Brabandt --- src/register.c | 5 +++-- src/testdir/test_registers.vim | 16 ++++++++++++++-- src/version.c | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/register.c b/src/register.c index f381e303be..8a4ae67489 100644 --- a/src/register.c +++ b/src/register.c @@ -832,8 +832,9 @@ insert_reg( if ((State & REPLACE_FLAG) != 0) { pos_T curpos; - u_save_cursor(); - del_bytes((long)STRLEN(y_current->y_array[0]), TRUE, FALSE); + if (u_save_cursor() == FAIL) + return FAIL; + del_chars((long)mb_charlen(y_current->y_array[0]), TRUE); curpos = curwin->w_cursor; if (oneright() == FAIL) // hit end of line, need to put forward (after the current position) diff --git a/src/testdir/test_registers.vim b/src/testdir/test_registers.vim index 50f39107b4..367d914987 100644 --- a/src/testdir/test_registers.vim +++ b/src/testdir/test_registers.vim @@ -949,7 +949,7 @@ endfunc func Test_insert_small_delete_replace_mode() new call setline(1, ['foo', 'bar', 'foobar', 'bar']) - let @-='foo' + let @- = 'foo' call cursor(2, 1) exe ":norm! R\-\-" call assert_equal('foofoo', getline(2)) @@ -960,9 +960,21 @@ func Test_insert_small_delete_replace_mode() exe ":norm! R\-ZZZZ" call assert_equal(['foo', 'foofoo', '', 'bfoobarZZZZ'], getline(1, 4)) call cursor(1, 1) - let @-='' + let @- = '' exe ":norm! R\-ZZZ" call assert_equal(['ZZZ', 'foofoo', '', 'bfoobarZZZZ'], getline(1, 4)) + let @- = 'βbβ' + call cursor(4, 1) + exe ":norm! R\-" + call assert_equal(['ZZZ', 'foofoo', '', 'βbβobarZZZZ'], getline(1, 4)) + let @- = 'bβb' + call cursor(4, 1) + exe ":norm! R\-" + call assert_equal(['ZZZ', 'foofoo', '', 'bβbobarZZZZ'], getline(1, 4)) + let @- = 'βbβ' + call cursor(4, 1) + exe ":norm! R\-" + call assert_equal(['ZZZ', 'foofoo', '', 'βbβobarZZZZ'], getline(1, 4)) bwipe! endfunc diff --git a/src/version.c b/src/version.c index 76a7668b0e..b221faaae0 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 21, /**/ 20, /**/ From 49471963fefbdf78239d9066d84e14e1876fb177 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Fri, 12 Jan 2024 17:48:08 +0100 Subject: [PATCH 036/143] patch 9.1.0022: Coverity complains about improper use of negative value Problem: Coverity complains about improper use of negative value Solution: Add a condition to validate that keytyped is larger or equal to 0 Apparently patch 9.1.0006 made it more explicit for Coverity, that the TOLOWER_LOC() macros do not handle negative values properly. However, that condition has always been there even before that, so add a condition to verify that keytyped is indeed at least 0 closes: #13824 Signed-off-by: Christian Brabandt --- src/cindent.c | 3 ++- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cindent.c b/src/cindent.c index 62894228b1..cf18441f60 100644 --- a/src/cindent.c +++ b/src/cindent.c @@ -4108,7 +4108,8 @@ in_cinkeys( } else // TODO: multi-byte - if (keytyped == (int)p[-1] || (icase && keytyped < 256 + if (keytyped == (int)p[-1] || (icase + && keytyped < 256 && keytyped >= 0 && TOLOWER_LOC(keytyped) == TOLOWER_LOC((int)p[-1]))) { line = ml_get_cursor(); diff --git a/src/version.c b/src/version.c index b221faaae0..562ba1317d 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 22, /**/ 21, /**/ From 48a75f3dfb906a2d333a7b1c3545e2eb359596db Mon Sep 17 00:00:00 2001 From: Igor Todorovski Date: Tue, 9 Jan 2024 21:05:48 +0000 Subject: [PATCH 037/143] patch 9.1.0023: xxd: few problems with EBCDIC for z/OS (MVS) Problem: xxd: few problems with EBCDIC for z/OS (MVS) Solution: Fix xxd build and support ASCII and UTF-8 on z/OS (MVS) natively, add MVS guard checks with __CHARSET_LIB, support $LIBS in the Makefile (Igor Todorovski) related: #13821 Signed-off-by: Igor Todorovski Signed-off-by: Christian Brabandt --- src/version.c | 2 ++ src/xxd/Makefile | 2 +- src/xxd/xxd.c | 13 +++++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/version.c b/src/version.c index 562ba1317d..0099da595f 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 23, /**/ 22, /**/ diff --git a/src/xxd/Makefile b/src/xxd/Makefile index 97bbcc77bc..d08af7aa01 100644 --- a/src/xxd/Makefile +++ b/src/xxd/Makefile @@ -1,7 +1,7 @@ # The most simplistic Makefile xxd: xxd.c - $(CC) $(CFLAGS) $(LDFLAGS) -DUNIX -o xxd xxd.c + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DUNIX -o xxd xxd.c $(LIBS) clean: rm -f xxd xxd.o diff --git a/src/xxd/xxd.c b/src/xxd/xxd.c index 26f8d8365d..20023e0ee1 100644 --- a/src/xxd/xxd.c +++ b/src/xxd/xxd.c @@ -58,6 +58,7 @@ * 20.06.2022 Permit setting the variable names used by -i by David Gow * 31.08.2023 -R never/auto/always prints colored output * 06.10.2023 enable -r -b to reverse bit dumps + * 12.01.2024 disable auto-conversion for z/OS (MVS) * * (c) 1990-1998 by Juergen Weigert (jnweiger@gmail.com) * @@ -138,7 +139,7 @@ extern void perror __P((char *)); # endif #endif -char version[] = "xxd 2023-10-25 by Juergen Weigert et al."; +char version[] = "xxd 2024-01-12 by Juergen Weigert et al."; #ifdef WIN32 char osver[] = " (Win32)"; #else @@ -587,7 +588,7 @@ begin_coloring_char (char *l, int *c, int e, int ebcdic) } else /* ASCII */ { - #ifdef __MVS__ + #if defined(__MVS__) && __CHARSET_LIB == 0 if (e >= 64) l[(*c)++] = COLOR_GREEN; #else @@ -905,6 +906,10 @@ main(int argc, char *argv[]) } rewind(fpo); } +#ifdef __MVS__ + // Disable auto-conversion on input file descriptors + __disableautocvt(fileno(fp)); +#endif if (revert) switch (hextype) @@ -1066,7 +1071,7 @@ main(int argc, char *argv[]) COLOR_PROLOGUE begin_coloring_char(l,&c,e,ebcdic); -#ifdef __MVS__ +#if defined(__MVS__) && __CHARSET_LIB == 0 if (e >= 64) l[c++] = e; else @@ -1094,7 +1099,7 @@ main(int argc, char *argv[]) c += addrlen + 3 + p; l[c++] = -#ifdef __MVS__ +#if defined(__MVS__) && __CHARSET_LIB == 0 (e >= 64) #else (e > 31 && e < 127) From 497e5282b6d21b99c01c6ecc6bf41b9b1781df6a Mon Sep 17 00:00:00 2001 From: Igor Todorovski Date: Fri, 12 Jan 2024 17:59:18 +0100 Subject: [PATCH 038/143] patch 9.1.0024: z/OS (MVS) support can be improved Problem: z/OS (MVS) support can be improved Solution: set UTF-8 as the default encoding for z/OS closes: #13821 Signed-off-by: Igor Todorovski Signed-off-by: Christian Brabandt --- src/option.c | 3 ++- src/option.h | 2 +- src/version.c | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/option.c b/src/option.c index 2372c1aa9b..14447f59ba 100644 --- a/src/option.c +++ b/src/option.c @@ -450,9 +450,10 @@ set_init_default_encoding(void) char_u *p; int opt_idx; -# ifdef MSWIN +# if defined(MSWIN) || defined(__MVS__) // MS-Windows has builtin support for conversion to and from Unicode, using // "utf-8" for 'encoding' should work best for most users. + // z/OS built should default to UTF-8 mode as setlocale does not respect utf-8 environment variable locales p = vim_strsave((char_u *)ENC_DFLT); # else // enc_locale() will try to find the encoding of the current locale. diff --git a/src/option.h b/src/option.h index 646056bf11..0cf6a8cf6d 100644 --- a/src/option.h +++ b/src/option.h @@ -130,7 +130,7 @@ typedef enum { #define ENC_UCSBOM "ucs-bom" // check for BOM at start of file // default value for 'encoding' -#ifdef MSWIN +#if defined(MSWIN) || defined(__MVS__) # define ENC_DFLT "utf-8" #else # define ENC_DFLT "latin1" diff --git a/src/version.c b/src/version.c index 0099da595f..5fba3dec25 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 24, /**/ 23, /**/ From dc4c37b9d5130c777b377287b8b38cd24da084cb Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 12 Jan 2024 18:02:10 +0100 Subject: [PATCH 039/143] patch 9.1.0025: A few typos in tests and justify.vim Problem: A few typos in tests and justify.vim Solution: fix them closes: #13848 Signed-off-by: dundargoc Signed-off-by: Christian Brabandt --- runtime/pack/dist/opt/justify/plugin/justify.vim | 2 +- src/testdir/test_normal.vim | 2 +- src/version.c | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/pack/dist/opt/justify/plugin/justify.vim b/runtime/pack/dist/opt/justify/plugin/justify.vim index 4ef3bf95fa..57be790423 100644 --- a/runtime/pack/dist/opt/justify/plugin/justify.vim +++ b/runtime/pack/dist/opt/justify/plugin/justify.vim @@ -80,7 +80,7 @@ " conformant with :left, :right and :center. " " If joinspaces is set, an extra space is added after '.', '?' and '!'. -" If 'cpooptions' include 'j', extra space is only added after '.'. +" If 'cpoptions' include 'j', extra space is only added after '.'. " (This may on occasion conflict with maxspaces.) diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index 38ad8107b4..0fd53b501e 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -2235,7 +2235,7 @@ func Test_normal29_brace() [DATA] call assert_equal(expected, getline(1, '$')) - " Test with { in cpooptions + " Test with { in cpoptions %d call append(0, text) set cpo+={ diff --git a/src/version.c b/src/version.c index 5fba3dec25..c8f0bb9c38 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 25, /**/ 24, /**/ From d8cb1ddab7b8cb19267a8877d62bbe3a06626fa2 Mon Sep 17 00:00:00 2001 From: Ken Takata Date: Fri, 12 Jan 2024 18:09:43 +0100 Subject: [PATCH 040/143] patch 9.1.0026: win32: Windows default font lacking Problem: win32: Windows default font lacking (@clach04) Solution: Improve default font (Ken Takata) win32: Improve default font Currently, Fixedsys is the default font on Windows. It is not suitable for recent High DPI environments. * Change the default font to Consolas. * Allow to change the default font by the translation message. E.g.: ``` msgid "DefaultFontNameForWindows" msgstr "Courier New" ``` fixes: #12919 closes: #13266 Signed-off-by: Ken Takata Signed-off-by: Christian Brabandt --- src/gui_w32.c | 12 +------ src/os_mswin.c | 62 +++++++++++++++++++++++++++----- src/proto/os_mswin.pro | 1 + src/testdir/test_mswin_event.vim | 4 +-- src/version.c | 2 ++ 5 files changed, 59 insertions(+), 22 deletions(-) diff --git a/src/gui_w32.c b/src/gui_w32.c index eb4c841388..0935ecfd12 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -392,16 +392,6 @@ static int (WINAPI *pGetSystemMetricsForDpi)(int, UINT) = NULL; static DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT dpiContext) = NULL; static DPI_AWARENESS (WINAPI *pGetAwarenessFromDpiAwarenessContext)(DPI_AWARENESS_CONTEXT) = NULL; - static UINT WINAPI -stubGetDpiForSystem(void) -{ - HWND hwnd = GetDesktopWindow(); - HDC hdc = GetWindowDC(hwnd); - UINT dpi = GetDeviceCaps(hdc, LOGPIXELSY); - ReleaseDC(hwnd, hdc); - return dpi; -} - static int WINAPI stubGetSystemMetricsForDpi(int nIndex, UINT dpi UNUSED) { @@ -5286,7 +5276,7 @@ load_dpi_func(void) fail: // Disable PerMonitorV2 APIs. - pGetDpiForSystem = stubGetDpiForSystem; + pGetDpiForSystem = vimGetDpiForSystem; pGetDpiForWindow = NULL; pGetSystemMetricsForDpi = stubGetSystemMetricsForDpi; pSetThreadDpiAwarenessContext = NULL; diff --git a/src/os_mswin.c b/src/os_mswin.c index 21b7db31f3..512fa40896 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -2747,19 +2747,22 @@ quality_id2name(DWORD id) return qp->name; } +// The default font height in 100% scaling (96dpi). +// (-12 in 96dpi equates to roughly 9pt) +#define DEFAULT_FONT_HEIGHT (-12) + static const LOGFONTW s_lfDefault = { - -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, + DEFAULT_FONT_HEIGHT, + 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FIXED_PITCH | FF_DONTCARE, - L"Fixedsys" // see _ReadVimIni + L"" // Default font name will be set later based on current language. }; -// Initialise the "current height" to -12 (same as s_lfDefault) just -// in case the user specifies a font in "guifont" with no size before a font -// with an explicit size has been set. This defaults the size to this value -// (-12 equates to roughly 9pt). -int current_font_height = -12; // also used in gui_w32.c +// This will be initialized when set_default_logfont() is called first time. +// The value will be based on the system DPI. +int current_font_height = 0; // also used in gui_w32.c /* * Convert a string representing a point size into pixels. The string should @@ -3026,6 +3029,47 @@ utf16ascncmp(const WCHAR *w, const char *p, size_t n) return 0; } +/* + * Equivalent of GetDpiForSystem(). + */ + UINT WINAPI +vimGetDpiForSystem(void) +{ + HWND hwnd = GetDesktopWindow(); + HDC hdc = GetWindowDC(hwnd); + UINT dpi = GetDeviceCaps(hdc, LOGPIXELSY); + ReleaseDC(hwnd, hdc); + return dpi; +} + +/* + * Set default logfont based on current language. + */ + static void +set_default_logfont(LOGFONTW *lf) +{ + // Default font name for current language on MS-Windows. + // If not translated, falls back to "Consolas". + // This must be a fixed-pitch font. + const char *defaultfontname = N_("DefaultFontNameForWindows"); + char *fontname = _(defaultfontname); + + if (strcmp(fontname, defaultfontname) == 0) + fontname = "Consolas"; + + *lf = s_lfDefault; + lf->lfHeight = DEFAULT_FONT_HEIGHT * (int)vimGetDpiForSystem() / 96; + if (current_font_height == 0) + current_font_height = lf->lfHeight; + + WCHAR *wfontname = enc_to_utf16((char_u*)fontname, NULL); + if (wfontname != NULL) + { + wcscpy_s(lf->lfFaceName, LF_FACESIZE, wfontname); + vim_free(wfontname); + } +} + /* * Get font info from "name" into logfont "lf". * Return OK for a valid name, FAIL otherwise. @@ -3043,7 +3087,7 @@ get_logfont( static LOGFONTW *lastlf = NULL; WCHAR *wname; - *lf = s_lfDefault; + set_default_logfont(lf); if (name == NULL) return OK; @@ -3083,7 +3127,7 @@ get_logfont( lf->lfFaceName[p - wname] = NUL; // First set defaults - lf->lfHeight = -12; + lf->lfHeight = DEFAULT_FONT_HEIGHT * (int)vimGetDpiForSystem() / 96; lf->lfWidth = 0; lf->lfWeight = FW_NORMAL; lf->lfItalic = FALSE; diff --git a/src/proto/os_mswin.pro b/src/proto/os_mswin.pro index 17a9ba25ee..47310104b8 100644 --- a/src/proto/os_mswin.pro +++ b/src/proto/os_mswin.pro @@ -51,6 +51,7 @@ void serverProcessPendingMessages(void); char *charset_id2name(int id); char *quality_id2name(DWORD id); void gui_mch_expand_font(optexpand_T *args, void *param, int (*add_match)(char_u *val)); +UINT WINAPI vimGetDpiForSystem(void); int get_logfont(LOGFONTW *lf, char_u *name, HDC printer_dc, int verbose); void channel_init_winsock(void); /* vim: set ft=c : */ diff --git a/src/testdir/test_mswin_event.vim b/src/testdir/test_mswin_event.vim index 4de016953e..b6609937c0 100644 --- a/src/testdir/test_mswin_event.vim +++ b/src/testdir/test_mswin_event.vim @@ -727,14 +727,14 @@ func Test_mswin_event_mouse() if has('gui_running') let args = { } let args.row = 9 - let args.col = 7 + let args.col = 5 let args.move = 1 let args.cell = 1 call test_mswin_event("mouse", args) call feedkeys("\", 'Lx!') let pos = getmousepos() call assert_equal(9, pos.screenrow) - call assert_equal(7, pos.screencol) + call assert_equal(5, pos.screencol) let args.cell = 0 call test_mswin_event("mouse", args) diff --git a/src/version.c b/src/version.c index c8f0bb9c38..6216b2f033 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 26, /**/ 25, /**/ From e79e2077607e8f829ba823308c91104a795736ba Mon Sep 17 00:00:00 2001 From: Ernie Rael Date: Sat, 13 Jan 2024 11:47:33 +0100 Subject: [PATCH 041/143] patch 9.1.0027: Vim is missing a foreach() func Problem: Vim is missing a foreach() func Solution: Implement foreach({expr1}, {expr2}) function, which applies {expr2} for each item in {expr1} without changing it (Ernie Rael) closes: #12166 Signed-off-by: Ernie Rael Signed-off-by: Christian Brabandt --- runtime/doc/builtin.txt | 43 +++++++++- runtime/doc/tags | 2 + runtime/doc/usr_41.txt | 4 +- src/blob.c | 37 +++++---- src/dict.c | 5 +- src/evalfunc.c | 35 ++++++-- src/list.c | 83 +++++++++++++------ src/proto/list.pro | 1 + src/strings.c | 5 +- src/structs.h | 5 +- src/testdir/test_filter_map.vim | 142 +++++++++++++++++++++++++++++++- src/version.c | 2 + 12 files changed, 303 insertions(+), 61 deletions(-) diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 9ac79c611b..4bbf5066fa 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1,4 +1,4 @@ -*builtin.txt* For Vim version 9.1. Last change: 2024 Jan 05 +*builtin.txt* For Vim version 9.1. Last change: 2024 Jan 13 VIM REFERENCE MANUAL by Bram Moolenaar @@ -198,6 +198,8 @@ foldclosedend({lnum}) Number last line of fold at {lnum} if closed foldlevel({lnum}) Number fold level at {lnum} foldtext() String line displayed for closed fold foldtextresult({lnum}) String text for closed fold at {lnum} +foreach({expr1}, {expr2}) List/Dict/Blob/String + for each item in {expr1} call {expr2} foreground() Number bring the Vim window to the foreground fullcommand({name} [, {vim9}]) String get full command from {name} funcref({name} [, {arglist}] [, {dict}]) @@ -2995,6 +2997,45 @@ foldtextresult({lnum}) *foldtextresult()* Can also be used as a |method|: > GetLnum()->foldtextresult() + +foreach({expr1}, {expr2}) *foreach()* + {expr1} must be a |List|, |String|, |Blob| or |Dictionary|. + For each item in {expr1} execute {expr2}. {expr1} is not + modified; its values may be, as with |:lockvar| 1. *E741* + See |map()| and |filter()| to modify {expr1}. + + {expr2} must be a |string| or |Funcref|. + + If {expr2} is a |string|, inside {expr2} |v:val| has the value + of the current item. For a |Dictionary| |v:key| has the key + of the current item and for a |List| |v:key| has the index of + the current item. For a |Blob| |v:key| has the index of the + current byte. For a |String| |v:key| has the index of the + current character. + Examples: > + call foreach(mylist, 'used[v:val] = true') +< This records the items that are in the {expr1} list. + + Note that {expr2} is the result of expression and is then used + as a command. Often it is good to use a |literal-string| to + avoid having to double backslashes. + + If {expr2} is a |Funcref| it must take two arguments: + 1. the key or the index of the current item. + 2. the value of the current item. + With a legacy script lambda you don't get an error if it only + accepts one argument, but with a Vim9 lambda you get "E1106: + One argument too many", the number of arguments must match. + If the function returns a value, it is ignored. + + Returns {expr1} in all cases. + When an error is encountered while executing {expr2} no + further items in {expr1} are processed. + When {expr2} is a Funcref errors inside a function are ignored, + unless it was defined with the "abort" flag. + + Can also be used as a |method|: > + mylist->foreach(expr2) < *foreground()* foreground() Move the Vim window to the foreground. Useful when sent from diff --git a/runtime/doc/tags b/runtime/doc/tags index b3691bb93f..40b90c0850 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -5167,6 +5167,7 @@ E738 eval.txt /*E738* E739 builtin.txt /*E739* E74 message.txt /*E74* E740 userfunc.txt /*E740* +E741 builtin.txt /*E741* E741 eval.txt /*E741* E742 userfunc.txt /*E742* E743 eval.txt /*E743* @@ -7148,6 +7149,7 @@ foldtextresult() builtin.txt /*foldtextresult()* font-sizes gui_x11.txt /*font-sizes* fontset mbyte.txt /*fontset* forced-motion motion.txt /*forced-motion* +foreach() builtin.txt /*foreach()* foreground() builtin.txt /*foreground()* fork os_unix.txt /*fork* form.vim syntax.txt /*form.vim* diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 2286d48516..0990a06513 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -1,4 +1,4 @@ -*usr_41.txt* For Vim version 9.1. Last change: 2023 May 06 +*usr_41.txt* For Vim version 9.1. Last change: 2024 Jan 13 VIM USER MANUAL - by Bram Moolenaar @@ -798,6 +798,7 @@ List manipulation: *list-functions* filter() remove selected items from a List map() change each List item mapnew() make a new List with changed items + foreach() apply function to List items reduce() reduce a List to a value slice() take a slice of a List sort() sort a List @@ -829,6 +830,7 @@ Dictionary manipulation: *dict-functions* filter() remove selected entries from a Dictionary map() change each Dictionary entry mapnew() make a new Dictionary with changed items + foreach() apply function to Dictionary items keys() get List of Dictionary keys values() get List of Dictionary values items() get List of Dictionary key-value pairs diff --git a/src/blob.c b/src/blob.c index c5d7eaed64..9cdd504b6e 100644 --- a/src/blob.c +++ b/src/blob.c @@ -641,25 +641,28 @@ blob_filter_map( if (filter_map_one(&tv, expr, filtermap, fc, &newtv, &rem) == FAIL || did_emsg) break; - if (newtv.v_type != VAR_NUMBER && newtv.v_type != VAR_BOOL) + if (filtermap != FILTERMAP_FOREACH) { - clear_tv(&newtv); - emsg(_(e_invalid_operation_for_blob)); - break; - } - if (filtermap != FILTERMAP_FILTER) - { - if (newtv.vval.v_number != val) - blob_set(b_ret, i, newtv.vval.v_number); - } - else if (rem) - { - char_u *p = (char_u *)blob_arg->bv_ga.ga_data; + if (newtv.v_type != VAR_NUMBER && newtv.v_type != VAR_BOOL) + { + clear_tv(&newtv); + emsg(_(e_invalid_operation_for_blob)); + break; + } + if (filtermap != FILTERMAP_FILTER) + { + if (newtv.vval.v_number != val) + blob_set(b_ret, i, newtv.vval.v_number); + } + else if (rem) + { + char_u *p = (char_u *)blob_arg->bv_ga.ga_data; - mch_memmove(p + i, p + i + 1, - (size_t)b->bv_ga.ga_len - i - 1); - --b->bv_ga.ga_len; - --i; + mch_memmove(p + i, p + i + 1, + (size_t)b->bv_ga.ga_len - i - 1); + --b->bv_ga.ga_len; + --i; + } } ++idx; } diff --git a/src/dict.c b/src/dict.c index cb22b42c91..508d00cdf7 100644 --- a/src/dict.c +++ b/src/dict.c @@ -1329,8 +1329,8 @@ dict_extend_func( } /* - * Implementation of map() and filter() for a Dict. Apply "expr" to every - * item in Dict "d" and return the result in "rettv". + * Implementation of map(), filter(), foreach() for a Dict. Apply "expr" to + * every item in Dict "d" and return the result in "rettv". */ void dict_filter_map( @@ -1392,7 +1392,6 @@ dict_filter_map( arg_errmsg, TRUE))) break; set_vim_var_string(VV_KEY, di->di_key, -1); - newtv.v_type = VAR_UNKNOWN; r = filter_map_one(&di->di_tv, expr, filtermap, fc, &newtv, &rem); clear_tv(get_vim_var_tv(VV_KEY)); if (r == FAIL || did_emsg) diff --git a/src/evalfunc.c b/src/evalfunc.c index e37b3a412a..9b3bdf756d 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -607,10 +607,11 @@ arg_list_or_dict_or_blob_or_string_mod( } /* - * Check second argument of map() or filter(). + * Check second argument of map(), filter(), foreach(). */ static int -check_map_filter_arg2(type_T *type, argcontext_T *context, int is_map) +check_map_filter_arg2(type_T *type, argcontext_T *context, + filtermap_T filtermap) { type_T *expected_member = NULL; type_T *(args[2]); @@ -663,12 +664,14 @@ check_map_filter_arg2(type_T *type, argcontext_T *context, int is_map) { where_T where = WHERE_INIT; - if (is_map) + if (filtermap == FILTERMAP_MAP) t_func_exp.tt_member = expected_member == NULL || type_any_or_unknown(type->tt_member) ? &t_any : expected_member; - else + else if (filtermap == FILTERMAP_FILTER) t_func_exp.tt_member = &t_bool; + else // filtermap == FILTERMAP_FOREACH + t_func_exp.tt_member = &t_unknown; if (args[0] == NULL) args[0] = &t_unknown; if (type->tt_argcount == -1) @@ -693,7 +696,7 @@ arg_filter_func(type_T *type, type_T *decl_type UNUSED, argcontext_T *context) return OK; if (type->tt_type == VAR_FUNC) - return check_map_filter_arg2(type, context, FALSE); + return check_map_filter_arg2(type, context, FILTERMAP_FILTER); semsg(_(e_string_or_function_required_for_argument_nr), 2); return FAIL; } @@ -710,7 +713,24 @@ arg_map_func(type_T *type, type_T *decl_type UNUSED, argcontext_T *context) return OK; if (type->tt_type == VAR_FUNC) - return check_map_filter_arg2(type, context, TRUE); + return check_map_filter_arg2(type, context, FILTERMAP_MAP); + semsg(_(e_string_or_function_required_for_argument_nr), 2); + return FAIL; +} + +/* + * Check second argument of foreach(), the function. + */ + static int +arg_foreach_func(type_T *type, type_T *decl_type UNUSED, argcontext_T *context) +{ + if (type->tt_type == VAR_STRING + || type->tt_type == VAR_PARTIAL + || type_any_or_unknown(type)) + return OK; + + if (type->tt_type == VAR_FUNC) + return check_map_filter_arg2(type, context, FILTERMAP_FOREACH); semsg(_(e_string_or_function_required_for_argument_nr), 2); return FAIL; } @@ -1173,6 +1193,7 @@ static argcheck_T arg1_len[] = {arg_len1}; static argcheck_T arg3_libcall[] = {arg_string, arg_string, arg_string_or_nr}; static argcheck_T arg14_maparg[] = {arg_string, arg_string, arg_bool, arg_bool}; static argcheck_T arg2_filter[] = {arg_list_or_dict_or_blob_or_string_mod, arg_filter_func}; +static argcheck_T arg2_foreach[] = {arg_list_or_dict_or_blob_or_string, arg_foreach_func}; static argcheck_T arg2_instanceof[] = {arg_object, varargs_class, NULL }; static argcheck_T arg2_map[] = {arg_list_or_dict_or_blob_or_string_mod, arg_map_func}; static argcheck_T arg2_mapnew[] = {arg_list_or_dict_or_blob_or_string, arg_any}; @@ -2013,6 +2034,8 @@ static funcentry_T global_functions[] = ret_string, f_foldtext}, {"foldtextresult", 1, 1, FEARG_1, arg1_lnum, ret_string, f_foldtextresult}, + {"foreach", 2, 2, FEARG_1, arg2_foreach, + ret_first_arg, f_foreach}, {"foreground", 0, 0, 0, NULL, ret_void, f_foreground}, {"fullcommand", 1, 2, FEARG_1, arg2_string_bool, diff --git a/src/list.c b/src/list.c index b50cb03c98..e9f1ae3206 100644 --- a/src/list.c +++ b/src/list.c @@ -2325,7 +2325,7 @@ f_uniq(typval_T *argvars, typval_T *rettv) } /* - * Handle one item for map() and filter(). + * Handle one item for map(), filter(), foreach(). * Sets v:val to "tv". Caller must set v:key. */ int @@ -2341,6 +2341,17 @@ filter_map_one( int retval = FAIL; copy_tv(tv, get_vim_var_tv(VV_VAL)); + + newtv->v_type = VAR_UNKNOWN; + if (filtermap == FILTERMAP_FOREACH && expr->v_type == VAR_STRING) + { + // foreach() is not limited to an expression + do_cmdline_cmd(expr->vval.v_string); + if (!did_emsg) + retval = OK; + goto theend; + } + argv[0] = *get_vim_var_tv(VV_KEY); argv[1] = *get_vim_var_tv(VV_VAL); if (eval_expr_typval(expr, FALSE, argv, 2, fc, newtv) == FAIL) @@ -2360,6 +2371,8 @@ filter_map_one( if (error) goto theend; } + else if (filtermap == FILTERMAP_FOREACH) + clear_tv(newtv); retval = OK; theend: clear_tv(get_vim_var_tv(VV_VAL)); @@ -2367,8 +2380,8 @@ theend: } /* - * Implementation of map() and filter() for a List. Apply "expr" to every item - * in List "l" and return the result in "rettv". + * Implementation of map(), filter(), foreach() for a List. Apply "expr" to + * every item in List "l" and return the result in "rettv". */ static void list_filter_map( @@ -2421,7 +2434,8 @@ list_filter_map( int stride = l->lv_u.nonmat.lv_stride; // List from range(): loop over the numbers - if (filtermap != FILTERMAP_MAPNEW) + // NOTE: foreach() returns the range_list_item + if (filtermap != FILTERMAP_MAPNEW && filtermap != FILTERMAP_FOREACH) { l->lv_first = NULL; l->lv_u.mat.lv_last = NULL; @@ -2444,27 +2458,30 @@ list_filter_map( clear_tv(&newtv); break; } - if (filtermap != FILTERMAP_FILTER) + if (filtermap != FILTERMAP_FOREACH) { - if (filtermap == FILTERMAP_MAP && argtype != NULL - && check_typval_arg_type( - argtype->tt_member, &newtv, - func_name, 0) == FAIL) + if (filtermap != FILTERMAP_FILTER) { - clear_tv(&newtv); - break; + if (filtermap == FILTERMAP_MAP && argtype != NULL + && check_typval_arg_type( + argtype->tt_member, &newtv, + func_name, 0) == FAIL) + { + clear_tv(&newtv); + break; + } + // map(), mapnew(): always append the new value to the + // list + if (list_append_tv_move(filtermap == FILTERMAP_MAP + ? l : l_ret, &newtv) == FAIL) + break; + } + else if (!rem) + { + // filter(): append the list item value when not rem + if (list_append_tv_move(l, &tv) == FAIL) + break; } - // map(), mapnew(): always append the new value to the - // list - if (list_append_tv_move(filtermap == FILTERMAP_MAP - ? l : l_ret, &newtv) == FAIL) - break; - } - else if (!rem) - { - // filter(): append the list item value when not rem - if (list_append_tv_move(l, &tv) == FAIL) - break; } val += stride; @@ -2508,7 +2525,7 @@ list_filter_map( break; } else if (filtermap == FILTERMAP_FILTER && rem) - listitem_remove(l, li); + listitem_remove(l, li); ++idx; } } @@ -2519,7 +2536,7 @@ list_filter_map( } /* - * Implementation of map() and filter(). + * Implementation of map(), filter() and foreach(). */ static void filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap) @@ -2527,16 +2544,19 @@ filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap) typval_T *expr; char *func_name = filtermap == FILTERMAP_MAP ? "map()" : filtermap == FILTERMAP_MAPNEW ? "mapnew()" - : "filter()"; + : filtermap == FILTERMAP_FILTER ? "filter()" + : "foreach()"; char_u *arg_errmsg = (char_u *)(filtermap == FILTERMAP_MAP ? N_("map() argument") : filtermap == FILTERMAP_MAPNEW ? N_("mapnew() argument") - : N_("filter() argument")); + : filtermap == FILTERMAP_FILTER + ? N_("filter() argument") + : N_("foreach() argument")); int save_did_emsg; type_T *type = NULL; - // map() and filter() return the first argument, also on failure. + // map(), filter(), foreach() return the first argument, also on failure. if (filtermap != FILTERMAP_MAPNEW && argvars[0].v_type != VAR_STRING) copy_tv(&argvars[0], rettv); @@ -2629,6 +2649,15 @@ f_mapnew(typval_T *argvars, typval_T *rettv) filter_map(argvars, rettv, FILTERMAP_MAPNEW); } +/* + * "foreach()" function + */ + void +f_foreach(typval_T *argvars, typval_T *rettv) +{ + filter_map(argvars, rettv, FILTERMAP_FOREACH); +} + /* * "add(list, item)" function */ diff --git a/src/proto/list.pro b/src/proto/list.pro index 5abe03c096..0b58c692a4 100644 --- a/src/proto/list.pro +++ b/src/proto/list.pro @@ -56,6 +56,7 @@ int filter_map_one(typval_T *tv, typval_T *expr, filtermap_T filtermap, funccall void f_filter(typval_T *argvars, typval_T *rettv); void f_map(typval_T *argvars, typval_T *rettv); void f_mapnew(typval_T *argvars, typval_T *rettv); +void f_foreach(typval_T *argvars, typval_T *rettv); void f_add(typval_T *argvars, typval_T *rettv); void f_count(typval_T *argvars, typval_T *rettv); void f_extend(typval_T *argvars, typval_T *rettv); diff --git a/src/strings.c b/src/strings.c index 0aeea4bce9..b38c3d0bd7 100644 --- a/src/strings.c +++ b/src/strings.c @@ -942,7 +942,6 @@ string_filter_map( break; len = (int)STRLEN(tv.vval.v_string); - newtv.v_type = VAR_UNKNOWN; set_vim_var_nr(VV_KEY, idx); if (filter_map_one(&tv, expr, filtermap, fc, &newtv, &rem) == FAIL || did_emsg) @@ -951,7 +950,7 @@ string_filter_map( clear_tv(&tv); break; } - else if (filtermap != FILTERMAP_FILTER) + if (filtermap == FILTERMAP_MAP || filtermap == FILTERMAP_MAPNEW) { if (newtv.v_type != VAR_STRING) { @@ -963,7 +962,7 @@ string_filter_map( else ga_concat(&ga, newtv.vval.v_string); } - else if (!rem) + else if (filtermap == FILTERMAP_FOREACH || !rem) ga_concat(&ga, tv.vval.v_string); clear_tv(&newtv); diff --git a/src/structs.h b/src/structs.h index 6d77deb454..85f440d35d 100644 --- a/src/structs.h +++ b/src/structs.h @@ -4879,11 +4879,12 @@ typedef struct { hashtab_T sve_hashtab; } save_v_event_T; -// Enum used by filter(), map() and mapnew() +// Enum used by filter(), map(), mapnew() and foreach() typedef enum { FILTERMAP_FILTER, FILTERMAP_MAP, - FILTERMAP_MAPNEW + FILTERMAP_MAPNEW, + FILTERMAP_FOREACH } filtermap_T; // Structure used by switch_win() to pass values to restore_win() diff --git a/src/testdir/test_filter_map.vim b/src/testdir/test_filter_map.vim index 6a07bec215..37ebe847b1 100644 --- a/src/testdir/test_filter_map.vim +++ b/src/testdir/test_filter_map.vim @@ -14,6 +14,18 @@ func Test_filter_map_list_expr_string() call assert_equal([0, 2, 4, 6], map([1, 2, 3, 4], 'v:key * 2')) call assert_equal([9, 9, 9, 9], map([1, 2, 3, 4], 9)) call assert_equal([7, 7, 7], map([1, 2, 3], ' 7 ')) + + " foreach() + let list01 = [1, 2, 3, 4] + let list02 = [] + call assert_equal([1, 2, 3, 4], foreach(list01, 'call add(list02, v:val * 2)')) + call assert_equal([2, 4, 6, 8], list02) + let list02 = [] + call assert_equal([1, 2, 3, 4], foreach(list01, 'call add(list02, v:key * 2)')) + call assert_equal([0, 2, 4, 6], list02) + let list02 = [] + call assert_equal([1, 2, 3, 4], foreach(list01, 'call add(list02, 9)')) + call assert_equal([9, 9, 9, 9], list02) endfunc " dict with expression string @@ -29,6 +41,14 @@ func Test_filter_map_dict_expr_string() call assert_equal({"foo": 2, "bar": 4, "baz": 6}, map(copy(dict), 'v:val * 2')) call assert_equal({"foo": "f", "bar": "b", "baz": "b"}, map(copy(dict), 'v:key[0]')) call assert_equal({"foo": 9, "bar": 9, "baz": 9}, map(copy(dict), 9)) + + " foreach() + let dict01 = {} + call assert_equal(dict, foreach(copy(dict), 'let dict01[v:key] = v:val * 2')) + call assert_equal({"foo": 2, "bar": 4, "baz": 6}, dict01) + let dict01 = {} + call assert_equal(dict, foreach(copy(dict), 'let dict01[v:key] = v:key[0]')) + call assert_equal({"foo": "f", "bar": "b", "baz": "b"}, dict01) endfunc " list with funcref @@ -54,6 +74,16 @@ func Test_filter_map_list_expr_funcref() return a:index * 2 endfunc call assert_equal([0, 2, 4, 6], map([1, 2, 3, 4], function('s:filter4'))) + + " foreach() + func! s:foreach1(index, val) abort + call add(g:test_variable, a:val + 1) + return [ 11, 12, 13, 14 ] + endfunc + let g:test_variable = [] + call assert_equal([0, 1, 2, 3, 4], foreach(range(5), function('s:foreach1'))) + call assert_equal([1, 2, 3, 4, 5], g:test_variable) + call remove(g:, 'test_variable') endfunc func Test_filter_map_nested() @@ -90,11 +120,46 @@ func Test_filter_map_dict_expr_funcref() return a:key[0] endfunc call assert_equal({"foo": "f", "bar": "b", "baz": "b"}, map(copy(dict), function('s:filter4'))) + + " foreach() + func! s:foreach1(key, val) abort + call extend(g:test_variable, {a:key: a:val * 2}) + return [ 11, 12, 13, 14 ] + endfunc + let g:test_variable = {} + call assert_equal(dict, foreach(copy(dict), function('s:foreach1'))) + call assert_equal({"foo": 2, "bar": 4, "baz": 6}, g:test_variable) + call remove(g:, 'test_variable') +endfunc + +func Test_map_filter_locked() + let list01 = [1, 2, 3, 4] + lockvar 1 list01 + call assert_fails('call filter(list01, "v:val > 1")', 'E741:') + call assert_equal([2, 4, 6, 8], map(list01, 'v:val * 2')) + call assert_equal([1, 2, 3, 4], map(list01, 'v:val / 2')) + call assert_equal([2, 4, 6, 8], mapnew(list01, 'v:val * 2')) + let g:test_variable = [] + call assert_equal([1, 2, 3, 4], foreach(list01, 'call add(g:test_variable, v:val * 2)')) + call remove(g:, 'test_variable') + call assert_fails('call filter(list01, "v:val > 1")', 'E741:') + unlockvar 1 list01 + lockvar! list01 + call assert_fails('call filter(list01, "v:val > 1")', 'E741:') + call assert_fails('call map(list01, "v:val * 2")', 'E741:') + call assert_equal([2, 4, 6, 8], mapnew(list01, 'v:val * 2')) + let g:test_variable = [] + call assert_equal([1, 2, 3, 4], foreach(list01, 'call add(g:test_variable, v:val * 2)')) + call assert_fails('call foreach(list01, "let list01[0] = -1")', 'E741:') + call assert_fails('call filter(list01, "v:val > 1")', 'E741:') + call remove(g:, 'test_variable') + unlockvar! list01 endfunc func Test_map_filter_fails() call assert_fails('call map([1], "42 +")', 'E15:') call assert_fails('call filter([1], "42 +")', 'E15:') + call assert_fails('call foreach([1], "let a = }")', 'E15:') call assert_fails("let l = filter([1, 2, 3], '{}')", 'E728:') call assert_fails("let l = filter({'k' : 10}, '{}')", 'E728:') call assert_fails("let l = filter([1, 2], {})", 'E731:') @@ -106,6 +171,8 @@ func Test_map_filter_fails() call assert_fails("let l = filter([1, 2], function('min'))", 'E118:') call assert_equal([1, 2, 3], filter([1, 2, 3], test_null_partial())) call assert_fails("let l = filter([1, 2], {a, b, c -> 1})", 'E119:') + call assert_fails('call foreach([1], "xyzzy")', 'E492:') + call assert_fails('call foreach([1], "let a = foo")', 'E121:') endfunc func Test_map_and_modify() @@ -123,7 +190,7 @@ endfunc func Test_filter_and_modify() let l = [0] - " cannot change the list halfway a map() + " cannot change the list halfway thru filter() call assert_fails('call filter(l, "remove(l, 0)")', 'E741:') let d = #{a: 0, b: 0, c: 0} @@ -133,6 +200,18 @@ func Test_filter_and_modify() call assert_fails('call filter(b, "remove(b, 0)")', 'E741:') endfunc +func Test_foreach_and_modify() + let l = [0] + " cannot change the list halfway thru foreach() + call assert_fails('call foreach(l, "let a = remove(l, 0)")', 'E741:') + + let d = #{a: 0, b: 0, c: 0} + call assert_fails('call foreach(d, "let a = remove(d, v:key)")', 'E741:') + + let b = 0z1234 + call assert_fails('call foreach(b, "let a = remove(b, 0)")', 'E741:') +endfunc + func Test_mapnew_dict() let din = #{one: 1, two: 2} let dout = mapnew(din, {k, v -> string(v)}) @@ -160,6 +239,36 @@ func Test_mapnew_blob() call assert_equal(0z129956, bout) endfunc +func Test_foreach_blob() + let lines =<< trim END + LET g:test_variable = [] + call assert_equal(0z0001020304, foreach(0z0001020304, 'call add(g:test_variable, v:val)')) + call assert_equal([0, 1, 2, 3, 4], g:test_variable) + END + call v9.CheckLegacyAndVim9Success(lines) + + func! s:foreach1(index, val) abort + call add(g:test_variable, a:val) + return [ 11, 12, 13, 14 ] + endfunc + let g:test_variable = [] + call assert_equal(0z0001020304, foreach(0z0001020304, function('s:foreach1'))) + call assert_equal([0, 1, 2, 3, 4], g:test_variable) + + let lines =<< trim END + def Foreach1(_, val: any): list + add(g:test_variable, val) + return [ 11, 12, 13, 14 ] + enddef + g:test_variable = [] + assert_equal(0z0001020304, foreach(0z0001020304, Foreach1)) + assert_equal([0, 1, 2, 3, 4], g:test_variable) + END + call v9.CheckDefSuccess(lines) + + call remove(g:, 'test_variable') +endfunc + " Test for using map(), filter() and mapnew() with a string func Test_filter_map_string() " filter() @@ -219,6 +328,37 @@ func Test_filter_map_string() END call v9.CheckLegacyAndVim9Success(lines) + " foreach() + let lines =<< trim END + VAR s = "abc" + LET g:test_variable = [] + call assert_equal(s, foreach(s, 'call add(g:test_variable, v:val)')) + call assert_equal(['a', 'b', 'c'], g:test_variable) + LET g:test_variable = [] + LET s = 'ã‚iã†ãˆãŠ' + call assert_equal(s, foreach(s, 'call add(g:test_variable, v:val)')) + call assert_equal(['ã‚', 'i', 'ã†', 'ãˆ', 'ãŠ'], g:test_variable) + END + call v9.CheckLegacyAndVim9Success(lines) + func! s:foreach1(index, val) abort + call add(g:test_variable, a:val) + return [ 11, 12, 13, 14 ] + endfunc + let g:test_variable = [] + call assert_equal('abcd', foreach('abcd', function('s:foreach1'))) + call assert_equal(['a', 'b', 'c', 'd'], g:test_variable) + let lines =<< trim END + def Foreach1(_, val: string): list + add(g:test_variable, val) + return [ 11, 12, 13, 14 ] + enddef + g:test_variable = [] + assert_equal('abcd', foreach('abcd', Foreach1)) + assert_equal(['a', 'b', 'c', 'd'], g:test_variable) + END + call v9.CheckDefSuccess(lines) + call remove(g:, 'test_variable') + let lines =<< trim END #" map() and filter() call assert_equal('[ã‚][âˆ][a][😊][â‰][💕][💕][b][💕]', map(filter('ã‚xâˆax😊xâ‰ðŸ’•💕b💕x', '"x" != v:val'), '"[" .. v:val .. "]"')) diff --git a/src/version.c b/src/version.c index 6216b2f033..a17ae156b2 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 27, /**/ 26, /**/ From c92b8bed1fa632569c8358feb3b72dd6a0844ef7 Mon Sep 17 00:00:00 2001 From: errael Date: Sun, 14 Jan 2024 10:11:07 -0800 Subject: [PATCH 042/143] runtime(help): delete duplicate help tag E741 (#13861) Signed-off-by: Ernie Rael Signed-off-by: Christian Brabandt --- runtime/doc/builtin.txt | 2 +- runtime/doc/tags | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 4bbf5066fa..adb5dc4355 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -3001,7 +3001,7 @@ foldtextresult({lnum}) *foldtextresult()* foreach({expr1}, {expr2}) *foreach()* {expr1} must be a |List|, |String|, |Blob| or |Dictionary|. For each item in {expr1} execute {expr2}. {expr1} is not - modified; its values may be, as with |:lockvar| 1. *E741* + modified; its values may be, as with |:lockvar| 1. |E741| See |map()| and |filter()| to modify {expr1}. {expr2} must be a |string| or |Funcref|. diff --git a/runtime/doc/tags b/runtime/doc/tags index 40b90c0850..caa76bcc47 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -5167,7 +5167,6 @@ E738 eval.txt /*E738* E739 builtin.txt /*E739* E74 message.txt /*E74* E740 userfunc.txt /*E740* -E741 builtin.txt /*E741* E741 eval.txt /*E741* E742 userfunc.txt /*E742* E743 eval.txt /*E743* From 8102a4c463c21f3bba4f27f0dbc402b9850de915 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Sun, 14 Jan 2024 18:24:05 +0000 Subject: [PATCH 043/143] CI: Check help tags for errors (duplicates, missing, etc) (#13865) - Run the doc make html awk script, which also checks, that all referenced help tags exists. - Run the doc maketags awk script, which checks for duplicates - in case of any error in the previous two steps, exit the CI with an error and show the errors.log file, that is generated by the previous 2 steps Signed-off-by: Christian Brabandt --- .github/workflows/ci.yml | 7 ++++++- runtime/doc/maketags.awk | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b51cadeab0..0efadcf9b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -265,7 +265,12 @@ jobs: if: contains(matrix.extra, 'vimtags') run: | # This will exit with an error code if the generated vim tags differs from source. - git diff --exit-code -- runtime/doc/tags + ( + cd runtime/doc + git diff --exit-code -- tags + make html; rm *.html tags.ref; + test -f errors.log && exit 3; + ) - name: Generate gcov files if: matrix.coverage diff --git a/runtime/doc/maketags.awk b/runtime/doc/maketags.awk index c6b2cd91f3..20b2b081ad 100644 --- a/runtime/doc/maketags.awk +++ b/runtime/doc/maketags.awk @@ -21,6 +21,13 @@ NR == 1 { nf=split(FILENAME,f,".") gsub(/%/,"\\%"); nf=split($0,tag," "); + if (counttag[tag[1]] > 0) + { + print "==============" > "errors.log" + print "Duplicate Tag " tag[1] > "errors.log" + print "==============" > "errors.log" + } + counttag[tag[1]]++ tagkey[t]=tag[1];tagref[t]=tag[2];tagnum[t]=NR; print $1 " " $2 " line " NR >"tags.ref" n=split($2,w,"."); From 1f13fcc9342e66842bf9847d01e585ea2c2b6b30 Mon Sep 17 00:00:00 2001 From: GuyBrush Date: Sun, 14 Jan 2024 20:08:40 +0100 Subject: [PATCH 044/143] patch 9.1.0028: win32: Ctrl-D cannot be used to close a pipe Problem: win32: Ctrl-D cannot be used to close a pipe Solution: Properly detect Ctrl-D when reading from a pipe (GuyBrush) Enabling Ctrl-D for gvim pipeline input and apply defensive programming on account of PR #12752 so that once PR 12752 is merged, CTRL-D will keep on working closes: #13849 Signed-off-by: GuyBrush Signed-off-by: Christian Brabandt --- src/os_win32.c | 16 ++++++++++++++-- src/version.c | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/os_win32.c b/src/os_win32.c index dbfc4eeca7..3f2b3c3a4c 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -5176,7 +5176,7 @@ mch_system_piped(char *cmd, int options) { /* * For pipes: Check for CTRL-C: send interrupt signal to - * child. Check for CTRL-D: EOF, close pipe to child. + * child. */ if (len == 1 && cmd != NULL) { @@ -5186,10 +5186,22 @@ mch_system_piped(char *cmd, int options) // now put 9 as SIGKILL TerminateProcess(pi.hProcess, 9); } - if (ta_buf[ta_len] == Ctrl_D) + } + + /* + * Check for CTRL-D: EOF, close pipe to child. + * Ctrl_D may be decorated by _OnChar() + */ + if ((len == 1 || len == 4 ) && cmd != NULL) + { + if (ta_buf[0] == Ctrl_D + || (ta_buf[0] == CSI + && ta_buf[1] == KS_MODIFIER + && ta_buf[3] == Ctrl_D)) { CloseHandle(g_hChildStd_IN_Wr); g_hChildStd_IN_Wr = NULL; + len = 0; } } diff --git a/src/version.c b/src/version.c index a17ae156b2..f01cac8b7c 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 28, /**/ 27, /**/ From d7d560374b836e62e180914b6e85f0eb20557a54 Mon Sep 17 00:00:00 2001 From: Danek Duvall Date: Sun, 14 Jan 2024 20:19:59 +0100 Subject: [PATCH 045/143] patch 9.1.0029: Cannot act on various terminal response codes Problem: Cannot act on various terminal response codes Solution: Add the TerminalResponseAll autocommand (Danek Duvall) closes: #13829 Signed-off-by: Danek Duvall Signed-off-by: Christian Brabandt --- runtime/doc/autocmd.txt | 21 +++++++++++++++- runtime/doc/eval.txt | 27 ++++++++++++++------ runtime/doc/tags | 1 + runtime/doc/todo.txt | 5 +--- runtime/syntax/vim.vim | 3 ++- src/autocmd.c | 56 +++++++++++++++++++++++++++++++++++------ src/term.c | 10 ++++++++ src/version.c | 2 ++ src/vim.h | 1 + 9 files changed, 104 insertions(+), 22 deletions(-) diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 2ac0247bb0..0ace7b1dae 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -1,4 +1,4 @@ -*autocmd.txt* For Vim version 9.1. Last change: 2023 May 20 +*autocmd.txt* For Vim version 9.1. Last change: 2024 Jan 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -340,6 +340,7 @@ Name triggered by ~ |GUIEnter| after starting the GUI successfully |GUIFailed| after starting the GUI failed |TermResponse| after the terminal response to |t_RV| is received +|TermResponseAll| after the terminal response to |t_RV| and others is received |QuitPre| when using `:quit`, before deciding whether to exit |ExitPre| when using a command that may make Vim exit @@ -1220,6 +1221,24 @@ TermResponse After the response to |t_RV| is received from triggered halfway executing another event, especially if file I/O, a shell command or anything else that takes time is involved. + *TermResponseAll* +TermResponseAll After the response to |t_RV|, |t_RC|, |t_RS|, + |t_RB|, |t_RF|, or |t_u7| are received from + the terminal. The value of |v:termresponse|, + |v:termblinkresp|, |v:termstyleresp|, + |v:termrbgresp|, |v:termrfgresp|, and + |v:termu7resp|, correspondingly, can be used. + will be set to any of: + "version", + "cursorblink", + "cursorshape", + "background", + "foreground", + "ambiguouswidth" + Note that this event may be triggered halfway + executing another event, especially if file I/O, + a shell command or anything else that takes time + is involved. *TextChanged* TextChanged After a change was made to the text in the current buffer in Normal mode. That is after diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index d52f7fe169..9c12fb8504 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 9.1. Last change: 2023 Dec 09 +*eval.txt* For Vim version 9.1. Last change: 2024 Jan 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -2568,8 +2568,9 @@ v:termresponse The escape sequence returned by the terminal for the |t_RV| 'c', with only digits and ';' in between. When this option is set, the TermResponse autocommand event is fired, so that you can react to the response from the - terminal. You can use |terminalprops()| to see what Vim - figured out about the terminal. + terminal. The TermResponseAll event is also fired, with + set to "version". You can use |terminalprops()| to see + what Vim figured out about the terminal. The response from a new xterm is: "[> Pp ; Pv ; Pc c". Pp is the terminal type: 0 for vt100 and 1 for vt220. Pv is the patch level (since this was introduced in patch 95, it's @@ -2581,27 +2582,37 @@ v:termresponse The escape sequence returned by the terminal for the |t_RV| *v:termblinkresp* v:termblinkresp The escape sequence returned by the terminal for the |t_RC| termcap entry. This is used to find out whether the terminal - cursor is blinking. This is used by |term_getcursor()|. + cursor is blinking. This is used by |term_getcursor()|. When + this option is set, the TermResponseAll autocommand event is + fired, with set to "cursorblink". *v:termstyleresp* v:termstyleresp The escape sequence returned by the terminal for the |t_RS| termcap entry. This is used to find out what the shape of the - cursor is. This is used by |term_getcursor()|. + cursor is. This is used by |term_getcursor()|. When this + option is set, the TermResponseAll autocommand event is fired, + with set to "cursorshape". *v:termrbgresp* v:termrbgresp The escape sequence returned by the terminal for the |t_RB| termcap entry. This is used to find out what the terminal - background color is, see 'background'. + background color is; see 'background'. When this option is + set, the TermResponseAll autocommand event is fired, with + set to "background". *v:termrfgresp* v:termrfgresp The escape sequence returned by the terminal for the |t_RF| termcap entry. This is used to find out what the terminal - foreground color is. + foreground color is. When this option is set, the + TermResponseAll autocommand event is fired, with set + to "foreground". *v:termu7resp* v:termu7resp The escape sequence returned by the terminal for the |t_u7| termcap entry. This is used to find out what the terminal - does with ambiguous width characters, see 'ambiwidth'. + does with ambiguous width characters, see 'ambiwidth'. When + this option is set, the TermResponseAll autocommand event is + fired, with set to "ambiguouswidth". *v:testing* *testing-variable* v:testing Must be set before using `test_garbagecollect_now()`. diff --git a/runtime/doc/tags b/runtime/doc/tags index caa76bcc47..88518600f6 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -5706,6 +5706,7 @@ TabNew autocmd.txt /*TabNew* Tcl if_tcl.txt /*Tcl* TermChanged autocmd.txt /*TermChanged* TermResponse autocmd.txt /*TermResponse* +TermResponseAll autocmd.txt /*TermResponseAll* TermdebugStartPost terminal.txt /*TermdebugStartPost* TermdebugStartPre terminal.txt /*TermdebugStartPre* TermdebugStopPost terminal.txt /*TermdebugStopPost* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index 746488ecc4..c29ac2e2c0 100644 --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 9.1. Last change: 2023 Dec 14 +*todo.txt* For Vim version 9.1. Last change: 2024 Jan 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1121,9 +1121,6 @@ When t_Co is changed from termresponse, the OptionSet autocommand event isn't triggered. Use the code from the end of set_num_option() in set_color_count(). -Add another autocommand like TermResponse that is fired for the other terminal -responses, such as bg and fg. Use "bg", "fg", "blink", etc. for the name. - When using command line window, CmdlineLeave is triggered without CmdlineEnter. (xtal8, 2017 Oct 30, #2263) Add some way to get the nested state. Although CmdwinEnter is obviously diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 165a809596..12e6f34741 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -8,6 +8,7 @@ " 2023 Dec 10 by Vim Project (improve variable matching) " 2023 Dec 21 by Vim Project (improve ex command matching) " 2023 Dec 30 by Vim Project (:syntax improvements) +" 2024 Jan 14 by Vim Project (TermResponseAll autocommand) " Version: 9.0-25 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_VIM " Automatically generated keyword lists: {{{1 @@ -73,7 +74,7 @@ syn keyword vimErrSetting contained bioskey biosk conskey consk autoprint beauti " AutoCmd Events {{{2 syn case ignore -syn keyword vimAutoEvent contained BufAdd BufDelete BufFilePost BufHidden BufNew BufRead BufReadPost BufUnload BufWinLeave BufWrite BufWritePost CmdlineChanged CmdlineLeave CmdwinEnter ColorScheme CompleteChanged CompleteDonePre CursorHoldI CursorMovedI DiffUpdated DirChanged DirChangedPre EncodingChanged ExitPre FileAppendCmd FileAppendPost FileAppendPre FileChangedRO FileChangedShell FileChangedShellPost FileEncoding FileExplorer FileReadCmd FileReadPost FileReadPre FileType FileWriteCmd FileWritePost FileWritePre FilterReadPost FilterReadPre FilterWritePost FilterWritePre FocusGained FocusLost FuncUndefined GUIEnter GUIFailed InsertChange InsertCharPre InsertEnter InsertLeave InsertLeavePre MenuPopup ModeChanged OptionSet QuickFixCmdPost QuickFixCmdPre QuitPre RemoteReply SafeState SafeStateAgain SessionLoadPost ShellCmdPost ShellFilterPost SigUSR1 SourceCmd SourcePost SourcePre SpellFileMissing StdinReadPost StdinReadPre SwapExists Syntax TabClosed TabEnter TabLeave TabNew TermChanged TerminalOpen TerminalWinOpen TermResponse TextChanged TextChangedI TextChangedP TextChangedT TextYankPost User VimEnter VimLeave VimLeavePre VimResized VimResume VimSuspend WinClosed WinEnter WinLeave WinNew WinResized WinScrolled +syn keyword vimAutoEvent contained BufAdd BufDelete BufFilePost BufHidden BufNew BufRead BufReadPost BufUnload BufWinLeave BufWrite BufWritePost CmdlineChanged CmdlineLeave CmdwinEnter ColorScheme CompleteChanged CompleteDonePre CursorHoldI CursorMovedI DiffUpdated DirChanged DirChangedPre EncodingChanged ExitPre FileAppendCmd FileAppendPost FileAppendPre FileChangedRO FileChangedShell FileChangedShellPost FileEncoding FileExplorer FileReadCmd FileReadPost FileReadPre FileType FileWriteCmd FileWritePost FileWritePre FilterReadPost FilterReadPre FilterWritePost FilterWritePre FocusGained FocusLost FuncUndefined GUIEnter GUIFailed InsertChange InsertCharPre InsertEnter InsertLeave InsertLeavePre MenuPopup ModeChanged OptionSet QuickFixCmdPost QuickFixCmdPre QuitPre RemoteReply SafeState SafeStateAgain SessionLoadPost ShellCmdPost ShellFilterPost SigUSR1 SourceCmd SourcePost SourcePre SpellFileMissing StdinReadPost StdinReadPre SwapExists Syntax TabClosed TabEnter TabLeave TabNew TermChanged TerminalOpen TerminalWinOpen TermResponse TermResponseAll TextChanged TextChangedI TextChangedP TextChangedT TextYankPost User VimEnter VimLeave VimLeavePre VimResized VimResume VimSuspend WinClosed WinEnter WinLeave WinNew WinResized WinScrolled syn keyword vimAutoEvent contained BufCreate BufEnter BufFilePre BufLeave BufNewFile BufReadCmd BufReadPre BufWinEnter BufWipeout BufWriteCmd BufWritePre CmdlineEnter CmdUndefined CmdwinLeave ColorSchemePre CompleteDone CursorHold CursorMoved " Highlight commonly used Groupnames {{{2 diff --git a/src/autocmd.c b/src/autocmd.c index a78e78b024..8b8f109ea0 100644 --- a/src/autocmd.c +++ b/src/autocmd.c @@ -179,6 +179,7 @@ static struct event_name {"TerminalOpen", EVENT_TERMINALOPEN}, {"TerminalWinOpen", EVENT_TERMINALWINOPEN}, {"TermResponse", EVENT_TERMRESPONSE}, + {"TermResponseAll", EVENT_TERMRESPONSEALL}, {"TextChanged", EVENT_TEXTCHANGED}, {"TextChangedI", EVENT_TEXTCHANGEDI}, {"TextChangedP", EVENT_TEXTCHANGEDP}, @@ -2100,7 +2101,8 @@ apply_autocmds_group( { if (event == EVENT_COLORSCHEME || event == EVENT_COLORSCHEMEPRE || event == EVENT_OPTIONSET - || event == EVENT_MODECHANGED) + || event == EVENT_MODECHANGED + || event == EVENT_TERMRESPONSEALL) autocmd_fname = NULL; else if (fname != NULL && !ends_excmd(*fname)) autocmd_fname = fname; @@ -2180,7 +2182,8 @@ apply_autocmds_group( || event == EVENT_USER || event == EVENT_WINCLOSED || event == EVENT_WINRESIZED - || event == EVENT_WINSCROLLED) + || event == EVENT_WINSCROLLED + || event == EVENT_TERMRESPONSEALL) { fname = vim_strsave(fname); autocmd_fname_full = TRUE; // don't expand it later @@ -2418,6 +2421,11 @@ BYPASS_AU: # ifdef FEAT_EVAL static char_u *old_termresponse = NULL; +static char_u *old_termu7resp = NULL; +static char_u *old_termblinkresp = NULL; +static char_u *old_termrbgresp = NULL; +static char_u *old_termrfgresp = NULL; +static char_u *old_termstyleresp = NULL; # endif /* @@ -2430,7 +2438,14 @@ block_autocmds(void) # ifdef FEAT_EVAL // Remember the value of v:termresponse. if (autocmd_blocked == 0) + { old_termresponse = get_vim_var_str(VV_TERMRESPONSE); + old_termu7resp = get_vim_var_str(VV_TERMU7RESP); + old_termblinkresp = get_vim_var_str(VV_TERMBLINKRESP); + old_termrbgresp = get_vim_var_str(VV_TERMRBGRESP); + old_termrfgresp = get_vim_var_str(VV_TERMRFGRESP); + old_termstyleresp = get_vim_var_str(VV_TERMSTYLERESP); + } # endif ++autocmd_blocked; } @@ -2441,12 +2456,37 @@ unblock_autocmds(void) --autocmd_blocked; # ifdef FEAT_EVAL - // When v:termresponse was set while autocommands were blocked, trigger - // the autocommands now. Esp. useful when executing a shell command - // during startup (vimdiff). - if (autocmd_blocked == 0 - && get_vim_var_str(VV_TERMRESPONSE) != old_termresponse) - apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, FALSE, curbuf); + // When v:termresponse, etc, were set while autocommands were blocked, + // trigger the autocommands now. Esp. useful when executing a shell + // command during startup (vimdiff). + if (autocmd_blocked == 0) + { + if (get_vim_var_str(VV_TERMRESPONSE) != old_termresponse) + { + apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, FALSE, curbuf); + apply_autocmds(EVENT_TERMRESPONSEALL, (char_u *)"version", NULL, FALSE, curbuf); + } + if (get_vim_var_str(VV_TERMU7RESP) != old_termu7resp) + { + apply_autocmds(EVENT_TERMRESPONSEALL, (char_u *)"ambiguouswidth", NULL, FALSE, curbuf); + } + if (get_vim_var_str(VV_TERMBLINKRESP) != old_termblinkresp) + { + apply_autocmds(EVENT_TERMRESPONSEALL, (char_u *)"cursorblink", NULL, FALSE, curbuf); + } + if (get_vim_var_str(VV_TERMRBGRESP) != old_termrbgresp) + { + apply_autocmds(EVENT_TERMRESPONSEALL, (char_u *)"background", NULL, FALSE, curbuf); + } + if (get_vim_var_str(VV_TERMRFGRESP) != old_termrfgresp) + { + apply_autocmds(EVENT_TERMRESPONSEALL, (char_u *)"foreground", NULL, FALSE, curbuf); + } + if (get_vim_var_str(VV_TERMSTYLERESP) != old_termstyleresp) + { + apply_autocmds(EVENT_TERMRESPONSEALL, (char_u *)"cursorshape", NULL, FALSE, curbuf); + } + } # endif } diff --git a/src/term.c b/src/term.c index dd59fdf65d..734b759e30 100644 --- a/src/term.c +++ b/src/term.c @@ -4986,6 +4986,8 @@ handle_u7_response(int *arg, char_u *tp UNUSED, int csi_len UNUSED) #ifdef FEAT_EVAL set_vim_var_string(VV_TERMU7RESP, tp, csi_len); #endif + apply_autocmds(EVENT_TERMRESPONSEALL, + (char_u *)"ambiguouswidth", NULL, FALSE, curbuf); } } else if (arg[0] == 3) @@ -5595,6 +5597,8 @@ handle_csi( #endif apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, FALSE, curbuf); + apply_autocmds(EVENT_TERMRESPONSEALL, + (char_u *)"version", NULL, FALSE, curbuf); key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; } @@ -5621,6 +5625,8 @@ handle_csi( # ifdef FEAT_EVAL set_vim_var_string(VV_TERMBLINKRESP, tp, *slen); # endif + apply_autocmds(EVENT_TERMRESPONSEALL, + (char_u *)"cursorblink", NULL, FALSE, curbuf); } #endif @@ -5784,6 +5790,8 @@ handle_osc(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen) set_vim_var_string(is_bg ? VV_TERMRBGRESP : VV_TERMRFGRESP, tp, *slen); #endif + apply_autocmds(EVENT_TERMRESPONSEALL, + is_bg ? (char_u *)"background" : (char_u *)"foreground", NULL, FALSE, curbuf); break; } if (i == len) @@ -5882,6 +5890,8 @@ handle_dcs(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen) #ifdef FEAT_EVAL set_vim_var_string(VV_TERMSTYLERESP, tp, *slen); #endif + apply_autocmds(EVENT_TERMRESPONSEALL, + (char_u *)"cursorshape", NULL, FALSE, curbuf); break; } } diff --git a/src/version.c b/src/version.c index f01cac8b7c..b44385a0d5 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 29, /**/ 28, /**/ diff --git a/src/vim.h b/src/vim.h index e41dfef01b..0f52ba217d 100644 --- a/src/vim.h +++ b/src/vim.h @@ -1422,6 +1422,7 @@ enum auto_event EVENT_TERMINALWINOPEN, // after a terminal buffer was created and // entering its window EVENT_TERMRESPONSE, // after setting "v:termresponse" + EVENT_TERMRESPONSEALL, // after setting terminal response vars EVENT_TEXTCHANGED, // text was modified not in Insert mode EVENT_TEXTCHANGEDI, // text was modified in Insert mode EVENT_TEXTCHANGEDP, // TextChangedI with popup menu visible From 93197fde0f1db09b1e495cf3eb14a8f42c318b80 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Sun, 14 Jan 2024 20:59:02 +0100 Subject: [PATCH 046/143] runtime(ftplugin): Use "*" browsefilter pattern to match "All Files" Problem: The "*.*" browsefilter pattern only matches all files on Windows (Daryl Lee) Solution: Use "*" to filter on all platforms but keep "*.*" as the label text on Windows. (Fixes #12685, Doug Kearns) The *.* browsefilter pattern used to match "All Files" on Windows is a legacy of the DOS 8.3 filename wildcard matching algorithm. For reasons of backward compatibility this still works on Windows to match all files, even those without an extension. However, this pattern only matches filenames containing a dot on other platforms. This often makes files without an extension difficult to access from the file dialog, e.g., "Makefile" On Windows it is still standard practice to use "*.*" for the filter label so ftplugins should use "All Files (*.*)" on Windows and "All Files (*)" on other platforms. This matches Vim's default browsefilter values. This commit also normalises the browsefilter conditional test to check for the Win32 and GTK GUI features and an unset b:browsefilter. closes: #12759 Signed-off-by: Doug Kearns Signed-off-by: Christian Brabandt --- runtime/doc/editing.txt | 7 ++++--- runtime/ftplugin/aap.vim | 9 +++++++-- runtime/ftplugin/abap.vim | 15 ++++++++++----- runtime/ftplugin/abaqus.vim | 9 +++++++-- runtime/ftplugin/ant.vim | 15 ++++++++++----- runtime/ftplugin/aspvbs.vim | 15 ++++++++++----- runtime/ftplugin/awk.vim | 14 +++++++++----- runtime/ftplugin/basic.vim | 10 +++++++--- runtime/ftplugin/c.vim | 32 +++++++++++++++++--------------- runtime/ftplugin/clojure.vim | 9 +++++++-- runtime/ftplugin/cobol.vim | 9 +++++++-- runtime/ftplugin/config.vim | 15 ++++++++++----- runtime/ftplugin/cs.vim | 11 ++++++++--- runtime/ftplugin/csh.vim | 10 +++++++--- runtime/ftplugin/diff.vim | 9 +++++++-- runtime/ftplugin/dosbatch.vim | 12 +++++++++--- runtime/ftplugin/dtd.vim | 15 ++++++++++----- runtime/ftplugin/eiffel.vim | 10 +++++++--- runtime/ftplugin/eruby.vim | 11 ++++++++--- runtime/ftplugin/expect.vim | 10 +++++++--- runtime/ftplugin/falcon.vim | 13 +++++++++---- runtime/ftplugin/forth.vim | 9 +++++++-- runtime/ftplugin/fortran.vim | 10 ++++++++-- runtime/ftplugin/fpcmake.vim | 12 ++++++++---- runtime/ftplugin/freebasic.vim | 10 +++++++--- runtime/ftplugin/haml.vim | 15 ++++++++++----- runtime/ftplugin/html.vim | 12 ++++++++---- runtime/ftplugin/icon.vim | 16 ++++++++++------ runtime/ftplugin/ishd.vim | 10 +++++++--- runtime/ftplugin/j.vim | 7 ++++++- runtime/ftplugin/java.vim | 15 ++++++++++----- runtime/ftplugin/javascript.vim | 8 ++++++-- runtime/ftplugin/json5.vim | 10 +++++++--- runtime/ftplugin/jsp.vim | 15 ++++++++++----- runtime/ftplugin/kotlin.vim | 10 +++++++--- runtime/ftplugin/kwt.vim | 15 ++++++++++----- runtime/ftplugin/lua.vim | 10 +++++++--- runtime/ftplugin/lynx.vim | 10 +++++++--- runtime/ftplugin/m3build.vim | 10 +++++++--- runtime/ftplugin/m3quake.vim | 10 +++++++--- runtime/ftplugin/meson.vim | 9 +++++++-- runtime/ftplugin/mf.vim | 7 ++++++- runtime/ftplugin/modula2.vim | 10 +++++++--- runtime/ftplugin/modula3.vim | 10 +++++++--- runtime/ftplugin/mp.vim | 7 ++++++- runtime/ftplugin/msmessages.vim | 13 +++++++++---- runtime/ftplugin/occam.vim | 17 +++++++++++------ runtime/ftplugin/octave.vim | 10 +++++++--- runtime/ftplugin/pascal.vim | 10 +++++++--- runtime/ftplugin/perl.vim | 9 +++++++-- runtime/ftplugin/php.vim | 10 +++++++--- runtime/ftplugin/pod.vim | 10 ++++++++-- runtime/ftplugin/poke.vim | 18 +++++++++++------- runtime/ftplugin/postscr.vim | 15 ++++++++++----- runtime/ftplugin/ps1.vim | 13 +++++++++---- runtime/ftplugin/ps1xml.vim | 13 +++++++++---- runtime/ftplugin/pyrex.vim | 13 +++++++++---- runtime/ftplugin/python.vim | 9 +++++++-- runtime/ftplugin/qml.vim | 12 +++++++++--- runtime/ftplugin/r.vim | 9 +++++++-- runtime/ftplugin/racket.vim | 9 +++++++-- runtime/ftplugin/readline.vim | 10 +++++++--- runtime/ftplugin/registry.vim | 15 ++++++++++----- runtime/ftplugin/rhelp.vim | 9 +++++++-- runtime/ftplugin/rmd.vim | 9 +++++++-- runtime/ftplugin/rnoweb.vim | 9 +++++++-- runtime/ftplugin/routeros.vim | 9 +++++++-- runtime/ftplugin/rrst.vim | 9 +++++++-- runtime/ftplugin/ruby.vim | 9 +++++++-- runtime/ftplugin/sed.vim | 10 +++++++--- runtime/ftplugin/sgml.vim | 15 ++++++++++----- runtime/ftplugin/sh.vim | 14 +++++++++----- runtime/ftplugin/solution.vim | 10 +++++++--- runtime/ftplugin/sql.vim | 13 +++++++++---- runtime/ftplugin/svg.vim | 15 ++++++++++----- runtime/ftplugin/tcl.vim | 13 +++++++++---- runtime/ftplugin/tcsh.vim | 10 +++++++--- runtime/ftplugin/tidy.vim | 16 ++++++++++------ runtime/ftplugin/typescript.vim | 15 ++++++++++----- runtime/ftplugin/vb.vim | 10 +++++++--- runtime/ftplugin/verilog.vim | 13 +++++++++---- runtime/ftplugin/vhdl.vim | 14 ++++++++------ runtime/ftplugin/wget.vim | 10 +++++++--- runtime/ftplugin/wget2.vim | 10 +++++++--- runtime/ftplugin/xhtml.vim | 15 ++++++++++----- runtime/ftplugin/xml.vim | 9 +++++++-- runtime/ftplugin/xsd.vim | 15 ++++++++++----- runtime/ftplugin/xslt.vim | 2 +- 88 files changed, 706 insertions(+), 309 deletions(-) diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index 2ea6839c90..d0f8938562 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -1,4 +1,4 @@ -*editing.txt* For Vim version 9.1. Last change: 2023 Sep 27 +*editing.txt* For Vim version 9.1. Last change: 2024 Jan 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1329,8 +1329,9 @@ b:browsefilter variable. You would most likely set b:browsefilter in a filetype plugin, so that the browse dialog would contain entries related to the type of file you are currently editing. Disadvantage: This makes it difficult to start editing a file of a different type. To overcome this, you -may want to add "All Files\t*.*\n" as the final filter, so that the user can -still access any desired file. +may want to add "All Files (*.*)\t*\n" as the final filter on Windows or "All +Files (*)\t*\n" on other platforms, so that the user can still access any +desired file. To avoid setting browsefilter when Vim does not actually support it, you can use has("browsefilter"): > diff --git a/runtime/ftplugin/aap.vim b/runtime/ftplugin/aap.vim index df839c99ae..cd7e2a425e 100644 --- a/runtime/ftplugin/aap.vim +++ b/runtime/ftplugin/aap.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: Aap recipe " Maintainer: The Vim Project -" Last Change: 2023 Aug 10 +" Last Change: 2024 Jan 14 " Former Maintainer: Bram Moolenaar " Only do this when not done yet for this buffer @@ -28,6 +28,11 @@ setlocal commentstring=#\ %s setlocal expandtab if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") - let b:browsefilter = "Aap Recipe Files (*.aap)\t*.aap\nAll Files (*.*)\t*.*\n" + let b:browsefilter = "Aap Recipe Files (*.aap)\t*.aap\n" + if has("win32") + let b:browsefilter ..= "All Files (*.*)\t*\n" + else + let b:browsefilter ..= "All Files (*)\t*\n" + endif let b:undo_ftplugin ..= " | unlet! b:browsefilter" endif diff --git a/runtime/ftplugin/abap.vim b/runtime/ftplugin/abap.vim index 61db8093fb..8b2040e5aa 100644 --- a/runtime/ftplugin/abap.vim +++ b/runtime/ftplugin/abap.vim @@ -3,7 +3,8 @@ " Author: Steven Oliver " Copyright: Copyright (c) 2013 Steven Oliver " License: You may redistribute this under the same terms as Vim itself -" Last Change: 2023 Aug 28 by Vim Project (undo_ftplugin) +" Last Change: 2023 Aug 28 by Vim Project (undo_ftplugin) +" 2024 Jan 14 by Vim Project (browsefilter) " -------------------------------------------------------------------------- " Only do this when not done yet for this buffer @@ -21,10 +22,14 @@ setlocal suffixesadd=.abap let b:undo_ftplugin = "setl sts< sua< sw<" " Windows allows you to filter the open file dialog -if has("gui_win32") && !exists("b:browsefilter") - let b:browsefilter = "ABAP Source Files (*.abap)\t*.abap\n" . - \ "All Files (*.*)\t*.*\n" - let b:undo_ftplugin .= " | unlet! b:browsefilter" +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") + let b:browsefilter = "ABAP Source Files (*.abap)\t*.abap\n" + if has("win32") + let b:browsefilter ..= "All Files (*.*)\t*\n" + else + let b:browsefilter ..= "All Files (*)\t*\n" + endif + let b:undo_ftplugin ..= " | unlet! b:browsefilter" endif let &cpo = s:cpo_save diff --git a/runtime/ftplugin/abaqus.vim b/runtime/ftplugin/abaqus.vim index 5931cd921d..c16e7b032e 100644 --- a/runtime/ftplugin/abaqus.vim +++ b/runtime/ftplugin/abaqus.vim @@ -2,6 +2,7 @@ " Language: Abaqus finite element input file (www.abaqus.com) " Maintainer: Carl Osterwisch " Last Change: 2022 Oct 08 +" 2024 Jan 14 by Vim Project (browsefilter) " Only do this when not done yet for this buffer if exists("b:did_ftplugin") | finish | endif @@ -49,8 +50,12 @@ endif if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:browsefilter = "Abaqus Input Files (*.inp *.inc)\t*.inp;*.inc\n" . \ "Abaqus Results (*.dat)\t*.dat\n" . - \ "Abaqus Messages (*.pre *.msg *.sta)\t*.pre;*.msg;*.sta\n" . - \ "All Files (*.*)\t*.*\n" + \ "Abaqus Messages (*.pre, *.msg, *.sta)\t*.pre;*.msg;*.sta\n" + if has("win32") + let b:browsefilter .= "All Files (*.*)\t*\n" + else + let b:browsefilter .= "All Files (*)\t*\n" + endif let b:undo_ftplugin .= "|unlet! b:browsefilter" endif diff --git a/runtime/ftplugin/ant.vim b/runtime/ftplugin/ant.vim index aee07ca4b9..65e01a1a76 100644 --- a/runtime/ftplugin/ant.vim +++ b/runtime/ftplugin/ant.vim @@ -1,10 +1,11 @@ " Vim filetype plugin file -" Language: ant +" Language: ant " " This runtime file is looking for a new maintainer. " " Former maintainer: Dan Sharp -" Last Changed: 20 Jan 2009 +" Last Change: 2009 Jan 20 +" 2024 Jan 14 by Vim Project (browsefilter) if exists("b:did_ftplugin") | finish | endif @@ -15,8 +16,12 @@ set cpo-=C " Define some defaults in case the included ftplugins don't set them. let s:undo_ftplugin = "" -let s:browsefilter = "XML Files (*.xml)\t*.xml\n" . - \ "All Files (*.*)\t*.*\n" +let s:browsefilter = "XML Files (*.xml)\t*.xml\n" +if has("win32") + let s:browsefilter .= "All Files (*.*)\t*\n" +else + let s:browsefilter .= "All Files (*)\t*\n" +endif runtime! ftplugin/xml.vim ftplugin/xml_*.vim ftplugin/xml/*.vim let b:did_ftplugin = 1 @@ -30,7 +35,7 @@ if exists("b:browsefilter") endif " Change the :browse e filter to primarily show Ant-related files. -if has("gui_win32") +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:browsefilter = "Build Files (build.xml)\tbuild.xml\n" . \ "Java Files (*.java)\t*.java\n" . \ "Properties Files (*.prop*)\t*.prop*\n" . diff --git a/runtime/ftplugin/aspvbs.vim b/runtime/ftplugin/aspvbs.vim index 70a130d287..6979bb8f84 100644 --- a/runtime/ftplugin/aspvbs.vim +++ b/runtime/ftplugin/aspvbs.vim @@ -1,10 +1,11 @@ " Vim filetype plugin file -" Language: aspvbs +" Language: aspvbs " " This runtime file is looking for a new maintainer. " " Former maintainer: Dan Sharp -" Last Changed: 20 Jan 2009 +" Last Change: 2009 Jan 20 +" 2024 Jan 14 by Vim Project (browsefilter) if exists("b:did_ftplugin") | finish | endif @@ -15,8 +16,12 @@ set cpo-=C " Define some defaults in case the included ftplugins don't set them. let s:undo_ftplugin = "" -let s:browsefilter = "HTML Files (*.html, *.htm)\t*.htm*\n" . - \ "All Files (*.*)\t*.*\n" +let s:browsefilter = "HTML Files (*.html, *.htm)\t*.htm*\n" +if has("win32") + let s:browsefilter .= "All Files (*.*)\t*\n" +else + let s:browsefilter .= "All Files (*)\t*\n" +endif let s:match_words = "" runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim @@ -51,7 +56,7 @@ if exists("loaded_matchit") endif " Change the :browse e filter to primarily show ASP-related files. -if has("gui_win32") +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:browsefilter="ASP Files (*.asp)\t*.asp\n" . s:browsefilter endif diff --git a/runtime/ftplugin/awk.vim b/runtime/ftplugin/awk.vim index 40fe304cf4..bcd772350a 100644 --- a/runtime/ftplugin/awk.vim +++ b/runtime/ftplugin/awk.vim @@ -2,7 +2,7 @@ " Language: awk, nawk, gawk, mawk " Maintainer: Doug Kearns " Previous Maintainer: Antonio Colombo -" Last Change: 2020 Sep 28 +" Last Change: 2024 Jan 14 " This plugin was prepared by Mark Sikora " This plugin was updated as proposed by Doug Kearns @@ -25,8 +25,7 @@ setlocal formatoptions-=t formatoptions+=croql setlocal define=function setlocal suffixesadd+=.awk -let b:undo_ftplugin = "setl fo< com< cms< def< sua<" . - \ " | unlet! b:browsefilter" +let b:undo_ftplugin = "setl fo< com< cms< def< sua<" " TODO: set this in scripts.vim? if exists("g:awk_is_gawk") @@ -49,8 +48,13 @@ if exists("g:awk_is_gawk") endif if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") - let b:browsefilter = "Awk Source Files (*.awk,*.gawk)\t*.awk;*.gawk\n" . - \ "All Files (*.*)\t*.*\n" + let b:browsefilter = "Awk Source Files (*.awk, *.gawk)\t*.awk;*.gawk\n" + if has("win32") + let b:browsefilter .= "All Files (*.*)\t*\n" + else + let b:browsefilter .= "All Files (*)\t*\n" + endif + let b:undo_ftplugin .= " | unlet! b:browsefilter" endif let &cpo = s:cpo_save diff --git a/runtime/ftplugin/basic.vim b/runtime/ftplugin/basic.vim index 4399fbf3ad..32f713b43e 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 -" Last Change: 2022 Jun 22 +" Last Change: 2024 Jan 14 if exists("b:did_ftplugin") finish @@ -45,8 +45,12 @@ endif 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" + \ "BASIC Include Files (*.bi, *.bm)\t*.bi;*.bm\n" + if has("win32") + let b:browsefilter ..= "All Files (*.*)\t*\n" + else + let b:browsefilter ..= "All Files (*)\t*\n" + endif let b:basic_set_browsefilter = 1 let b:undo_ftplugin ..= " | unlet! b:browsefilter b:basic_set_browsefilter" endif diff --git a/runtime/ftplugin/c.vim b/runtime/ftplugin/c.vim index 4ddc4a5392..e2eebc5492 100644 --- a/runtime/ftplugin/c.vim +++ b/runtime/ftplugin/c.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: C " Maintainer: The Vim Project -" Last Change: 2023 Aug 10 +" Last Change: 2023 Aug 22 " Former Maintainer: Bram Moolenaar " Only do this when not done yet for this buffer @@ -48,24 +48,26 @@ if !exists("b:match_words") let b:undo_ftplugin ..= " | unlet! b:match_skip b:match_words" endif -" Win32 can filter files in the browse dialog +" Win32 and GTK can filter files in the browse dialog if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") if &ft == "cpp" - let b:browsefilter = "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" . - \ "C Header Files (*.h)\t*.h\n" . - \ "C Source Files (*.c)\t*.c\n" . - \ "All Files (*.*)\t*.*\n" + let b:browsefilter = "C++ Source Files (*.cpp, *.c++)\t*.cpp;*.c++\n" .. + \ "C Header Files (*.h)\t*.h\n" .. + \ "C Source Files (*.c)\t*.c\n" elseif &ft == "ch" - let b:browsefilter = "Ch Source Files (*.ch *.chf)\t*.ch;*.chf\n" . - \ "C Header Files (*.h)\t*.h\n" . - \ "C Source Files (*.c)\t*.c\n" . - \ "All Files (*.*)\t*.*\n" + let b:browsefilter = "Ch Source Files (*.ch, *.chf)\t*.ch;*.chf\n" .. + \ "C Header Files (*.h)\t*.h\n" .. + \ "C Source Files (*.c)\t*.c\n" else - let b:browsefilter = "C Source Files (*.c)\t*.c\n" . - \ "C Header Files (*.h)\t*.h\n" . - \ "Ch Source Files (*.ch *.chf)\t*.ch;*.chf\n" . - \ "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" . - \ "All Files (*.*)\t*.*\n" + let b:browsefilter = "C Source Files (*.c)\t*.c\n" .. + \ "C Header Files (*.h)\t*.h\n" .. + \ "Ch Source Files (*.ch, *.chf)\t*.ch;*.chf\n" .. + \ "C++ Source Files (*.cpp, *.c++)\t*.cpp;*.c++\n" + endif + if has("win32") + let b:browsefilter ..= "All Files (*.*)\t*\n" + else + let b:browsefilter ..= "All Files (*)\t*\n" endif let b:undo_ftplugin ..= " | unlet! b:browsefilter" endif diff --git a/runtime/ftplugin/clojure.vim b/runtime/ftplugin/clojure.vim index c922d75699..4da7554d85 100644 --- a/runtime/ftplugin/clojure.vim +++ b/runtime/ftplugin/clojure.vim @@ -6,6 +6,7 @@ " URL: https://github.com/clojure-vim/clojure.vim " License: Vim (see :h license) " Last Change: 2022-03-24 +" 2024 Jan 14 by Vim Project (browsefilter) if exists("b:did_ftplugin") finish @@ -66,10 +67,14 @@ endif " Filter files in the browse dialog if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") - let b:browsefilter = "All Files\t*\n" . - \ "Clojure Files\t*.clj;*.cljc;*.cljs;*.cljx\n" . + let b:browsefilter = "Clojure Files\t*.clj;*.cljc;*.cljs;*.cljx\n" . \ "EDN Files\t*.edn\n" . \ "Java Files\t*.java\n" + if has("win32") + let b:browsefilter .= "All Files (*.*)\t*\n" + else + let b:browsefilter .= "All Files (*)\t*\n" + endif let b:undo_ftplugin .= ' | unlet! b:browsefilter' endif diff --git a/runtime/ftplugin/cobol.vim b/runtime/ftplugin/cobol.vim index ec1e95456d..5e52702fd5 100644 --- a/runtime/ftplugin/cobol.vim +++ b/runtime/ftplugin/cobol.vim @@ -3,6 +3,7 @@ " Maintainer: Ankit Jain " (formerly Tim Pope ) " Last Update: By Ankit Jain (add gtk support) on 15.08.2020 +" 2024 Jan 14 by Vim Project (browsefilter) " Insert mode mappings: " Normal mode mappings: < > << >> [[ ]] [] ][ @@ -39,8 +40,12 @@ endif " add gtk support if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") - let b:browsefilter = "COBOL Source Files (*.cbl, *.cob)\t*.cbl;*.cob;*.lib\n". - \ "All Files (*.*)\t*.*\n" + let b:browsefilter = "COBOL Source Files (*.cbl, *.cob)\t*.cbl;*.cob;*.lib\n" + if has("win32") + let b:browsefilter .= "All Files (*.*)\t*\n" + else + let b:browsefilter .= "All Files (*)\t*\n" + endif endif let b:undo_ftplugin = "setlocal com< cms< fo< et< tw<" . diff --git a/runtime/ftplugin/config.vim b/runtime/ftplugin/config.vim index 73136cbc66..595fc657b9 100644 --- a/runtime/ftplugin/config.vim +++ b/runtime/ftplugin/config.vim @@ -1,10 +1,11 @@ " Vim filetype plugin file -" Language: config +" Language: config " " This runtime file is looking for a new maintainer. " " Former maintainer: Dan Sharp -" Last Changed: 20 Jan 2009 +" Last Change: 2009 Jan 20 +" 2024 Jan 14 by Vim Project (browsefilter) if exists("b:did_ftplugin") | finish | endif @@ -15,8 +16,12 @@ set cpo-=C " Define some defaults in case the included ftplugins don't set them. let s:undo_ftplugin = "" -let s:browsefilter = "Bourne Shell Files (*.sh)\t*.sh\n" . - \ "All Files (*.*)\t*.*\n" +let s:browsefilter = "Bourne Shell Files (*.sh)\t*.sh\n" +if has("win32") + let s:browsefilter .= "All Files (*.*)\t*\n" +else + let s:browsefilter .= "All Files (*)\t*\n" +endif let s:match_words = "" runtime! ftplugin/sh.vim ftplugin/sh_*.vim ftplugin/sh/*.vim @@ -31,7 +36,7 @@ if exists("b:browsefilter") endif " Change the :browse e filter to primarily show configure-related files. -if has("gui_win32") +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:browsefilter="Configure Scripts (configure.*, config.*)\tconfigure*;config.*\n" . \ s:browsefilter endif diff --git a/runtime/ftplugin/cs.vim b/runtime/ftplugin/cs.vim index 0734d11d22..ada71315e1 100644 --- a/runtime/ftplugin/cs.vim +++ b/runtime/ftplugin/cs.vim @@ -3,6 +3,7 @@ " Maintainer: Nick Jensen " Former Maintainer: Johannes Zellner " Last Change: 2022-11-16 +" 2024 Jan 14 by Vim Project (browsefilter) " License: Vim (see :h license) " Repository: https://github.com/nickspoons/vim-cs @@ -31,10 +32,14 @@ if exists('loaded_matchit') && !exists('b:match_words') endif if (has('gui_win32') || has('gui_gtk')) && !exists('b:browsefilter') - let b:browsefilter = "C# Source Files (*.cs *.csx)\t*.cs;*.csx\n" . + let b:browsefilter = "C# Source Files (*.cs, *.csx)\t*.cs;*.csx\n" . \ "C# Project Files (*.csproj)\t*.csproj\n" . - \ "Visual Studio Solution Files (*.sln)\t*.sln\n" . - \ "All Files (*.*)\t*.*\n" + \ "Visual Studio Solution Files (*.sln)\t*.sln\n" + if has("win32") + let b:browsefilter ..= "All Files (*.*)\t*\n" + else + let b:browsefilter ..= "All Files (*)\t*\n" + endif let b:undo_ftplugin .= ' | unlet! b:browsefilter' endif diff --git a/runtime/ftplugin/csh.vim b/runtime/ftplugin/csh.vim index 2feec57bb2..a22bee3279 100644 --- a/runtime/ftplugin/csh.vim +++ b/runtime/ftplugin/csh.vim @@ -3,7 +3,7 @@ " Maintainer: Doug Kearns " Previous Maintainer: Dan Sharp " Contributor: Johannes Zellner -" Last Change: 2023 Oct 09 +" Last Change: 2024 Jan 14 if exists("b:did_ftplugin") finish @@ -44,8 +44,12 @@ if exists("loaded_matchit") && !exists("b:match_words") endif if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") - let b:browsefilter = "csh Scripts (*.csh)\t*.csh\n" .. - \ "All Files (*.*)\t*.*\n" + let b:browsefilter = "csh Scripts (*.csh)\t*.csh\n" + if has("win32") + let b:browsefilter ..= "All Files (*.*)\t*\n" + else + let b:browsefilter ..= "All Files (*)\t*\n" + endif let b:csh_set_browsefilter = 1 let b:undo_ftplugin ..= " | unlet! b:browsefilter b:csh_set_browsefilter" endif diff --git a/runtime/ftplugin/diff.vim b/runtime/ftplugin/diff.vim index f2a0820be9..2daa48aeb4 100644 --- a/runtime/ftplugin/diff.vim +++ b/runtime/ftplugin/diff.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: Diff " Maintainer: The Vim Project -" Last Change: 2023 Aug 10 +" Last Change: 2023 Aug 22 " Former Maintainer: Bram Moolenaar " Only do this when not done yet for this buffer @@ -19,6 +19,11 @@ setlocal nomodeline let &l:commentstring = "# %s" if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") - let b:browsefilter = "Diff Files (*.diff)\t*.diff\nPatch Files (*.patch)\t*.h\nAll Files (*.*)\t*.*\n" + let b:browsefilter = "Diff Files (*.diff)\t*.diff\nPatch Files (*.patch)\t*.h\n" + if has("win32") + let b:browsefilter ..= "All Files (*.*)\t*\n" + else + let b:browsefilter ..= "All Files (*)\t*\n" + endif let b:undo_ftplugin ..= " | unlet! b:browsefilter" endif diff --git a/runtime/ftplugin/dosbatch.vim b/runtime/ftplugin/dosbatch.vim index f02f26b1fd..5001cf68bd 100644 --- a/runtime/ftplugin/dosbatch.vim +++ b/runtime/ftplugin/dosbatch.vim @@ -2,6 +2,7 @@ " Language: MS-DOS/Windows .bat files " Maintainer: Mike Williams " Last Change: 12th February 2023 +" 2024 Jan 14 by Vim Project (browsefilter) " " Options Flags: " dosbatch_colons_comment - any value to treat :: as comment line @@ -37,12 +38,17 @@ if executable('help.exe') endif " Define patterns for the browse file filter -if has("gui_win32") && !exists("b:browsefilter") - let b:browsefilter = "DOS Batch Files (*.bat, *.cmd)\t*.bat;*.cmd\nAll Files (*.*)\t*.*\n" +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") + let b:browsefilter = "DOS Batch Files (*.bat, *.cmd)\t*.bat;*.cmd\n" + if has("win32") + let b:browsefilter ..= "All Files (*.*)\t*\n" + else + let b:browsefilter ..= "All Files (*)\t*\n" + endif endif let b:undo_ftplugin = "setlocal comments< formatoptions< keywordprg<" - \ . "| unlet! b:browsefiler" + \ . "| unlet! b:browsefilter" let &cpo = s:cpo_save unlet s:cpo_save diff --git a/runtime/ftplugin/dtd.vim b/runtime/ftplugin/dtd.vim index a046118c70..bea8c5c18a 100644 --- a/runtime/ftplugin/dtd.vim +++ b/runtime/ftplugin/dtd.vim @@ -1,10 +1,11 @@ " Vim filetype plugin file -" Language: dtd +" Language: dtd " " This runtime file is looking for a new maintainer. " " Former maintainer: Dan Sharp -" Last Changed: 20 Jan 2009 +" Last Change: 2009 Jan 20 +" 2024 Jan 14 by Vim Project (browsefilter) if exists("b:did_ftplugin") | finish | endif let b:did_ftplugin = 1 @@ -27,10 +28,14 @@ if exists("loaded_matchit") endif " Change the :browse e filter to primarily show Java-related files. -if has("gui_win32") +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:browsefilter="DTD Files (*.dtd)\t*.dtd\n" . - \ "XML Files (*.xml)\t*.xml\n" . - \ "All Files (*.*)\t*.*\n" + \ "XML Files (*.xml)\t*.xml\n" + if has("win32") + let b:browsefilter .= "All Files (*.*)\t*\n" + else + let b:browsefilter .= "All Files (*)\t*\n" + endif endif " Undo the stuff we changed. diff --git a/runtime/ftplugin/eiffel.vim b/runtime/ftplugin/eiffel.vim index 216fdde162..e193110cde 100644 --- a/runtime/ftplugin/eiffel.vim +++ b/runtime/ftplugin/eiffel.vim @@ -1,7 +1,7 @@ " Vim filetype plugin " Language: Eiffel " Maintainer: Doug Kearns -" Last Change: 2010 Aug 29 +" Last Change: 2024 Jan 14 if (exists("b:did_ftplugin")) finish @@ -18,8 +18,12 @@ setlocal formatoptions-=t formatoptions+=croql if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:browsefilter = "Eiffel Source Files (*.e)\t*.e\n" . - \ "Eiffel Control Files (*.ecf, *.ace, *.xace)\t*.ecf;*.ace;*.xace\n" . - \ "All Files (*.*)\t*.*\n" + \ "Eiffel Control Files (*.ecf, *.ace, *.xace)\t*.ecf;*.ace;*.xace\n" + if has("win32") + let b:browsefilter .= "All Files (*.*)\t*\n" + else + let b:browsefilter .= "All Files (*)\t*\n" + endif endif if exists("loaded_matchit") && !exists("b:match_words") diff --git a/runtime/ftplugin/eruby.vim b/runtime/ftplugin/eruby.vim index 893fa58d32..b5c4665d24 100644 --- a/runtime/ftplugin/eruby.vim +++ b/runtime/ftplugin/eruby.vim @@ -4,6 +4,7 @@ " URL: https://github.com/vim-ruby/vim-ruby " Release Coordinator: Doug Kearns " Last Change: 2022 May 15 +" 2024 Jan 14 by Vim Project (browsefilter) " Only do this when not done yet for this buffer if exists("b:did_ftplugin") @@ -15,7 +16,11 @@ set cpo-=C " Define some defaults in case the included ftplugins don't set them. let s:undo_ftplugin = "" -let s:browsefilter = "All Files (*.*)\t*.*\n" +if has("win32") + let s:browsefilter = "All Files (*.*)\t*\n" +else + let s:browsefilter = "All Files (*)\t*\n" +endif let s:match_words = "" if !exists("g:eruby_default_subtype") @@ -109,8 +114,8 @@ exe 'cmap