Mercurial > hg > RemoteEditor > vim7
changeset 9:6a13985590e6
*** empty log message ***
line wrap: on
line diff
--- a/runtime/autoload/ada.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/autoload/ada.vim Fri Aug 29 15:41:29 2008 +0900 @@ -2,13 +2,15 @@ " Description: Perform Ada specific completion & tagging. " Language: Ada (2005) " $Id$ -" Maintainer: Martin Krischik +" Maintainer: Martin Krischik <krischik@users.sourceforge.net> +" Taylor Venable <taylor@metasyntax.net> " Neil Bird <neil@fnxweb.com> +" Ned Okie <nokie@radford.edu> " $Author$ " $Date$ -" Version: 4.2 +" Version: 4.6 " $Revision$ -" $HeadURL: https://svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/ada.vim $ +" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/ada.vim $ " History: 24.05.2006 MK Unified Headers " 26.05.2006 MK ' should not be in iskeyword. " 16.07.2006 MK Ada-Mode as vim-ball @@ -17,6 +19,10 @@ " 05.11.2006 MK Bram suggested not to use include protection for " autoload " 05.11.2006 MK Bram suggested to save on spaces +" 08.07.2007 TV fix mapleader problems. +" 09.05.2007 MK Session just won't work no matter how much +" tweaking is done +" 19.09.2007 NO still some mapleader problems " Help Page: ft-ada-functions "------------------------------------------------------------------------------ @@ -425,30 +431,49 @@ execute '!ctags --excmd=number ' . l:Filename endfunction ada#Create_Tags -function ada#Switch_Session (New_Session) "{{{1 - if a:New_Session != v:this_session - " - " We actualy got a new session - otherwise there - " is nothing to do. - " - if strlen (v:this_session) > 0 - execute 'mksession! ' . v:this_session - endif +" Section: ada#Switch_Session {{{1 +" +function ada#Switch_Session (New_Session) + " + " you should not save to much date into the seession since they will + " be sourced + " + let l:sessionoptions=&sessionoptions + + try + set sessionoptions=buffers,curdir,folds,globals,resize,slash,tabpages,tabpages,unix,winpos,winsize - let v:this_session = a:New_Session + if a:New_Session != v:this_session + " + " We actualy got a new session - otherwise there + " is nothing to do. + " + if strlen (v:this_session) > 0 + execute 'mksession! ' . v:this_session + endif - if filereadable (v:this_session) - execute 'source ' . v:this_session - endif + let v:this_session = a:New_Session - augroup ada_session - autocmd! - autocmd VimLeavePre * execute 'mksession! ' . v:this_session - augroup END - endif + "if filereadable (v:this_session) + "execute 'source ' . v:this_session + "endif + + augroup ada_session + autocmd! + autocmd VimLeavePre * execute 'mksession! ' . v:this_session + augroup END + + "if exists ("g:Tlist_Auto_Open") && g:Tlist_Auto_Open + "TlistOpen + "endif + + endif + finally + let &sessionoptions=l:sessionoptions + endtry return -endfunction ada#Switch_Session "}}}1 +endfunction ada#Switch_Session " Section: GNAT Pretty Printer folding {{{1 " @@ -546,18 +571,23 @@ \ a:Keys . \" <C-O>:" . a:Command . "<CR>" else + if exists("g:mapleader") + let l:leader = g:mapleader + else + let l:leader = '\' + endif execute \ "50amenu " . \ "Ada." . escape(a:Text, ' ') . - \ "<Tab>" . escape(g:mapleader . "a" . a:Keys , '\') . + \ "<Tab>" . escape(l:leader . "a" . a:Keys , '\') . \ " :" . a:Command . "<CR>" execute \ "nnoremap <buffer>" . - \ escape(g:mapleader . "a" . a:Keys , '\') . + \ escape(l:leader . "a" . a:Keys , '\') . \" :" . a:Command execute \ "inoremap <buffer>" . - \ escape(g:mapleader . "a" . a:Keys , '\') . + \ escape(l:leader . "a" . a:Keys , '\') . \" <C-O>:" . a:Command endif return @@ -566,10 +596,15 @@ " Section: ada#Map_Popup {{{2 " function ada#Map_Popup (Text, Keys, Command) + if exists("g:mapleader") + let l:leader = g:mapleader + else + let l:leader = '\' + endif execute \ "50amenu " . \ "PopUp." . escape(a:Text, ' ') . - \ "<Tab>" . escape(g:mapleader . "a" . a:Keys , '\') . + \ "<Tab>" . escape(l:leader . "a" . a:Keys , '\') . \ " :" . a:Command . "<CR>" call ada#Map_Menu (a:Text, a:Keys, a:Command)
--- a/runtime/autoload/adacomplete.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/autoload/adacomplete.vim Fri Aug 29 15:41:29 2008 +0900 @@ -5,9 +5,9 @@ " Maintainer: Martin Krischik " $Author$ " $Date$ -" Version: 4.2 +" Version: 4.6 " $Revision$ -" $HeadURL: https://svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/adacomplete.vim $ +" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/adacomplete.vim $ " History: 24.05.2006 MK Unified Headers " 26.05.2006 MK improved search for begin of word. " 16.07.2006 MK Ada-Mode as vim-ball
--- a/runtime/autoload/decada.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/autoload/decada.vim Fri Aug 29 15:41:29 2008 +0900 @@ -3,12 +3,12 @@ " Language: Ada (Dec Ada) " $Id$ " Copyright: Copyright (C) 2006 Martin Krischik -" Maintainer: Martin Krischik +" Maintainer: Martin Krischik <krischik@users.sourceforge.net> " $Author$ " $Date$ -" Version: 4.2 +" Version: 4.6 " $Revision$ -" $HeadURL: https://svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/decada.vim $ +" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/decada.vim $ " History: 21.07.2006 MK New Dec Ada " 15.10.2006 MK Bram's suggestion for runtime integration " 05.11.2006 MK Bram suggested not to use include protection for @@ -45,7 +45,7 @@ call ada#Switch_Session (a:1) elseif argc() == 0 && strlen (v:servername) > 0 call ada#Switch_Session ( - \ expand('~')[0:-2] . ".vimfiles.session]" . + \ expand('~')[0:-2] . ".vimfiles.session]decada_" . \ v:servername . ".vim") endif return
--- a/runtime/autoload/gnat.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/autoload/gnat.vim Fri Aug 29 15:41:29 2008 +0900 @@ -3,12 +3,13 @@ " Language: Ada (GNAT) " $Id$ " Copyright: Copyright (C) 2006 Martin Krischik -" Maintainer: Martin Krischik +" Maintainer: Martin Krischi <krischik@users.sourceforge.net>k +" Ned Okie <nokie@radford.edu> " $Author$ " $Date$ -" Version: 4.2 +" Version: 4.6 " $Revision$ -" $HeadURL: https://svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/gnat.vim $ +" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/gnat.vim $ " History: 24.05.2006 MK Unified Headers " 16.07.2006 MK Ada-Mode as vim-ball " 05.08.2006 MK Add session support @@ -16,6 +17,7 @@ " 05.11.2006 MK Bram suggested not to use include protection for " autoload " 05.11.2006 MK Bram suggested to save on spaces +" 19.09.2007 NO use project file only when there is a project " Help Page: compiler-gnat "------------------------------------------------------------------------------ @@ -71,13 +73,19 @@ execute 'mksession! ' . v:this_session endif - if strlen (self.Project_File) > 0 - call ada#Switch_Session ( - \ expand('~') . "/vimfiles/session/" . - \ fnamemodify (self.Project_File, ":t:r") . ".vim") - else - call ada#Switch_Session ('') - endif + "if strlen (self.Project_File) > 0 + "if has("vms") + "call ada#Switch_Session ( + "\ expand('~')[0:-2] . ".vimfiles.session]gnat_" . + "\ fnamemodify (self.Project_File, ":t:r") . ".vim") + "else + "call ada#Switch_Session ( + "\ expand('~') . "/vimfiles/session/gnat_" . + "\ fnamemodify (self.Project_File, ":t:r") . ".vim") + "endif + "else + "call ada#Switch_Session ('') + "endif return endfunction gnat#Set_Project_File " }}}1
--- a/runtime/autoload/rubycomplete.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/autoload/rubycomplete.vim Fri Aug 29 15:41:29 2008 +0900 @@ -36,7 +36,7 @@ endif if !exists("g:rubycomplete_buffer_loading") - let g:rubycomplete_classes_in_global = 0 + let g:rubycomplete_buffer_loading = 0 endif if !exists("g:rubycomplete_include_object") @@ -301,7 +301,7 @@ def get_buffer_entity(name, vimfun) loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading") - return nil if loading_allowed != '1' + return nil if loading_allowed.to_i.zero? return nil if /(\"|\')+/.match( name ) buf = VIM::Buffer.current nums = eval( VIM::evaluate( vimfun % name ) ) @@ -368,7 +368,7 @@ # this will be a little expensive. loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading") allow_aggressive_load = VIM::evaluate("exists('g:rubycomplete_classes_in_global') && g:rubycomplete_classes_in_global") - return [] if allow_aggressive_load != '1' || loading_allowed != '1' + return [] if allow_aggressive_load.to_i.zero? || loading_allowed.to_i.zero? buf = VIM::Buffer.current eob = buf.length @@ -401,7 +401,7 @@ def load_rails allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") - return if allow_rails != '1' + return if allow_rails.to_i.zero? buf_path = VIM::evaluate('expand("%:p")') file_name = VIM::evaluate('expand("%:t")') @@ -461,7 +461,7 @@ def get_rails_helpers allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded') - return [] if allow_rails != '1' || rails_loaded != '1' + return [] if allow_rails.to_i.zero? || rails_loaded.to_i.zero? buf_path = VIM::evaluate('expand("%:p")') buf_path.gsub!( /\\/, "/" ) @@ -511,7 +511,7 @@ def add_rails_columns( cls ) allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded') - return [] if allow_rails != '1' || rails_loaded != '1' + return [] if allow_rails.to_i.zero? || rails_loaded.to_i.zero? begin eval( "#{cls}.establish_connection" ) @@ -534,7 +534,7 @@ def get_rails_view_methods allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded') - return [] if allow_rails != '1' || rails_loaded != '1' + return [] if allow_rails.to_i.zero? || rails_loaded.to_i.zero? buf_path = VIM::evaluate('expand("%:p")') buf_path.gsub!( /\\/, "/" ) @@ -580,7 +580,7 @@ def get_completions(base) loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading") - if loading_allowed == '1' + if loading_allowed.to_i == 1 load_requires load_rails end
--- a/runtime/compiler/decada.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/compiler/decada.vim Fri Aug 29 15:41:29 2008 +0900 @@ -3,14 +3,15 @@ " Language: Ada (Dec Ada) " $Id$ " Copyright: Copyright (C) 2006 Martin Krischik -" Maintainer: Martin Krischik +" Maintainer: Martin Krischik <krischik@users.sourceforge.net> " $Author$ " $Date$ -" Version: 4.2 +" Version: 4.6 " $Revision$ -" $HeadURL: https://svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/compiler/decada.vim $ +" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/compiler/decada.vim $ " History: 21.07.2006 MK New Dec Ada " 15.10.2006 MK Bram's suggestion for runtime integration +" 08.09.2006 MK Correct double load protection. " Help Page: compiler-decada "------------------------------------------------------------------------------ @@ -24,6 +25,13 @@ if !exists("g:decada") let g:decada = decada#New () + + call ada#Map_Menu ( + \'Dec Ada.Build', + \'<F7>', + \'call decada.Make ()') + + call g:decada.Set_Session () endif if exists(":CompilerSet") != 2 @@ -33,16 +41,9 @@ command -nargs=* CompilerSet setlocal <args> endif -call g:decada.Set_Session () - execute "CompilerSet makeprg=" . escape (g:decada.Make_Command, ' ') execute "CompilerSet errorformat=" . escape (g:decada.Error_Format, ' ') -call ada#Map_Menu ( - \'Dec Ada.Build', - \'<F7>', - \'call decada.Make ()') - finish " 1}}} "------------------------------------------------------------------------------
--- a/runtime/compiler/eruby.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/compiler/eruby.vim Fri Aug 29 15:41:29 2008 +0900 @@ -38,4 +38,4 @@ let &cpo = s:cpo_save unlet s:cpo_save -" vim: nowrap sw=2 sts=2 ts=8 ff=unix: +" vim: nowrap sw=2 sts=2 ts=8:
--- a/runtime/compiler/gnat.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/compiler/gnat.vim Fri Aug 29 15:41:29 2008 +0900 @@ -3,15 +3,17 @@ " Language: Ada (GNAT) " $Id$ " Copyright: Copyright (C) 2006 Martin Krischik -" Maintainer: Martin Krischik +" Maintainer: Martin Krischi <krischik@users.sourceforge.net>k +" Ned Okie <nokie@radford.edu> " $Author$ " $Date$ -" Version: 4.2 +" Version: 4.6 " $Revision$ -" $HeadURL: https://svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/compiler/gnat.vim $ +" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/compiler/gnat.vim $ " History: 24.05.2006 MK Unified Headers " 16.07.2006 MK Ada-Mode as vim-ball " 15.10.2006 MK Bram's suggestion for runtime integration +" 19.09.2007 NO use project file only when there is a project " Help Page: compiler-gnat "------------------------------------------------------------------------------ @@ -46,6 +48,8 @@ \ 'GNAT.Set Projectfile\.\.\.', \ ':SetProject', \ 'call gnat.Set_Project_File ()') + + call g:gnat.Set_Session () endif if exists(":CompilerSet") != 2 @@ -55,8 +59,6 @@ command -nargs=* CompilerSet setlocal <args> endif -call g:gnat.Set_Session () - execute "CompilerSet makeprg=" . escape (g:gnat.Get_Command('Make'), ' ') execute "CompilerSet errorformat=" . escape (g:gnat.Error_Format, ' ')
--- a/runtime/compiler/ruby.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/compiler/ruby.vim Fri Aug 29 15:41:29 2008 +0900 @@ -65,4 +65,4 @@ let &cpo = s:cpo_save unlet s:cpo_save -" vim: nowrap sw=2 sts=2 ts=8 ff=unix: +" vim: nowrap sw=2 sts=2 ts=8:
--- a/runtime/compiler/rubyunit.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/compiler/rubyunit.vim Fri Aug 29 15:41:29 2008 +0900 @@ -32,4 +32,4 @@ let &cpo = s:cpo_save unlet s:cpo_save -" vim: nowrap sw=2 sts=2 ts=8 ff=unix: +" vim: nowrap sw=2 sts=2 ts=8:
--- a/runtime/ftplugin/ada.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/ftplugin/ada.vim Fri Aug 29 15:41:29 2008 +0900 @@ -2,13 +2,14 @@ " Description: Perform Ada specific completion & tagging. " Language: Ada (2005) " $Id$ -" Maintainer: Martin Krischik +" Maintainer: Martin Krischik <krischik@users.sourceforge.net> +" Taylor Venable <taylor@metasyntax.net> " Neil Bird <neil@fnxweb.com> " $Author$ " $Date$ -" Version: 4.2 +" Version: 4.6 " $Revision$ -" $HeadURL: https://svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/ftplugin/ada.vim $ +" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/ftplugin/ada.vim $ " History: 24.05.2006 MK Unified Headers " 26.05.2006 MK ' should not be in iskeyword. " 16.07.2006 MK Ada-Mode as vim-ball @@ -17,6 +18,7 @@ " 05.11.2006 MK Bram suggested not to use include protection for " autoload " 05.11.2006 MK Bram suggested to save on spaces +" 08.07.2007 TV fix default compiler problems. " Help Page: ft-ada-plugin "------------------------------------------------------------------------------ " Provides mapping overrides for tag jumping that figure out the current @@ -30,7 +32,7 @@ endif " Don't load another plugin for this buffer -let b:did_ftplugin = 38 +let b:did_ftplugin = 45 " " Temporarily set cpoptions to ensure the script loads OK @@ -38,12 +40,21 @@ let s:cpoptions = &cpoptions set cpoptions-=C -" Section: Comments {{{1 +" Section: Comments {{{1 " setlocal comments=O:--,:--\ \ setlocal commentstring=--\ \ %s setlocal complete=.,w,b,u,t,i +" Section: case {{{1 +" +setlocal nosmartcase +setlocal ignorecase + +" Section: formatoptions {{{1 +" +setlocal formatoptions+=ron + " Section: Tagging {{{1 " if exists ("g:ada_extended_tagging") @@ -104,8 +115,17 @@ \ s:notend . '\<record\>:\<end\>\s\+\<record\>' endif + " Section: Compiler {{{1 " +if ! exists("g:ada_default_compiler") + if has("vms") + let g:ada_default_compiler = 'decada' + else + let g:ada_default_compiler = 'gnat' + endif +endif + if ! exists("current_compiler") || \ current_compiler != g:ada_default_compiler execute "compiler " . g:ada_default_compiler
--- a/runtime/ftplugin/eruby.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/ftplugin/eruby.vim Fri Aug 29 15:41:29 2008 +0900 @@ -27,7 +27,7 @@ let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$") let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+') if b:eruby_subtype == '' - let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\)\+$','',''),'\.\zs\w\+$') + let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\)\+$','',''),'\.\zs\w\+$') endif if b:eruby_subtype == 'rhtml' let b:eruby_subtype = 'html' @@ -98,4 +98,4 @@ let &cpo = s:save_cpo -" vim: nowrap sw=2 sts=2 ts=8 ff=unix: +" vim: nowrap sw=2 sts=2 ts=8:
--- a/runtime/ftplugin/ruby.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/ftplugin/ruby.vim Fri Aug 29 15:41:29 2008 +0900 @@ -227,4 +227,4 @@ " differs on Windows. Email gsinclair@soyabean.com.au if you need help. " -" vim: nowrap sw=2 sts=2 ts=8 ff=unix: +" vim: nowrap sw=2 sts=2 ts=8:
--- a/runtime/indent/ada.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/indent/ada.vim Fri Aug 29 15:41:29 2008 +0900 @@ -3,17 +3,19 @@ " Language: Ada (2005) " $Id$ " Copyright: Copyright (C) 2006 Martin Krischik -" Maintainer: Martin Krischik +" Maintainer: Martin Krischik <krischik@users.sourceforge.net> " Neil Bird <neil@fnxweb.com> +" Ned Okie <nokie@radford.edu> " $Author$ " $Date$ -" Version: 4.2 +" Version: 4.6 " $Revision$ -" $HeadURL: https://svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/indent/ada.vim $ +" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/indent/ada.vim $ " History: 24.05.2006 MK Unified Headers " 16.07.2006 MK Ada-Mode as vim-ball " 15.10.2006 MK Bram's suggestion for runtime integration " 05.11.2006 MK Bram suggested to save on spaces +" 19.09.2007 NO g: missing before ada#Comment " Help Page: ft-vim-indent "------------------------------------------------------------------------------ " ToDo: @@ -27,7 +29,7 @@ finish endif -let b:did_indent = 1 +let b:did_indent = 45 setlocal indentexpr=GetAdaIndent() setlocal indentkeys-=0{,0} @@ -58,7 +60,7 @@ " Seems to work OK as it 'starts' with the indent of the /previous/ line. function s:MainBlockIndent (prev_indent, prev_lnum, blockstart, stop_at) let lnum = a:prev_lnum - let line = substitute( getline(lnum), ada#Comment, '', '' ) + let line = substitute( getline(lnum), g:ada#Comment, '', '' ) while lnum > 1 if a:stop_at != '' && line =~ '^\s*' . a:stop_at && indent(lnum) < a:prev_indent return a:prev_indent @@ -72,7 +74,7 @@ let lnum = prevnonblank(lnum - 1) " Get previous non-blank/non-comment-only line while 1 - let line = substitute( getline(lnum), ada#Comment, '', '' ) + let line = substitute( getline(lnum), g:ada#Comment, '', '' ) if line !~ '^\s*$' && line !~ '^\s*#' break endif @@ -116,7 +118,7 @@ " Get previous non-blank/non-comment-only line while 1 let line = getline(lnum) - let line = substitute( line, ada#Comment, '', '' ) + let line = substitute( line, g:ada#Comment, '', '' ) if line !~ '^\s*$' break endif @@ -143,7 +145,8 @@ let lnum = prevnonblank(lnum - 1) " Get previous non-blank/non-comment-only line while 1 - let line = substitute( getline(lnum), ada#Comment, '', '' ) + let line = substitute( getline(lnum), g:ada#Comment, '', '' ) + if line !~ '^\s*$' && line !~ '^\s*#' break endif @@ -222,7 +225,7 @@ exe lnum exe 'normal! $F)%' if getline('.') =~ '^\s*(' - " Dire layout - use previous indent (could check for ada#Comment here) + " Dire layout - use previous indent (could check for g:ada#Comment here) let ind = indent( prevnonblank( line('.')-1 ) ) else let ind = indent('.')
--- a/runtime/indent/cmake.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/indent/cmake.vim Fri Aug 29 15:41:29 2008 +0900 @@ -1,11 +1,11 @@ " ============================================================================= -" +" " Program: CMake - Cross-Platform Makefile Generator " Module: $RCSfile$ " Language: VIM " Date: $Date$ " Version: $Revision$ -" +" " ============================================================================= " Vim indent file @@ -65,8 +65,8 @@ \ ')\s*' . \ '\(' . cmake_regex_comment . '\)\?$' - let cmake_indent_begin_regex = '^\s*\(IF\|MACRO\|FOREACH\|ELSE\|WHILE\)\s*(' - let cmake_indent_end_regex = '^\s*\(ENDIF\|ENDFOREACH\|ENDMACRO\|ELSE\|ENDWHILE\)\s*(' + let cmake_indent_begin_regex = '^\s*\(IF\|MACRO\|FOREACH\|ELSE\|ELSEIF\|WHILE\)\s*(' + let cmake_indent_end_regex = '^\s*\(ENDIF\|ENDFOREACH\|ENDMACRO\|ELSE\|ELSEIF\|ENDWHILE\)\s*(' " Add if previous_line =~? cmake_indent_comment_line " Handle comments
--- a/runtime/indent/eruby.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/indent/eruby.vim Fri Aug 29 15:41:29 2008 +0900 @@ -12,7 +12,7 @@ runtime! indent/ruby.vim unlet! b:did_indent -set indentexpr= +setlocal indentexpr= if exists("b:eruby_subtype") exe "runtime! indent/".b:eruby_subtype.".vim" @@ -40,12 +40,17 @@ finish endif -function! GetErubyIndent() +function! GetErubyIndent(...) + if a:0 && a:1 == '.' + let v:lnum = line('.') + elseif a:0 && a:1 =~ '^\d' + let v:lnum = a:1 + endif let vcol = col('.') call cursor(v:lnum,1) - let inruby = searchpair('<%','','%>') + let inruby = searchpair('<%','','%>','W') call cursor(v:lnum,vcol) - if inruby && getline(v:lnum) !~ '^<%' + if inruby && getline(v:lnum) !~ '^<%\|^\s*-\=%>' let ind = GetRubyIndent() else exe "let ind = ".b:eruby_subtype_indentexpr @@ -53,15 +58,15 @@ let lnum = prevnonblank(v:lnum-1) let line = getline(lnum) let cline = getline(v:lnum) - if cline =~# '<%\s*\%(end\|else\|\%(ensure\|rescue\|elsif\|when\).\{-\}\)\s*\%(-\=%>\|$\)' + if cline =~# '<%-\=\s*\%(}\|end\|else\|\%(ensure\|rescue\|elsif\|when\).\{-\}\)\s*\%(-\=%>\|$\)' let ind = ind - &sw endif - if line =~# '\<do\%(\s*|[^|]*|\)\=\s*-\=%>' + if line =~# '\%({\|\<do\)\%(\s*|[^|]*|\)\=\s*-\=%>' let ind = ind + &sw - elseif line =~# '<%\s*\%(module\|class\|def\|if\|for\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\)\>.*%>' + elseif line =~# '<%-\=\s*\%(module\|class\|def\|if\|for\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\)\>.*%>' let ind = ind + &sw endif - if line =~# '^\s*<%[=#]\=\s*$' && cline !~# '^\s*end\>' + if line =~# '^\s*<%[=#-]\=\s*$' && cline !~# '^\s*end\>' let ind = ind + &sw endif if cline =~# '^\s*-\=%>\s*$' @@ -70,4 +75,4 @@ return ind endfunction -" vim:set sw=2 sts=2 ts=8 noet ff=unix: +" vim:set sw=2 sts=2 ts=8 noet:
--- a/runtime/indent/ruby.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/indent/ruby.vim Fri Aug 29 15:41:29 2008 +0900 @@ -34,26 +34,26 @@ " ============ " Regex of syntax group names that are or delimit string or are comments. -let s:syng_strcom = '\<ruby\%(String\|StringDelimiter\|ASCIICode' . - \ '\|Interpolation\|NoInterpolation\|Escape\|Comment\|Documentation\)\>' +let s:syng_strcom = '\<ruby\%(String\|StringEscape\|ASCIICode' . + \ '\|Interpolation\|NoInterpolation\|Comment\|Documentation\)\>' " Regex of syntax group names that are strings. let s:syng_string = - \ '\<ruby\%(String\|StringDelimiter\|Interpolation\|NoInterpolation\|Escape\)\>' + \ '\<ruby\%(String\|Interpolation\|NoInterpolation\|StringEscape\)\>' " Regex of syntax group names that are strings or documentation. let s:syng_stringdoc = - \'\<ruby\%(String\|StringDelimiter\|Interpolation\|NoInterpolation\|Escape\|Documentation\)\>' + \'\<ruby\%(String\|Interpolation\|NoInterpolation\|StringEscape\|Documentation\)\>' " Expression used to check whether we should skip a match with searchpair(). let s:skip_expr = - \ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '".s:syng_strcom."'" + \ "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'" " Regex used for words that, at the start of a line, add a level of indent. let s:ruby_indent_keywords = '^\s*\zs\<\%(module\|class\|def\|if\|for' . \ '\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure' . \ '\|rescue\)\>' . - \ '\|\%([*+/,=:-]\|<<\|>>\)\s*\zs' . + \ '\|\%([*+/,=-]\|<<\|>>\|:\s\)\s*\zs' . \ '\<\%(if\|for\|while\|until\|case\|unless\|begin\)\>' " Regex used for words that, at the start of a line, remove a level of indent. @@ -65,7 +65,7 @@ " TODO: the do here should be restricted somewhat (only at end of line)? let s:end_start_regex = '^\s*\zs\<\%(module\|class\|def\|if\|for' . \ '\|while\|until\|case\|unless\|begin\)\>' . - \ '\|\%([*+/,=:-]\|<<\|>>\)\s*\zs' . + \ '\|\%([*+/,=-]\|<<\|>>\|:\s\)\s*\zs' . \ '\<\%(if\|for\|while\|until\|case\|unless\|begin\)\>' . \ '\|\<do\>' @@ -78,15 +78,15 @@ " Expression used for searchpair() call for finding match for 'end' keyword. let s:end_skip_expr = s:skip_expr . \ ' || (expand("<cword>") == "do"' . - \ ' && getline(".") =~ "^\\s*\\<while\\|until\\|for\\>")' + \ ' && getline(".") =~ "^\\s*\\<\\(while\\|until\\|for\\)\\>")' " Regex that defines continuation lines, not including (, {, or [. -let s:continuation_regex = '\%([\\*+/.,=:-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$' +let s:continuation_regex = '\%([\\*+/.,:]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$' " Regex that defines continuation lines. " TODO: this needs to deal with if ...: and so on let s:continuation_regex2 = - \ '\%([\\*+/.,=:({[-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$' + \ '\%([\\*+/.,:({[]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$' " Regex that defines blocks. let s:block_regex = @@ -97,17 +97,17 @@ " Check if the character at lnum:col is inside a string, comment, or is ascii. function s:IsInStringOrComment(lnum, col) - return synIDattr(synID(a:lnum, a:col, 0), 'name') =~ s:syng_strcom + return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_strcom endfunction " Check if the character at lnum:col is inside a string. function s:IsInString(lnum, col) - return synIDattr(synID(a:lnum, a:col, 0), 'name') =~ s:syng_string + return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string endfunction " Check if the character at lnum:col is inside a string or documentation. function s:IsInStringOrDocumentation(lnum, col) - return synIDattr(synID(a:lnum, a:col, 0), 'name') =~ s:syng_stringdoc + return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_stringdoc endfunction " Find line above 'lnum' that isn't empty, in a comment, or in a string. @@ -259,6 +259,11 @@ " Find a non-blank, non-multi-line string line above the current line. let lnum = s:PrevNonBlankNonString(v:lnum - 1) + " If the line is empty and inside a string, use the previous line. + if line =~ '^\s*$' && lnum != prevnonblank(v:lnum - 1) + return indent(prevnonblank(v:lnum)) + endif + " At the start of the file use zero indent. if lnum == 0 return 0 @@ -370,4 +375,4 @@ let &cpo = s:cpo_save unlet s:cpo_save -" vim:set sw=2 sts=2 ts=8 noet ff=unix: +" vim:set sw=2 sts=2 ts=8 noet:
--- a/runtime/scripts.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/scripts.vim Fri Aug 29 15:41:29 2008 +0900 @@ -1,7 +1,7 @@ " Vim support file to detect file types in scripts " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last change: 2007 Apr 29 +" Last change: 2008 Aug 09 " This file is called by an autocommand for every file that has just been " loaded into a buffer. It checks if the type of file can be recognized by @@ -168,7 +168,7 @@ set ft=zsh " ELM Mail files - elseif s:line1 =~ '^From [a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\= .*[12][09]\d\d$' + elseif s:line1 =~ '^From \([a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\=\|-\) .* \(19\|20\)\d\d$' set ft=mail " Mason @@ -234,6 +234,14 @@ elseif s:line1 =~ '\<DTD\s\+XHTML\s' set ft=xhtml + " HTML (e.g.: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN") + elseif s:line1 =~? '\<DOCTYPE\s\+html\>' + set ft=html + + " PDF + elseif s:line1 =~ '^%PDF-' + set ft=pdf + " XXD output elseif s:line1 =~ '^\x\{7}: \x\{2} \=\x\{2} \=\x\{2} \=\x\{2} ' set ft=xxd @@ -271,7 +279,7 @@ set ft=virata " Strace - elseif s:line1 =~ '^[0-9]* *execve(' + elseif s:line1 =~ '^\(\[pid \d\+\] \)\=[0-9:.]* *execve(' || s:line1 =~ '^__libc_start_main' set ft=strace " VSE JCL @@ -309,6 +317,10 @@ elseif s:line1 =~ 'exec\s\+\S*scheme' || s:line2 =~ 'exec\s\+\S*scheme' set ft=scheme + " Git output + elseif s:line1 =~ '^\(commit\|tree\|object\) \x\{40\}$\|^tag \S\+$' + set ft=git + " CVS diff else let lnum = 1
--- a/runtime/syntax/ada.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/syntax/ada.vim Fri Aug 29 15:41:29 2008 +0900 @@ -9,9 +9,9 @@ " Contributors: Preben Randhol. " $Author$ " $Date$ -" Version: 4.2 +" Version: 4.6 " $Revision$ -" $HeadURL: https://svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/syntax/ada.vim $ +" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/syntax/ada.vim $ " http://www.dwheeler.com/vim " History: 24.05.2006 MK Unified Headers " 26.05.2006 MK ' should not be in iskeyword. @@ -38,8 +38,6 @@ " Section: Ada is entirely case-insensitive. {{{1 " syntax case ignore -setlocal nosmartcase -setlocal ignorecase " Section: Highlighting commands {{{1 " @@ -98,7 +96,8 @@ " if exists("g:ada_rainbow_color") syntax match adaSpecial "[:;.,]" - runtime plugin/Rainbow_Parenthsis.vim + call rainbow_parenthsis#LoadRound () + call rainbow_parenthsis#Activate () else syntax match adaSpecial "[:;().,]" endif @@ -159,7 +158,7 @@ " Section: end {{{1 " Unless special ("end loop", "end if", etc.), "end" marks the end of a " begin, package, task etc. Assiging it to adaEnd. -syntax match adaEnd "\<end\>" +syntax match adaEnd /\<end\>/ syntax keyword adaPreproc pragma @@ -346,9 +345,6 @@ endif -" Section: formatoptions {{{1 -" -setlocal formatoptions+=ron " Section: sync {{{1 "
--- a/runtime/syntax/bzr.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/syntax/bzr.vim Fri Aug 29 15:41:29 2008 +0900 @@ -4,7 +4,7 @@ " URL: http://www.hlabs.spb.ru/vim/bzr.vim " Revision: $Id$ " Filenames: bzr_log.* -" Version: 1.0 +" Version: 1.1 " For version 5.x: Clear all syntax items. " For version 6.x: Quit when a syntax file was already loaded. @@ -14,7 +14,7 @@ finish endif -syn region bzrRegion start="^-\{14} This line and the following will be ignored -\{14}$" end="\%$" contains=ALL +syn region bzrRegion start="^-\{14} This line and the following will be ignored -\{14}$" end="\%$" contains=ALL contains=@NoSpell syn match bzrRemoved "^removed:$" contained syn match bzrAdded "^added:$" contained syn match bzrRenamed "^renamed:$" contained
--- a/runtime/syntax/cmake.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/syntax/cmake.vim Fri Aug 29 15:41:29 2008 +0900 @@ -49,7 +49,7 @@ syn keyword cmakeDeprecated ABSTRACT_FILES BUILD_NAME SOURCE_FILES SOURCE_FILES_REMOVE VTK_MAKE_INSTANTIATOR VTK_WRAP_JAVA VTK_WRAP_PYTHON VTK_WRAP_TCL WRAP_EXCLUDE_FILES \ nextgroup=cmakeArgument syn keyword cmakeStatement - \ ADD_CUSTOM_COMMAND ADD_CUSTOM_TARGET ADD_DEFINITIONS ADD_DEPENDENCIES ADD_EXECUTABLE ADD_LIBRARY ADD_SUBDIRECTORY ADD_TEST AUX_SOURCE_DIRECTORY BUILD_COMMAND BUILD_NAME CMAKE_MINIMUM_REQUIRED CONFIGURE_FILE CREATE_TEST_SOURCELIST ELSE ENABLE_LANGUAGE ENABLE_TESTING ENDFOREACH ENDIF ENDWHILE EXEC_PROGRAM EXECUTE_PROCESS EXPORT_LIBRARY_DEPENDENCIES FILE FIND_FILE FIND_LIBRARY FIND_PACKAGE FIND_PATH FIND_PROGRAM FLTK_WRAP_UI FOREACH GET_CMAKE_PROPERTY GET_DIRECTORY_PROPERTY GET_FILENAME_COMPONENT GET_SOURCE_FILE_PROPERTY GET_TARGET_PROPERTY GET_TEST_PROPERTY IF INCLUDE INCLUDE_DIRECTORIES INCLUDE_EXTERNAL_MSPROJECT INCLUDE_REGULAR_EXPRESSION INSTALL INSTALL_FILES INSTALL_PROGRAMS INSTALL_TARGETS LINK_DIRECTORIES LINK_LIBRARIES LIST LOAD_CACHE LOAD_COMMAND MACRO MAKE_DIRECTORY MARK_AS_ADVANCED MATH MESSAGE OPTION OUTPUT_REQUIRED_FILES PROJECT QT_WRAP_CPP QT_WRAP_UI REMOVE REMOVE_DEFINITIONS SEPARATE_ARGUMENTS SET SET_DIRECTORY_PROPERTIES SET_SOURCE_FILES_PROPERTIES SET_TARGET_PROPERTIES SET_TESTS_PROPERTIES SITE_NAME SOURCE_GROUP STRING SUBDIR_DEPENDS SUBDIRS TARGET_LINK_LIBRARIES TRY_COMPILE TRY_RUN USE_MANGLED_MESA UTILITY_SOURCE VARIABLE_REQUIRES VTK_MAKE_INSTANTIATOR VTK_WRAP_JAVA VTK_WRAP_PYTHON VTK_WRAP_TCL WHILE WRITE_FILE ENDMACRO + \ ADD_CUSTOM_COMMAND ADD_CUSTOM_TARGET ADD_DEFINITIONS ADD_DEPENDENCIES ADD_EXECUTABLE ADD_LIBRARY ADD_SUBDIRECTORY ADD_TEST AUX_SOURCE_DIRECTORY BUILD_COMMAND BUILD_NAME CMAKE_MINIMUM_REQUIRED CONFIGURE_FILE CREATE_TEST_SOURCELIST ELSE ELSEIF ENABLE_LANGUAGE ENABLE_TESTING ENDFOREACH ENDIF ENDWHILE EXEC_PROGRAM EXECUTE_PROCESS EXPORT_LIBRARY_DEPENDENCIES FILE FIND_FILE FIND_LIBRARY FIND_PACKAGE FIND_PATH FIND_PROGRAM FLTK_WRAP_UI FOREACH GET_CMAKE_PROPERTY GET_DIRECTORY_PROPERTY GET_FILENAME_COMPONENT GET_SOURCE_FILE_PROPERTY GET_TARGET_PROPERTY GET_TEST_PROPERTY IF INCLUDE INCLUDE_DIRECTORIES INCLUDE_EXTERNAL_MSPROJECT INCLUDE_REGULAR_EXPRESSION INSTALL INSTALL_FILES INSTALL_PROGRAMS INSTALL_TARGETS LINK_DIRECTORIES LINK_LIBRARIES LIST LOAD_CACHE LOAD_COMMAND MACRO MAKE_DIRECTORY MARK_AS_ADVANCED MATH MESSAGE OPTION OUTPUT_REQUIRED_FILES PROJECT QT_WRAP_CPP QT_WRAP_UI REMOVE REMOVE_DEFINITIONS SEPARATE_ARGUMENTS SET SET_DIRECTORY_PROPERTIES SET_SOURCE_FILES_PROPERTIES SET_TARGET_PROPERTIES SET_TESTS_PROPERTIES SITE_NAME SOURCE_GROUP STRING SUBDIR_DEPENDS SUBDIRS TARGET_LINK_LIBRARIES TRY_COMPILE TRY_RUN USE_MANGLED_MESA UTILITY_SOURCE VARIABLE_REQUIRES VTK_MAKE_INSTANTIATOR VTK_WRAP_JAVA VTK_WRAP_PYTHON VTK_WRAP_TCL WHILE WRITE_FILE ENDMACRO \ nextgroup=cmakeArgumnts "syn match cmakeMacro /^\s*[A-Z_]\+/ nextgroup=cmakeArgumnts
--- a/runtime/syntax/def.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/syntax/def.vim Fri Aug 29 15:41:29 2008 +0900 @@ -1,8 +1,8 @@ " Vim syntax file " Language: Microsoft Module-Definition (.def) File -" Maintainer: Rob Brady <robb@datatone.com> +" Orig Author: Rob Brady <robb@datatone.com> +" Maintainer: Wu Yongwei <wuyongwei@gmail.com> " Last Change: $Date$ -" URL: http://www.datatone.com/~robb/vim/syntax/def.vim " $Revision$ " For version 5.x: Clear all syntax items @@ -23,7 +23,7 @@ syn keyword defStorage LOADONCALL MOVEABLE DISCARDABLE SINGLE syn keyword defStorage FIXED PRELOAD -syn match defOrdinal "@\d\+" +syn match defOrdinal "\s\+@\d\+" syn region defString start=+'+ end=+'+
--- a/runtime/syntax/eruby.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/syntax/eruby.vim Fri Aug 29 15:41:29 2008 +0900 @@ -22,7 +22,7 @@ let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$") let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+') if b:eruby_subtype == '' - let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\)\+$','',''),'\.\zs\w\+$') + let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\)\+$','',''),'\.\zs\w\+$') endif if b:eruby_subtype == 'rhtml' let b:eruby_subtype = 'html' @@ -55,31 +55,20 @@ syn cluster erubyRegions contains=erubyOneLiner,erubyBlock,erubyExpression,erubyComment -exe 'syn region erubyOneLiner matchgroup=erubyDelimiter start="^%\{1,'.b:eruby_nest_level.'\}%\@!" end="$" contains=@rubyTop containedin=ALLBUT,@erbRegions keepend oneline' -exe 'syn region erubyBlock matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}%\@!-\=" end="-\=%>" contains=@rubyTop containedin=ALLBUT,@erbRegions' -exe 'syn region erubyExpression matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}=" end="-\=%>" contains=@rubyTop containedin=ALLBUT,@erbRegions' -exe 'syn region erubyComment matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}#" end="-\=%>" contains=rubyTodo,@Spell containedin=ALLBUT,@erbRegions keepend' +exe 'syn region erubyOneLiner matchgroup=erubyDelimiter start="^%\{1,'.b:eruby_nest_level.'\}%\@!" end="$" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend oneline' +exe 'syn region erubyBlock matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}%\@!-\=" end="-\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend' +exe 'syn region erubyExpression matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}=" end="-\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=@rubyTop containedin=ALLBUT,@erubyRegions keepend' +exe 'syn region erubyComment matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}#" end="-\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=rubyTodo,@Spell containedin=ALLBUT,@erubyRegions keepend' " Define the default highlighting. -" For version 5.7 and earlier: only when not done already -" For version 5.8 and later: only when an item doesn't have highlighting yet -if version >= 508 || !exists("did_eruby_syntax_inits") - if version < 508 - let did_ruby_syntax_inits = 1 - command -nargs=+ HiLink hi link <args> - else - command -nargs=+ HiLink hi def link <args> - endif - HiLink erubyDelimiter Delimiter - HiLink erubyComment Comment +hi def link erubyDelimiter Delimiter +hi def link erubyComment Comment - delcommand HiLink -endif let b:current_syntax = 'eruby' if main_syntax == 'eruby' unlet main_syntax endif -" vim: nowrap sw=2 sts=2 ts=8 ff=unix: +" vim: nowrap sw=2 sts=2 ts=8:
--- a/runtime/syntax/forth.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/syntax/forth.vim Fri Aug 29 15:41:29 2008 +0900 @@ -1,42 +1,68 @@ " Vim syntax file " Language: FORTH " Maintainer: Christian V. J. Brüssow <cvjb@cvjb.de> -" Last Change: Di 06 Jul 2004 18:40:33 CEST +" Last Change: Sa 09 Feb 2008 13:27:29 CET " Filenames: *.fs,*.ft -" URL: http://www.cvjb.de/comp/vim/forth.vim +" URL: http://www.cvjb.de/comp/vim/forth.vim " $Id$ " The list of keywords is incomplete, compared with the offical ANS " wordlist. If you use this language, please improve it, and send me " the patches. +" +" Before sending me patches, please download the newest version of this file +" from http://www.cvjb.de/comp/vim/forth.vim or http://www.vim.org/ (search +" for forth.vim). " Many Thanks to... " -" 2004-07-06: -" Changed "syn sync ccomment maxlines=200" line: splitted it into two separate -" lines. +" 2008-02-09: +" Shawn K. Quinn <sjquinn at speakeasy dot net> send a big patch with +" new words commonly used in Forth programs or defined by GNU Forth. " +" 2007-07-11: +" Benjamin Krill <ben at codiert dot org> send me a patch +" to highlight space errors. +" You can toggle this feature on through setting the +" flag forth_space_errors in you vimrc. If you have switched it on, +" you can turn off highlighting of trailing spaces in comments by +" setting forth_no_trail_space_error in your vimrc. If you do not want +" the highlighting of a tabulator following a space in comments, you +" can turn this off by setting forth_no_tab_space_error. +" +" 2006-05-25: +" Bill McCarthy <WJMc@...> and Ilya Sher <ilya-vim@...> +" Who found a bug in the ccomment line in 2004!!! +" I'm really very sorry, that it has taken two years to fix that +" in the offical version of this file. Shame on me. +" I think my face will be red the next ten years... +" +" 2006-05-21: +" Thomas E. Vaughan <tevaugha at ball dot com> send me a patch +" for the parenthesis comment word, so words with a trailing +" parenthesis will not start the highlighting for such comments. +" " 2003-05-10: " Andrew Gaul <andrew at gaul.org> send me a patch for " forthOperators. " " 2003-04-03: -" Ron Aaron <ronaharon at yahoo.com> made updates for an +" Ron Aaron <ron at ronware dot org> made updates for an " improved Win32Forth support. " " 2002-04-22: -" Charles Shattuck <charley at forth.org> helped me to settle up with the +" Charles Shattuck <charley at forth dot org> helped me to settle up with the " binary and hex number highlighting. " " 2002-04-20: -" Charles Shattuck <charley at forth.org> send me some code for correctly +" Charles Shattuck <charley at forth dot org> send me some code for correctly " highlighting char and [char] followed by an opening paren. He also added " some words for operators, conditionals, and definitions; and added the " highlighting for s" and c". " " 2000-03-28: -" John Providenza <john at probo.com> made improvements for the +" John Providenza <john at probo dot com> made improvements for the " highlighting of strings, and added the code for highlighting hex numbers. " @@ -61,33 +87,48 @@ syn match forthTodo contained 'Copyright\(\s([Cc])\)\=\(\s[0-9]\{2,4}\)\=' " Characters allowed in keywords -" I don't know if 128-255 are allowed in ANS-FORHT +" I don't know if 128-255 are allowed in ANS-FORTH if version >= 600 setlocal iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255 else set iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255 endif +" when wanted, highlight trailing white space +if exists("forth_space_errors") + if !exists("forth_no_trail_space_error") + syn match forthSpaceError display excludenl "\s\+$" + endif + if !exists("forth_no_tab_space_error") + syn match forthSpaceError display " \+\t"me=e-1 + endif +endif " Keywords " basic mathematical and logical operators syn keyword forthOperators + - * / MOD /MOD NEGATE ABS MIN MAX -syn keyword forthOperators AND OR XOR NOT INVERT 2* 2/ 1+ 1- 2+ 2- 8* +syn keyword forthOperators AND OR XOR NOT LSHIFT RSHIFT INVERT 2* 2/ 1+ +syn keyword forthOperators 1- 2+ 2- 8* UNDER+ syn keyword forthOperators M+ */ */MOD M* UM* M*/ UM/MOD FM/MOD SM/REM -syn keyword forthOperators D+ D- DNEGATE DABS DMIN DMAX +syn keyword forthOperators D+ D- DNEGATE DABS DMIN DMAX D2* D2/ syn keyword forthOperators F+ F- F* F/ FNEGATE FABS FMAX FMIN FLOOR FROUND syn keyword forthOperators F** FSQRT FEXP FEXPM1 FLN FLNP1 FLOG FALOG FSIN syn keyword forthOperators FCOS FSINCOS FTAN FASIN FACOS FATAN FATAN2 FSINH -syn keyword forthOperators FCOSH FTANH FASINH FACOSH FATANH -syn keyword forthOperators 0< 0<= 0<> 0= 0> 0>= < <= <> = > >= -syn keyword forthOperators ?NEGATE ?DNEGATE +syn keyword forthOperators FCOSH FTANH FASINH FACOSH FATANH F2* F2/ 1/F +syn keyword forthOperators F~REL F~ABS F~ +syn keyword forthOperators 0< 0<= 0<> 0= 0> 0>= < <= <> = > >= U< U<= +syn keyword forthOperators U> U>= D0< D0<= D0<> D0= D0> D0>= D< D<= D<> +syn keyword forthOperators D= D> D>= DU< DU<= DU> DU>= WITHIN ?NEGATE +syn keyword forthOperators ?DNEGATE " stack manipulations syn keyword forthStack DROP NIP DUP OVER TUCK SWAP ROT -ROT ?DUP PICK ROLL -syn keyword forthStack 2DROP 2NIP 2DUP 2OVER 2TUCK 2SWAP 2ROT -syn keyword forthStack 3DUP 4DUP +syn keyword forthStack 2DROP 2NIP 2DUP 2OVER 2TUCK 2SWAP 2ROT 2-ROT +syn keyword forthStack 3DUP 4DUP 5DUP 3DROP 4DROP 5DROP 8DROP 4SWAP 4ROT +syn keyword forthStack 4-ROT 4TUCK 8SWAP 8DUP syn keyword forthRStack >R R> R@ RDROP 2>R 2R> 2R@ 2RDROP +syn keyword forthRstack 4>R 4R> 4R@ 4RDROP syn keyword forthFStack FDROP FNIP FDUP FOVER FTUCK FSWAP FROT " stack pointer manipulations @@ -112,24 +153,40 @@ syn keyword forthLoop UNLOOP LEAVE ?LEAVE EXIT DONE FOR NEXT " new words +syn match forthClassDef '\<:class\s*[^ \t]\+\>' +syn match forthObjectDef '\<:object\s*[^ \t]\+\>' syn match forthColonDef '\<:m\?\s*[^ \t]\+\>' syn keyword forthEndOfColonDef ; ;M ;m -syn keyword forthDefine CONSTANT 2CONSTANT FCONSTANT VARIABLE 2VARIABLE CREATE -syn keyword forthDefine USER VALUE TO DEFER IS DOES> IMMEDIATE COMPILE-ONLY -syn keyword forthDefine COMPILE RESTRICT INTERPRET POSTPONE EXECUTE LITERAL -syn keyword forthDefine CREATE-INTERPRET/COMPILE INTERPRETATION> <INTERPRETATION -syn keyword forthDefine COMPILATION> <COMPILATION ] LASTXT COMP' POSTPONE, -syn keyword forthDefine FIND-NAME NAME>INT NAME?INT NAME>COMP NAME>STRING STATE -syn keyword forthDefine C; CVARIABLE +syn keyword forthEndOfClassDef ;class +syn keyword forthEndOfObjectDef ;object +syn keyword forthDefine CONSTANT 2CONSTANT FCONSTANT VARIABLE 2VARIABLE +syn keyword forthDefine FVARIABLE CREATE USER VALUE TO DEFER IS DOES> IMMEDIATE +syn keyword forthDefine COMPILE-ONLY COMPILE RESTRICT INTERPRET POSTPONE EXECUTE +syn keyword forthDefine LITERAL CREATE-INTERPRET/COMPILE INTERPRETATION> +syn keyword forthDefine <INTERPRETATION COMPILATION> <COMPILATION ] LASTXT +syn keyword forthDefine COMP' POSTPONE, FIND-NAME NAME>INT NAME?INT NAME>COMP +syn keyword forthDefine NAME>STRING STATE C; CVARIABLE +syn keyword forthDefine , 2, F, C, +syn match forthDefine "\[IFDEF]" +syn match forthDefine "\[IFUNDEF]" +syn match forthDefine "\[THEN]" +syn match forthDefine "\[ENDIF]" +syn match forthDefine "\[ELSE]" +syn match forthDefine "\[?DO]" +syn match forthDefine "\[DO]" +syn match forthDefine "\[LOOP]" +syn match forthDefine "\[+LOOP]" +syn match forthDefine "\[NEXT]" +syn match forthDefine "\[BEGIN]" +syn match forthDefine "\[UNTIL]" +syn match forthDefine "\[AGAIN]" +syn match forthDefine "\[WHILE]" +syn match forthDefine "\[REPEAT]" syn match forthDefine "\[COMP']" syn match forthDefine "'" syn match forthDefine '\<\[\>' syn match forthDefine "\[']" syn match forthDefine '\[COMPILE]' -syn match forthClassDef '\<:class\s*[^ \t]\+\>' -syn match forthObjectDef '\<:object\s*[^ \t]\+\>' -syn keyword forthEndOfClassDef ';class' -syn keyword forthEndOfObjectDef ';object' " debugging syn keyword forthDebug PRINTDEBUGDATA PRINTDEBUGLINE @@ -148,27 +205,48 @@ syn region forthCharOps start=+."\s+ skip=+\\"+ end=+"+ " char-number conversion -syn keyword forthConversion <# # #> #S (NUMBER) (NUMBER?) CONVERT D>F D>S DIGIT -syn keyword forthConversion DPL F>D HLD HOLD NUMBER S>D SIGN >NUMBER +syn keyword forthConversion <<# <# # #> #>> #S (NUMBER) (NUMBER?) CONVERT D>F +syn keyword forthConversion D>S DIGIT DPL F>D HLD HOLD NUMBER S>D SIGN >NUMBER +syn keyword forthConversion F>S S>F " interptreter, wordbook, compiler syn keyword forthForth (LOCAL) BYE COLD ABORT >BODY >NEXT >LINK CFA >VIEW HERE syn keyword forthForth PAD WORDS VIEW VIEW> N>LINK NAME> LINK> L>NAME FORGET -syn keyword forthForth BODY> +syn keyword forthForth BODY> ASSERT( ASSERT0( ASSERT1( ASSERT2( ASSERT3( ) syn region forthForth start=+ABORT"\s+ skip=+\\"+ end=+"+ " vocabularies syn keyword forthVocs ONLY FORTH ALSO ROOT SEAL VOCS ORDER CONTEXT #VOCS syn keyword forthVocs VOCABULARY DEFINITIONS +" File keywords +syn keyword forthFileMode R/O R/W W/O BIN +syn keyword forthFileWords OPEN-FILE CREATE-FILE CLOSE-FILE DELETE-FILE +syn keyword forthFileWords RENAME-FILE READ-FILE READ-LINE KEY-FILE +syn keyword forthFileWords KEY?-FILE WRITE-FILE WRITE-LINE EMIT-FILE +syn keyword forthFileWords FLUSH-FILE FILE-STATUS FILE-POSITION +syn keyword forthFileWords REPOSITION-FILE FILE-SIZE RESIZE-FILE +syn keyword forthFileWords SLURP-FILE SLURP-FID STDIN STDOUT STDERR +syn keyword forthBlocks OPEN-BLOCKS USE LOAD --> BLOCK-OFFSET +syn keyword forthBlocks GET-BLOCK-FID BLOCK-POSITION LIST SCR BLOCK +syn keyword forthBlocks BUFER EMPTY-BUFFERS EMPTY-BUFFER UPDATE UPDATED? +syn keyword forthBlocks SAVE-BUFFERS SAVE-BUFFER FLUSH THRU +LOAD +THRU +syn keyword forthBlocks BLOCK-INCLUDED + " numbers syn keyword forthMath DECIMAL HEX BASE syn match forthInteger '\<-\=[0-9.]*[0-9.]\+\>' +syn match forthInteger '\<&-\=[0-9.]*[0-9.]\+\>' " recognize hex and binary numbers, the '$' and '%' notation is for gforth syn match forthInteger '\<\$\x*\x\+\>' " *1* --- dont't mess syn match forthInteger '\<\x*\d\x*\>' " *2* --- this order! syn match forthInteger '\<%[0-1]*[0-1]\+\>' -syn match forthFloat '\<-\=\d*[.]\=\d\+[Ee]\d\+\>' +syn match forthFloat '\<-\=\d*[.]\=\d\+[DdEe]\d\+\>' +syn match forthFloat '\<-\=\d*[.]\=\d\+[DdEe][-+]\d\+\>' + +" XXX If you find this overkill you can remove it. this has to come after the +" highlighting for numbers otherwise it has no effect. +syn region forthComment start='0 \[if\]' end='\[endif\]' end='\[then\]' contains=forthTodo " Strings syn region forthString start=+\.*\"+ end=+"+ end=+$+ @@ -177,27 +255,32 @@ syn region forthString start=+c\"+ end=+"+ end=+$+ " Comments -syn match forthComment '\\\s.*$' contains=forthTodo -syn region forthComment start='\\S\s' end='.*' contains=forthTodo -syn match forthComment '\.(\s[^)]*)' contains=forthTodo -syn region forthComment start='(\s' skip='\\)' end=')' contains=forthTodo -syn region forthComment start='/\*' end='\*/' contains=forthTodo -"syn match forthComment '(\s[^\-]*\-\-[^\-]*)' contains=forthTodo +syn match forthComment '\\\s.*$' contains=forthTodo,forthSpaceError +syn region forthComment start='\\S\s' end='.*' contains=forthTodo,forthSpaceError +syn match forthComment '\.(\s[^)]*)' contains=forthTodo,forthSpaceError +syn region forthComment start='\s(\s' skip='\\)' end=')' contains=forthTodo,forthSpaceError +syn region forthComment start='/\*' end='\*/' contains=forthTodo,forthSpaceError " Include files syn match forthInclude '^INCLUDE\s\+\k\+' +syn match forthInclude '^require\s\+\k\+' syn match forthInclude '^fload\s\+' syn match forthInclude '^needs\s\+' +" Locals definitions +syn region forthLocals start='{\s' start='{$' end='\s}' end='^}' +syn match forthLocals '{ }' " otherwise, at least two spaces between +syn region forthDeprecated start='locals|' end='|' + " Define the default highlighting. " For version 5.7 and earlier: only when not done already " For version 5.8 and later: only when an item doesn't have highlighting yet if version >= 508 || !exists("did_forth_syn_inits") if version < 508 - let did_forth_syn_inits = 1 - command -nargs=+ HiLink hi link <args> + let did_forth_syn_inits = 1 + command -nargs=+ HiLink hi link <args> else - command -nargs=+ HiLink hi def link <args> + command -nargs=+ HiLink hi def link <args> endif " The default methods for highlighting. Can be overriden later. @@ -231,6 +314,12 @@ HiLink forthObjectDef Define HiLink forthEndOfObjectDef Define HiLink forthInclude Include + HiLink forthLocals Type " nothing else uses type and locals must stand out + HiLink forthDeprecated Error " if you must, change to Type + HiLink forthFileMode Function + HiLink forthFileWords Statement + HiLink forthBlocks Statement + HiLink forthSpaceError Error delcommand HiLink endif
--- a/runtime/syntax/rhelp.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/syntax/rhelp.vim Fri Aug 29 15:41:29 2008 +0900 @@ -1,8 +1,8 @@ " Vim syntax file " Language: R Help File " Maintainer: Johannes Ranke <jranke@uni-bremen.de> -" Last Change: 2006 Apr 24 -" Version: 0.7 +" Last Change: 2008 Apr 10 +" Version: 0.7.1 " SVN: $Id$ " Remarks: - Now includes R syntax highlighting in the appropriate " sections if an r.vim file is in the same directory or in the @@ -107,6 +107,7 @@ syn match rhelpSection "\\dontrun\>" syn match rhelpSection "\\dontshow\>" syn match rhelpSection "\\testonly\>" +syn match rhelpSection "\\donttest\>" " Freely named Sections {{{1 syn region rhelpFreesec matchgroup=Delimiter start="\\section{" matchgroup=Delimiter transparent end=/}/
--- a/runtime/syntax/ruby.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/syntax/ruby.vim Fri Aug 29 15:41:29 2008 +0900 @@ -19,6 +19,8 @@ setlocal foldmethod=syntax endif +syn cluster rubyNotTop contains=@rubyExtendedStringSpecial,@rubyRegexpSpecial,@rubyDeclaration,rubyConditional,rubyTodo + if exists("ruby_space_errors") if !exists("ruby_no_trail_space_error") syn match rubySpaceError display excludenl "\s\+$" @@ -32,14 +34,14 @@ if exists("ruby_operators") syn match rubyOperator "\%([~!^&|*/%+-]\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@<!>\|\*\*\|\.\.\.\|\.\.\|::\)" syn match rubyPseudoOperator "\%(-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=\)" - syn region rubyBracketOperator matchgroup=rubyOperator start="\%([_[:lower:]]\w*[?!=]\=\|[})]\)\@<=\[\s*" end="\s*]" contains=TOP + syn region rubyBracketOperator matchgroup=rubyOperator start="\%(\w[?!]\=\|[]})]\)\@<=\[\s*" end="\s*]" contains=ALLBUT,@rubyNotTop endif " Expression Substitution and Backslash Notation -syn match rubyEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display -syn match rubyEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display +syn match rubyStringEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display +syn match rubyStringEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display -syn region rubyInterpolation matchgroup=rubyInterpolationDelimiter start="#{" end="}" contained contains=TOP +syn region rubyInterpolation matchgroup=rubyInterpolationDelimiter start="#{" end="}" contained contains=ALLBUT,@rubyNotTop syn match rubyInterpolation "#\%(\$\|@@\=\)\w\+" display contained contains=rubyInterpolationDelimiter,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable,rubyPredefinedVariable syn match rubyInterpolationDelimiter "#\ze\%(\$\|@@\=\)\w\+" display contained syn match rubyInterpolation "#\$\%(-\w\|\W\)" display contained contains=rubyInterpolationDelimiter,rubyPredefinedVariable,rubyInvalidVariable @@ -51,17 +53,32 @@ syn match rubyDelimEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE -syn region rubyNestedParentheses start="(" end=")" skip="\\\\\|\\)" transparent contained contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape -syn region rubyNestedCurlyBraces start="{" end="}" skip="\\\\\|\\}" transparent contained contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimEscape -syn region rubyNestedAngleBrackets start="<" end=">" skip="\\\\\|\\>" transparent contained contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimEscape -if exists("ruby_operators") - syn region rubyNestedSquareBrackets start="\[" end="\]" skip="\\\\\|\\\]" transparent contained contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape -else - syn region rubyNestedSquareBrackets start="\[" end="\]" skip="\\\\\|\\\]" transparent containedin=rubyArrayLiteral contained contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape -endif +syn region rubyNestedParentheses start="(" skip="\\\\\|\\)" matchgroup=rubyString end=")" transparent contained +syn region rubyNestedCurlyBraces start="{" skip="\\\\\|\\}" matchgroup=rubyString end="}" transparent contained +syn region rubyNestedAngleBrackets start="<" skip="\\\\\|\\>" matchgroup=rubyString end=">" transparent contained +syn region rubyNestedSquareBrackets start="\[" skip="\\\\\|\\\]" matchgroup=rubyString end="\]" transparent contained -syn cluster rubyStringSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyEscape +" These are mostly Oniguruma ready +syn region rubyRegexpComment matchgroup=rubyRegexpSpecial start="(?#" skip="\\)" end=")" contained +syn region rubyRegexpParens matchgroup=rubyRegexpSpecial start="(\(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\)" end=")" contained transparent contains=@rubyRegexpSpecial +syn region rubyRegexpBrackets matchgroup=rubyRegexpCharClass start="\[\^\=" skip="\\\]" end="\]" contained transparent contains=rubyStringEscape,rubyRegexpEscape,rubyRegexpCharClass oneline +syn match rubyRegexpCharClass "\\[DdHhSsWw]" contained display +syn match rubyRegexpCharClass "\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|xdigit\):\]" contained +syn match rubyRegexpEscape "\\[].*?+^$|\\/(){}[]" contained display +syn match rubyRegexpQuantifier "[*?+][?+]\=" contained display +syn match rubyRegexpQuantifier "{\d\+\%(,\d*\)\=}?\=" contained display +syn match rubyRegexpAnchor "[$^]\|\\[ABbGZz]" contained display +syn match rubyRegexpDot "\." contained display +syn match rubyRegexpSpecial "|" contained display +syn match rubyRegexpSpecial "\\[1-9]\d\=\d\@!" contained display +syn match rubyRegexpSpecial "\\k<\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\=>" contained display +syn match rubyRegexpSpecial "\\k'\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\='" contained display +syn match rubyRegexpSpecial "\\g<\%([a-z_]\w*\|-\=\d\+\)>" contained display +syn match rubyRegexpSpecial "\\g'\%([a-z_]\w*\|-\=\d\+\)'" contained display + +syn cluster rubyStringSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape syn cluster rubyExtendedStringSpecial contains=@rubyStringSpecial,rubyNestedParentheses,rubyNestedCurlyBraces,rubyNestedAngleBrackets,rubyNestedSquareBrackets +syn cluster rubyRegexpSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape,rubyRegexpSpecial,rubyRegexpEscape,rubyRegexpBrackets,rubyRegexpCharClass,rubyRegexpDot,rubyRegexpQuantifier,rubyRegexpAnchor,rubyRegexpParens,rubyRegexpComment " Numbers and ASCII Codes syn match rubyASCIICode "\%(\w\|[]})\"'/]\)\@<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)" @@ -83,14 +100,14 @@ syn match rubySymbol "[]})\"':]\@<!:\%(\^\|\~\|<<\|<=>\|<=\|<\|===\|==\|=\~\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" syn match rubySymbol "[]})\"':]\@<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)" syn match rubySymbol "[]})\"':]\@<!:\%(\$\|@@\=\)\=\h\w*" -syn match rubySymbol "[]})\"':]\@<!:\h\w*[?!=]\=" +syn match rubySymbol "[]})\"':]\@<!:\h\w*\%([?!=]>\@!\)\=" syn region rubySymbol start="[]})\"':]\@<!:\"" end="\"" skip="\\\\\|\\\"" syn region rubySymbol start="[]})\"':]\@<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold syn match rubyBlockParameter "\h\w*" contained syn region rubyBlockParameterList start="\%(\%(\<do\>\|{\)\s*\)\@<=|" end="|" oneline display contains=rubyBlockParameter -syn match rubyInvalidVariable "$[^ A-Za-z-]" +syn match rubyInvalidVariable "$[^ A-Za-z_-]" syn match rubyPredefinedVariable #$[!$&"'*+,./0:;<=>?@\`~1-9]# syn match rubyPredefinedVariable "$_\>" display syn match rubyPredefinedVariable "$-[0FIKadilpvw]\>" display @@ -104,32 +121,32 @@ "syn match rubyPredefinedConstant "\%(::\)\=\zs\%(NotImplementError\)\>" " Normal Regular Expression -syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,[>]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyStringSpecial fold -syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\<\%(split\|scan\|gsub\|sub\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyStringSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,[>]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial keepend fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/[ \t=]\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold + +" Generalized Regular Expression +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyRegexpSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyRegexpSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyRegexpSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial fold " Normal String and Shell Command Output syn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold syn region rubyString matchgroup=rubyStringDelimiter start="'" end="'" skip="\\\\\|\\'" fold syn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial fold -" Generalized Regular Expression -syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold -syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimEscape fold -syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold -syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape fold -syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape fold - " Generalized Single Quoted String, Symbol and Array of Strings syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimEscape syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimEscape syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimEscape syn region rubyString matchgroup=rubyStringDelimiter start="%[qw](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimEscape -syn region rubySymbol start="%[s]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold -syn region rubySymbol start="%[s]{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimEscape -syn region rubySymbol start="%[s]<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimEscape -syn region rubySymbol start="%[s]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimEscape -syn region rubySymbol start="%[s](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimEscape +syn region rubySymbol matchgroup=rubySymbolDelimiter start="%[s]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold +syn region rubySymbol matchgroup=rubySymbolDelimiter start="%[s]{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimEscape +syn region rubySymbol matchgroup=rubySymbolDelimiter start="%[s]<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimEscape +syn region rubySymbol matchgroup=rubySymbolDelimiter start="%[s]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimEscape +syn region rubySymbol matchgroup=rubySymbolDelimiter start="%[s](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimEscape " Generalized Double Quoted String and Array of Strings and Shell Command Output " Note: %= is not matched here as the beginning of a double quoted string @@ -141,10 +158,10 @@ syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape fold " Here Document -syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs\%(\h\w*\)+ end=+$+ oneline contains=TOP -syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=TOP -syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs'\%([^']*\)'+ end=+$+ oneline contains=TOP -syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=TOP +syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs\%(\h\w*\)+ end=+$+ oneline contains=ALLBUT,@rubyNotTop +syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=ALLBUT,@rubyNotTop +syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs'\%([^']*\)'+ end=+$+ oneline contains=ALLBUT,@rubyNotTop +syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=ALLBUT,@rubyNotTop syn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<\z(\h\w*\)\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend syn region rubyString start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<"\z([^"]*\)"\ze+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend @@ -163,43 +180,46 @@ syn match rubyAliasDeclaration "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable nextgroup=rubyAliasDeclaration2 skipwhite syn match rubyAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable syn match rubyMethodDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable -syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant -syn match rubyModuleDeclaration "[^[:space:];#]\+" contained contains=rubyConstant +syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant,rubyOperator +syn match rubyModuleDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant,rubyOperator syn match rubyFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:].:?!=]\@!" contained containedin=rubyMethodDeclaration syn match rubyFunction "\%(\s\|^\)\@<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2 syn match rubyFunction "\%([[:space:].]\|^\)\@<=\%(\[\]=\=\|\*\*\|[+-]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|==\|=\~\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration +syn cluster rubyDeclaration contains=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration,rubyModuleDeclaration,rubyClassDeclaration,rubyFunction,rubyBlockParameter + " Expensive Mode - match 'end' with the appropriate opening keyword for syntax " based folding and special highlighting of module/class/method definitions if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive") syn match rubyDefine "\<alias\>" nextgroup=rubyAliasDeclaration skipwhite skipnl syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl + syn match rubyDefine "\<undef\>" nextgroup=rubyFunction skipwhite skipnl syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl - syn region rubyBlock start="\<def\>" matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=TOP fold - syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=TOP fold - syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=TOP fold + syn region rubyBlock start="\<def\>" matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop fold + syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=ALLBUT,@rubyNotTop fold + syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=ALLBUT,@rubyNotTop fold " modifiers syn match rubyConditionalModifier "\<\%(if\|unless\)\>" display syn match rubyRepeatModifier "\<\%(while\|until\)\>" display - syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=TOP fold + syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold " curly bracket block or hash literal - syn region rubyCurlyBlock start="{" end="}" contains=TOP fold - syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\w\|[\]})]\)\@<!\[" end="]" contains=TOP fold + syn region rubyCurlyBlock start="{" end="}" contains=ALLBUT,@rubyNotTop fold + syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\w\|[\]})]\)\@<!\[" end="]" contains=ALLBUT,@rubyNotTop fold " statements without 'do' - syn region rubyBlockExpression matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=TOP fold - syn region rubyCaseExpression matchgroup=rubyConditional start="\<case\>" end="\<end\>" contains=TOP fold - syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!?]\)\s*\)\@<=\%(if\|unless\)\>" end="\<end\>" contains=TOP fold + syn region rubyBlockExpression matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold + syn region rubyCaseExpression matchgroup=rubyConditional start="\<case\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold + syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![?!]\)\s*\)\@<=\%(if\|unless\)\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold - syn keyword rubyConditional then else when contained containedin=rubyCaseExpression - syn keyword rubyConditional then else elsif contained containedin=rubyConditionalExpression + syn match rubyConditional "\<\%(then\|else\|when\)\>[?!]\@!" contained containedin=rubyCaseExpression + syn match rubyConditional "\<\%(then\|else\|elsif\)\>[?!]\@!" contained containedin=rubyConditionalExpression " statements with optional 'do' - syn region rubyOptionalDoLine matchgroup=rubyRepeat start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyOptionalDo end="\%(\<do\>\)" end="\ze\%(;\|$\)" oneline contains=TOP - syn region rubyRepeatExpression start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat end="\<end\>" contains=TOP nextgroup=rubyOptionalDoLine fold + syn region rubyOptionalDoLine matchgroup=rubyRepeat start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyOptionalDo end="\%(\<do\>\)" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@rubyNotTop + syn region rubyRepeatExpression start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat end="\<end\>" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine fold if !exists("ruby_minlines") let ruby_minlines = 50 @@ -207,31 +227,35 @@ exec "syn sync minlines=" . ruby_minlines else - syn match rubyControl "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl - syn match rubyControl "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl - syn match rubyControl "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl - syn keyword rubyControl case begin do for if unless while until else elsif then when end - syn keyword rubyKeyword alias + syn match rubyControl "\<def\>[?!]\@!" nextgroup=rubyMethodDeclaration skipwhite skipnl + syn match rubyControl "\<class\>[?!]\@!" nextgroup=rubyClassDeclaration skipwhite skipnl + syn match rubyControl "\<module\>[?!]\@!" nextgroup=rubyModuleDeclaration skipwhite skipnl + syn match rubyControl "\<\%(case\|begin\|do\|for\|if\|unless\|while\|until\|else\|elsif\|then\|when\|end\)\>[?!]\@!" + syn match rubyKeyword "\<\%(alias\|undef\)\>[?!]\@!" endif " Keywords " Note: the following keywords have already been defined: " begin case class def do end for if module unless until while -syn keyword rubyControl and break ensure in next not or redo rescue retry return +syn match rubyControl "\<\%(and\|break\|ensure\|in\|next\|not\|or\|redo\|rescue\|retry\|return\)\>[?!]\@!" syn match rubyOperator "\<defined?" display -syn keyword rubyKeyword super undef yield -syn keyword rubyBoolean true false -syn keyword rubyPseudoVariable nil self __FILE__ __LINE__ -syn keyword rubyBeginEnd BEGIN END +syn match rubyKeyword "\<\%(super\|yield\)\>[?!]\@!" +syn match rubyBoolean "\<\%(true\|false\)\>[?!]\@!" +syn match rubyPseudoVariable "\<\%(nil\|self\|__FILE__\|__LINE__\)\>[?!]\@!" +syn match rubyBeginEnd "\<\%(BEGIN\|END\)\>[?!]\@!" " Special Methods if !exists("ruby_no_special_methods") - syn keyword rubyAccess public protected private - syn keyword rubyAttribute attr attr_accessor attr_reader attr_writer - syn match rubyControl "\<\%(exit!\|\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>\)" + syn keyword rubyAccess public protected private module_function + " attr is a common variable name + syn match rubyAttribute "\%(\%(^\|;\)\s*\)\@<=attr\>\(\s*[.=]\)\@!" + syn keyword rubyAttribute attr_accessor attr_reader attr_writer + syn match rubyControl "\<\%(exit!\|\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>[?!]\@!\)" syn keyword rubyEval eval class_eval instance_eval module_eval syn keyword rubyException raise fail catch throw - syn keyword rubyInclude autoload extend include load require + " false positive with 'include?' + syn match rubyInclude "\<include\>[?!]\@!" + syn keyword rubyInclude autoload extend load require syn keyword rubyKeyword callcc caller lambda proc endif @@ -252,6 +276,9 @@ syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(not\|or\|redo\|rescue\|retry\|return\|self\|super\|then\|true\)\>" transparent contains=NONE syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(undef\|unless\|until\|when\|while\|yield\|BEGIN\|END\|__FILE__\|__LINE__\)\>" transparent contains=NONE +syn match rubyKeywordAsMethod "\<\%(alias\|begin\|case\|class\|def\|do\|end\)[?!]" transparent contains=NONE +syn match rubyKeywordAsMethod "\<\%(if\|module\|undef\|unless\|until\|while\)[?!]" transparent contains=NONE + syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(abort\|at_exit\|attr\|attr_accessor\|attr_reader\)\>" transparent contains=NONE syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(attr_writer\|autoload\|callcc\|catch\|caller\)\>" transparent contains=NONE syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(eval\|class_eval\|instance_eval\|module_eval\|exit\)\>" transparent contains=NONE @@ -305,15 +332,24 @@ hi def link rubyData Comment hi def link rubyDataDirective Delimiter hi def link rubyDocumentation Comment -hi def link rubyEscape Special +hi def link rubyTodo Todo + +hi def link rubyStringEscape Special hi def link rubyInterpolationDelimiter Delimiter hi def link rubyNoInterpolation rubyString hi def link rubySharpBang PreProc hi def link rubyRegexpDelimiter rubyStringDelimiter +hi def link rubySymbolDelimiter rubyStringDelimiter hi def link rubyStringDelimiter Delimiter +hi def link rubyString String +hi def link rubyRegexpEscape rubyRegexpSpecial +hi def link rubyRegexpQuantifier rubyRegexpSpecial +hi def link rubyRegexpAnchor rubyRegexpSpecial +hi def link rubyRegexpDot rubyRegexpCharClass +hi def link rubyRegexpCharClass rubyRegexpSpecial +hi def link rubyRegexpSpecial Special +hi def link rubyRegexpComment Comment hi def link rubyRegexp rubyString -hi def link rubyString String -hi def link rubyTodo Todo hi def link rubyInvalidVariable Error hi def link rubyError Error @@ -321,4 +357,4 @@ let b:current_syntax = "ruby" -" vim: nowrap sw=2 sts=2 ts=8 noet ff=unix: +" vim: nowrap sw=2 sts=2 ts=8 noet:
--- a/runtime/syntax/svn.vim Wed Aug 13 17:54:25 2008 +0900 +++ b/runtime/syntax/svn.vim Fri Aug 29 15:41:29 2008 +0900 @@ -4,10 +4,11 @@ " URL: http://www.hlabs.spb.ru/vim/svn.vim " Revision: $Id$ " Filenames: svn-commit*.tmp -" Version: 1.5 +" Version: 1.6 " Contributors: " Stefano Zacchiroli +" A. S. Budden " For version 5.x: Clear all syntax items. " For version 6.x: Quit when a syntax file was already loaded. @@ -17,7 +18,7 @@ finish endif -syn region svnRegion start="^--.*--$" end="\%$" contains=ALL +syn region svnRegion start="^--.*--$" end="\%$" contains=ALL contains=@NoSpell syn match svnRemoved "^D .*$" contained syn match svnAdded "^A[ M] .*$" contained syn match svnModified "^M[ M] .*$" contained
--- a/src/eval.c Wed Aug 13 17:54:25 2008 +0900 +++ b/src/eval.c Fri Aug 29 15:41:29 2008 +0900 @@ -10,12 +10,14 @@ /* * eval.c: Expression evaluation. */ -#if defined(MSDOS) || defined(MSWIN) +#if defined(MSDOS) || defined(WIN16) || defined(WIN32) || defined(_WIN64) # include "vimio.h" /* for mch_open(), must be before vim.h */ #endif #include "vim.h" +#if defined(FEAT_EVAL) || defined(PROTO) + #ifdef AMIGA # include <time.h> /* for strftime() */ #endif @@ -24,11 +26,9 @@ # include <time.h> /* for time_t */ #endif -#ifdef HAVE_FCNTL_H -# include <fcntl.h> -#endif - -#if defined(FEAT_EVAL) || defined(PROTO) +#if defined(FEAT_FLOAT) && defined(HAVE_MATH_H) +# include <math.h> +#endif #define DICT_MAXNEST 100 /* maximum nesting of lists and dicts */ @@ -108,6 +108,7 @@ static char *e_letwrong = N_("E734: Wrong variable type for %s="); static char *e_nofunc = N_("E130: Unknown function: %s"); static char *e_illvar = N_("E461: Illegal variable name: %s"); + /* * All user-defined global variables are stored in dictionary "globvardict". * "globvars_var" is the variable that is used for "g:". @@ -164,13 +165,13 @@ int uf_profiling; /* TRUE when func is being profiled */ /* profiling the function as a whole */ int uf_tm_count; /* nr of calls */ - proftime_T uf_tm_total; /* time spend in function + children */ - proftime_T uf_tm_self; /* time spend in function itself */ + proftime_T uf_tm_total; /* time spent in function + children */ + proftime_T uf_tm_self; /* time spent in function itself */ proftime_T uf_tm_children; /* time spent in children this call */ /* profiling the function per line */ int *uf_tml_count; /* nr of times line was executed */ - proftime_T *uf_tml_total; /* time spend in a line + children */ - proftime_T *uf_tml_self; /* time spend in a line itself */ + proftime_T *uf_tml_total; /* time spent in a line + children */ + proftime_T *uf_tml_self; /* time spent in a line itself */ proftime_T uf_tml_start; /* start time for current line */ proftime_T uf_tml_children; /* time spent in children for this line */ proftime_T uf_tml_wait; /* start wait time for current line */ @@ -345,13 +346,16 @@ {VV_NAME("mouse_win", VAR_NUMBER), 0}, {VV_NAME("mouse_lnum", VAR_NUMBER), 0}, {VV_NAME("mouse_col", VAR_NUMBER), 0}, + {VV_NAME("operator", VAR_STRING), VV_RO}, + {VV_NAME("searchforward", VAR_NUMBER), 0}, }; /* shorthand */ -#define vv_type vv_di.di_tv.v_type -#define vv_nr vv_di.di_tv.vval.v_number -#define vv_str vv_di.di_tv.vval.v_string -#define vv_tv vv_di.di_tv +#define vv_type vv_di.di_tv.v_type +#define vv_nr vv_di.di_tv.vval.v_number +#define vv_float vv_di.di_tv.vval.v_float +#define vv_str vv_di.di_tv.vval.v_string +#define vv_tv vv_di.di_tv /* * The v: variables are stored in dictionary "vimvardict". @@ -401,8 +405,8 @@ static int eval3 __ARGS((char_u **arg, typval_T *rettv, int evaluate)); static int eval4 __ARGS((char_u **arg, typval_T *rettv, int evaluate)); static int eval5 __ARGS((char_u **arg, typval_T *rettv, int evaluate)); -static int eval6 __ARGS((char_u **arg, typval_T *rettv, int evaluate)); -static int eval7 __ARGS((char_u **arg, typval_T *rettv, int evaluate)); +static int eval6 __ARGS((char_u **arg, typval_T *rettv, int evaluate, int want_string)); +static int eval7 __ARGS((char_u **arg, typval_T *rettv, int evaluate, int want_string)); static int eval_index __ARGS((char_u **arg, typval_T *rettv, int evaluate, int verbose)); static int get_option_tv __ARGS((char_u **arg, typval_T *rettv, int evaluate)); @@ -449,18 +453,28 @@ static char_u *echo_string __ARGS((typval_T *tv, char_u **tofree, char_u *numbuf, int copyID)); static char_u *tv2string __ARGS((typval_T *tv, char_u **tofree, char_u *numbuf, int copyID)); static char_u *string_quote __ARGS((char_u *str, int function)); +#ifdef FEAT_FLOAT +static int string2float __ARGS((char_u *text, float_T *value)); +#endif static int get_env_tv __ARGS((char_u **arg, typval_T *rettv, int evaluate)); static int find_internal_func __ARGS((char_u *name)); static char_u *deref_func_name __ARGS((char_u *name, int *lenp)); static int get_func_tv __ARGS((char_u *name, int len, typval_T *rettv, char_u **arg, linenr_T firstline, linenr_T lastline, int *doesrange, int evaluate, dict_T *selfdict)); static int call_func __ARGS((char_u *name, int len, typval_T *rettv, int argcount, typval_T *argvars, linenr_T firstline, linenr_T lastline, int *doesrange, int evaluate, dict_T *selfdict)); static void emsg_funcname __ARGS((char *ermsg, char_u *name)); - +static int non_zero_arg __ARGS((typval_T *argvars)); + +#ifdef FEAT_FLOAT +static void f_abs __ARGS((typval_T *argvars, typval_T *rettv)); +#endif static void f_add __ARGS((typval_T *argvars, typval_T *rettv)); static void f_append __ARGS((typval_T *argvars, typval_T *rettv)); static void f_argc __ARGS((typval_T *argvars, typval_T *rettv)); static void f_argidx __ARGS((typval_T *argvars, typval_T *rettv)); static void f_argv __ARGS((typval_T *argvars, typval_T *rettv)); +#ifdef FEAT_FLOAT +static void f_atan __ARGS((typval_T *argvars, typval_T *rettv)); +#endif static void f_browse __ARGS((typval_T *argvars, typval_T *rettv)); static void f_browsedir __ARGS((typval_T *argvars, typval_T *rettv)); static void f_bufexists __ARGS((typval_T *argvars, typval_T *rettv)); @@ -472,6 +486,9 @@ static void f_byte2line __ARGS((typval_T *argvars, typval_T *rettv)); static void f_byteidx __ARGS((typval_T *argvars, typval_T *rettv)); static void f_call __ARGS((typval_T *argvars, typval_T *rettv)); +#ifdef FEAT_FLOAT +static void f_ceil __ARGS((typval_T *argvars, typval_T *rettv)); +#endif static void f_changenr __ARGS((typval_T *argvars, typval_T *rettv)); static void f_char2nr __ARGS((typval_T *argvars, typval_T *rettv)); static void f_cindent __ARGS((typval_T *argvars, typval_T *rettv)); @@ -484,6 +501,9 @@ #endif static void f_confirm __ARGS((typval_T *argvars, typval_T *rettv)); static void f_copy __ARGS((typval_T *argvars, typval_T *rettv)); +#ifdef FEAT_FLOAT +static void f_cos __ARGS((typval_T *argvars, typval_T *rettv)); +#endif static void f_count __ARGS((typval_T *argvars, typval_T *rettv)); static void f_cscope_connection __ARGS((typval_T *argvars, typval_T *rettv)); static void f_cursor __ARGS((typval_T *argsvars, typval_T *rettv)); @@ -506,6 +526,11 @@ static void f_filter __ARGS((typval_T *argvars, typval_T *rettv)); static void f_finddir __ARGS((typval_T *argvars, typval_T *rettv)); static void f_findfile __ARGS((typval_T *argvars, typval_T *rettv)); +#ifdef FEAT_FLOAT +static void f_float2nr __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_floor __ARGS((typval_T *argvars, typval_T *rettv)); +#endif +static void f_fnameescape __ARGS((typval_T *argvars, typval_T *rettv)); static void f_fnamemodify __ARGS((typval_T *argvars, typval_T *rettv)); static void f_foldclosed __ARGS((typval_T *argvars, typval_T *rettv)); static void f_foldclosedend __ARGS((typval_T *argvars, typval_T *rettv)); @@ -531,6 +556,7 @@ static void f_getftype __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getline __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getmatches __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_getpid __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getpos __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getqflist __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getreg __ARGS((typval_T *argvars, typval_T *rettv)); @@ -575,6 +601,9 @@ static void f_line2byte __ARGS((typval_T *argvars, typval_T *rettv)); static void f_lispindent __ARGS((typval_T *argvars, typval_T *rettv)); static void f_localtime __ARGS((typval_T *argvars, typval_T *rettv)); +#ifdef FEAT_FLOAT +static void f_log10 __ARGS((typval_T *argvars, typval_T *rettv)); +#endif static void f_map __ARGS((typval_T *argvars, typval_T *rettv)); static void f_maparg __ARGS((typval_T *argvars, typval_T *rettv)); static void f_mapcheck __ARGS((typval_T *argvars, typval_T *rettv)); @@ -594,6 +623,9 @@ static void f_nextnonblank __ARGS((typval_T *argvars, typval_T *rettv)); static void f_nr2char __ARGS((typval_T *argvars, typval_T *rettv)); static void f_pathshorten __ARGS((typval_T *argvars, typval_T *rettv)); +#ifdef FEAT_FLOAT +static void f_pow __ARGS((typval_T *argvars, typval_T *rettv)); +#endif static void f_prevnonblank __ARGS((typval_T *argvars, typval_T *rettv)); static void f_printf __ARGS((typval_T *argvars, typval_T *rettv)); static void f_pumvisible __ARGS((typval_T *argvars, typval_T *rettv)); @@ -611,6 +643,9 @@ static void f_repeat __ARGS((typval_T *argvars, typval_T *rettv)); static void f_resolve __ARGS((typval_T *argvars, typval_T *rettv)); static void f_reverse __ARGS((typval_T *argvars, typval_T *rettv)); +#ifdef FEAT_FLOAT +static void f_round __ARGS((typval_T *argvars, typval_T *rettv)); +#endif static void f_search __ARGS((typval_T *argvars, typval_T *rettv)); static void f_searchdecl __ARGS((typval_T *argvars, typval_T *rettv)); static void f_searchpair __ARGS((typval_T *argvars, typval_T *rettv)); @@ -630,11 +665,18 @@ static void f_setwinvar __ARGS((typval_T *argvars, typval_T *rettv)); static void f_shellescape __ARGS((typval_T *argvars, typval_T *rettv)); static void f_simplify __ARGS((typval_T *argvars, typval_T *rettv)); +#ifdef FEAT_FLOAT +static void f_sin __ARGS((typval_T *argvars, typval_T *rettv)); +#endif static void f_sort __ARGS((typval_T *argvars, typval_T *rettv)); static void f_soundfold __ARGS((typval_T *argvars, typval_T *rettv)); static void f_spellbadword __ARGS((typval_T *argvars, typval_T *rettv)); static void f_spellsuggest __ARGS((typval_T *argvars, typval_T *rettv)); static void f_split __ARGS((typval_T *argvars, typval_T *rettv)); +#ifdef FEAT_FLOAT +static void f_sqrt __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_str2float __ARGS((typval_T *argvars, typval_T *rettv)); +#endif static void f_str2nr __ARGS((typval_T *argvars, typval_T *rettv)); #ifdef HAVE_STRFTIME static void f_strftime __ARGS((typval_T *argvars, typval_T *rettv)); @@ -650,6 +692,7 @@ static void f_synID __ARGS((typval_T *argvars, typval_T *rettv)); static void f_synIDattr __ARGS((typval_T *argvars, typval_T *rettv)); static void f_synIDtrans __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_synstack __ARGS((typval_T *argvars, typval_T *rettv)); static void f_system __ARGS((typval_T *argvars, typval_T *rettv)); static void f_tabpagebuflist __ARGS((typval_T *argvars, typval_T *rettv)); static void f_tabpagenr __ARGS((typval_T *argvars, typval_T *rettv)); @@ -661,6 +704,9 @@ static void f_tolower __ARGS((typval_T *argvars, typval_T *rettv)); static void f_toupper __ARGS((typval_T *argvars, typval_T *rettv)); static void f_tr __ARGS((typval_T *argvars, typval_T *rettv)); +#ifdef FEAT_FLOAT +static void f_trunc __ARGS((typval_T *argvars, typval_T *rettv)); +#endif static void f_type __ARGS((typval_T *argvars, typval_T *rettv)); static void f_values __ARGS((typval_T *argvars, typval_T *rettv)); static void f_virtcol __ARGS((typval_T *argvars, typval_T *rettv)); @@ -784,6 +830,7 @@ /* add to compat scope dict */ hash_add(&compat_hashtab, p->vv_di.di_key); } + set_vim_var_nr(VV_SEARCHFORWARD, 1L); } #if defined(EXITFREE) || defined(PROTO) @@ -814,15 +861,15 @@ /* global variables */ vars_clear(&globvarht); - /* functions */ - free_all_functions(); - hash_clear(&func_hashtab); - /* autoloaded script names */ ga_clear_strings(&ga_loaded); /* unreferenced lists and dicts */ (void)garbage_collect(); + + /* functions */ + free_all_functions(); + hash_clear(&func_hashtab); } #endif @@ -1228,7 +1275,8 @@ if (dolist && tv.v_type == VAR_LIST) { ga_init2(&ga, (int)sizeof(char), 80); - list_join(&ga, tv.vval.v_list, (char_u *)"\n", TRUE, 0); + if (tv.vval.v_list != NULL) + list_join(&ga, tv.vval.v_list, (char_u *)"\n", TRUE, 0); ga_append(&ga, NUL); retval = (char_u *)ga.ga_data; } @@ -1333,6 +1381,7 @@ /* * Evaluate an expression to a list with suggestions. * For the "expr:" part of 'spellsuggest'. + * Returns NULL when there is an error. */ list_T * eval_spell_expr(badword, expr) @@ -1418,7 +1467,8 @@ || defined(FEAT_COMPL_FUNC) || defined(PROTO) /* * Call some vimL function and return the result in "*rettv". - * Uses argv[argc] for the function arguments. + * Uses argv[argc] for the function arguments. Only Number and String + * arguments are currently supported. * Returns OK or FAIL. */ static int @@ -1539,8 +1589,9 @@ # endif /* - * Call vimL function "func" and return the result as a list + * Call vimL function "func" and return the result as a List. * Uses argv[argc] for the function arguments. + * Returns NULL when there is something wrong. */ void * call_func_retlist(func, argc, argv, safe) @@ -2845,16 +2896,36 @@ { /* nr += nr or nr -= nr*/ n = get_tv_number(tv1); - if (*op == '+') - n += get_tv_number(tv2); +#ifdef FEAT_FLOAT + if (tv2->v_type == VAR_FLOAT) + { + float_T f = n; + + if (*op == '+') + f += tv2->vval.v_float; + else + f -= tv2->vval.v_float; + clear_tv(tv1); + tv1->v_type = VAR_FLOAT; + tv1->vval.v_float = f; + } else - n -= get_tv_number(tv2); - clear_tv(tv1); - tv1->v_type = VAR_NUMBER; - tv1->vval.v_number = n; - } - else - { +#endif + { + if (*op == '+') + n += get_tv_number(tv2); + else + n -= get_tv_number(tv2); + clear_tv(tv1); + tv1->v_type = VAR_NUMBER; + tv1->vval.v_number = n; + } + } + else + { + if (tv2->v_type == VAR_FLOAT) + break; + /* str .= str */ s = get_tv_string(tv1); s = concat_str(s, get_tv_string_buf(tv2, numbuf)); @@ -2863,6 +2934,27 @@ tv1->vval.v_string = s; } return OK; + +#ifdef FEAT_FLOAT + case VAR_FLOAT: + { + float_T f; + + if (*op == '.' || (tv2->v_type != VAR_FLOAT + && tv2->v_type != VAR_NUMBER + && tv2->v_type != VAR_STRING)) + break; + if (tv2->v_type == VAR_FLOAT) + f = tv2->vval.v_float; + else + f = get_tv_number(tv2); + if (*op == '+') + tv1->vval.v_float += f; + else + tv1->vval.v_float -= f; + } + return OK; +#endif } } @@ -3406,6 +3498,7 @@ hashtab_T *ht; hashitem_T *hi; char_u *varname; + dictitem_T *di; ht = find_var_ht(name, &varname); if (ht != NULL && *varname != NUL) @@ -3413,9 +3506,9 @@ hi = hash_find(ht, varname); if (!HASHITEM_EMPTY(hi)) { - if (var_check_fixed(HI2DI(hi)->di_flags, name)) - return FAIL; - if (var_check_ro(HI2DI(hi)->di_flags, name)) + di = HI2DI(hi); + if (var_check_fixed(di->di_flags, name) + || var_check_ro(di->di_flags, name)) return FAIL; delete_var(ht, hi); return OK; @@ -3564,8 +3657,8 @@ } /* - * Return TRUE if typeval "tv" is locked: Either tha value is locked itself or - * it refers to a List or Dictionary that is locked. + * Return TRUE if typeval "tv" is locked: Either that value is locked itself + * or it refers to a List or Dictionary that is locked. */ static int tv_islocked(tv) @@ -4110,7 +4203,7 @@ } /* - * If there is a comparitive operator, use it. + * If there is a comparative operator, use it. */ if (type != TYPE_UNKNOWN) { @@ -4126,7 +4219,7 @@ ic = FALSE; ++len; } - /* nothing appened: use 'ignorecase' */ + /* nothing appended: use 'ignorecase' */ else ic = p_ic; @@ -4233,6 +4326,40 @@ } } +#ifdef FEAT_FLOAT + /* + * If one of the two variables is a float, compare as a float. + * When using "=~" or "!~", always compare as string. + */ + else if ((rettv->v_type == VAR_FLOAT || var2.v_type == VAR_FLOAT) + && type != TYPE_MATCH && type != TYPE_NOMATCH) + { + float_T f1, f2; + + if (rettv->v_type == VAR_FLOAT) + f1 = rettv->vval.v_float; + else + f1 = get_tv_number(rettv); + if (var2.v_type == VAR_FLOAT) + f2 = var2.vval.v_float; + else + f2 = get_tv_number(&var2); + n1 = FALSE; + switch (type) + { + case TYPE_EQUAL: n1 = (f1 == f2); break; + case TYPE_NEQUAL: n1 = (f1 != f2); break; + case TYPE_GREATER: n1 = (f1 > f2); break; + case TYPE_GEQUAL: n1 = (f1 >= f2); break; + case TYPE_SMALLER: n1 = (f1 < f2); break; + case TYPE_SEQUAL: n1 = (f1 <= f2); break; + case TYPE_UNKNOWN: + case TYPE_MATCH: + case TYPE_NOMATCH: break; /* avoid gcc warning */ + } + } +#endif + /* * If one of the two variables is a number, compare as a number. * When using "=~" or "!~", always compare as string. @@ -4325,6 +4452,9 @@ typval_T var3; int op; long n1, n2; +#ifdef FEAT_FLOAT + float_T f1 = 0, f2 = 0; +#endif char_u *s1, *s2; char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN]; char_u *p; @@ -4332,7 +4462,7 @@ /* * Get the first variable. */ - if (eval6(arg, rettv, evaluate) == FAIL) + if (eval6(arg, rettv, evaluate, FALSE) == FAIL) return FAIL; /* @@ -4344,7 +4474,11 @@ if (op != '+' && op != '-' && op != '.') break; - if (op != '+' || rettv->v_type != VAR_LIST) + if ((op != '+' || rettv->v_type != VAR_LIST) +#ifdef FEAT_FLOAT + && (op == '.' || rettv->v_type != VAR_FLOAT) +#endif + ) { /* For "list + ...", an illegal use of the first operand as * a number cannot be determined before evaluating the 2nd @@ -4364,7 +4498,7 @@ * Get the second variable. */ *arg = skipwhite(*arg + 1); - if (eval6(arg, &var2, evaluate) == FAIL) + if (eval6(arg, &var2, evaluate, op == '.') == FAIL) { clear_tv(rettv); return FAIL; @@ -4408,29 +4542,73 @@ { int error = FALSE; - n1 = get_tv_number_chk(rettv, &error); - if (error) - { - /* This can only happen for "list + non-list". - * For "non-list + ..." or "something - ...", we returned - * before evaluating the 2nd operand. */ - clear_tv(rettv); - return FAIL; - } - n2 = get_tv_number_chk(&var2, &error); - if (error) - { - clear_tv(rettv); - clear_tv(&var2); - return FAIL; +#ifdef FEAT_FLOAT + if (rettv->v_type == VAR_FLOAT) + { + f1 = rettv->vval.v_float; + n1 = 0; + } + else +#endif + { + n1 = get_tv_number_chk(rettv, &error); + if (error) + { + /* This can only happen for "list + non-list". For + * "non-list + ..." or "something - ...", we returned + * before evaluating the 2nd operand. */ + clear_tv(rettv); + return FAIL; + } +#ifdef FEAT_FLOAT + if (var2.v_type == VAR_FLOAT) + f1 = n1; +#endif + } +#ifdef FEAT_FLOAT + if (var2.v_type == VAR_FLOAT) + { + f2 = var2.vval.v_float; + n2 = 0; + } + else +#endif + { + n2 = get_tv_number_chk(&var2, &error); + if (error) + { + clear_tv(rettv); + clear_tv(&var2); + return FAIL; + } +#ifdef FEAT_FLOAT + if (rettv->v_type == VAR_FLOAT) + f2 = n2; +#endif } clear_tv(rettv); - if (op == '+') - n1 = n1 + n2; - else - n1 = n1 - n2; - rettv->v_type = VAR_NUMBER; - rettv->vval.v_number = n1; + +#ifdef FEAT_FLOAT + /* If there is a float on either side the result is a float. */ + if (rettv->v_type == VAR_FLOAT || var2.v_type == VAR_FLOAT) + { + if (op == '+') + f1 = f1 + f2; + else + f1 = f1 - f2; + rettv->v_type = VAR_FLOAT; + rettv->vval.v_float = f1; + } + else +#endif + { + if (op == '+') + n1 = n1 + n2; + else + n1 = n1 - n2; + rettv->v_type = VAR_NUMBER; + rettv->vval.v_number = n1; + } } clear_tv(&var2); } @@ -4450,20 +4628,25 @@ * Return OK or FAIL. */ static int -eval6(arg, rettv, evaluate) +eval6(arg, rettv, evaluate, want_string) char_u **arg; typval_T *rettv; int evaluate; + int want_string; /* after "." operator */ { typval_T var2; int op; long n1, n2; +#ifdef FEAT_FLOAT + int use_float = FALSE; + float_T f1 = 0, f2; +#endif int error = FALSE; /* * Get the first variable. */ - if (eval7(arg, rettv, evaluate) == FAIL) + if (eval7(arg, rettv, evaluate, want_string) == FAIL) return FAIL; /* @@ -4477,7 +4660,16 @@ if (evaluate) { - n1 = get_tv_number_chk(rettv, &error); +#ifdef FEAT_FLOAT + if (rettv->v_type == VAR_FLOAT) + { + f1 = rettv->vval.v_float; + use_float = TRUE; + n1 = 0; + } + else +#endif + n1 = get_tv_number_chk(rettv, &error); clear_tv(rettv); if (error) return FAIL; @@ -4489,37 +4681,87 @@ * Get the second variable. */ *arg = skipwhite(*arg + 1); - if (eval7(arg, &var2, evaluate) == FAIL) + if (eval7(arg, &var2, evaluate, FALSE) == FAIL) return FAIL; if (evaluate) { - n2 = get_tv_number_chk(&var2, &error); - clear_tv(&var2); - if (error) - return FAIL; +#ifdef FEAT_FLOAT + if (var2.v_type == VAR_FLOAT) + { + if (!use_float) + { + f1 = n1; + use_float = TRUE; + } + f2 = var2.vval.v_float; + n2 = 0; + } + else +#endif + { + n2 = get_tv_number_chk(&var2, &error); + clear_tv(&var2); + if (error) + return FAIL; +#ifdef FEAT_FLOAT + if (use_float) + f2 = n2; +#endif + } /* * Compute the result. + * When either side is a float the result is a float. */ - if (op == '*') - n1 = n1 * n2; - else if (op == '/') - { - if (n2 == 0) /* give an error message? */ - n1 = 0x7fffffffL; - else - n1 = n1 / n2; - } - else - { - if (n2 == 0) /* give an error message? */ - n1 = 0; - else - n1 = n1 % n2; - } - rettv->v_type = VAR_NUMBER; - rettv->vval.v_number = n1; +#ifdef FEAT_FLOAT + if (use_float) + { + if (op == '*') + f1 = f1 * f2; + else if (op == '/') + { + /* We rely on the floating point library to handle divide + * by zero to result in "inf" and not a crash. */ + f1 = f1 / f2; + } + else + { + EMSG(_("E804: Cannot use '%' with Float")); + return FAIL; + } + rettv->v_type = VAR_FLOAT; + rettv->vval.v_float = f1; + } + else +#endif + { + if (op == '*') + n1 = n1 * n2; + else if (op == '/') + { + if (n2 == 0) /* give an error message? */ + { + if (n1 == 0) + n1 = -0x7fffffffL - 1L; /* similar to NaN */ + else if (n1 < 0) + n1 = -0x7fffffffL; + else + n1 = 0x7fffffffL; + } + else + n1 = n1 / n2; + } + else + { + if (n2 == 0) /* give an error message? */ + n1 = 0; + else + n1 = n1 % n2; + } + rettv->v_type = VAR_NUMBER; + rettv->vval.v_number = n1; + } } } @@ -4553,15 +4795,15 @@ * Return OK or FAIL. */ static int -eval7(arg, rettv, evaluate) +eval7(arg, rettv, evaluate, want_string) char_u **arg; typval_T *rettv; int evaluate; + int want_string; /* after "." operator */ { long n; int len; char_u *s; - int val; char_u *start_leader, *end_leader; int ret = OK; char_u *alias; @@ -4595,14 +4837,57 @@ case '7': case '8': case '9': - vim_str2nr(*arg, NULL, &len, TRUE, TRUE, &n, NULL); - *arg += len; - if (evaluate) - { - rettv->v_type = VAR_NUMBER; - rettv->vval.v_number = n; - } - break; + { +#ifdef FEAT_FLOAT + char_u *p = skipdigits(*arg + 1); + int get_float = FALSE; + + /* We accept a float when the format matches + * "[0-9]\+\.[0-9]\+\([eE][+-]\?[0-9]\+\)\?". This is very + * strict to avoid backwards compatibility problems. + * Don't look for a float after the "." operator, so that + * ":let vers = 1.2.3" doesn't fail. */ + if (!want_string && p[0] == '.' && vim_isdigit(p[1])) + { + get_float = TRUE; + p = skipdigits(p + 2); + if (*p == 'e' || *p == 'E') + { + ++p; + if (*p == '-' || *p == '+') + ++p; + if (!vim_isdigit(*p)) + get_float = FALSE; + else + p = skipdigits(p + 1); + } + if (ASCII_ISALPHA(*p) || *p == '.') + get_float = FALSE; + } + if (get_float) + { + float_T f; + + *arg += string2float(*arg, &f); + if (evaluate) + { + rettv->v_type = VAR_FLOAT; + rettv->vval.v_float = f; + } + } + else +#endif + { + vim_str2nr(*arg, NULL, &len, TRUE, TRUE, &n, NULL); + *arg += len; + if (evaluate) + { + rettv->v_type = VAR_NUMBER; + rettv->vval.v_number = n; + } + } + break; + } /* * String constant: "string". @@ -4730,8 +5015,15 @@ if (ret == OK && evaluate && end_leader > start_leader) { int error = FALSE; - - val = get_tv_number_chk(rettv, &error); + int val = 0; +#ifdef FEAT_FLOAT + float_T f = 0.0; + + if (rettv->v_type == VAR_FLOAT) + f = rettv->vval.v_float; + else +#endif + val = get_tv_number_chk(rettv, &error); if (error) { clear_tv(rettv); @@ -4743,13 +5035,37 @@ { --end_leader; if (*end_leader == '!') - val = !val; + { +#ifdef FEAT_FLOAT + if (rettv->v_type == VAR_FLOAT) + f = !f; + else +#endif + val = !val; + } else if (*end_leader == '-') - val = -val; - } - clear_tv(rettv); - rettv->v_type = VAR_NUMBER; - rettv->vval.v_number = val; + { +#ifdef FEAT_FLOAT + if (rettv->v_type == VAR_FLOAT) + f = -f; + else +#endif + val = -val; + } + } +#ifdef FEAT_FLOAT + if (rettv->v_type == VAR_FLOAT) + { + clear_tv(rettv); + rettv->vval.v_float = f; + } + else +#endif + { + clear_tv(rettv); + rettv->v_type = VAR_NUMBER; + rettv->vval.v_number = val; + } } } @@ -4776,7 +5092,11 @@ char_u *s; char_u *key = NULL; - if (rettv->v_type == VAR_FUNC) + if (rettv->v_type == VAR_FUNC +#ifdef FEAT_FLOAT + || rettv->v_type == VAR_FLOAT +#endif + ) { if (verbose) EMSG(_("E695: Cannot index a Funcref")); @@ -5500,6 +5820,8 @@ { listitem_T *item1, *item2; + if (l1 == NULL || l2 == NULL) + return FALSE; if (l1 == l2) return TRUE; if (list_len(l1) != list_len(l2)) @@ -5538,6 +5860,8 @@ dictitem_T *item2; int todo; + if (d1 == NULL || d2 == NULL) + return FALSE; if (d1 == d2) return TRUE; if (dict_len(d1) != dict_len(d2)) @@ -5562,7 +5886,7 @@ /* * Return TRUE if "tv1" and "tv2" have the same value. * Compares the items just like "==" would compare them, but strings and - * numbers are different. + * numbers are different. Floats and numbers are also different. */ static int tv_equal(tv1, tv2, ic) @@ -5604,6 +5928,11 @@ case VAR_NUMBER: return tv1->vval.v_number == tv2->vval.v_number; +#ifdef FEAT_FLOAT + case VAR_FLOAT: + return tv1->vval.v_float == tv2->vval.v_float; +#endif + case VAR_STRING: s1 = get_tv_string_buf(tv1, buf1); s2 = get_tv_string_buf(tv2, buf2); @@ -5902,8 +6231,11 @@ listitem_T *bef; { listitem_T *item; - - for (item = l2->lv_first; item != NULL; item = item->li_next) + int todo = l2->lv_len; + + /* We also quit the loop when we have inserted the original item count of + * the list, avoid a hang when we extend a list with itself. */ + for (item = l2->lv_first; item != NULL && --todo >= 0; item = item->li_next) if (list_insert_tv(l1, &item->li_tv, bef) == FAIL) return FAIL; return OK; @@ -5921,6 +6253,9 @@ { list_T *l; + if (l1 == NULL || l2 == NULL) + return FAIL; + /* make a copy of the first list. */ l = list_copy(l1, FALSE, 0); if (l == NULL) @@ -6893,6 +7228,14 @@ r = get_tv_string_buf(tv, numbuf); break; +#ifdef FEAT_FLOAT + case VAR_FLOAT: + *tofree = NULL; + vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv->vval.v_float); + r = numbuf; + break; +#endif + default: EMSG2(_(e_intern2), "echo_string()"); *tofree = NULL; @@ -6924,6 +7267,12 @@ case VAR_STRING: *tofree = string_quote(tv->vval.v_string, FALSE); return *tofree; +#ifdef FEAT_FLOAT + case VAR_FLOAT: + *tofree = NULL; + vim_snprintf((char *)numbuf, NUMBUFLEN - 1, "%g", tv->vval.v_float); + return numbuf; +#endif case VAR_NUMBER: case VAR_LIST: case VAR_DICT: @@ -6980,6 +7329,27 @@ return s; } +#ifdef FEAT_FLOAT +/* + * Convert the string "text" to a floating point number. + * This uses strtod(). setlocale(LC_NUMERIC, "C") has been used to make sure + * this always uses a decimal point. + * Returns the length of the text that was consumed. + */ + static int +string2float(text, value) + char_u *text; + float_T *value; /* result stored here */ +{ + char *s = (char *)text; + float_T f; + + f = strtod(s, &s); + *value = f; + return (int)((char_u *)s - text); +} +#endif + /* * Get the value of an environment variable. * "arg" is pointing to the '$'. It is advanced to after the name. @@ -7049,11 +7419,17 @@ /* implementation of function */ } functions[] = { +#ifdef FEAT_FLOAT + {"abs", 1, 1, f_abs}, +#endif {"add", 2, 2, f_add}, {"append", 2, 2, f_append}, {"argc", 0, 0, f_argc}, {"argidx", 0, 0, f_argidx}, {"argv", 0, 1, f_argv}, +#ifdef FEAT_FLOAT + {"atan", 1, 1, f_atan}, +#endif {"browse", 4, 4, f_browse}, {"browsedir", 2, 2, f_browsedir}, {"bufexists", 1, 1, f_bufexists}, @@ -7068,6 +7444,9 @@ {"byte2line", 1, 1, f_byte2line}, {"byteidx", 2, 2, f_byteidx}, {"call", 2, 3, f_call}, +#ifdef FEAT_FLOAT + {"ceil", 1, 1, f_ceil}, +#endif {"changenr", 0, 0, f_changenr}, {"char2nr", 1, 1, f_char2nr}, {"cindent", 1, 1, f_cindent}, @@ -7080,6 +7459,9 @@ #endif {"confirm", 1, 4, f_confirm}, {"copy", 1, 1, f_copy}, +#ifdef FEAT_FLOAT + {"cos", 1, 1, f_cos}, +#endif {"count", 2, 4, f_count}, {"cscope_connection",0,3, f_cscope_connection}, {"cursor", 1, 3, f_cursor}, @@ -7103,6 +7485,11 @@ {"filter", 2, 2, f_filter}, {"finddir", 1, 3, f_finddir}, {"findfile", 1, 3, f_findfile}, +#ifdef FEAT_FLOAT + {"float2nr", 1, 1, f_float2nr}, + {"floor", 1, 1, f_floor}, +#endif + {"fnameescape", 1, 1, f_fnameescape}, {"fnamemodify", 2, 2, f_fnamemodify}, {"foldclosed", 1, 1, f_foldclosed}, {"foldclosedend", 1, 1, f_foldclosedend}, @@ -7129,6 +7516,7 @@ {"getline", 1, 2, f_getline}, {"getloclist", 1, 1, f_getqflist}, {"getmatches", 0, 0, f_getmatches}, + {"getpid", 0, 0, f_getpid}, {"getpos", 1, 1, f_getpos}, {"getqflist", 0, 0, f_getqflist}, {"getreg", 0, 2, f_getreg}, @@ -7175,6 +7563,9 @@ {"line2byte", 1, 1, f_line2byte}, {"lispindent", 1, 1, f_lispindent}, {"localtime", 0, 0, f_localtime}, +#ifdef FEAT_FLOAT + {"log10", 1, 1, f_log10}, +#endif {"map", 2, 2, f_map}, {"maparg", 1, 3, f_maparg}, {"mapcheck", 1, 3, f_mapcheck}, @@ -7190,10 +7581,13 @@ #ifdef vim_mkdir {"mkdir", 1, 3, f_mkdir}, #endif - {"mode", 0, 0, f_mode}, + {"mode", 0, 1, f_mode}, {"nextnonblank", 1, 1, f_nextnonblank}, {"nr2char", 1, 1, f_nr2char}, {"pathshorten", 1, 1, f_pathshorten}, +#ifdef FEAT_FLOAT + {"pow", 2, 2, f_pow}, +#endif {"prevnonblank", 1, 1, f_prevnonblank}, {"printf", 2, 19, f_printf}, {"pumvisible", 0, 0, f_pumvisible}, @@ -7211,11 +7605,14 @@ {"repeat", 2, 2, f_repeat}, {"resolve", 1, 1, f_resolve}, {"reverse", 1, 1, f_reverse}, - {"search", 1, 3, f_search}, +#ifdef FEAT_FLOAT + {"round", 1, 1, f_round}, +#endif + {"search", 1, 4, f_search}, {"searchdecl", 1, 3, f_searchdecl}, - {"searchpair", 3, 6, f_searchpair}, - {"searchpairpos", 3, 6, f_searchpairpos}, - {"searchpos", 1, 3, f_searchpos}, + {"searchpair", 3, 7, f_searchpair}, + {"searchpairpos", 3, 7, f_searchpairpos}, + {"searchpos", 1, 4, f_searchpos}, {"server2client", 2, 2, f_server2client}, {"serverlist", 0, 0, f_serverlist}, {"setbufvar", 3, 3, f_setbufvar}, @@ -7228,13 +7625,20 @@ {"setreg", 2, 3, f_setreg}, {"settabwinvar", 4, 4, f_settabwinvar}, {"setwinvar", 3, 3, f_setwinvar}, - {"shellescape", 1, 1, f_shellescape}, + {"shellescape", 1, 2, f_shellescape}, {"simplify", 1, 1, f_simplify}, +#ifdef FEAT_FLOAT + {"sin", 1, 1, f_sin}, +#endif {"sort", 1, 2, f_sort}, {"soundfold", 1, 1, f_soundfold}, {"spellbadword", 0, 1, f_spellbadword}, {"spellsuggest", 1, 3, f_spellsuggest}, {"split", 1, 3, f_split}, +#ifdef FEAT_FLOAT + {"sqrt", 1, 1, f_sqrt}, + {"str2float", 1, 1, f_str2float}, +#endif {"str2nr", 1, 2, f_str2nr}, #ifdef HAVE_STRFTIME {"strftime", 1, 2, f_strftime}, @@ -7250,6 +7654,7 @@ {"synID", 3, 3, f_synID}, {"synIDattr", 2, 3, f_synIDattr}, {"synIDtrans", 1, 1, f_synIDtrans}, + {"synstack", 2, 2, f_synstack}, {"system", 1, 2, f_system}, {"tabpagebuflist", 0, 1, f_tabpagebuflist}, {"tabpagenr", 0, 1, f_tabpagenr}, @@ -7261,6 +7666,9 @@ {"tolower", 1, 1, f_tolower}, {"toupper", 1, 1, f_toupper}, {"tr", 3, 3, f_tr}, +#ifdef FEAT_FLOAT + {"trunc", 1, 1, f_trunc}, +#endif {"type", 1, 1, f_type}, {"values", 1, 1, f_values}, {"virtcol", 1, 1, f_virtcol}, @@ -7700,10 +8108,54 @@ vim_free(p); } +/* + * Return TRUE for a non-zero Number and a non-empty String. + */ + static int +non_zero_arg(argvars) + typval_T *argvars; +{ + return ((argvars[0].v_type == VAR_NUMBER + && argvars[0].vval.v_number != 0) + || (argvars[0].v_type == VAR_STRING + && argvars[0].vval.v_string != NULL + && *argvars[0].vval.v_string != NUL)); +} + /********************************************* * Implementation of the built-in functions */ +#ifdef FEAT_FLOAT +/* + * "abs(expr)" function + */ + static void +f_abs(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + if (argvars[0].v_type == VAR_FLOAT) + { + rettv->v_type = VAR_FLOAT; + rettv->vval.v_float = fabs(argvars[0].vval.v_float); + } + else + { + varnumber_T n; + int error = FALSE; + + n = get_tv_number_chk(&argvars[0], &error); + if (error) + rettv->vval.v_number = -1; + else if (n > 0) + rettv->vval.v_number = n; + else + rettv->vval.v_number = -n; + } +} +#endif + /* * "add(list, item)" function */ @@ -7832,6 +8284,50 @@ alist_name(&ARGLIST[idx]), -1); } +#ifdef FEAT_FLOAT +static int get_float_arg __ARGS((typval_T *argvars, float_T *f)); + +/* + * Get the float value of "argvars[0]" into "f". + * Returns FAIL when the argument is not a Number or Float. + */ + static int +get_float_arg(argvars, f) + typval_T *argvars; + float_T *f; +{ + if (argvars[0].v_type == VAR_FLOAT) + { + *f = argvars[0].vval.v_float; + return OK; + } + if (argvars[0].v_type == VAR_NUMBER) + { + *f = (float_T)argvars[0].vval.v_number; + return OK; + } + EMSG(_("E808: Number or Float required")); + return FAIL; +} + +/* + * "atan()" function + */ + static void +f_atan(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + float_T f; + + rettv->v_type = VAR_FLOAT; + if (get_float_arg(argvars, &f) == OK) + rettv->vval.v_float = atan(f); + else + rettv->vval.v_float = 0.0; +} +#endif + /* * "browse(save, title, initdir, default)" function */ @@ -8149,7 +8645,7 @@ } rettv->vval.v_number = (varnumber_T)(t - str); #else - if (idx <= STRLEN(str)) + if ((size_t)idx <= STRLEN(str)) rettv->vval.v_number = idx; #endif } @@ -8219,6 +8715,25 @@ clear_tv(&argv[--argc]); } +#ifdef FEAT_FLOAT +/* + * "ceil({float})" function + */ + static void +f_ceil(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + float_T f; + + rettv->v_type = VAR_FLOAT; + if (get_float_arg(argvars, &f) == OK) + rettv->vval.v_float = ceil(f); + else + rettv->vval.v_float = 0.0; +} +#endif + /* * "changenr()" function */ @@ -8479,6 +8994,25 @@ item_copy(&argvars[0], rettv, FALSE, 0); } +#ifdef FEAT_FLOAT +/* + * "cos()" function + */ + static void +f_cos(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + float_T f; + + rettv->v_type = VAR_FLOAT; + if (get_float_arg(argvars, &f) == OK) + rettv->vval.v_float = cos(f); + else + rettv->vval.v_float = 0.0; +} +#endif + /* * "count()" function */ @@ -8794,6 +9328,11 @@ case VAR_NUMBER: n = argvars[0].vval.v_number == 0; break; +#ifdef FEAT_FLOAT + case VAR_FLOAT: + n = argvars[0].vval.v_float == 0.0; + break; +#endif case VAR_LIST: n = argvars[0].vval.v_list == NULL || argvars[0].vval.v_list->lv_first == NULL; @@ -9171,15 +9710,19 @@ typval_T *argvars; typval_T *rettv; { - FILE *fd; + int fd; char_u *p; int n; +#ifndef O_NONBLOCK +# define O_NONBLOCK 0 +#endif p = get_tv_string(&argvars[0]); - if (*p && !mch_isdir(p) && (fd = mch_fopen((char *)p, "r")) != NULL) + if (*p && !mch_isdir(p) && (fd = mch_open((char *)p, + O_RDONLY | O_NONBLOCK, 0)) >= 0) { n = TRUE; - fclose(fd); + close(fd); } else n = FALSE; @@ -9199,13 +9742,13 @@ rettv->vval.v_number = filewritable(get_tv_string(&argvars[0])); } -static void findfilendir __ARGS((typval_T *argvars, typval_T *rettv, int dir)); - - static void -findfilendir(argvars, rettv, dir) - typval_T *argvars; - typval_T *rettv; - int dir; +static void findfilendir __ARGS((typval_T *argvars, typval_T *rettv, int find_what)); + + static void +findfilendir(argvars, rettv, find_what) + typval_T *argvars; + typval_T *rettv; + int find_what; { #ifdef FEAT_SEARCHPATH char_u *fname; @@ -9250,8 +9793,11 @@ vim_free(fresult); fresult = find_file_in_path_option(first ? fname : NULL, first ? (int)STRLEN(fname) : 0, - 0, first, path, dir, curbuf->b_ffname, - dir ? (char_u *)"" : curbuf->b_p_sua); + 0, first, path, + find_what, + curbuf->b_ffname, + find_what == FINDFILE_DIR + ? (char_u *)"" : curbuf->b_p_sua); first = FALSE; if (fresult != NULL && rettv->v_type == VAR_LIST) @@ -9441,7 +9987,7 @@ typval_T *argvars; typval_T *rettv; { - findfilendir(argvars, rettv, TRUE); + findfilendir(argvars, rettv, FINDFILE_DIR); } /* @@ -9452,7 +9998,62 @@ typval_T *argvars; typval_T *rettv; { - findfilendir(argvars, rettv, FALSE); + findfilendir(argvars, rettv, FINDFILE_FILE); +} + +#ifdef FEAT_FLOAT +/* + * "float2nr({float})" function + */ + static void +f_float2nr(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + float_T f; + + if (get_float_arg(argvars, &f) == OK) + { + if (f < -0x7fffffff) + rettv->vval.v_number = -0x7fffffff; + else if (f > 0x7fffffff) + rettv->vval.v_number = 0x7fffffff; + else + rettv->vval.v_number = (varnumber_T)f; + } + else + rettv->vval.v_number = 0; +} + +/* + * "floor({float})" function + */ + static void +f_floor(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + float_T f; + + rettv->v_type = VAR_FLOAT; + if (get_float_arg(argvars, &f) == OK) + rettv->vval.v_float = floor(f); + else + rettv->vval.v_float = 0.0; +} +#endif + +/* + * "fnameescape({string})" function + */ + static void +f_fnameescape(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + rettv->vval.v_string = vim_strsave_fnameescape( + get_tv_string(&argvars[0]), FALSE); + rettv->v_type = VAR_STRING; } /* @@ -9877,17 +10478,12 @@ if (buf != NULL && varname != NULL) { + /* set curbuf to be our buf, temporarily */ + save_curbuf = curbuf; + curbuf = buf; + if (*varname == '&') /* buffer-local-option */ - { - /* set curbuf to be our buf, temporarily */ - save_curbuf = curbuf; - curbuf = buf; - get_option_tv(&varname, rettv, TRUE); - - /* restore previous notion of curbuf */ - curbuf = save_curbuf; - } else { if (*varname == NUL) @@ -9896,10 +10492,13 @@ * find_var_in_ht(). */ varname = (char_u *)"b:" + 2; /* look up the variable */ - v = find_var_in_ht(&buf->b_vars.dv_hashtab, varname, FALSE); + v = find_var_in_ht(&curbuf->b_vars.dv_hashtab, varname, FALSE); if (v != NULL) copy_tv(&v->di_tv, rettv); } + + /* restore previous notion of curbuf */ + curbuf = save_curbuf; } --emsg_off; @@ -10367,6 +10966,18 @@ } /* + * "getpid()" function + */ +/*ARGSUSED*/ + static void +f_getpid(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + rettv->vval.v_number = mch_get_pid(); +} + +/* * "getpos(string)" function */ static void @@ -10564,7 +11175,7 @@ } /* - * Find window specifed by "vp" in tabpage "tp". + * Find window specified by "vp" in tabpage "tp". */ static win_T * find_win_by_nr(vp, tp) @@ -10856,6 +11467,9 @@ #ifdef FEAT_FIND_ID "find_in_path", #endif +#ifdef FEAT_FLOAT + "float", +#endif #ifdef FEAT_FOLDING "folding", #endif @@ -10966,6 +11580,9 @@ # ifdef FEAT_MOUSE_PTERM "mouse_pterm", # endif +# ifdef FEAT_SYSMOUSE + "mouse_sysmouse", +# endif # ifdef FEAT_MOUSE_XTERM "mouse_xterm", # endif @@ -11777,7 +12394,7 @@ typval_T *argvars; typval_T *rettv; { - /* Add an entry to the stack of typehead storage. */ + /* Add an entry to the stack of typeahead storage. */ if (ga_grow(&ga_userinput, 1) == OK) { save_typeahead((tasave_T *)(ga_userinput.ga_data) @@ -12309,6 +12926,25 @@ } } +#ifdef FEAT_FLOAT +/* + * "log10()" function + */ + static void +f_log10(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + float_T f; + + rettv->v_type = VAR_FLOAT; + if (get_float_arg(argvars, &f) == OK) + rettv->vval.v_float = log10(f); + else + rettv->vval.v_float = 0.0; +} +#endif + /* * "map()" function */ @@ -12817,7 +13453,10 @@ typval_T *argvars; typval_T *rettv; { - char_u buf[2]; + char_u buf[3]; + + buf[1] = NUL; + buf[2] = NUL; #ifdef FEAT_VISUAL if (VIsual_active) @@ -12829,21 +13468,55 @@ } else #endif - if (State == HITRETURN || State == ASKMORE || State == SETWSIZE) + if (State == HITRETURN || State == ASKMORE || State == SETWSIZE + || State == CONFIRM) + { buf[0] = 'r'; + if (State == ASKMORE) + buf[1] = 'm'; + else if (State == CONFIRM) + buf[1] = '?'; + } + else if (State == EXTERNCMD) + buf[0] = '!'; else if (State & INSERT) { +#ifdef FEAT_VREPLACE + if (State & VREPLACE_FLAG) + { + buf[0] = 'R'; + buf[1] = 'v'; + } + else +#endif if (State & REPLACE_FLAG) buf[0] = 'R'; else buf[0] = 'i'; } else if (State & CMDLINE) + { buf[0] = 'c'; - else + if (exmode_active) + buf[1] = 'v'; + } + else if (exmode_active) + { + buf[0] = 'c'; + buf[1] = 'e'; + } + else + { buf[0] = 'n'; - - buf[1] = NUL; + if (finish_op) + buf[1] = 'o'; + } + + /* Clear out the minor mode when the argument is not a non-zero number or + * non-empty string. */ + if (!non_zero_arg(&argvars[0])) + buf[1] = NUL; + rettv->vval.v_string = vim_strsave(buf); rettv->v_type = VAR_STRING; } @@ -12917,6 +13590,26 @@ } } +#ifdef FEAT_FLOAT +/* + * "pow()" function + */ + static void +f_pow(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + float_T fx, fy; + + rettv->v_type = VAR_FLOAT; + if (get_float_arg(argvars, &fx) == OK + && get_float_arg(&argvars[1], &fy) == OK) + rettv->vval.v_float = pow(fx, fy); + else + rettv->vval.v_float = 0.0; +} +#endif + /* * "prevnonblank()" function */ @@ -13840,7 +14533,7 @@ } /* Shorten "remain". */ if (*q != NUL) - mch_memmove(remain, q - 1, STRLEN(q - 1) + 1); + STRMOVE(remain, q - 1); else { vim_free(remain); @@ -13876,7 +14569,7 @@ while (q[0] == '.' && vim_ispathsep(q[1])) q += 2; if (q > p) - mch_memmove(p, p + 2, STRLEN(p + 2) + (size_t)1); + STRMOVE(p, p + 2); } } @@ -13933,6 +14626,7 @@ rettv->vval.v_list = l; rettv->v_type = VAR_LIST; ++l->lv_refcount; + l->lv_idx = l->lv_len - l->lv_idx - 1; } } @@ -14018,6 +14712,10 @@ int dir; int retval = 0; /* default: FAIL */ long lnum_stop = 0; + proftime_T tm; +#ifdef FEAT_RELTIME + long time_limit = 0; +#endif int options = SEARCH_KEEP; int subpatnum; @@ -14031,14 +14729,26 @@ if (flags & SP_END) options |= SEARCH_END; - /* Optional extra argument: line number to stop searching. */ - if (argvars[1].v_type != VAR_UNKNOWN - && argvars[2].v_type != VAR_UNKNOWN) + /* Optional arguments: line number to stop searching and timeout. */ + if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN) { lnum_stop = get_tv_number_chk(&argvars[2], NULL); if (lnum_stop < 0) goto theend; - } +#ifdef FEAT_RELTIME + if (argvars[3].v_type != VAR_UNKNOWN) + { + time_limit = get_tv_number_chk(&argvars[3], NULL); + if (time_limit < 0) + goto theend; + } +#endif + } + +#ifdef FEAT_RELTIME + /* Set the time limit, if there is one. */ + profile_setlimit(time_limit, &tm); +#endif /* * This function does not accept SP_REPEAT and SP_RETCOUNT flags. @@ -14055,7 +14765,7 @@ pos = save_cursor = curwin->w_cursor; subpatnum = searchit(curwin, curbuf, &pos, dir, pat, 1L, - options, RE_SEARCH, (linenr_T)lnum_stop); + options, RE_SEARCH, (linenr_T)lnum_stop, &tm); if (subpatnum != FAIL) { if (flags & SP_SUBPAT) @@ -14087,6 +14797,26 @@ return retval; } +#ifdef FEAT_FLOAT +/* + * "round({float})" function + */ + static void +f_round(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + float_T f; + + rettv->v_type = VAR_FLOAT; + if (get_float_arg(argvars, &f) == OK) + /* round() is not in C90, use ceil() or floor() instead. */ + rettv->vval.v_float = f > 0 ? floor(f + 0.5) : ceil(f - 0.5); + else + rettv->vval.v_float = 0.0; +} +#endif + /* * "search()" function */ @@ -14145,6 +14875,7 @@ char_u nbuf3[NUMBUFLEN]; int retval = 0; /* default: FAIL */ long lnum_stop = 0; + long time_limit = 0; /* Get the three pattern arguments: start, middle, end. */ spat = get_tv_string_chk(&argvars[0]); @@ -14168,6 +14899,10 @@ goto theend; } + /* Using 'r' implies 'W', otherwise it doesn't work. */ + if (flags & SP_REPEAT) + p_ws = FALSE; + /* Optional fifth argument: skip expression */ if (argvars[3].v_type == VAR_UNKNOWN || argvars[4].v_type == VAR_UNKNOWN) @@ -14180,13 +14915,21 @@ lnum_stop = get_tv_number_chk(&argvars[5], NULL); if (lnum_stop < 0) goto theend; +#ifdef FEAT_RELTIME + if (argvars[6].v_type != VAR_UNKNOWN) + { + time_limit = get_tv_number_chk(&argvars[6], NULL); + if (time_limit < 0) + goto theend; + } +#endif } } if (skip == NULL) goto theend; /* type error */ retval = do_searchpair(spat, mpat, epat, dir, skip, flags, - match_pos, lnum_stop); + match_pos, lnum_stop, time_limit); theend: p_ws = save_p_ws; @@ -14238,7 +14981,8 @@ * Returns 0 or -1 for no match, */ long -do_searchpair(spat, mpat, epat, dir, skip, flags, match_pos, lnum_stop) +do_searchpair(spat, mpat, epat, dir, skip, flags, match_pos, + lnum_stop, time_limit) char_u *spat; /* start pattern */ char_u *mpat; /* middle pattern */ char_u *epat; /* end pattern */ @@ -14247,6 +14991,7 @@ int flags; /* SP_SETPCMARK and other SP_ values */ pos_T *match_pos; linenr_T lnum_stop; /* stop at this line if not zero */ + long time_limit; /* stop after this many msec */ { char_u *save_cpo; char_u *pat, *pat2 = NULL, *pat3 = NULL; @@ -14261,10 +15006,16 @@ int nest = 1; int err; int options = SEARCH_KEEP; + proftime_T tm; /* Make 'cpoptions' empty, the 'l' flag should not be used here. */ save_cpo = p_cpo; - p_cpo = (char_u *)""; + p_cpo = empty_option; + +#ifdef FEAT_RELTIME + /* Set the time limit, if there is one. */ + profile_setlimit(time_limit, &tm); +#endif /* Make two search patterns: start/end (pat2, for in nested pairs) and * start/middle/end (pat3, for the top pair). */ @@ -14289,7 +15040,7 @@ for (;;) { n = searchit(curwin, curbuf, &pos, dir, pat, 1L, - options, RE_SEARCH, lnum_stop); + options, RE_SEARCH, lnum_stop, &tm); if (n == FAIL || (firstpos.lnum != 0 && equalpos(pos, firstpos))) /* didn't find it or found the first match again: FAIL */ break; @@ -14308,6 +15059,9 @@ } foundpos = pos; + /* clear the start flag to avoid getting stuck here */ + options &= ~SEARCH_START; + /* If the skip pattern matches, ignore this match. */ if (*skip != NUL) { @@ -14371,7 +15125,11 @@ theend: vim_free(pat2); vim_free(pat3); - p_cpo = save_cpo; + if (p_cpo == empty_option) + p_cpo = save_cpo; + else + /* Darn, evaluating the {skip} expression changed the value. */ + free_string_option(save_cpo); return retval; } @@ -14601,6 +15359,8 @@ appended_lines_mark(lcount, added); } +static void set_qf_ll_list __ARGS((win_T *wp, typval_T *list_arg, typval_T *action_arg, typval_T *rettv)); + /* * Used by "setqflist()" and "setloclist()" functions */ @@ -14732,24 +15492,31 @@ int fnum; char_u *name; + rettv->vval.v_number = -1; name = get_tv_string_chk(argvars); if (name != NULL) { if (list2fpos(&argvars[1], &pos, &fnum) == OK) { --pos.col; - if (name[0] == '.') /* cursor */ - { + if (name[0] == '.' && name[1] == NUL) + { + /* set cursor */ if (fnum == curbuf->b_fnum) { curwin->w_cursor = pos; check_cursor(); + rettv->vval.v_number = 0; } else EMSG(_(e_invarg)); } - else if (name[0] == '\'') /* mark */ - (void)setmark_pos(name[1], &pos, fnum); + else if (name[0] == '\'' && name[1] != NUL && name[2] == NUL) + { + /* set mark */ + if (setmark_pos(name[1], &pos, fnum) == OK) + rettv->vval.v_number = 0; + } else EMSG(_(e_invarg)); } @@ -14952,7 +15719,8 @@ typval_T *argvars; typval_T *rettv; { - rettv->vval.v_string = vim_strsave_shellescape(get_tv_string(&argvars[0])); + rettv->vval.v_string = vim_strsave_shellescape( + get_tv_string(&argvars[0]), non_zero_arg(&argvars[1])); rettv->v_type = VAR_STRING; } @@ -14972,6 +15740,25 @@ rettv->v_type = VAR_STRING; } +#ifdef FEAT_FLOAT +/* + * "sin()" function + */ + static void +f_sin(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + float_T f; + + rettv->v_type = VAR_FLOAT; + if (get_float_arg(argvars, &f) == OK) + rettv->vval.v_float = sin(f); + else + rettv->vval.v_float = 0.0; +} +#endif + static int #ifdef __BORLANDC__ _RTLENTRYF @@ -15051,10 +15838,9 @@ if (res == FAIL) res = ITEM_COMPARE_FAIL; else - /* return value has wrong type */ res = get_tv_number_chk(&rettv, &item_compare_func_err); if (item_compare_func_err) - res = ITEM_COMPARE_FAIL; + res = ITEM_COMPARE_FAIL; /* return value has wrong type */ clear_tv(&rettv); return res; } @@ -15132,7 +15918,7 @@ if (!item_compare_func_err) { /* Clear the List and append the items in the sorted order. */ - l->lv_first = l->lv_last = NULL; + l->lv_first = l->lv_last = l->lv_idx_item = NULL; l->lv_len = 0; for (i = 0; i < len; ++i) list_append(l, ptrs[i]); @@ -15361,6 +16147,41 @@ p_cpo = save_cpo; } +#ifdef FEAT_FLOAT +/* + * "sqrt()" function + */ + static void +f_sqrt(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + float_T f; + + rettv->v_type = VAR_FLOAT; + if (get_float_arg(argvars, &f) == OK) + rettv->vval.v_float = sqrt(f); + else + rettv->vval.v_float = 0.0; +} + +/* + * "str2float()" function + */ + static void +f_str2float(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + char_u *p = skipwhite(get_tv_string(&argvars[0])); + + if (*p == '+') + p = skipwhite(p + 1); + (void)string2float(p, &rettv->vval.v_float); + rettv->v_type = VAR_FLOAT; +} +#endif + /* * "str2nr()" function */ @@ -15384,6 +16205,8 @@ } p = skipwhite(get_tv_string(&argvars[0])); + if (*p == '+') + p = skipwhite(p + 1); vim_str2nr(p, NULL, NULL, base == 8 ? 2 : 0, base == 16 ? 2 : 0, &n, NULL); rettv->vval.v_number = n; } @@ -15500,7 +16323,7 @@ rettv->v_type = VAR_STRING; rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf, 0); - /* Make a copy if we have a value but it's not in allocate memory. */ + /* Make a copy if we have a value but it's not in allocated memory. */ if (rettv->vval.v_string != NULL && tofree == NULL) rettv->vval.v_string = vim_strsave(rettv->vval.v_string); } @@ -15688,7 +16511,7 @@ if (!transerr && lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count && col >= 0 && col < (long)STRLEN(ml_get(lnum))) - id = syn_get_id(curwin, lnum, (colnr_T)col, trans, NULL); + id = syn_get_id(curwin, lnum, (colnr_T)col, trans, NULL, FALSE); #endif rettv->vval.v_number = id; @@ -15811,6 +16634,46 @@ } /* + * "synstack(lnum, col)" function + */ +/*ARGSUSED*/ + static void +f_synstack(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ +#ifdef FEAT_SYN_HL + long lnum; + long col; + int i; + int id; +#endif + + rettv->v_type = VAR_LIST; + rettv->vval.v_list = NULL; + +#ifdef FEAT_SYN_HL + lnum = get_tv_lnum(argvars); /* -1 on type error */ + col = get_tv_number(&argvars[1]) - 1; /* -1 on type error */ + + if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count + && col >= 0 && col < (long)STRLEN(ml_get(lnum)) + && rettv_list_alloc(rettv) != FAIL) + { + (void)syn_get_id(curwin, lnum, (colnr_T)col, FALSE, NULL, TRUE); + for (i = 0; ; ++i) + { + id = syn_get_stack_item(i); + if (id < 0) + break; + if (list_append_number(rettv->vval.v_list, id) == FAIL) + break; + } + } +#endif +} + +/* * "system()" function */ static void @@ -15826,7 +16689,7 @@ FILE *fd; if (check_restricted() || check_secure()) - return; + goto done; if (argvars[1].v_type != VAR_UNKNOWN) { @@ -15837,7 +16700,7 @@ if ((infile = vim_tempname('i')) == NULL) { EMSG(_(e_notmp)); - return; + goto done; } fd = mch_fopen((char *)infile, WRITEBIN); @@ -16348,6 +17211,26 @@ rettv->vval.v_string = ga.ga_data; } +#ifdef FEAT_FLOAT +/* + * "trunc({float})" function + */ + static void +f_trunc(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + float_T f; + + rettv->v_type = VAR_FLOAT; + if (get_float_arg(argvars, &f) == OK) + /* trunc() is not in C90, use floor() or ceil() instead. */ + rettv->vval.v_float = f > 0 ? floor(f) : ceil(f); + else + rettv->vval.v_float = 0.0; +} +#endif + /* * "type(expr)" function */ @@ -16365,6 +17248,9 @@ case VAR_FUNC: n = 2; break; case VAR_LIST: n = 3; break; case VAR_DICT: n = 4; break; +#ifdef FEAT_FLOAT + case VAR_FLOAT: n = 5; break; +#endif default: EMSG2(_(e_intern2), "f_type()"); n = 0; break; } rettv->vval.v_number = n; @@ -16422,10 +17308,7 @@ rettv->vval.v_string = vim_strsave(str); /* A non-zero number or non-empty string argument: reset mode. */ - if ((argvars[0].v_type == VAR_NUMBER - && argvars[0].vval.v_number != 0) - || (argvars[0].v_type == VAR_STRING - && *get_tv_string(&argvars[0]) != NUL)) + if (non_zero_arg(&argvars[0])) curbuf->b_visual_mode_eval = NUL; #else rettv->vval.v_number = 0; /* return anything, it won't work anyway */ @@ -16781,9 +17664,17 @@ name = get_tv_string_chk(varp); if (name == NULL) return NULL; - if (name[0] == '.') /* cursor */ + if (name[0] == '.') /* cursor */ return &curwin->w_cursor; - if (name[0] == '\'') /* mark */ +#ifdef FEAT_VISUAL + if (name[0] == 'v' && name[1] == NUL) /* Visual start */ + { + if (VIsual_active) + return &VIsual; + return &curwin->w_cursor; + } +#endif + if (name[0] == '\'') /* mark */ { pp = getmark_fnum(name[1], FALSE, fnum); if (pp == NULL || pp == (pos_T *)-1 || pp->lnum <= 0) @@ -17194,7 +18085,6 @@ return vimvars[idx].vv_nr; } -#if defined(FEAT_AUTOCMD) || defined(PROTO) /* * Get string v: variable value. Uses a static buffer, can only be used once. */ @@ -17204,7 +18094,6 @@ { return get_tv_string(&vimvars[idx].vv_tv); } -#endif /* * Set v:count, v:count1 and v:prevcount. @@ -17496,7 +18385,7 @@ } /* - * Allocate memory for a variable type-value, and make it emtpy (0 or NULL + * Allocate memory for a variable type-value, and make it empty (0 or NULL * value). */ static typval_T * @@ -17551,6 +18440,9 @@ dict_unref(varp->vval.v_dict); break; case VAR_NUMBER: +#ifdef FEAT_FLOAT + case VAR_FLOAT: +#endif case VAR_UNKNOWN: break; default: @@ -17590,6 +18482,11 @@ case VAR_NUMBER: varp->vval.v_number = 0; break; +#ifdef FEAT_FLOAT + case VAR_FLOAT: + varp->vval.v_float = 0.0; + break; +#endif case VAR_UNKNOWN: break; default: @@ -17638,8 +18535,13 @@ { case VAR_NUMBER: return (long)(varp->vval.v_number); +#ifdef FEAT_FLOAT + case VAR_FLOAT: + EMSG(_("E805: Using a Float as a Number")); + break; +#endif case VAR_FUNC: - EMSG(_("E703: Using a Funcref as a number")); + EMSG(_("E703: Using a Funcref as a Number")); break; case VAR_STRING: if (varp->vval.v_string != NULL) @@ -17647,10 +18549,10 @@ TRUE, TRUE, &n, NULL); return n; case VAR_LIST: - EMSG(_("E745: Using a List as a number")); + EMSG(_("E745: Using a List as a Number")); break; case VAR_DICT: - EMSG(_("E728: Using a Dictionary as a number")); + EMSG(_("E728: Using a Dictionary as a Number")); break; default: EMSG2(_(e_intern2), "get_tv_number()"); @@ -17761,6 +18663,11 @@ case VAR_DICT: EMSG(_("E731: using Dictionary as a String")); break; +#ifdef FEAT_FLOAT + case VAR_FLOAT: + EMSG(_("E806: using Float as a String")); + break; +#endif case VAR_STRING: if (varp->vval.v_string != NULL) return varp->vval.v_string; @@ -18145,7 +19052,14 @@ && !((v->di_tv.v_type == VAR_STRING || v->di_tv.v_type == VAR_NUMBER) && (tv->v_type == VAR_STRING - || tv->v_type == VAR_NUMBER))) + || tv->v_type == VAR_NUMBER)) +#ifdef FEAT_FLOAT + && !((v->di_tv.v_type == VAR_NUMBER + || v->di_tv.v_type == VAR_FLOAT) + && (tv->v_type == VAR_NUMBER + || tv->v_type == VAR_FLOAT)) +#endif + ) { EMSG2(_("E706: Variable type mismatch for: %s"), name); return; @@ -18172,7 +19086,11 @@ else if (v->di_tv.v_type != VAR_NUMBER) EMSG2(_(e_intern2), "set_var()"); else + { v->di_tv.vval.v_number = get_tv_number(tv); + if (STRCMP(varname, "searchforward") == 0) + set_search_direction(v->di_tv.vval.v_number ? '/' : '?'); + } return; } @@ -18209,7 +19127,7 @@ v->di_flags = 0; } - if (copy || tv->v_type == VAR_NUMBER) + if (copy || tv->v_type == VAR_NUMBER || tv->v_type == VAR_FLOAT) copy_tv(tv, &v->di_tv); else { @@ -18299,6 +19217,11 @@ case VAR_NUMBER: to->vval.v_number = from->vval.v_number; break; +#ifdef FEAT_FLOAT + case VAR_FLOAT: + to->vval.v_float = from->vval.v_float; + break; +#endif case VAR_STRING: case VAR_FUNC: if (from->vval.v_string == NULL) @@ -18361,6 +19284,9 @@ switch (from->v_type) { case VAR_NUMBER: +#ifdef FEAT_FLOAT + case VAR_FLOAT: +#endif case VAR_STRING: case VAR_FUNC: copy_tv(from, to); @@ -18426,6 +19352,10 @@ ++emsg_skip; while (*arg != NUL && *arg != '|' && *arg != '\n' && !got_int) { + /* If eval1() causes an error message the text from the command may + * still need to be cleared. E.g., "echo 22,44". */ + need_clr_eos = needclr; + p = arg; if (eval1(&arg, &rettv, !eap->skip) == FAIL) { @@ -18436,8 +19366,11 @@ */ if (!aborting()) EMSG2(_(e_invexpr2), p); - break; - } + need_clr_eos = FALSE; + break; + } + need_clr_eos = FALSE; + if (!eap->skip) { if (atstart) @@ -19656,6 +20589,9 @@ int st_len = 0; todo = (int)func_hashtab.ht_used; + if (todo == 0) + return; /* nothing to dump */ + sorttab = (ufunc_T **)alloc((unsigned)(sizeof(ufunc_T) * todo)); for (hi = func_hashtab.ht_array; todo > 0; ++hi) @@ -19704,6 +20640,8 @@ prof_self_cmp); prof_sort_list(fd, sorttab, st_len, "SELF", TRUE); } + + vim_free(sorttab); } static void @@ -20270,7 +21208,7 @@ if (!fp->uf_profiling && has_profiling(FALSE, fp->uf_name, NULL)) func_do_profile(fp); if (fp->uf_profiling - || (fc.caller != NULL && &fc.caller->func->uf_profiling)) + || (fc.caller != NULL && fc.caller->func->uf_profiling)) { ++fp->uf_tm_count; profile_start(&call_start); @@ -20301,13 +21239,13 @@ #ifdef FEAT_PROFILE if (do_profiling == PROF_YES && (fp->uf_profiling - || (fc.caller != NULL && &fc.caller->func->uf_profiling))) + || (fc.caller != NULL && fc.caller->func->uf_profiling))) { profile_end(&call_start); profile_sub_wait(&wait_start, &call_start); profile_add(&fp->uf_tm_total, &call_start); profile_self(&fp->uf_tm_self, &call_start, &fp->uf_tm_children); - if (fc.caller != NULL && &fc.caller->func->uf_profiling) + if (fc.caller != NULL && fc.caller->func->uf_profiling) { profile_add(&fc.caller->func->uf_tm_children, &call_start); profile_add(&fc.caller->func->uf_tml_children, &call_start); @@ -20374,7 +21312,7 @@ did_emsg |= save_did_emsg; current_funccal = fc.caller; - /* The a: variables typevals were not alloced, only free the allocated + /* The a: variables typevals were not allocated, only free the allocated * variables. */ vars_clear_ext(&fc.l_avars.dv_hashtab, FALSE); @@ -20708,7 +21646,7 @@ /* * Return TRUE if the currently active function should be ended, because a - * return was encountered or an error occured. Used inside a ":while". + * return was encountered or an error occurred. Used inside a ":while". */ int func_has_ended(cookie) @@ -20735,9 +21673,9 @@ #if defined(FEAT_VIMINFO) || defined(FEAT_SESSION) typedef enum { - VAR_FLAVOUR_DEFAULT, - VAR_FLAVOUR_SESSION, - VAR_FLAVOUR_VIMINFO + VAR_FLAVOUR_DEFAULT, /* doesn't start with uppercase */ + VAR_FLAVOUR_SESSION, /* starts with uppercase, some lower */ + VAR_FLAVOUR_VIMINFO /* all uppercase */ } var_flavour_T; static var_flavour_T var_flavour __ARGS((char_u *varname)); @@ -20770,7 +21708,7 @@ int writing; { char_u *tab; - int is_string = FALSE; + int type = VAR_NUMBER; typval_T tv; if (!writing && (find_viminfo_parameter('!') != NULL)) @@ -20780,24 +21718,27 @@ { *tab++ = '\0'; /* isolate the variable name */ if (*tab == 'S') /* string var */ - is_string = TRUE; + type = VAR_STRING; +#ifdef FEAT_FLOAT + else if (*tab == 'F') + type = VAR_FLOAT; +#endif tab = vim_strchr(tab, '\t'); if (tab != NULL) { - if (is_string) - { - tv.v_type = VAR_STRING; + tv.v_type = type; + if (type == VAR_STRING) tv.vval.v_string = viminfo_readstring(virp, (int)(tab - virp->vir_line + 1), TRUE); - } - else - { - tv.v_type = VAR_NUMBER; +#ifdef FEAT_FLOAT + else if (type == VAR_FLOAT) + (void)string2float(tab + 1, &tv.vval.v_float); +#endif + else tv.vval.v_number = atol((char *)tab + 1); - } set_var(virp->vir_line + 1, &tv, FALSE); - if (is_string) + if (type == VAR_STRING) vim_free(tv.vval.v_string); } } @@ -20839,6 +21780,9 @@ { case VAR_STRING: s = "STR"; break; case VAR_NUMBER: s = "NUM"; break; +#ifdef FEAT_FLOAT + case VAR_FLOAT: s = "FLO"; break; +#endif default: continue; } fprintf(fp, "!%s\t%s\t", this_var->di_key, s); @@ -20898,6 +21842,24 @@ } vim_free(p); } +#ifdef FEAT_FLOAT + else if (this_var->di_tv.v_type == VAR_FLOAT + && var_flavour(this_var->di_key) == VAR_FLAVOUR_SESSION) + { + float_T f = this_var->di_tv.vval.v_float; + int sign = ' '; + + if (f < 0) + { + f = -f; + sign = '-'; + } + if ((fprintf(fd, "let %s = %c&%f", + this_var->di_key, sign, f) < 0) + || put_eol(fd) == FAIL) + return FAIL; + } +#endif } } return OK; @@ -20930,9 +21892,9 @@ #endif /* FEAT_EVAL */ + #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) || defined(PROTO) - #ifdef WIN3264 /* * Functions for ":8" filename modifier: get 8.3 version of a filename. @@ -20942,8 +21904,12 @@ static int shortpath_for_partial __ARGS((char_u **fnamep, char_u **bufp, int *fnamelen)); /* - * Get the short pathname of a file. - * Returns 1 on success. *fnamelen is 0 for nonexistent path. + * Get the short path (8.3) for the filename in "fnamep". + * Only works for a valid file name. + * When the path gets longer "fnamep" is changed and the allocated buffer + * is put in "bufp". + * *fnamelen is the length of "fnamep" and set to 0 for a nonexistent path. + * Returns OK on success, FAIL on failure. */ static int get_short_pathname(fnamep, bufp, fnamelen) @@ -20951,36 +21917,44 @@ char_u **bufp; int *fnamelen; { - int l,len; + int l, len; char_u *newbuf; len = *fnamelen; - l = GetShortPathName(*fnamep, *fnamep, len); if (l > len - 1) { /* If that doesn't work (not enough space), then save the string - * and try again with a new buffer big enough - */ + * and try again with a new buffer big enough. */ newbuf = vim_strnsave(*fnamep, l); if (newbuf == NULL) - return 0; + return FAIL; vim_free(*bufp); *fnamep = *bufp = newbuf; - l = GetShortPathName(*fnamep,*fnamep,l+1); - - /* Really should always succeed, as the buffer is big enough */ + /* Really should always succeed, as the buffer is big enough. */ + l = GetShortPathName(*fnamep, *fnamep, l+1); } *fnamelen = l; - return 1; -} - -/* - * Create a short path name. Returns the length of the buffer it needs. - * Doesn't copy over the end of the buffer passed in. + return OK; +} + +/* + * Get the short path (8.3) for the filename in "fname". The converted + * path is returned in "bufp". + * + * Some of the directories specified in "fname" may not exist. This function + * will shorten the existing directories at the beginning of the path and then + * append the remaining non-existing path. + * + * fname - Pointer to the filename to shorten. On return, contains the + * pointer to the shortened pathname + * bufp - Pointer to an allocated buffer for the filename. + * fnamelen - Length of the filename pointed to by fname + * + * Returns OK on success (or nothing done) and FAIL on failure (out of memory). */ static int shortpath_for_invalid_fname(fname, bufp, fnamelen) @@ -20988,85 +21962,106 @@ char_u **bufp; int *fnamelen; { - char_u *s, *p, *pbuf2, *pbuf3; + char_u *short_fname, *save_fname, *pbuf_unused; + char_u *endp, *save_endp; char_u ch; - int len, len2, plen, slen; + int old_len, len; + int new_len, sfx_len; + int retval = OK; /* Make a copy */ - len2 = *fnamelen; - pbuf2 = vim_strnsave(*fname, len2); - pbuf3 = NULL; - - s = pbuf2 + len2 - 1; /* Find the end */ - slen = 1; - plen = len2; - - if (after_pathsep(pbuf2, s + 1)) - { - --s; - ++slen; - --plen; - } - - do - { - /* Go back one path-separator */ - while (s > pbuf2 && !after_pathsep(pbuf2, s + 1)) - { - --s; - ++slen; - --plen; - } - if (s <= pbuf2) - break; - - /* Remember the character that is about to be splatted */ - ch = *s; - *s = 0; /* get_short_pathname requires a null-terminated string */ - - /* Try it in situ */ - p = pbuf2; - if (!get_short_pathname(&p, &pbuf3, &plen)) - { - vim_free(pbuf2); - return -1; - } - *s = ch; /* Preserve the string */ - } while (plen == 0); - - if (plen > 0) - { - /* Remember the length of the new string. */ - *fnamelen = len = plen + slen; + old_len = *fnamelen; + save_fname = vim_strnsave(*fname, old_len); + pbuf_unused = NULL; + short_fname = NULL; + + endp = save_fname + old_len - 1; /* Find the end of the copy */ + save_endp = endp; + + /* + * Try shortening the supplied path till it succeeds by removing one + * directory at a time from the tail of the path. + */ + len = 0; + for (;;) + { + /* go back one path-separator */ + while (endp > save_fname && !after_pathsep(save_fname, endp + 1)) + --endp; + if (endp <= save_fname) + break; /* processed the complete path */ + + /* + * Replace the path separator with a NUL and try to shorten the + * resulting path. + */ + ch = *endp; + *endp = 0; + short_fname = save_fname; + len = (int)STRLEN(short_fname) + 1; + if (get_short_pathname(&short_fname, &pbuf_unused, &len) == FAIL) + { + retval = FAIL; + goto theend; + } + *endp = ch; /* preserve the string */ + + if (len > 0) + break; /* successfully shortened the path */ + + /* failed to shorten the path. Skip the path separator */ + --endp; + } + + if (len > 0) + { + /* + * Succeeded in shortening the path. Now concatenate the shortened + * path with the remaining path at the tail. + */ + + /* Compute the length of the new path. */ + sfx_len = (int)(save_endp - endp) + 1; + new_len = len + sfx_len; + + *fnamelen = new_len; vim_free(*bufp); - if (len > len2) - { - /* If there's not enough space in the currently allocated string, - * then copy it to a buffer big enough. - */ - *fname= *bufp = vim_strnsave(p, len); + if (new_len > old_len) + { + /* There is not enough space in the currently allocated string, + * copy it to a buffer big enough. */ + *fname = *bufp = vim_strnsave(short_fname, new_len); if (*fname == NULL) - return -1; - } - else - { - /* Transfer pbuf2 to being the main buffer (it's big enough) */ - *fname = *bufp = pbuf2; - if (p != pbuf2) - strncpy(*fname, p, plen); - pbuf2 = NULL; - } - /* Concat the next bit */ - strncpy(*fname + plen, s, slen); - (*fname)[len] = '\0'; - } - vim_free(pbuf3); - vim_free(pbuf2); - return 0; + { + retval = FAIL; + goto theend; + } + } + else + { + /* Transfer short_fname to the main buffer (it's big enough), + * unless get_short_pathname() did its work in-place. */ + *fname = *bufp = save_fname; + if (short_fname != save_fname) + vim_strncpy(save_fname, short_fname, len); + save_fname = NULL; + } + + /* concat the not-shortened part of the path */ + vim_strncpy(*fname + len, endp, sfx_len); + (*fname)[new_len] = NUL; + } + +theend: + vim_free(pbuf_unused); + vim_free(save_fname); + + return retval; } /* * Get a pathname for a partial path. + * Returns OK for success, FAIL for failure. */ static int shortpath_for_partial(fnamep, bufp, fnamelen) @@ -21079,9 +22074,8 @@ char_u *pbuf, *tfname; int hasTilde; - /* Count up the path seperators from the RHS.. so we know which part - * of the path to return. - */ + /* Count up the path separators from the RHS.. so we know which part + * of the path to return. */ sepcount = 0; for (p = *fnamep; p < *fnamep + *fnamelen; mb_ptr_adv(p)) if (vim_ispathsep(*p)) @@ -21096,8 +22090,8 @@ len = tflen = (int)STRLEN(tfname); - if (!get_short_pathname(&tfname, &pbuf, &len)) - return -1; + if (get_short_pathname(&tfname, &pbuf, &len) == FAIL) + return FAIL; if (len == 0) { @@ -21106,8 +22100,8 @@ * there's not a lot of point in guessing what it might be. */ len = tflen; - if (shortpath_for_invalid_fname(&tfname, &pbuf, &len) == -1) - return -1; + if (shortpath_for_invalid_fname(&tfname, &pbuf, &len) == FAIL) + return FAIL; } /* Count the paths backward to find the beginning of the desired string. */ @@ -21131,7 +22125,7 @@ if (p >= tfname) *p = '~'; else - return -1; + return FAIL; } else ++p; @@ -21142,7 +22136,7 @@ *bufp = pbuf; *fnamep = p; - return 0; + return OK; } #endif /* WIN3264 */ @@ -21150,7 +22144,7 @@ * Adjust a filename, according to a string of modifiers. * *fnamep must be NUL terminated when called. When returning, the length is * determined by *fnamelen. - * Returns valid flags. + * Returns VALID_ flags or -1 for failure. * When there is an error, *fnamep is set to NULL. */ int @@ -21362,7 +22356,7 @@ */ if (!has_fullname && !vim_isAbsName(*fnamep)) { - if (shortpath_for_partial(fnamep, bufp, fnamelen) == -1) + if (shortpath_for_partial(fnamep, bufp, fnamelen) == FAIL) return -1; } else @@ -21372,7 +22366,7 @@ /* Simple case, already have the full-name * Nearly always shorter, so try first time. */ l = *fnamelen; - if (!get_short_pathname(fnamep, bufp, &l)) + if (get_short_pathname(fnamep, bufp, &l) == FAIL) return -1; if (l == 0) @@ -21380,7 +22374,7 @@ /* Couldn't find the filename.. search the paths. */ l = *fnamelen; - if (shortpath_for_invalid_fname(fnamep, bufp, &l ) == -1) + if (shortpath_for_invalid_fname(fnamep, bufp, &l) == FAIL) return -1; } *fnamelen = l; @@ -21528,7 +22522,7 @@ /* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */ save_cpo = p_cpo; - p_cpo = (char_u *)""; + p_cpo = empty_option; ga_init2(&ga, 1, 200); @@ -21589,7 +22583,11 @@ ret = vim_strsave(ga.ga_data == NULL ? str : (char_u *)ga.ga_data); ga_clear(&ga); - p_cpo = save_cpo; + if (p_cpo == empty_option) + p_cpo = save_cpo; + else + /* Darn, evaluating {sub} expression changed the value. */ + free_string_option(save_cpo); return ret; }
--- a/src/if_cscope.c Wed Aug 13 17:54:25 2008 +0900 +++ b/src/if_cscope.c Fri Aug 29 15:41:29 2008 +0900 @@ -23,7 +23,6 @@ #else /* not UNIX, must be WIN32 */ # include "vimio.h" -# include <fcntl.h> #endif #include "if_cscope.h" @@ -75,7 +74,7 @@ { "add", cs_add, N_("Add a new database"), "add file|dir [pre-path] [flags]", 0 }, { "find", cs_find, - N_("Query for a pattern"), FIND_USAGE, 1 }, + N_("Query for a pattern"), "find c|d|e|f|g|i|s|t name", 1 }, { "help", cs_help, N_("Show this message"), "help", 0 }, { "kill", cs_kill, @@ -171,7 +170,7 @@ cs_init(); - if (eap->arg == NULL || strlen((const char *)(eap->arg)) == 0) + if (*eap->arg == NUL) { (void)EMSG(_("E562: Usage: cstag <ident>")); return; @@ -1181,7 +1180,16 @@ (void)smsg((char_u *)_("%-5s: %-30s (Usage: %s)"), cmdp->name, _(cmdp->help), cmdp->usage); if (strcmp(cmdp->name, "find") == 0) - MSG_PUTS(FIND_HELP); + MSG_PUTS(_("\n" + " c: Find functions calling this function\n" + " d: Find functions called by this function\n" + " e: Find this egrep pattern\n" + " f: Find this file\n" + " g: Find this definition\n" + " i: Find files #including this file\n" + " s: Find this C symbol\n" + " t: Find assignments to\n")); + cmdp++; } @@ -1225,7 +1233,7 @@ csinfo[i].nIndexHigh = 0; csinfo[i].nIndexLow = 0; #endif - csinfo[i].pid = -1; + csinfo[i].pid = 0; csinfo[i].fr_fp = NULL; csinfo[i].to_fp = NULL; #if defined(WIN32) @@ -1400,7 +1408,7 @@ return NULL; /* Store length of eap->arg before it gets modified by strtok(). */ - eap_arg_len = STRLEN(eap->arg); + eap_arg_len = (int)STRLEN(eap->arg); if ((stok = strtok((char *)(eap->arg), (const char *)" ")) == NULL) return NULL; @@ -2096,6 +2104,18 @@ return CSCOPE_SUCCESS; } +#if defined(UNIX) && defined(SIGALRM) +/* + * Used to catch and ignore SIGALRM below. + */ +/* ARGSUSED */ + static RETSIGTYPE +sig_handler SIGDEFARG(sigarg) +{ + /* do nothing */ + SIGRETURN; +} +#endif /* * PRIVATE: cs_release_csp @@ -2108,9 +2128,6 @@ int i; int freefnpp; { -#if defined(UNIX) - int pstat; -#else /* * Trying to exit normally (not sure whether it is fit to UNIX cscope */ @@ -2119,6 +2136,88 @@ (void)fputs("q\n", csinfo[i].to_fp); (void)fflush(csinfo[i].to_fp); } +#if defined(UNIX) + { + int waitpid_errno; + int pstat; + pid_t pid; + +# if defined(HAVE_SIGACTION) + struct sigaction sa, old; + + /* Use sigaction() to limit the waiting time to two seconds. */ + sigemptyset(&sa.sa_mask); + sa.sa_handler = sig_handler; + sa.sa_flags = SA_NODEFER; + sigaction(SIGALRM, &sa, &old); + alarm(2); /* 2 sec timeout */ + + /* Block until cscope exits or until timer expires */ + pid = waitpid(csinfo[i].pid, &pstat, 0); + waitpid_errno = errno; + + /* cancel pending alarm if still there and restore signal */ + alarm(0); + sigaction(SIGALRM, &old, NULL); +# else + int waited; + + /* Can't use sigaction(), loop for two seconds. First yield the CPU + * to give cscope a chance to exit quickly. */ + sleep(0); + for (waited = 0; waited < 40; ++waited) + { + pid = waitpid(csinfo[i].pid, &pstat, WNOHANG); + waitpid_errno = errno; + if (pid != 0) + break; /* break unless the process is still running */ + mch_delay(50L, FALSE); /* sleep 50 ms */ + } +# endif + /* + * If the cscope process is still running: kill it. + * Safety check: If the PID would be zero here, the entire X session + * would be killed. -1 and 1 are dangerous as well. + */ + if (pid < 0 && csinfo[i].pid > 1) + { +# ifdef ECHILD + int alive = TRUE; + + if (waitpid_errno == ECHILD) + { + /* + * When using 'vim -g', vim is forked and cscope process is + * no longer a child process but a sibling. So waitpid() + * fails with errno being ECHILD (No child processes). + * Don't send SIGKILL to cscope immediately but wait + * (polling) for it to exit normally as result of sending + * the "q" command, hence giving it a chance to clean up + * its temporary files. + */ + int waited; + + sleep(0); + for (waited = 0; waited < 40; ++waited) + { + /* Check whether cscope process is still alive */ + if (kill(csinfo[i].pid, 0) != 0) + { + alive = FALSE; /* cscope process no longer exists */ + break; + } + mch_delay(50L, FALSE); /* sleep 50ms */ + } + } + if (alive) +# endif + { + kill(csinfo[i].pid, SIGKILL); + (void)waitpid(csinfo[i].pid, &pstat, 0); + } + } + } +#else /* !UNIX */ if (csinfo[i].hProc != NULL) { /* Give cscope a chance to exit normally */ @@ -2133,18 +2232,6 @@ if (csinfo[i].to_fp != NULL) (void)fclose(csinfo[i].to_fp); - /* - * Safety check: If the PID would be zero here, the entire X session would - * be killed. -1 and 1 are dangerous as well. - */ -#if defined(UNIX) - if (csinfo[i].pid > 1) - { - kill(csinfo[i].pid, SIGTERM); - (void)waitpid(csinfo[i].pid, &pstat, 0); - } -#endif - if (freefnpp) { vim_free(csinfo[i].fname);
--- a/src/if_cscope.h Wed Aug 13 17:54:25 2008 +0900 +++ b/src/if_cscope.h Fri Aug 29 15:41:29 2008 +0900 @@ -42,17 +42,6 @@ * f 7name Find this file * i 8name Find files #including this file */ -#define FIND_USAGE "find c|d|e|f|g|i|s|t name" -#define FIND_HELP "\n\ - c: Find functions calling this function\n\ - d: Find functions called by this function\n\ - e: Find this egrep pattern\n\ - f: Find this file\n\ - g: Find this definition\n\ - i: Find files #including this file\n\ - s: Find this C symbol\n\ - t: Find assignments to\n" - typedef struct { char * name;
--- a/src/if_sniff.c Wed Aug 13 17:54:25 2008 +0900 +++ b/src/if_sniff.c Fri Aug 29 15:41:29 2008 +0900 @@ -11,7 +11,6 @@ #ifdef WIN32 # include <stdio.h> -# include <fcntl.h> # include "vimio.h" # include <process.h> # include <string.h>
--- a/src/menu.c Wed Aug 13 17:54:25 2008 +0900 +++ b/src/menu.c Fri Aug 29 15:41:29 2008 +0900 @@ -152,7 +152,7 @@ while (*arg != NUL && *arg != ' ') { if (*arg == '\\') - mch_memmove(arg, arg + 1, STRLEN(arg)); + STRMOVE(arg, arg + 1); mb_ptr_adv(arg); } if (*arg != NUL) @@ -300,7 +300,7 @@ else if (STRNICMP(arg, "<TAB>", 5) == 0) { *arg = TAB; - mch_memmove(arg + 1, arg + 5, STRLEN(arg + 4)); + STRMOVE(arg + 1, arg + 5); } arg++; } @@ -1120,6 +1120,7 @@ parent = menu; menu = menu->children; } + vim_free(path_name); /* Now we have found the matching menu, and we list the mappings */ /* Highlight title */ @@ -1442,7 +1443,7 @@ { if (*p == '\\' || *p == Ctrl_V) { - mch_memmove(p, p + 1, STRLEN(p)); + STRMOVE(p, p + 1); if (*p == NUL) break; } @@ -1659,7 +1660,7 @@ *mnemonic = c; } #endif - mch_memmove(p, p + 1, STRLEN(p)); + STRMOVE(p, p + 1); p = p + 1; } }
--- a/src/po/sk.cp1250.po Wed Aug 13 17:54:25 2008 +0900 +++ b/src/po/sk.cp1250.po Fri Aug 29 15:41:29 2008 +0900 @@ -346,7 +346,7 @@ msgstr "E716: kžúč sa v Slovníku (Dictionary) nenachádza: %s" msgid "E122: Function %s already exists, add ! to replace it" -msgstr "E112: Funkcia %s u existuje. Pouite ! pre jej nahradenie." +msgstr "E122: Funkcia %s u existuje. Pouite ! pre jej nahradenie." msgid "E717: Dictionary entry already exists" msgstr "E717: Záznam v Slovníku (Dictionary) u existuje" @@ -527,7 +527,7 @@ msgstr "E241: Nemôem posla na %s" msgid "E277: Unable to read a server reply" -msgstr "E227: Nemôem číta odpoveď servra" +msgstr "E277: Nemôem číta odpoveď servra" msgid "E655: Too many symbolic links (cycle?)" msgstr "E655: Príli mnoho symbolických odkazov (slučka?)" @@ -544,13 +544,13 @@ msgid "E677: Error writing temp file" msgstr "E677: Chyba pri zápise dočasného súboru" -msgid "E703: Using a Funcref as a number" +msgid "E703: Using a Funcref as a Number" msgstr "E703: Pouitý odkaz na Funkciu (Funcref) ako číslo" -msgid "E745: Using a List as a number" +msgid "E745: Using a List as a Number" msgstr "E745: Zoznam (List) pouitý ako číslo" -msgid "E728: Using a Dictionary as a number" +msgid "E728: Using a Dictionary as a Number" msgstr "E728: Slovník (Dictionary) pouitý ako číslo" msgid "E729: using Funcref as a String" @@ -866,7 +866,7 @@ msgstr "E156: Chýba meno pre značku" msgid "E612: Too many signs defined" -msgstr "E255: Príli mnoho definovaných značiek" +msgstr "E612: Príli mnoho definovaných značiek" #, c-format msgid "E239: Invalid sign text: %s" @@ -1128,7 +1128,7 @@ msgid "Append File" msgstr "Pripoji súbor" -msgid "E747: Cannot change directory, buffer is modifed (add ! to override)" +msgid "E747: Cannot change directory, buffer is modified (add ! to override)" msgstr "E747: Nemono zmeni adresár, buffer je modifikovaný (pouite ! pre vynútenie)" msgid "E186: No previous directory" @@ -1260,13 +1260,13 @@ msgstr "E579: vnorenie :if je príli hlboké" msgid "E580: :endif without :if" -msgstr "E580 :endif bez zodpovedajúceho :if" +msgstr "E580: :endif bez zodpovedajúceho :if" msgid "E581: :else without :if" -msgstr "E581 :else bez zodpovedajúceho :if" +msgstr "E581: :else bez zodpovedajúceho :if" msgid "E582: :elseif without :if" -msgstr "E582 :elseif bez zodpovedajúceho :if" +msgstr "E582: :elseif bez zodpovedajúceho :if" msgid "E583: multiple :else" msgstr "E583: viacnásobné :else" @@ -1439,7 +1439,7 @@ msgid "E204: Autocommand changed number of lines in unexpected way" msgstr "E204: Automatický príkaz neočakávaným spôsobom zmenil počet riadkov" -msgid "NetBeans dissallows writes of unmodified buffers" +msgid "NetBeans disallows writes of unmodified buffers" msgstr "NetBeans rozhranie nedovolilo zapísa nemodifikované buffre" msgid "Partial writes disallowed for NetBeans buffers" @@ -4644,7 +4644,7 @@ msgid "Too many compound flags" msgstr "Príli mnoho upravovacích príznakov" -msgid "Too many posponed prefixes and/or compound flags" +msgid "Too many postponed prefixes and/or compound flags" msgstr "Príli mnoho odloených prípon a/alebo upravovacích príznakov" #, c-format @@ -5126,14 +5126,14 @@ #. Only MS VC 4.1 and earlier can do Win32s msgid "" "\n" -"MS-Windows 16/32 bit GUI version" +"MS-Windows 16/32-bit GUI version" msgstr "" "\n" "16/32 bitová GUI verzia pre MS Windows" msgid "" "\n" -"MS-Windows 32 bit GUI version" +"MS-Windows 32-bit GUI version" msgstr "" "\n" "32 bitová GUI verzia pre MS Windows" @@ -5146,28 +5146,28 @@ msgid "" "\n" -"MS-Windows 32 bit console version" +"MS-Windows 32-bit console version" msgstr "" "\n" "32 bitová verzia pre MS Windows konzolu" msgid "" "\n" -"MS-Windows 16 bit version" +"MS-Windows 16-bit version" msgstr "" "\n" "16 bitová verzia pre MS Windows" msgid "" "\n" -"32 bit MS-DOS version" +"32-bit MS-DOS version" msgstr "" "\n" "32 bitová verzia pre MS-DOS" msgid "" "\n" -"16 bit MS-DOS version" +"16-bit MS-DOS version" msgstr "" "\n" "16 bitová MS-DOS verzia"
--- a/src/po/sk.po Wed Aug 13 17:54:25 2008 +0900 +++ b/src/po/sk.po Fri Aug 29 15:41:29 2008 +0900 @@ -346,7 +346,7 @@ msgstr "E716: kľúč sa v Slovníku (Dictionary) nenachádza: %s" msgid "E122: Function %s already exists, add ! to replace it" -msgstr "E112: Funkcia %s už existuje. Použite ! pre jej nahradenie." +msgstr "E122: Funkcia %s už existuje. Použite ! pre jej nahradenie." msgid "E717: Dictionary entry already exists" msgstr "E717: Záznam v Slovníku (Dictionary) už existuje" @@ -527,7 +527,7 @@ msgstr "E241: Nemôžem poslať na %s" msgid "E277: Unable to read a server reply" -msgstr "E227: Nemôžem čítať odpoveď servra" +msgstr "E277: Nemôžem čítať odpoveď servra" msgid "E655: Too many symbolic links (cycle?)" msgstr "E655: Príliš mnoho symbolických odkazov (slučka?)" @@ -544,13 +544,13 @@ msgid "E677: Error writing temp file" msgstr "E677: Chyba pri zápise dočasného súboru" -msgid "E703: Using a Funcref as a number" +msgid "E703: Using a Funcref as a Number" msgstr "E703: Použitý odkaz na Funkciu (Funcref) ako číslo" -msgid "E745: Using a List as a number" +msgid "E745: Using a List as a Number" msgstr "E745: Zoznam (List) použitý ako číslo" -msgid "E728: Using a Dictionary as a number" +msgid "E728: Using a Dictionary as a Number" msgstr "E728: Slovník (Dictionary) použitý ako číslo" msgid "E729: using Funcref as a String" @@ -866,7 +866,7 @@ msgstr "E156: Chýba meno pre značku" msgid "E612: Too many signs defined" -msgstr "E255: Príliš mnoho definovaných značiek" +msgstr "E612: Príliš mnoho definovaných značiek" #, c-format msgid "E239: Invalid sign text: %s" @@ -1128,7 +1128,7 @@ msgid "Append File" msgstr "Pripojiť súbor" -msgid "E747: Cannot change directory, buffer is modifed (add ! to override)" +msgid "E747: Cannot change directory, buffer is modified (add ! to override)" msgstr "E747: Nemožno zmeniť adresár, buffer je modifikovaný (použite ! pre vynútenie)" msgid "E186: No previous directory" @@ -1260,13 +1260,13 @@ msgstr "E579: vnorenie :if je príliš hlboké" msgid "E580: :endif without :if" -msgstr "E580 :endif bez zodpovedajúceho :if" +msgstr "E580: :endif bez zodpovedajúceho :if" msgid "E581: :else without :if" -msgstr "E581 :else bez zodpovedajúceho :if" +msgstr "E581: :else bez zodpovedajúceho :if" msgid "E582: :elseif without :if" -msgstr "E582 :elseif bez zodpovedajúceho :if" +msgstr "E582: :elseif bez zodpovedajúceho :if" msgid "E583: multiple :else" msgstr "E583: viacnásobné :else" @@ -1439,7 +1439,7 @@ msgid "E204: Autocommand changed number of lines in unexpected way" msgstr "E204: Automatický príkaz neočakávaným spôsobom zmenil počet riadkov" -msgid "NetBeans dissallows writes of unmodified buffers" +msgid "NetBeans disallows writes of unmodified buffers" msgstr "NetBeans rozhranie nedovolilo zapísať nemodifikované buffre" msgid "Partial writes disallowed for NetBeans buffers" @@ -4644,7 +4644,7 @@ msgid "Too many compound flags" msgstr "Príliš mnoho upravovacích príznakov" -msgid "Too many posponed prefixes and/or compound flags" +msgid "Too many postponed prefixes and/or compound flags" msgstr "Príliš mnoho odložených prípon a/alebo upravovacích príznakov" #, c-format @@ -5126,14 +5126,14 @@ #. Only MS VC 4.1 and earlier can do Win32s msgid "" "\n" -"MS-Windows 16/32 bit GUI version" +"MS-Windows 16/32-bit GUI version" msgstr "" "\n" "16/32 bitová GUI verzia pre MS Windows" msgid "" "\n" -"MS-Windows 32 bit GUI version" +"MS-Windows 32-bit GUI version" msgstr "" "\n" "32 bitová GUI verzia pre MS Windows" @@ -5146,28 +5146,28 @@ msgid "" "\n" -"MS-Windows 32 bit console version" +"MS-Windows 32-bit console version" msgstr "" "\n" "32 bitová verzia pre MS Windows konzolu" msgid "" "\n" -"MS-Windows 16 bit version" +"MS-Windows 16-bit version" msgstr "" "\n" "16 bitová verzia pre MS Windows" msgid "" "\n" -"32 bit MS-DOS version" +"32-bit MS-DOS version" msgstr "" "\n" "32 bitová verzia pre MS-DOS" msgid "" "\n" -"16 bit MS-DOS version" +"16-bit MS-DOS version" msgstr "" "\n" "16 bitová MS-DOS verzia"
--- a/src/pty.c Wed Aug 13 17:54:25 2008 +0900 +++ b/src/pty.c Fri Aug 29 15:41:29 2008 +0900 @@ -41,10 +41,6 @@ #include "vim.h" -#ifdef HAVE_FCNTL_H -# include <fcntl.h> -#endif - #include <signal.h> #ifdef __CYGWIN32__ @@ -274,9 +270,10 @@ } #endif -#if defined(HAVE_SVR4_PTYS) && !defined(PTY_DONE) && !defined(hpux) +#if defined(HAVE_SVR4_PTYS) && !defined(PTY_DONE) && !defined(hpux) && !defined(MACOS_X) -/* NOTE: Even though HPUX can have /dev/ptmx, the code below doesn't work! */ +/* NOTE: Even though HPUX can have /dev/ptmx, the code below doesn't work! + * Same for Mac OS X Leopard. */ #define PTY_DONE int OpenPTY(ttyn)
--- a/src/spell.c Wed Aug 13 17:54:25 2008 +0900 +++ b/src/spell.c Fri Aug 29 15:41:29 2008 +0900 @@ -77,7 +77,7 @@ /* * Do the opposite: based on a maximum end score and a known sound score, - * compute the the maximum word score that can be used. + * compute the maximum word score that can be used. */ #define MAXSCORE(word_score, sound_score) ((4 * word_score - sound_score) / 3) @@ -311,10 +311,6 @@ #if defined(FEAT_SPELL) || defined(PROTO) -#ifdef HAVE_FCNTL_H -# include <fcntl.h> -#endif - #ifndef UNIX /* it's in os_unix.h for Unix */ # include <time.h> /* for time_t */ #endif @@ -629,7 +625,7 @@ /* TRUE if a word appears in the list of banned words. */ #define WAS_BANNED(su, word) (!HASHITEM_EMPTY(hash_find(&su->su_banned, word))) -/* Number of suggestions kept when cleaning up. we need to keep more than +/* Number of suggestions kept when cleaning up. We need to keep more than * what is displayed, because when rescore_suggestions() is called the score * may change and wrong suggestions may be removed later. */ #define SUG_CLEAN_COUNT(su) ((su)->su_maxcount < 130 ? 150 : (su)->su_maxcount + 20) @@ -753,6 +749,7 @@ static int spell_iswordp __ARGS((char_u *p, buf_T *buf)); static int spell_iswordp_nmw __ARGS((char_u *p)); #ifdef FEAT_MBYTE +static int spell_mb_isword_class __ARGS((int cl)); static int spell_iswordp_w __ARGS((int *p, buf_T *buf)); #endif static int write_spell_prefcond __ARGS((FILE *fd, garray_T *gap)); @@ -2146,7 +2143,7 @@ { col = (int)(p - buf); (void)syn_get_id(wp, lnum, (colnr_T)col, - FALSE, &can_spell); + FALSE, &can_spell, FALSE); if (!can_spell) attr = HLF_COUNT; } @@ -2268,6 +2265,8 @@ /* * For spell checking: concatenate the start of the following line "line" into * "buf", blanking-out special characters. Copy less then "maxlen" bytes. + * Keep the blanks at the start of the next line, this is used in win_line() + * to skip those bytes if the word was OK. */ void spell_cat_line(buf, line, maxlen) @@ -2284,12 +2283,14 @@ if (*p != NUL) { - *buf = ' '; - vim_strncpy(buf + 1, line, maxlen - 2); - n = (int)(p - line); - if (n >= maxlen) - n = maxlen - 1; - vim_memset(buf + 1, ' ', n); + /* Only worth concatenating if there is something else than spaces to + * concatenate. */ + n = (int)(p - line) + 1; + if (n < maxlen - 1) + { + vim_memset(buf, ' ', n); + vim_strncpy(buf + n, p, maxlen - 1 - n); + } } } @@ -2940,7 +2941,7 @@ /* * Read a string of length "cnt" from "fd" into allocated memory. - * Returns NULL when out of memory. + * Returns NULL when out of memory or unable to read that many bytes. */ static char_u * read_string(fd, cnt) @@ -2949,14 +2950,23 @@ { char_u *str; int i; + int c; /* allocate memory */ str = alloc((unsigned)cnt + 1); if (str != NULL) { - /* Read the string. Doesn't check for truncated file. */ + /* Read the string. Quit when running into the EOF. */ for (i = 0; i < cnt; ++i) - str[i] = getc(fd); + { + c = getc(fd); + if (c == EOF) + { + vim_free(str); + return NULL; + } + str[i] = c; + } str[i] = NUL; } return str; @@ -3286,6 +3296,7 @@ { int done = 0; int i; + int c; char_u word[MAXWLEN]; while (done < len) @@ -3293,7 +3304,10 @@ /* Read one word at a time. */ for (i = 0; ; ++i) { - word[i] = getc(fd); + c = getc(fd); + if (c == EOF) + return SP_TRUNCERROR; + word[i] = c; if (word[i] == NUL) break; if (i == MAXWLEN - 1) @@ -3540,6 +3554,11 @@ while (todo-- > 0) { c = getc(fd); /* <compflags> */ + if (c == EOF) + { + vim_free(pat); + return SP_TRUNCERROR; + } /* Add all flags to "sl_compallflags". */ if (vim_strchr((char_u *)"+*[]/", c) == NULL @@ -5961,7 +5980,7 @@ else if (spin->si_newprefID == 0 || spin->si_newprefID == 127) MSG(_("Too many compound flags")); else - MSG(_("Too many posponed prefixes and/or compound flags")); + MSG(_("Too many postponed prefixes and/or compound flags")); } if (syllable != NULL) @@ -6019,7 +6038,7 @@ flag = get_affitem(affile->af_flagtype, &p); if (flag == affile->af_comppermit || flag == affile->af_compforbid) { - mch_memmove(prevp, p, STRLEN(p) + 1); + STRMOVE(prevp, p); p = prevp; if (flag == affile->af_comppermit) entry->ae_comppermit = TRUE; @@ -6510,7 +6529,7 @@ for (p = w; *p != NUL; mb_ptr_adv(p)) { if (*p == '\\' && (p[1] == '\\' || p[1] == '/')) - mch_memmove(p, p + 1, STRLEN(p)); + STRMOVE(p, p + 1); else if (*p == '/') { *p = NUL; @@ -9785,7 +9804,7 @@ c = mb_ptr2char(s); if (c > 255) - return mb_get_class(s) >= 2; + return spell_mb_isword_class(mb_get_class(s)); return spelltab.st_isw[c]; } #endif @@ -9808,7 +9827,7 @@ { c = mb_ptr2char(p); if (c > 255) - return mb_get_class(p) >= 2; + return spell_mb_isword_class(mb_get_class(p)); return spelltab.st_isw[c]; } #endif @@ -9817,6 +9836,18 @@ #ifdef FEAT_MBYTE /* + * Return TRUE if word class indicates a word character. + * Only for characters above 255. + * Unicode subscript and superscript are not considered word characters. + */ + static int +spell_mb_isword_class(cl) + int cl; +{ + return cl >= 2 && cl != 0x2070 && cl != 0x2080; +} + +/* * Return TRUE if "p" points to a word character. * Wide version of spell_iswordp(). */ @@ -9837,7 +9868,7 @@ if (*s > 255) { if (enc_utf8) - return utf_class(*s) >= 2; + return spell_mb_isword_class(utf_class(*s)); if (enc_dbcs) return dbcs_class((unsigned)*s >> 8, *s & 0xff) >= 2; return 0; @@ -10343,7 +10374,7 @@ curwin->w_cursor.lnum = 0; while (!got_int) { - if (do_search(NULL, '/', frompat, 1L, SEARCH_KEEP) == 0 + if (do_search(NULL, '/', frompat, 1L, SEARCH_KEEP, NULL) == 0 || u_save_cursor() == FAIL) break; @@ -12557,7 +12588,7 @@ tl = (int)STRLEN(ftp->ft_to); if (fl != tl) { - mch_memmove(p + tl, p + fl, STRLEN(p + fl) + 1); + STRMOVE(p + tl, p + fl); repextra += tl - fl; } mch_memmove(p, ftp->ft_to, tl); @@ -12587,7 +12618,7 @@ p = fword + sp->ts_fidx; if (fl != tl) { - mch_memmove(p + fl, p + tl, STRLEN(p + tl) + 1); + STRMOVE(p + fl, p + tl); repextra -= tl - fl; } mch_memmove(p, ftp->ft_from, fl); @@ -13018,7 +13049,7 @@ if (vim_iswhite(su->su_badptr[su->su_badlen]) && *skiptowhite(stp->st_word) == NUL) for (p = fword; *(p = skiptowhite(p)) != NUL; ) - mch_memmove(p, p + 1, STRLEN(p)); + STRMOVE(p, p + 1); spell_soundfold(slang, fword, TRUE, badsound2); pbad = badsound2; @@ -14264,8 +14295,7 @@ s++; } if (k > k0) - mch_memmove(word + i + k0, word + i + k, - STRLEN(word + i + k) + 1); + STRMOVE(word + i + k0, word + i + k); /* new "actual letter" */ c = word[i]; @@ -14287,8 +14317,7 @@ { if (c != NUL) res[reslen++] = c; - mch_memmove(word, word + i + 1, - STRLEN(word + i + 1) + 1); + STRMOVE(word, word + i + 1); i = 0; z0 = 1; }
--- a/src/version.c Wed Aug 13 17:54:25 2008 +0900 +++ b/src/version.c Fri Aug 29 15:41:29 2008 +0900 @@ -217,6 +217,11 @@ #else "-find_in_path", #endif +#ifdef FEAT_FLOAT + "+float", +#else + "-float", +#endif #ifdef FEAT_FOLDING "+folding", #else @@ -345,6 +350,11 @@ # else "-mouse_netterm", # endif +# ifdef FEAT_SYSMOUSE + "+mouse_sysmouse", +# else + "-mouse_sysmouse", +# endif # ifdef FEAT_MOUSE_XTERM "+mouse_xterm", # else @@ -667,302 +677,6 @@ static int included_patches[] = { /* Add new patch number below this line */ /**/ - 154, -/**/ - 153, -/**/ - 152, -/**/ - 151, -/**/ - 150, -/**/ - 149, -/**/ - 148, -/**/ - 147, -/**/ - 146, -/**/ - 145, -/**/ - 144, -/**/ - 143, -/**/ - 142, -/**/ - 141, -/**/ - 140, -/**/ - 139, -/**/ - 138, -/**/ - 137, -/**/ - 136, -/**/ - 135, -/**/ - 134, -/**/ - 133, -/**/ - 132, -/**/ - 131, -/**/ - 130, -/**/ - 129, -/**/ - 128, -/**/ - 127, -/**/ - 126, -/**/ - 125, -/**/ - 124, -/**/ - 123, -/**/ - 122, -/**/ - 121, -/**/ - 120, -/**/ - 119, -/**/ - 118, -/**/ - 117, -/**/ - 116, -/**/ - 115, -/**/ - 114, -/**/ - 113, -/**/ - 112, -/**/ - 111, -/**/ - 110, -/**/ - 109, -/**/ - 108, -/**/ - 107, -/**/ - 106, -/**/ - 105, -/**/ - 104, -/**/ - 103, -/**/ - 102, -/**/ - 101, -/**/ - 100, -/**/ - 99, -/**/ - 98, -/**/ - 97, -/**/ - 96, -/**/ - 95, -/**/ - 94, -/**/ - 93, -/**/ - 92, -/**/ - 91, -/**/ - 90, -/**/ - 89, -/**/ - 88, -/**/ - 87, -/**/ - 86, -/**/ - 85, -/**/ - 84, -/**/ - 83, -/**/ - 82, -/**/ - 81, -/**/ - 80, -/**/ - 79, -/**/ - 78, -/**/ - 77, -/**/ - 76, -/**/ - 75, -/**/ - 74, -/**/ - 73, -/**/ - 72, -/**/ - 71, -/**/ - 70, -/**/ - 69, -/**/ - 68, -/**/ - 67, -/**/ - 66, -/**/ - 65, -/**/ - 64, -/**/ - 63, -/**/ - 62, -/**/ - 61, -/**/ - 60, -/**/ - 59, -/**/ - 58, -/**/ - 57, -/**/ - 56, -/**/ - 55, -/**/ - 54, -/**/ - 53, -/**/ - 52, -/**/ - 51, -/**/ - 50, -/**/ - 49, -/**/ - 48, -/**/ - 47, -/**/ - 46, -/**/ - 45, -/**/ - 44, -/**/ - 43, -/**/ - 42, -/**/ - 41, -/**/ - 40, -/**/ - 39, -/**/ - 38, -/**/ - 37, -/**/ - 36, -/**/ - 35, -/**/ - 34, -/**/ - 33, -/**/ - 32, -/**/ - 31, -/**/ - 30, -/**/ - 29, -/**/ - 28, -/**/ - 27, -/**/ - 26, -/**/ - 25, -/**/ - 24, -/**/ - 23, -/**/ - 22, -/**/ - 21, -/**/ - 20, -/**/ - 19, -/**/ - 18, -/**/ - 17, -/**/ - 16, -/**/ - 15, -/**/ - 14, -/**/ - 13, -/**/ - 12, -/**/ - 11, -/**/ - 10, -/**/ - 9, -/**/ - 8, -/**/ - 7, -/**/ 6, /**/ 5, @@ -1037,12 +751,12 @@ # ifdef FEAT_GUI_W32 # if defined(_MSC_VER) && (_MSC_VER <= 1010) /* Only MS VC 4.1 and earlier can do Win32s */ - MSG_PUTS(_("\nMS-Windows 16/32 bit GUI version")); + MSG_PUTS(_("\nMS-Windows 16/32-bit GUI version")); # else # ifdef _WIN64 - MSG_PUTS(_("\nMS-Windows 64 bit GUI version")); + MSG_PUTS(_("\nMS-Windows 64-bit GUI version")); # else - MSG_PUTS(_("\nMS-Windows 32 bit GUI version")); + MSG_PUTS(_("\nMS-Windows 32-bit GUI version")); # endif # endif if (gui_is_win32s()) @@ -1051,17 +765,21 @@ MSG_PUTS(_(" with OLE support")); # endif # else - MSG_PUTS(_("\nMS-Windows 32 bit console version")); +# ifdef _WIN64 + MSG_PUTS(_("\nMS-Windows 64-bit console version")); +# else + MSG_PUTS(_("\nMS-Windows 32-bit console version")); +# endif # endif #endif #ifdef WIN16 - MSG_PUTS(_("\nMS-Windows 16 bit version")); + MSG_PUTS(_("\nMS-Windows 16-bit version")); #endif #ifdef MSDOS # ifdef DJGPP - MSG_PUTS(_("\n32 bit MS-DOS version")); + MSG_PUTS(_("\n32-bit MS-DOS version")); # else - MSG_PUTS(_("\n16 bit MS-DOS version")); + MSG_PUTS(_("\n16-bit MS-DOS version")); # endif #endif #ifdef MACOS @@ -1080,7 +798,7 @@ MSG_PUTS(_("\nRISC OS version")); #endif #ifdef VMS - MSG_PUTS("\nOpenVMS version"); + MSG_PUTS(_("\nOpenVMS version")); # ifdef HAVE_PATHDEF if (*compiled_arch != NUL) { @@ -1485,9 +1203,9 @@ if (*mesg == ' ') { - vim_strncpy(modby, _("Modified by "), MODBY_LEN - 1); + vim_strncpy(modby, (char_u *)_("Modified by "), MODBY_LEN - 1); l = STRLEN(modby); - vim_strncpy(modby + l, MODIFIED_BY, MODBY_LEN - l - 1); + vim_strncpy(modby + l, (char_u *)MODIFIED_BY, MODBY_LEN - l - 1); mesg = modby; } #endif