changeset 840:2c885fab04e3 v7.0e06

updated for version 7.0e06
author vimboss
date Sat, 22 Apr 2006 22:33:57 +0000
parents 1f3b1021f002
children c2cae213194d
files runtime/autoload/rubycomplete.vim runtime/autoload/sqlcomplete.vim runtime/doc/motion.txt runtime/doc/pattern.txt runtime/doc/pi_tar.txt runtime/doc/pi_zip.txt runtime/doc/sql.txt runtime/doc/tags runtime/doc/todo.txt runtime/doc/various.txt runtime/doc/version7.txt runtime/indent/fortran.vim runtime/indent/python.vim runtime/syntax/doxygen.vim runtime/syntax/fortran.vim src/Make_mvc.mak src/diff.c src/edit.c src/eval.c src/ex_cmds.c src/ex_docmd.c src/ex_eval.c src/fold.c src/getchar.c src/gui_gtk.c src/gui_gtk_x11.c src/gui_w32.c src/hardcopy.c src/mbyte.c src/menu.c src/message.c src/misc1.c src/misc2.c src/netbeans.c src/normal.c src/ops.c src/option.c src/os_mswin.c src/os_unix.c src/os_win32.c src/proto/message.pro src/regexp.c src/spell.c src/syntax.c src/testdir/test61.in src/testdir/test61.ok src/version.h src/vim.h src/window.c
diffstat 49 files changed, 731 insertions(+), 367 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/autoload/rubycomplete.vim
+++ b/runtime/autoload/rubycomplete.vim
@@ -10,6 +10,7 @@
 " Ruby IRB/Complete author: Keiju ISHITSUKA(keiju@ishitsuka.com)
 " ----------------------------------------------------------------------------
 
+" {{{ requirement checks
 if !has('ruby')
     echohl ErrorMsg
     echo "Error: Required vim compiled with +ruby"
@@ -23,8 +24,17 @@ if version < 700
     echohl None
     finish
 endif
+" }}} requirement checks
 
+if !exists("g:rubycomplete_rails")
+    let g:rubycomplete_rails = 0
+endif
 
+if !exists("g:rubycomplete_classes_in_global")
+    let g:rubycomplete_classes_in_global = 0
+endif
+
+" {{{ vim-side support functions
 function! GetBufferRubyModule(name)
     let [snum,enum] = GetBufferRubyEntity(a:name, "module")
     return snum . '..' . enum
@@ -103,6 +113,8 @@ function! GetRubyVarType(v)
     return ''
 endfunction
 
+"}}} vim-side support functions
+
 function! rubycomplete#Complete(findstart, base)
      "findstart = 1 when we need to get the text length
     if a:findstart
@@ -133,6 +145,7 @@ endfunction
 
 function! s:DefRuby()
 ruby << RUBYEOF
+# {{{ ruby completion
 RailsWords = [
       "has_many", "has_one",
       "belongs_to",
@@ -164,11 +177,11 @@ Operators = [ "%", "&", "*", "**", "+", 
 
 
 def load_requires
-  @buf = VIM::Buffer.current
-  enum = @buf.line_number
+  buf = VIM::Buffer.current
+  enum = buf.line_number
   nums = Range.new( 1, enum )
   nums.each do |x|
-    ln = @buf[x]
+    ln = buf[x]
     begin
       eval( "require %s" % $1 ) if /.*require\s*(.*)$/.match( ln )
     rescue Exception
@@ -198,7 +211,7 @@ def load_buffer_module(name)
 end
 
 def get_buffer_entity(name, vimfun)
-  @buf = VIM::Buffer.current
+  buf = VIM::Buffer.current
   nums = eval( VIM::evaluate( vimfun % name ) )
   return nil if nums == nil 
   return nil if nums.min == nums.max && nums.min == 0
@@ -207,7 +220,7 @@ def get_buffer_entity(name, vimfun)
   classdef = ""
   nums.each do |x|
     if x != cur_line
-      ln = @buf[x] 
+      ln = buf[x] 
       classdef += "%s\n" % ln
     end
   end
@@ -215,6 +228,25 @@ def get_buffer_entity(name, vimfun)
   return classdef
 end
 
+def get_buffer_classes()
+  # this will be a little expensive.
+  allow_aggressive_load = VIM::evaluate('g:rubycomplete_classes_in_global')
+  return [] if allow_aggressive_load != '1'
+
+  buf = VIM::Buffer.current
+  eob = buf.length
+  ret = []
+  rg = 1..eob
+
+  rg.each do |x|
+    if /^\s*class\s*([A-Za-z0-9_-]*)(\s*<\s*([A-Za-z0-9_:-]*))?\s*/.match( buf[x] )
+      ret.push $1  
+    end
+  end
+
+  return ret
+end
+
 def load_rails()
   allow_rails = VIM::evaluate('g:rubycomplete_rails')
   return if allow_rails != '1'
@@ -233,13 +265,19 @@ def load_rails()
         break
     end
   end
+  
+  return if pok == nil
   bootfile = pok + "/boot.rb"
-  require bootfile if pok != nil && File.exists?( bootfile )
+  if File.exists?( bootfile )
+    require bootfile 
+    VIM::evaluate('let g:rubycomplete_rails_loaded = 1') 
+  end
 end
 
 def get_rails_helpers
   allow_rails = VIM::evaluate('g:rubycomplete_rails')
-  return [] if allow_rails != '1'
+  rails_loaded = VIM::evaluate('g:rubycomplete_rails_loaded')
+  return [] if allow_rails != '1' || rails_loaded != '1'
   return RailsWords 
 end
 
@@ -404,14 +442,21 @@ def get_completions(base)
         receiver = $1
         message = input
         load_buffer_class( receiver )
-        candidates = eval( "#{receiver}.instance_methods" )
-        candidates += get_rails_helpers
-        select_message(receiver, message, candidates)
+        begin
+          candidates = eval( "#{receiver}.instance_methods" )
+          candidates += get_rails_helpers
+          select_message(receiver, message, candidates)
+        rescue Exception
+          found = nil
+        end
       end
     end
     
     if inclass == nil || found == nil
       candidates = eval("self.class.constants")
+      candidates += get_buffer_classes
+      candidates.uniq!
+      candidates.sort!
       (candidates|ReservedWords).grep(/^#{Regexp.quote(input)}/)
     end
   end
@@ -459,10 +504,12 @@ def select_message(receiver, message, ca
   candidates.uniq!
   candidates.sort!
 end
+
+# }}} ruby completion
 RUBYEOF
 endfunction
 
+let g:rubycomplete_rails_loaded = 0
 
-let g:rubycomplete_rails = 0
 call s:DefRuby()
-" vim: set et ts=4:
+" vim:tw=78:sw=4:ts=8:ft=vim:norl:
--- a/runtime/autoload/sqlcomplete.vim
+++ b/runtime/autoload/sqlcomplete.vim
@@ -1,8 +1,8 @@
 " Vim completion script
 " Language:    SQL
 " Maintainer:  David Fishburn <fishburn@ianywhere.com>
-" Version:     2.0
-" Last Change: Mon Apr 03 2006 10:21:36 PM
+" Version:     3.0
+" Last Change: Thu Apr 20 2006 8:47:12 PM
 
 " Set completion with CTRL-X CTRL-O to autoloaded function.
 " This check is in place in case this script is
@@ -18,7 +18,7 @@ endif
 if exists('g:loaded_sql_completion')
     finish 
 endif
-let g:loaded_sql_completion = 1
+let g:loaded_sql_completion = 30
 
 " Maintains filename of dictionary
 let s:sql_file_table        = ""
@@ -60,6 +60,24 @@ if !exists('g:omni_sql_precache_syntax_g
                 \ 'sqlStatement'
                 \ ]
 endif
+" Set ignorecase to the ftplugin standard
+if !exists('g:omni_sql_ignorecase')
+    let g:omni_sql_ignorecase = &ignorecase
+endif
+" During table completion, should the table list also
+" include the owner name
+if !exists('g:omni_sql_include_owner')
+    let g:omni_sql_include_owner = 0
+    if exists('g:loaded_dbext')
+        if g:loaded_dbext >= 300
+            " New to dbext 3.00, by default the table lists include the owner
+            " name of the table.  This is used when determining how much of
+            " whatever has been typed should be replaced as part of the 
+            " code replacement.
+            let g:omni_sql_include_owner = 1
+        endif
+    endif
+endif
 
 " This function is used for the 'omnifunc' option.
 function! sqlcomplete#Complete(findstart, base)
@@ -81,15 +99,27 @@ function! sqlcomplete#Complete(findstart
         while start > 0
             if line[start - 1] =~ '\w'
                 let start -= 1
-            elseif line[start - 1] =~ '\.' && compl_type =~ 'column'
-                " If the completion type is column then assume we are looking
-                " for column completion column_type can be either 
-                " 'column' or 'column_csv'
-                if lastword == -1 && compl_type == 'column'
-                    " Do not replace the table name prefix or alias
-                    " if completing only a single column name
+            elseif line[start - 1] =~ '\.' && 
+                        \ compl_type =~ 'column\|table\|view\|procedure'
+                " If lastword has already been set for column completion
+                " break from the loop, since we do not also want to pickup
+                " a table name if it was also supplied.
+                if lastword != -1 && compl_type =~ 'column'
+                    break
+                endif
+                " Assume we are looking for column completion
+                " column_type can be either 'column' or 'column_csv'
+                if lastword == -1 && compl_type =~ 'column'
                     let lastword = start
                 endif
+                " If omni_sql_include_owner = 0, do not include the table
+                " name as part of the substitution, so break here
+                if lastword == -1 && 
+                            \ compl_type =~ 'table\|view\|procedure' && 
+                            \ g:omni_sql_include_owner == 0
+                    let lastword = start
+                    break
+                endif
                 let start -= 1
             else
                 break
@@ -144,6 +174,14 @@ function! sqlcomplete#Complete(findstart
         if s:sql_file_{compl_type} != ""
             if filereadable(s:sql_file_{compl_type})
                 let compl_list = readfile(s:sql_file_{compl_type})
+                " let dic_list = readfile(s:sql_file_{compl_type})
+                " if !empty(dic_list)
+                "     for elem in dic_list
+                "         let kind = (compl_type=='table'?'m':(compl_type=='procedure'?'f':'v'))
+                "         let item = {'word':elem, 'menu':elem, 'kind':kind, 'info':compl_type}
+                "         let compl_list += [item]
+                "     endfor
+                " endif
             endif
         endif
     elseif compl_type == 'column'
@@ -203,8 +241,8 @@ function! sqlcomplete#Complete(findstart
     if base != ''
         " Filter the list based on the first few characters the user
         " entered
-        let expr = 'v:val =~ "^'.base.'"'
-        let compl_list = filter(copy(compl_list), expr)
+        let expr = 'v:val '.(g:omni_sql_ignorecase==1?'=~?':'=~#').' "^'.base.'"'
+        let compl_list = filter(deepcopy(compl_list), expr)
     endif
 
     if exists('b:sql_compl_savefunc') && b:sql_compl_savefunc != ""
@@ -297,8 +335,8 @@ function! s:SQLCCheck4dbext()
         " Leave time for the user to read the error message
         :sleep 2
         return -1
-    elseif g:loaded_dbext < 210
-        let msg = "The dbext plugin must be at least version 2.10 " .
+    elseif g:loaded_dbext < 300
+        let msg = "The dbext plugin must be at least version 3.00 " .
                     \ " for dynamic SQL completion"
         call s:SQLCErrorMsg(msg)
         " Leave time for the user to read the error message
@@ -363,7 +401,7 @@ function! s:SQLCGetColumns(table_name, l
     let table_alias  = ''
     let move_to_top  = 1
 
-    if g:loaded_dbext >= 210
+    if g:loaded_dbext >= 300
         let saveSettingAlias = DB_listOption('use_tbl_alias')
         exec 'DBSetOption use_tbl_alias=n'
     endif
@@ -479,7 +517,7 @@ function! s:SQLCGetColumns(table_name, l
          call cursor(curline, curcol)
          
          if found == 0
-             if g:loaded_dbext > 201
+             if g:loaded_dbext > 300
                  exec 'DBSetOption use_tbl_alias='.saveSettingAlias
              endif
 
@@ -502,7 +540,7 @@ function! s:SQLCGetColumns(table_name, l
 
     endif
 
-    if g:loaded_dbext > 201
+    if g:loaded_dbext > 300
         exec 'DBSetOption use_tbl_alias='.saveSettingAlias
     endif
 
--- a/runtime/doc/motion.txt
+++ b/runtime/doc/motion.txt
@@ -1,4 +1,4 @@
-*motion.txt*    For Vim version 7.0e.  Last change: 2006 Apr 18
+*motion.txt*    For Vim version 7.0e.  Last change: 2006 Apr 22
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -769,6 +769,7 @@ g'{mark}  g`{mark}
 						*:marks*
 :marks			List all the current marks (not a motion command).
 			The |'(|, |')|, |'{| and |'}| marks are not listed.
+			The first column is number zero.
 			{not in Vi}
 						*E283*
 :marks {arg}		List the marks that are mentioned in {arg} (not a
--- a/runtime/doc/pattern.txt
+++ b/runtime/doc/pattern.txt
@@ -1,4 +1,4 @@
-*pattern.txt*   For Vim version 7.0e.  Last change: 2006 Apr 02
+*pattern.txt*   For Vim version 7.0e.  Last change: 2006 Apr 22
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -342,6 +342,50 @@ 5. An atom can be one of a long list of 
 
 
 ==============================================================================
+3. Magic							*/magic*
+
+Some characters in the pattern are taken literally.  They match with the same
+character in the text.  When preceded with a backslash however, these
+characters get a special meaning.
+
+Other characters have a special meaning without a backslash.  They need to be
+preceded with a backslash to match literally.
+
+If a character is taken literally or not depends on the 'magic' option and the
+items mentioned next.
+							*/\m* */\M*
+Use of "\m" makes the pattern after it be interpreted as if 'magic' is set,
+ignoring the actual value of the 'magic' option.
+Use of "\M" makes the pattern after it be interpreted as if 'nomagic' is used.
+							*/\v* */\V*
+Use of "\v" means that in the pattern after it all ASCII characters except
+'0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning.  "very magic"
+
+Use of "\V" means that in the pattern after it only the backslash has a
+special meaning.  "very nomagic"
+
+Examples:
+after:	  \v	   \m	    \M	     \V		matches ~
+		'magic' 'nomagic'
+	  $	   $	    $	     \$		matches end-of-line
+	  .	   .	    \.	     \.		matches any character
+	  *	   *	    \*	     \*		any number of the previous atom
+	  ()	   \(\)     \(\)     \(\)	grouping into an atom
+	  |	   \|	    \|	     \|		separating alternatives
+	  \a	   \a	    \a	     \a		alphabetic character
+	  \\	   \\	    \\	     \\		literal backslash
+	  \.	   \.	    .	     .		literal dot
+	  \{	   {	    {	     {		literal '{'
+	  a	   a	    a	     a		literal 'a'
+
+{only Vim supports \m, \M, \v and \V}
+
+It is recommended to always keep the 'magic' option at the default setting,
+which is 'magic'.  This avoids portability problems.  To make a pattern immune
+to the 'magic' option being set or not, put "\m" or "\M" at the start of the
+pattern.
+
+==============================================================================
 4. Overview of pattern items				*pattern-overview*
 
 Overview of multi items.				*/multi* *E61* *E62*
@@ -486,51 +530,6 @@ cat\Z			Both "cat" and "càt" ("a" followed by 0x0300)
 
 
 ==============================================================================
-3. Magic							*/magic*
-
-Some characters in the pattern are taken literally.  They match with the same
-character in the text.  When preceded with a backslash however, these
-characters get a special meaning.
-
-Other characters have a special meaning without a backslash.  They need to be
-preceded with a backslash to match literally.
-
-If a character is taken literally or not depends on the 'magic' option and the
-items mentioned next.
-							*/\m* */\M*
-Use of "\m" makes the pattern after it be interpreted as if 'magic' is set,
-ignoring the actual value of the 'magic' option.
-Use of "\M" makes the pattern after it be interpreted as if 'nomagic' is used.
-							*/\v* */\V*
-Use of "\v" means that in the pattern after it all ASCII characters except
-'0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning.  "very magic"
-
-Use of "\V" means that in the pattern after it only the backslash has a
-special meaning.  "very nomagic"
-
-Examples:
-after:	  \v	   \m	    \M	     \V		matches ~
-		'magic' 'nomagic'
-	  $	   $	    $	     \$		matches end-of-line
-	  .	   .	    \.	     \.		matches any character
-	  *	   *	    \*	     \*		any number of the previous atom
-	  ()	   \(\)     \(\)     \(\)	grouping into an atom
-	  |	   \|	    \|	     \|		separating alternatives
-	  \a	   \a	    \a	     \a		alphabetic character
-	  \\	   \\	    \\	     \\		literal backslash
-	  \.	   \.	    .	     .		literal dot
-	  \{	   {	    {	     {		literal '{'
-	  a	   a	    a	     a		literal 'a'
-
-{only Vim supports \m, \M, \v and \V}
-
-It is recommended to always keep the 'magic' option at the default setting,
-which is 'magic'.  This avoids portability problems.  To make a pattern immune
-to the 'magic' option being set or not, put "\m" or "\M" at the start of the
-pattern.
-
-
-==============================================================================
 5. Multi items						*pattern-multi-items*
 
 An atom can be followed by an indication of how many times the atom can be
--- a/runtime/doc/pi_tar.txt
+++ b/runtime/doc/pi_tar.txt
@@ -1,4 +1,4 @@
-*tar.txt*	For Vim version 7.0e.  Last change: 2006 Mar 24
+*pi_tar.txt*	For Vim version 7.0e.  Last change: 2006 Apr 22
 
        	       	       +====================+
        	       	       | Tar File Interface |
--- a/runtime/doc/pi_zip.txt
+++ b/runtime/doc/pi_zip.txt
@@ -1,4 +1,4 @@
-*zip.txt*	For Vim version 7.0e.  Last change: 2006 Apr 10
+*pi_zip.txt*	For Vim version 7.0e.  Last change: 2006 Apr 22
 
 				+====================+
 				| Zip File Interface |
--- a/runtime/doc/sql.txt
+++ b/runtime/doc/sql.txt
@@ -1,4 +1,4 @@
-*sql.txt*   	For Vim version 7.0e.  Last change: Mon Apr 03 2006 10:34:00 PM
+*sql.txt*   	For Vim version 7.0e.  Last change: Fri Apr 21 2006 10:39:11 PM
 
 by David Fishburn
 
@@ -82,7 +82,7 @@ The following keywords are supported: >
 
     create[ or replace] procedure|function|event
     returns
-<
+ 
 
 1.2 Text Object Motions		        	*sql-object-motions*
 -----------------------
@@ -96,7 +96,7 @@ file): >
     [[              move backwards to the previous 'begin'
     ][              move forward to the next 'end'
     []              move backwards to the previous 'end'
-<
+ 
 
 1.3 Predefined Object Motions                   *sql-predefined-objects*
 -----------------------------
@@ -111,7 +111,7 @@ flexible as possible, you can override t
     let g:ftplugin_sql_objects = 'function,procedure,event,table,trigger' .
                 \ ',schema,service,publication,database,datatype,domain' .
                 \ ',index,subscription,synchronization,view,variable'
-<                
+                 
 The following |Normal| mode and |Visual| mode maps have been created which use
 the above list: >
     ]}              move forward to the next 'create <object name>'
@@ -128,14 +128,14 @@ Repeatedly pressing ]} will cycle throug
     end;
 
     create index i1 on t1 (c1);
-<
+ 
 The default setting for g:ftplugin_sql_objects is: >
     let g:ftplugin_sql_objects = 'function,procedure,event,' .
                 \ '\\(existing\\\\|global\\s\\+temporary\\s\\+\\)\\\{,1}' .
                 \ 'table,trigger' .
                 \ ',schema,service,publication,database,datatype,domain' .
                 \ ',index,subscription,synchronization,view,variable'
-<
+ 
 The above will also handle these cases: >
     create table t1 (
         ...
@@ -146,7 +146,7 @@ The above will also handle these cases: 
     create global temporary table t3 (
         ...
     );
-<
+ 
 By default, the ftplugin only searches for CREATE statements.  You can also
 override this via your |vimrc| with the following: >
     let g:ftplugin_sql_statements = 'create,alter'
@@ -157,7 +157,7 @@ The filetype plugin defines three types 
     3.  /*
          *
          */
-<         
+          
 The following |Normal| mode and |Visual| mode maps have been created to work
 with comments: >
     ]"              move forward to the beginning of a comment
@@ -170,7 +170,7 @@ 1.4 Macros                              
 Vim's feature to find macro definitions, |'define'|, is supported using this
 regular expression: >
     \c\<\(VARIABLE\|DECLARE\|IN\|OUT\|INOUT\)\>
-<
+ 
 This addresses the following code: >
     CREATE VARIABLE myVar1 INTEGER;
 
@@ -187,11 +187,11 @@ This addresses the following code: >
           FROM T1
          WHERE c4 = myVar1;
     END;
-<
+ 
 Place your cursor on "myVar1" on this line: >
          WHERE c4 = myVar1;
                      ^
-<
+ 
 Press any of the following keys: >
     [d
     [D
@@ -235,7 +235,7 @@ For the people that work with many diffe
 able to flip between the various vendors rules (indent, syntax) on a per
 buffer basis, at any time.  The ftplugin/sql.vim file defines this function: >
     SQLSetType
-<
+ 
 Executing this function without any parameters will set the indent and syntax
 scripts back to their defaults, see |sql-type-default|.  If you have turned
 off Vi's compatibility mode, |'compatible'|, you can use the <Tab> key to
@@ -252,12 +252,12 @@ examples: >
     :SQLSetType sqlanywhere
     :SQLSetType sqlinformix
     :SQLSetType mysql
-<
+ 
 The easiest approach is to the use <Tab> character which will first complete
 the command name (SQLSetType), after a space and another <Tab>, display a list
 of available Vim script names: >
     :SQL<Tab><space><Tab>
-<
+ 
 
 2.2 SQL Dialect Default		        	*sql-type-default*
 -----------------------
@@ -267,10 +267,10 @@ your |vimrc|: >
     let g:sql_type_default = 'sqlanywhere'
     let g:sql_type_default = 'sqlinformix'
     let g:sql_type_default = 'mysql'
-<
+ 
 If you added the following to your |vimrc|: >
     let g:sql_type_default = 'sqlinformix'
-<
+ 
 The next time edit a SQL file the following scripts will be automatically 
 loaded by Vim: >
     ftplugin/sql.vim
@@ -299,7 +299,7 @@ can create any of the following: >
     Windows
         $VIM/vimfiles/syntax/sqlite.vim
         $VIM/vimfiles/indent/sqlite.vim
-<
+ 
 No changes are necessary to the SQLSetType function.  It will automatically
 pickup the new SQL files and load them when you issue the SQLSetType command. 
 
@@ -330,11 +330,11 @@ The defaults static maps are: >
     imap <buffer> <C-C>o <C-\><C-O>:call sqlcomplete#Map('sqlOption')<CR><C-X><C-O>
     imap <buffer> <C-C>T <C-\><C-O>:call sqlcomplete#Map('sqlType')<CR><C-X><C-O>
     imap <buffer> <C-C>s <C-\><C-O>:call sqlcomplete#Map('sqlStatement')<CR><C-X><C-O>
-< 
+  
 The static maps (which are based on the syntax highlight groups) follow this
 format: >
     imap <buffer> <C-C>k <C-\><C-O>:call sqlcomplete#Map('sqlKeyword')<CR><C-X><C-O>
-<
+ 
 This command breaks down as: >
     imap                   - Create an insert map
     <buffer>               - Only for this buffer
@@ -362,7 +362,7 @@ This command breaks down as: >
                              plugin will also cache this result until Vim is
                              restarted.  The syntax list is retrieved using
                              the syntaxcomplete plugin.
-<
+ 
 Using the 'syntax' keyword is a special case.  This instructs the
 syntaxcomplete plugin to retrieve all syntax items.  So this will effectively
 work for any of Vim's SQL syntax files.  At the time of writing this includes
@@ -382,7 +382,7 @@ Here are some examples of the entries wh
          - Isolation_level, On_error, Qualify_owners, Fire_triggers, ...
      Types
          - Integer, Char, Varchar, Date, DateTime, Timestamp, ...
-<
+ 
  
 4.2 Dynamic Mode  		                *sql-completion-dynamic*
 ----------------
@@ -402,7 +402,7 @@ to display a list of tables, procedures,
          - All stored procedures for all schema owners
      Column List
          - For the selected table, the columns that are part of the table
-<
+ 
 To enable the popup, while in INSERT mode, use the following key combinations
 for each group (where <C-C> means hold the CTRL key down while pressing 
 the space bar):
@@ -425,7 +425,7 @@ the popup window.  This makes the re-dis
 fast.  If new tables or columns are added to the database it may become 
 necessary to clear the plugins cache.  The default map for this is: >
     imap <buffer> <C-C>R <C-\><C-O>:call sqlcomplete#Map('ResetCache')<CR><C-X><C-O>
-<
+ 
  
 4.3 SQL Tutorial				*sql-completion-tutorial*
 ----------------
@@ -436,10 +436,10 @@ completion plugin so that: >
      b) You are introduced to some of the more common features
      c) Show how to customize it to your preferences
      d) Demonstrate "Best of Use" of the plugin (easiest way to configure).
-<
+ 
 First, create a new buffer: >
      :e tutorial.sql
-<
+ 
 
 Static features
 ---------------
@@ -461,7 +461,7 @@ depending on the syntax file you are usi
 (sqlanywhere.vim) has support for this: >
      BEGIN
         DECLARE customer_id <C-C>T <-- Choose a type from the list
-< 
+  
 
 Dynamic features
 ----------------
@@ -484,7 +484,7 @@ list.  After the list is displayed press
 popup window and the table name already chosen when the list became active. >
  
  4.3.1 Table Completion:			*sql-completion-tables*
-<
+ 
 Press <C-C>t to display a list of tables from within the database you
 have connected via the dbext plugin.  
 NOTE: All of the SQL completion popups support typing a prefix before pressing
@@ -492,7 +492,7 @@ the key map.  This will limit the conten
 beginning with those characters.  >
  
  4.3.2 Column Completion:			*sql-completion-columns*
-<
+ 
 The SQL completion plugin can also display a list of columns for particular
 tables.  The column completion is trigger via <C-C>c.
 
@@ -503,7 +503,7 @@ together.  If you wish to enable this fu
 a key and create this mapping (see |sql-completion-maps| for further 
 details on where to create this imap): >
     imap <buffer> <your_keystroke> <CR><C-\><C-O>:call sqlcomplete#Map('column')<CR><C-X><C-O>
-<
+ 
 Example of using column completion:
      - Press <C-C>t again to display the list of tables.  
      - When the list is displayed in the completion window, press <C-Right>,
@@ -561,7 +561,7 @@ following statement: >
             employee e,
             site_options so
       where c.
-<
+ 
 In INSERT mode after typing the final "c." which is an alias for the
 "customer" table, you can press either <C-C>c or <C-X><C-O>.  This will
 popup a list of columns for the customer table.  It does this by looking back
@@ -572,12 +572,12 @@ keyword is also supported, "customer AS 
  
  
  4.3.3 Procedure Completion:			*sql-completion-procedures*
-<
+ 
 Similar to the table list, <C-C>p, will display a list of stored
 procedures stored within the database. >
  
  4.3.4 View Completion:				*sql-completion-views*
-<
+ 
 Similar to the table list, <C-C>v, will display a list of views in the
 database.
 
@@ -615,7 +615,32 @@ your |vimrc|: >
                    use mixed case then the first letter of the table is used: >
                    mytablename --> m
                    MYTABLENAME --> M
-<
+ 
+    omni_sql_ignorecase
+<       - Default: Current setting for|ignorecase|
+        - Valid settings are 0 or 1.  
+        - When entering a few letters before initiating completion, the list
+          will be filtered to display only the entries which begin with the
+          list of characters.  When this option is set to 0, the list will be
+          filtered using case sensitivity. >
+ 
+    omni_sql_include_owner
+<       - Default: 0, unless dbext.vim 3.00 has been installed
+        - Valid settings are 0 or 1.  
+        - When completing tables, procedure or views and using dbext.vim 3.00 
+          or higher the list of objects will also include the owner name.
+          When completing these objects and omni_sql_include_owner is enabled
+          the owner name will be be replaced. >
+ 
+    omni_sql_precache_syntax_groups
+<       - Default: 
+          ['syntax','sqlKeyword','sqlFunction','sqlOption','sqlType','sqlStatement']
+        - sqlcomplete can be used in conjunction with other completion
+          plugins.  This is outlined at |sql-completion-filetypes|.  When the 
+          filetype is changed temporarily to SQL, the sqlcompletion plugin
+          will cache the syntax groups listed in the List specified in this
+          option.
+>
  
 4.5 SQL Maps	        			*sql-completion-maps*
 ------------
@@ -642,7 +667,8 @@ highlighting rules. >
 
 Dynamic Maps
 ------------
-These are maps which use populate the completion list using the dbext.vim plugin. >
+These are maps which use populate the completion list using the dbext.vim
+plugin. >
     <C-C>t  
 <       - Displays a list of tables. >
     <C-C>p
@@ -683,7 +709,7 @@ If you do not wish the default maps crea
 your platform (often a case on *nix) you define the following variable in
 your |vimrc|: >
     let g:omni_sql_no_default_maps = 1
-< 
+  
 Do no edit ftplugin/sql.vim directly!  If you change this file your changes
 will be over written on future updates.  Vim has a special directory structure
 which allows you to make customizations without changing the files that are
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -259,6 +259,7 @@
 'grepformat'	options.txt	/*'grepformat'*
 'grepprg'	options.txt	/*'grepprg'*
 'gtl'	options.txt	/*'gtl'*
+'gtt'	options.txt	/*'gtt'*
 'guicursor'	options.txt	/*'guicursor'*
 'guifont'	options.txt	/*'guifont'*
 'guifontset'	options.txt	/*'guifontset'*
@@ -267,6 +268,7 @@
 'guioptions'	options.txt	/*'guioptions'*
 'guipty'	options.txt	/*'guipty'*
 'guitablabel'	options.txt	/*'guitablabel'*
+'guitabtooltip'	options.txt	/*'guitabtooltip'*
 'hardtabs'	vi_diff.txt	/*'hardtabs'*
 'helpfile'	options.txt	/*'helpfile'*
 'helpheight'	options.txt	/*'helpheight'*
@@ -3198,6 +3200,7 @@ CTRL-W_bar	windows.txt	/*CTRL-W_bar*
 CTRL-W_c	windows.txt	/*CTRL-W_c*
 CTRL-W_d	tagsrch.txt	/*CTRL-W_d*
 CTRL-W_f	windows.txt	/*CTRL-W_f*
+CTRL-W_gF	windows.txt	/*CTRL-W_gF*
 CTRL-W_g]	windows.txt	/*CTRL-W_g]*
 CTRL-W_g_CTRL-]	windows.txt	/*CTRL-W_g_CTRL-]*
 CTRL-W_gf	windows.txt	/*CTRL-W_gf*
@@ -4006,6 +4009,8 @@ E787	diff.txt	/*E787*
 E788	autocmd.txt	/*E788*
 E789	syntax.txt	/*E789*
 E79	message.txt	/*E79*
+E790	undo.txt	/*E790*
+E791	mbyte.txt	/*E791*
 E80	message.txt	/*E80*
 E800	arabic.txt	/*E800*
 E81	map.txt	/*E81*
@@ -6298,6 +6303,7 @@ netrw-settings	pi_netrw.txt	/*netrw-sett
 netrw-sexplore	pi_netrw.txt	/*netrw-sexplore*
 netrw-sort	pi_netrw.txt	/*netrw-sort*
 netrw-sortsequence	pi_netrw.txt	/*netrw-sortsequence*
+netrw-starpat	pi_netrw.txt	/*netrw-starpat*
 netrw-starstar	pi_netrw.txt	/*netrw-starstar*
 netrw-start	pi_netrw.txt	/*netrw-start*
 netrw-transparent	pi_netrw.txt	/*netrw-transparent*
@@ -6504,6 +6510,8 @@ pi_gzip.txt	pi_gzip.txt	/*pi_gzip.txt*
 pi_netrw.txt	pi_netrw.txt	/*pi_netrw.txt*
 pi_paren.txt	pi_paren.txt	/*pi_paren.txt*
 pi_spec.txt	pi_spec.txt	/*pi_spec.txt*
+pi_tar.txt	pi_tar.txt	/*pi_tar.txt*
+pi_zip.txt	pi_zip.txt	/*pi_zip.txt*
 plaintex.vim	syntax.txt	/*plaintex.vim*
 plsql	sql.txt	/*plsql*
 plugin	usr_05.txt	/*plugin*
@@ -7246,7 +7254,6 @@ tar-history	pi_tar.txt	/*tar-history*
 tar-manual	pi_tar.txt	/*tar-manual*
 tar-options	pi_tar.txt	/*tar-options*
 tar-usage	pi_tar.txt	/*tar-usage*
-tar.txt	pi_tar.txt	/*tar.txt*
 tcl	if_tcl.txt	/*tcl*
 tcl-beep	if_tcl.txt	/*tcl-beep*
 tcl-buffer	if_tcl.txt	/*tcl-buffer*
@@ -7858,7 +7865,6 @@ zip-copyright	pi_zip.txt	/*zip-copyright
 zip-history	pi_zip.txt	/*zip-history*
 zip-manual	pi_zip.txt	/*zip-manual*
 zip-usage	pi_zip.txt	/*zip-usage*
-zip.txt	pi_zip.txt	/*zip.txt*
 zj	fold.txt	/*zj*
 zk	fold.txt	/*zk*
 zl	scroll.txt	/*zl*
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt*      For Vim version 7.0e.  Last change: 2006 Apr 21
+*todo.txt*      For Vim version 7.0e.  Last change: 2006 Apr 22
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -30,16 +30,11 @@ be worked on, but only if you sponsor Vi
 							*known-bugs*
 -------------------- Known bugs and current work -----------------------
 
-Win32: Crash when adding many menu entries. (Karl Waedt)
-
 Crash in "z=" when the change triggers checking out the file, FileChangedRO
 event.  Problem in move_lines()?  FileChangedShell also involved? (Neil Bird)
 Added a few checks for valid buffer, did that help?
 
-Fix coverity false positives?
-
 Add more tests for all new functionality in Vim 7.  Especially new functions.
-    :undojoin
 
 Win32: Describe how to do debugging. (George Reilly)
 
@@ -209,6 +204,10 @@ 9   Crash with X command server over ssh
 8   GTK 2: Combining UTF-8 characters not displayed properly in menus (Mikolaj
     Machowski)  They are displayed as separate characters.  Problem in
     creating a label?
+8   GTK2: selecting button in confirm dialog with keys and hitting Enter
+    doesn't select that button. (Steve Hall)
+    It's possible to set the default button but it's not clear how to obtain
+    the currently selected (highlighted) button.
 8   GTK 2: Combining UTF-8 characters are sometimes not drawn properly.
     Depends on the font size, "monospace 13" has the problem.  Vim seems to do
     everything right, must be a GTK bug.  Is there a way to work around it?
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -1,4 +1,4 @@
-*various.txt*   For Vim version 7.0e.  Last change: 2006 Mar 25
+*various.txt*   For Vim version 7.0e.  Last change: 2006 Apr 22
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -819,7 +819,7 @@ Hints for translators:
   languages in the specified directory.
 
 ==============================================================================
-4. Using Vim like less or more					*less*
+3. Using Vim like less or more					*less*
 
 If you use the less or more program to view a file, you don't get syntax
 highlighting.  Thus you would like to use Vim instead.  You can do this by
--- a/runtime/doc/version7.txt
+++ b/runtime/doc/version7.txt
@@ -1,4 +1,4 @@
-*version7.txt*  For Vim version 7.0e.  Last change: 2006 Apr 21
+*version7.txt*  For Vim version 7.0e.  Last change: 2006 Apr 22
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -2572,7 +2572,7 @@ Completion could hang when 'lines' is 6 
 
 Added CTRL-W gF: open file under cursor in new tab page and jump to the line
 number following the file name.
-Added 'guitabtooltip', but it's not implemented anywhere yet.
+Added 'guitabtooltip'.  Implemented for Win32 (Yegappan Lakshmanan).
 
 Added "throw" to 'debug' option: thow an exception for error messages even
 whey they would otherwise be ignored.
@@ -2582,5 +2582,17 @@ mapping found" warning instead of a prop
 
 Motif: default to using XpmAttributes instead of XpmAttributes_21.
 
+A few more changes for 64 bit MS-Windows. (George Reilly)
+
+Got ml_get errors when doing "o" and selecting in other window where there are
+less line shorter than the cursor position in the other window.  ins_mouse()
+was using position in wrong window.
+
+Win32 GUI: Crash when giving a lot of messages during startup.  Allocate twice
+as much memory for the dialog template.
+
+Fixed a few leaks and wrong pointer use reported by coverity.
+
+When showing menus the mode character was sometimes wrong.
 
  vim:tw=78:ts=8:ft=help:norl:
--- a/runtime/indent/fortran.vim
+++ b/runtime/indent/fortran.vim
@@ -1,8 +1,8 @@
 " Vim indent file
 " Language:	Fortran95 (and Fortran90, Fortran77, F and elf90)
-" Version:	0.36
+" Version:	0.37
 " URL:		http://www.unb.ca/chem/ajit/indent/fortran.vim
-" Last Change:	2006 Apr. 02
+" Last Change:	2006 Apr. 22
 " Maintainer:	Ajit J. Thakkar <ajit@unb.ca>; <http://www.unb.ca/chem/ajit/>
 " Usage:	Do :help fortran-indent from Vim
 
@@ -14,6 +14,7 @@ let b:did_indent = 1
 
 setlocal indentkeys+==~end,=~case,=~if,=~else,=~do,=~where,=~elsewhere,=~select
 setlocal indentkeys+==~endif,=~enddo,=~endwhere,=~endselect
+setlocal indentkeys+==~type,=~interface
 
 " Determine whether this is a fixed or free format source file
 " if this hasn't been done yet
@@ -81,20 +82,25 @@ function FortranGetIndent(lnum)
   endif
 
   "Add a shiftwidth to statements following if, else, case,
-  "where and elsewhere statements
+  "where, elsewhere, type and interface statements
   if prevstat =~? '^\s*\(\d\+\s\)\=\s*\(else\|case\|where\|elsewhere\)\>'
+	\ ||prevstat =~? '^\s*\(\d\+\s\)\=\s*\(type\|interface\)\>'
 	\ || prevstat =~? '^\s*\(\d\+\s\)\=\s*\(\a\w*\s*:\)\=\s*if\>'
      let ind = ind + &sw
     " Remove unwanted indent after logical and arithmetic ifs
     if prevstat =~? '\<if\>' && prevstat !~? '\<then\>'
       let ind = ind - &sw
     endif
+    " Remove unwanted indent after type( statements
+    if prevstat =~? '\<type\s*('
+      let ind = ind - &sw
+    endif
   endif
 
   "Subtract a shiftwidth from else, elsewhere, case, end if,
-  " end where and end select statements
+  " end where, end select, end interface and end type statements
   if getline(v:lnum) =~? '^\s*\(\d\+\s\)\=\s*'
-	\. '\(else\|elsewhere\|case\|end\s*\(if\|where\|select\)\)\>'
+	\. '\(else\|elsewhere\|case\|end\s*\(if\|where\|select\|interface\|type\)\)\>'
     let ind = ind - &sw
     " Fix indent for case statement immediately after select
     if prevstat =~? '\<select\>'
--- a/runtime/indent/python.vim
+++ b/runtime/indent/python.vim
@@ -2,7 +2,7 @@
 " Language:		Python
 " Maintainer:		Bram Moolenaar <Bram@vim.org>
 " Original Author:	David Bustos <bustos@caltech.edu>
-" Last Change:		2006 Apr 21
+" Last Change:		2006 Apr 22
 
 " Only load this indent file when no other was loaded.
 if exists("b:did_indent")
--- a/runtime/syntax/doxygen.vim
+++ b/runtime/syntax/doxygen.vim
@@ -185,11 +185,20 @@ try
   syn region doxygenVerbatimRegion contained matchgroup=doxygenOther start=+\<verbatim\>+ matchgroup=doxygenOther end=+[\\@]\@<=\<endverbatim\>+ contains=doxygenVerbatimRegionSpecial,doxygenContinueComment,doxygenErrorComment
   syn match doxygenVerbatimRegionSpecial contained +[\\@]\(endverbatim\>\)\@=+
 
-  let b:doxygen_syntax_save=b:current_syntax
-  unlet b:current_syntax
+  if exists('b:current_syntax') 
+    let b:doxygen_syntax_save=b:current_syntax
+    unlet b:current_syntax
+  endif
+
   syn include @Dotx syntax/dot.vim
-  let b:current_syntax=b:doxygen_syntax_save
-  unlet b:doxygen_syntax_save
+
+  if exists('b:doxygen_syntax_save') 
+    let b:current_syntax=b:doxygen_syntax_save
+    unlet b:doxygen_syntax_save
+  else
+    unlet b:current_syntax
+  endif
+
   syn region doxygenDotRegion contained matchgroup=doxygenOther start=+\<dot\>+ matchgroup=doxygenOther end=+[\\@]\@<=\<enddot\>+ contains=doxygenDotRegionSpecial,doxygenErrorComment,doxygenContinueComment,@Dotx
   syn match doxygenDotRegionSpecial contained +[\\@]\(enddot\>\)\@=+
 
--- a/runtime/syntax/fortran.vim
+++ b/runtime/syntax/fortran.vim
@@ -1,8 +1,8 @@
 " Vim syntax file
 " Language:	Fortran95 (and Fortran90, Fortran77, F and elf90)
-" Version:	0.87
+" Version:	0.88
 " URL:		http://www.unb.ca/chem/ajit/syntax/fortran.vim
-" Last Change:	2006 Apr. 04
+" Last Change:	2006 Apr. 22
 " Maintainer:	Ajit J. Thakkar (ajit AT unb.ca); <http://www.unb.ca/chem/ajit/>
 " Usage:	Do :help fortran-syntax from Vim
 " Credits:
@@ -279,7 +279,7 @@ syn keyword fortran77IntrinsicR	dble dpr
 syn match   fortran77OperatorR	"\.\s*[gl][et]\s*\."
 syn match   fortran77OperatorR	"\.\s*\(eq\|ne\)\s*\."
 
-if b:fortran_dialect == "f95"
+if b:fortran_dialect == "f95" || b:fortran_dialect == "F"
   syn keyword fortranRepeat		forall
   syn match fortranRepeat		"\<end\s*forall"
   syn keyword fortran95Intrinsic	null cpu_time
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -1,9 +1,8 @@
-# Makefile for Vim on Win32 (Windows NT and Windows 95), using the
-# Microsoft Visual C++ 2.x and MSVC 4.x compilers (or newer).
-# It builds on Windows 95 and all four NT platforms: i386, Alpha, MIPS, and
-# PowerPC.  The NT/i386 binary and the Windows 95 binary are identical.
+# Makefile for Vim on Win32 (Windows NT/2000/XP/2003 and Windows 95/98/Me)
+# and Win64, using the Microsoft Visual C++ compilers. Known to work with
+# VC5, VC6 (VS98), VC7.0 (VS2002), VC7.1 (VS2003), and VC8 (VS2005).
 #
-# To build using Borland C++, use Make_bc3.mak or Make_bc5.mak.
+# To build using other Windows compilers, see INSTALLpc.txt
 #
 # This makefile can build the console, GUI, OLE-enable, Perl-enabled and
 # Python-enabled versions of vim for Win32 platforms.
@@ -172,8 +171,11 @@ OBJDIR = $(OBJDIR)d
 
 !ifdef PROCESSOR_ARCHITECTURE
 # We're on Windows NT or using VC 6+
-! ifndef CPU
+! ifdef CPU
+ASSEMBLY_ARCHITECTURE=$(CPU)
+! else
 CPU = $(PROCESSOR_ARCHITECTURE)
+ASSEMBLY_ARCHITECTURE = $(PROCESSOR_ARCHITECTURE)
 !  if ("$(CPU)" == "x86") || ("$(CPU)" == "X86")
 CPU = i386
 !  endif
@@ -183,6 +185,9 @@ CPU = i386
 CPU = i386
 !endif # !PROCESSOR_ARCHITECTURE
 
+!if ("$(CPU)" == "AMD64") || ("$(CPU)" == "IA64")
+DEFINES=$(DEFINES) /Wp64
+!endif
 
 # Build a retail version by default
 
@@ -752,6 +757,7 @@ clean:
 	- if exist $(VIM).pdb del $(VIM).pdb
 	- if exist $(VIM).map del $(VIM).map
 	- if exist $(VIM).ncb del $(VIM).ncb
+	- if exist gvim.exe.mnf del gvim.exe.mnf
 	- if exist vimrun.exe del vimrun.exe
 	- if exist install.exe del install.exe
 	- if exist uninstal.exe del uninstal.exe
@@ -933,7 +939,7 @@ if_perl.c : if_perl.xs typemap
 $(OUTDIR)/xpm_w32.obj: $(OUTDIR) xpm_w32.c
 	$(CC) $(CFLAGS) $(XPM_INC) xpm_w32.c
 
-$(OUTDIR)/vim.res:	$(OUTDIR) vim.rc version.h tools.bmp tearoff.bmp \
+$(OUTDIR)/vim.res:	$(OUTDIR) gvim.exe.mnf vim.rc version.h tools.bmp tearoff.bmp \
 		vim.ico vim_error.ico vim_alert.ico vim_info.ico vim_quest.ico
 	$(RC) /l 0x409 /Fo$(OUTDIR)/vim.res $(RCFLAGS) vim.rc
 
@@ -963,6 +969,30 @@ E_CFLAGS = $(E0_CFLAGS:"=\")
 	@echo char_u *compiled_user = (char_u *)"$(USERNAME)"; >> $(PATHDEF_SRC)
 	@echo char_u *compiled_sys = (char_u *)"$(USERDOMAIN)"; >> $(PATHDEF_SRC)
 
+gvim.exe.mnf: auto
+	@echo ^<?xml version="1.0" encoding="UTF-8" standalone="yes"?^> >$@
+	@echo ^<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"^> >>$@
+	@echo   ^<assemblyIdentity >>$@
+	@echo     processorArchitecture="$(ASSEMBLY_ARCHITECTURE)" >>$@
+	@echo     version="7.0.0.0" >>$@
+	@echo     type="win32" >>$@
+	@echo     name="Vim" >>$@
+	@echo   /^> >>$@
+	@echo   ^<description^>Vi Improved - A Text Editor^</description^> >>$@
+	@echo   ^<dependency^> >>$@
+	@echo     ^<dependentAssembly^> >>$@
+	@echo       ^<assemblyIdentity >>$@
+	@echo         type="win32" >>$@
+	@echo         name="Microsoft.Windows.Common-Controls" >>$@
+	@echo         version="6.0.0.0" >>$@
+	@echo         publicKeyToken="6595b64144ccf1df" >>$@
+	@echo         language="*" >>$@
+	@echo         processorArchitecture="$(ASSEMBLY_ARCHITECTURE)" >>$@
+	@echo       /^> >>$@
+	@echo     ^</dependentAssembly^> >>$@
+	@echo   ^</dependency^> >>$@
+	@echo ^</assembly^> >>$@
+
 auto:
 	if not exist auto/nul mkdir auto
 
--- a/src/diff.c
+++ b/src/diff.c
@@ -1330,7 +1330,7 @@ diff_read(idx_orig, idx_new, fname)
 	    /* Allocate a new diffblock. */
 	    dp = diff_alloc_new(curtab, dprev, dp);
 	    if (dp == NULL)
-		return;
+		goto done;
 
 	    dp->df_lnum[idx_orig] = lnum_orig;
 	    dp->df_count[idx_orig] = count_orig;
@@ -1357,6 +1357,7 @@ diff_read(idx_orig, idx_new, fname)
 	notset = TRUE;
     }
 
+done:
     fclose(fd);
 }
 
--- a/src/edit.c
+++ b/src/edit.c
@@ -178,7 +178,9 @@ static int  spell_bad_len = 0;	/* length
 #endif
 static void stop_insert __ARGS((pos_T *end_insert_pos, int esc));
 static int  echeck_abbr __ARGS((int));
+#if 0
 static void replace_push_off __ARGS((int c));
+#endif
 static int  replace_pop __ARGS((void));
 static void replace_join __ARGS((int off));
 static void replace_pop_ins __ARGS((void));
@@ -5823,7 +5825,7 @@ redo_literal(c)
  */
     static void
 start_arrow(end_insert_pos)
-    pos_T    *end_insert_pos;
+    pos_T    *end_insert_pos;	    /* can be NULL */
 {
     if (!arrow_used)	    /* something has been inserted */
     {
@@ -5912,11 +5914,13 @@ stop_arrow()
 }
 
 /*
- * do a few things to stop inserting
+ * Do a few things to stop inserting.
+ * "end_insert_pos" is where insert ended.  It is NULL when we already jumped
+ * to another window/buffer.
  */
     static void
 stop_insert(end_insert_pos, esc)
-    pos_T	*end_insert_pos;	/* where insert ended */
+    pos_T	*end_insert_pos;
     int		esc;			/* called by ins_esc() */
 {
     int		cc;
@@ -5941,7 +5945,7 @@ stop_insert(end_insert_pos, esc)
     else
 	vim_free(ptr);
 
-    if (!arrow_used)
+    if (!arrow_used && end_insert_pos != NULL)
     {
 	/* Auto-format now.  It may seem strange to do this when stopping an
 	 * insertion (or moving the cursor), but it's required when appending
@@ -5987,7 +5991,7 @@ stop_insert(end_insert_pos, esc)
 	 * of the line, and put the cursor back.
 	 * Do this when ESC was used or moving the cursor up/down. */
 	if (did_ai && (esc || (vim_strchr(p_cpo, CPO_INDENT) == NULL
-			   && curwin->w_cursor.lnum != end_insert_pos->lnum)))
+			&& curwin->w_cursor.lnum != end_insert_pos->lnum)))
 	{
 	    pos_T	tpos = curwin->w_cursor;
 
@@ -6030,9 +6034,13 @@ stop_insert(end_insert_pos, esc)
     can_si_back = FALSE;
 #endif
 
-    /* set '[ and '] to the inserted text */
-    curbuf->b_op_start = Insstart;
-    curbuf->b_op_end = *end_insert_pos;
+    /* Set '[ and '] to the inserted text.  When end_insert_pos is NULL we are
+     * now in a different buffer. */
+    if (end_insert_pos != NULL)
+    {
+	curbuf->b_op_start = Insstart;
+	curbuf->b_op_end = *end_insert_pos;
+    }
 }
 
 /*
@@ -6563,6 +6571,7 @@ replace_push(c)
     ++replace_stack_nr;
 }
 
+#if 0
 /*
  * call replace_push(c) with replace_offset set to the first NUL.
  */
@@ -6580,6 +6589,7 @@ replace_push_off(c)
     replace_push(c);
     replace_offset = 0;
 }
+#endif
 
 /*
  * Pop one item from the replace stack.
@@ -8023,7 +8033,9 @@ ins_bs(c, mode, inserted_space_p)
 	    int		ts;
 	    colnr_T	vcol;
 	    colnr_T	want_vcol;
+#if 0
 	    int		extra = 0;
+#endif
 
 	    *inserted_space_p = FALSE;
 	    if (p_sta && in_indent)
@@ -8082,15 +8094,19 @@ ins_bs(c, mode, inserted_space_p)
 #endif
 		{
 		    ins_str((char_u *)" ");
-		    if ((State & REPLACE_FLAG) && extra <= 1)
+		    if ((State & REPLACE_FLAG) /* && extra <= 1 */)
 		    {
+#if 0
 			if (extra)
 			    replace_push_off(NUL);
 			else
+#endif
 			    replace_push(NUL);
 		    }
+#if 0
 		    if (extra == 2)
 			extra = 1;
+#endif
 		}
 		getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
 	    }
@@ -8205,6 +8221,7 @@ ins_mouse(c)
     int	    c;
 {
     pos_T	tpos;
+    win_T	*old_curwin = curwin;
 
 # ifdef FEAT_GUI
     /* When GUI is active, also move/paste when 'mouse' is empty */
@@ -8217,7 +8234,25 @@ ins_mouse(c)
     tpos = curwin->w_cursor;
     if (do_mouse(NULL, c, BACKWARD, 1L, 0))
     {
-	start_arrow(&tpos);
+#ifdef FEAT_WINDOWS
+	win_T	*new_curwin = curwin;
+
+	if (curwin != old_curwin && win_valid(old_curwin))
+	{
+	    /* Mouse took us to another window.  We need to go back to the
+	     * previous one to stop insert there properly. */
+	    curwin = old_curwin;
+	    curbuf = curwin->w_buffer;
+	}
+#endif
+	start_arrow(curwin == old_curwin ? &tpos : NULL);
+#ifdef FEAT_WINDOWS
+	if (curwin != new_curwin && win_valid(new_curwin))
+	{
+	    curwin = new_curwin;
+	    curbuf = curwin->w_buffer;
+	}
+#endif
 # ifdef FEAT_CINDENT
 	can_cindent = TRUE;
 # endif
--- a/src/eval.c
+++ b/src/eval.c
@@ -1413,7 +1413,7 @@ call_vim_function(func, argc, argv, safe
     void	*save_funccalp = NULL;
     int		ret;
 
-    argvars = (typval_T *)alloc((unsigned)(argc * sizeof(typval_T)));
+    argvars = (typval_T *)alloc((unsigned)((argc + 1) * sizeof(typval_T)));
     if (argvars == NULL)
 	return FAIL;
 
@@ -7318,7 +7318,7 @@ get_func_tv(name, len, rettv, arg, first
 {
     char_u	*argp;
     int		ret = OK;
-    typval_T	argvars[MAX_FUNC_ARGS];	/* vars for arguments */
+    typval_T	argvars[MAX_FUNC_ARGS + 1];	/* vars for arguments */
     int		argcount = 0;		/* number of arguments found */
 
     /*
@@ -7375,7 +7375,8 @@ call_func(name, len, rettv, argcount, ar
     int		len;		/* length of "name" */
     typval_T	*rettv;		/* return value goes here */
     int		argcount;	/* number of "argvars" */
-    typval_T	*argvars;	/* vars for arguments */
+    typval_T	*argvars;	/* vars for arguments, must have "argcount"
+				   PLUS ONE elements! */
     linenr_T	firstline;	/* first line of range */
     linenr_T	lastline;	/* last line of range */
     int		*doesrange;	/* return: function handled range */
@@ -8064,7 +8065,7 @@ f_call(argvars, rettv)
     typval_T	*rettv;
 {
     char_u	*func;
-    typval_T	argv[MAX_FUNC_ARGS];
+    typval_T	argv[MAX_FUNC_ARGS + 1];
     int		argc = 0;
     listitem_T	*item;
     int		dummy;
@@ -8943,7 +8944,7 @@ f_extend(argvars, rettv)
 			break;
 		if (i == 3)
 		{
-		    EMSGN(_(e_invarg2), action);
+		    EMSG2(_(e_invarg2), action);
 		    return;
 		}
 	    }
@@ -12997,7 +12998,7 @@ remote_common(argvars, rettv, expr)
 	char_u		str[30];
 	char_u		*idvar;
 
-	sprintf((char *)str, "0x%x", (unsigned int)w);
+	sprintf((char *)str, PRINTF_HEX_LONG_U, (long_u)w);
 	v.di_tv.v_type = VAR_STRING;
 	v.di_tv.vval.v_string = vim_strsave(str);
 	idvar = get_tv_string_chk(&argvars[2]);
@@ -13064,7 +13065,7 @@ f_remote_peek(argvars, rettv)
     dictitem_T	v;
     char_u	*s = NULL;
 # ifdef WIN32
-    int		n = 0;
+    long_u	n = 0;
 # endif
     char_u	*serverid;
 
@@ -13080,7 +13081,7 @@ f_remote_peek(argvars, rettv)
 	return;		/* type error; errmsg already given */
     }
 # ifdef WIN32
-    sscanf(serverid, "%x", &n);
+    sscanf(serverid, SCANF_HEX_LONG_U, &n);
     if (n == 0)
 	rettv->vval.v_number = -1;
     else
@@ -13128,9 +13129,9 @@ f_remote_read(argvars, rettv)
     {
 # ifdef WIN32
 	/* The server's HWND is encoded in the 'id' parameter */
-	int		n = 0;
-
-	sscanf(serverid, "%x", &n);
+	long_u		n = 0;
+
+	sscanf(serverid, SCANF_HEX_LONG_U, &n);
 	if (n != 0)
 	    r = serverGetReply((HWND)n, FALSE, TRUE, TRUE);
 	if (r == NULL)
@@ -14585,7 +14586,7 @@ item_compare2(s1, s2)
 {
     int		res;
     typval_T	rettv;
-    typval_T	argv[2];
+    typval_T	argv[3];
     int		dummy;
 
     /* shortcut after failure in previous call; compare all items equal */
@@ -15133,11 +15134,12 @@ f_strridx(argvars, rettv)
 
     needle = get_tv_string_chk(&argvars[1]);
     haystack = get_tv_string_buf_chk(&argvars[0], buf);
-    haystack_len = (int)STRLEN(haystack);
 
     rettv->vval.v_number = -1;
     if (needle == NULL || haystack == NULL)
 	return;		/* type error; errmsg already given */
+
+    haystack_len = (int)STRLEN(haystack);
     if (argvars[2].v_type != VAR_UNKNOWN)
     {
 	/* Third argument: upper limit for index */
@@ -15398,7 +15400,10 @@ f_system(argvars, rettv)
 	}
 	p = get_tv_string_buf_chk(&argvars[1], buf);
 	if (p == NULL)
+	{
+	    fclose(fd);
 	    goto done;		/* type error; errmsg already given */
+	}
 	if (fwrite(p, STRLEN(p), 1, fd) != 1)
 	    err = TRUE;
 	if (fclose(fd) != 0)
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -1778,6 +1778,7 @@ write_viminfo(file, forceit)
 	    tt = msg_didany;
 	    EMSG2(_("E137: Viminfo file is not writable: %s"), fname);
 	    msg_didany = tt;
+	    fclose(fp_in);
 	    goto end;
 	}
 #endif
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -9438,7 +9438,8 @@ eval_vars(src, usedlen, lnump, errormsg,
 		break;
 #if defined(FEAT_CLIENTSERVER)
 	case SPEC_CLIENT:	/* Source of last submitted input */
-		sprintf((char *)strbuf, "0x%x", (unsigned int)clientWindow);
+		sprintf((char *)strbuf, PRINTF_HEX_LONG_U,
+							(long_u)clientWindow);
 		result = strbuf;
 		break;
 #endif
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -1136,7 +1136,7 @@ ex_continue(eap)
 	 * next).  Therefor, inactivate all conditionals except the ":while"
 	 * itself (if reached). */
 	idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE);
-	if ((cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR)))
+	if (idx >= 0 && (cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR)))
 	{
 	    rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel);
 
@@ -1175,7 +1175,7 @@ ex_break(eap)
 	 * executed next) is found.  In the latter case, make the ":break"
 	 * pending for execution at the ":endtry". */
 	idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, TRUE);
-	if (!(cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR)))
+	if (idx >= 0 && !(cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR)))
 	{
 	    cstack->cs_pending[idx] = CSTP_BREAK;
 	    report_make_pending(CSTP_BREAK, NULL);
@@ -1861,7 +1861,7 @@ ex_endtry(eap)
 	 * after errors except when this ":endtry" is not within a ":try".
 	 * Restore "emsg_silent" if it has been reset by this try conditional.
 	 */
-	cleanup_conditionals(cstack, CSF_TRY | CSF_SILENT, TRUE);
+	(void)cleanup_conditionals(cstack, CSF_TRY | CSF_SILENT, TRUE);
 
 	--cstack->cs_idx;
 	--cstack->cs_trylevel;
--- a/src/fold.c
+++ b/src/fold.c
@@ -2594,8 +2594,9 @@ foldUpdateIEMSRecurse(gap, level, startl
 
 	/*
 	 * The fold includes the line "flp->lnum" and "flp->lnum_save".
+	 * Check "fp" for safety.
 	 */
-	if (lvl > level)
+	if (lvl > level && fp != NULL)
 	{
 	    /*
 	     * There is a nested fold, handle it recursively.
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -4053,14 +4053,19 @@ ExpandMappings(regmatch, num_file, file)
 	}
     } /* for (round) */
 
-    /* Sort the matches */
-    sort_strings(*file, count);
-
-    /* Remove multiple entries */
+    if (count > 1)
     {
-	char_u	**ptr1 = *file;
-	char_u	**ptr2 = ptr1 + 1;
-	char_u	**ptr3 = ptr1 + count;
+	char_u	**ptr1;
+	char_u	**ptr2;
+	char_u	**ptr3;
+
+	/* Sort the matches */
+	sort_strings(*file, count);
+
+	/* Remove multiple entries */
+	ptr1 = *file;
+	ptr2 = ptr1 + 1;
+	ptr3 = ptr1 + count;
 
 	while (ptr2 < ptr3)
 	{
--- a/src/gui_gtk.c
+++ b/src/gui_gtk.c
@@ -787,12 +787,12 @@ gui_mch_add_menu_item(vimmenu_T *menu, i
 # endif /* FEAT_TOOLBAR */
     {
 	/* No parent, must be a non-menubar menu */
-	if (parent->submenu_id == NULL)
+	if (parent == NULL || parent->submenu_id == NULL)
 	    return;
 
 	/* Make place for the possible tearoff handle item.  Not in the popup
 	 * menu, it doesn't have a tearoff item. */
-	if (parent != NULL && !menu_is_popup(parent->name))
+	if (!menu_is_popup(parent->name))
 	    ++idx;
 
 	if (menu_is_separator(menu->name))
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -2024,6 +2024,8 @@ drag_handle_uri_list(GdkDragContext	*con
 
 	gui_handle_drop(x, y, modifiers, fnames, nfiles);
     }
+    else
+	vim_free(fnames);
 }
 
     static void
@@ -4707,7 +4709,7 @@ gui_mch_font_dialog(char_u *oldval)
 	     * that, because in 'guifont' it separates names. */
 	    p = vim_strsave_escaped((char_u *)name, (char_u *)",");
 	    g_free(name);
-	    if (input_conv.vc_type != CONV_NONE)
+	    if (p != NULL && input_conv.vc_type != CONV_NONE)
 	    {
 		fontname = string_convert(&input_conv, p, NULL);
 		vim_free(p);
@@ -6870,7 +6872,7 @@ mch_set_mouse_shape(int shape)
 	    else
 		id &= ~1;	/* they are always even (why?) */
 	}
-	else
+	else if (shape < sizeof(mshape_ids) / sizeof(int))
 	    id = mshape_ids[shape];
 # ifdef HAVE_GTK_MULTIHEAD
 	c = gdk_cursor_new_for_display(
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -181,13 +181,14 @@
 # define ID_BEVAL_TOOLTIP   200
 # define BEVAL_TEXT_LEN	    MAXPATHL
 
-static void make_tooltip __ARGS((BalloonEval *beval, char *text, POINT pt));
-static void delete_tooltip __ARGS((BalloonEval *beval));
-static VOID CALLBACK BevalTimerProc __ARGS((HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime));
-
 #ifndef UINT_PTR
 # define UINT_PTR UINT
 #endif
+
+static void make_tooltip __ARGS((BalloonEval *beval, char *text, POINT pt));
+static void delete_tooltip __ARGS((BalloonEval *beval));
+static VOID CALLBACK BevalTimerProc __ARGS((HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime));
+
 static BalloonEval  *cur_beval = NULL;
 static UINT_PTR	    BevalTimerId = 0;
 static DWORD	    LastActivity = 0;
@@ -811,9 +812,102 @@ init_mouse_wheel(void)
     case WM_NOTIFY:
 	switch (((LPNMHDR) lParam)->code)
 	{
-# ifdef FEAT_TOOLBAR
+# ifdef FEAT_MBYTE
+	    case TTN_GETDISPINFOW:
+# endif
 	    case TTN_NEEDTEXT:
+# ifdef FEAT_GUI_TABLINE
+		if (gui_mch_showing_tabline()
+			&& ((LPNMHDR)lParam)->hwndFrom ==
+					       TabCtrl_GetToolTips(s_tabhwnd))
 		{
+		    LPNMTTDISPINFO	lpdi;
+		    POINT		pt;
+		    static char         *tt_text = NULL;
+		    static int          tt_text_len = 0;
+
+		    /*
+		     * Mouse is over the GUI tabline. Display the tooltip
+		     * for the tab under the cursor
+		     */
+		    lpdi = (LPNMTTDISPINFO)lParam;
+		    lpdi->hinst = NULL;
+		    lpdi->szText[0] = '\0';
+
+		    /*
+		     * Get the cursor position within the tab control
+		     */
+		    GetCursorPos(&pt);
+		    if (ScreenToClient(s_tabhwnd, &pt) != 0)
+		    {
+			TCHITTESTINFO htinfo;
+			int idx;
+
+			/*
+			 * Get the tab under the cursor
+			 */
+			htinfo.pt.x = pt.x;
+			htinfo.pt.y = pt.y;
+			idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
+			if (idx != -1)
+			{
+			    tabpage_T *tp;
+
+			    tp = find_tabpage(idx + 1);
+			    if (tp != NULL)
+			    {
+#  ifdef FEAT_MBYTE
+				WCHAR	*wstr = NULL;
+#  endif
+				get_tabline_label(tp, TRUE);
+#  ifdef FEAT_MBYTE
+				if (enc_codepage >= 0
+					     && (int)GetACP() != enc_codepage)
+				{
+				    wstr = enc_to_ucs2(NameBuff, NULL);
+				    if (wstr != NULL)
+				    {
+					int wlen;
+
+					wlen = (wcslen(wstr) + 1)
+							      * sizeof(WCHAR);
+					if (tt_text_len < wlen)
+					{
+					    tt_text = vim_realloc(tt_text,
+									wlen);
+					    if (tt_text != NULL)
+						tt_text_len = wlen;
+					}
+					if (tt_text != NULL)
+					    wcscpy((WCHAR *)tt_text, wstr);
+					lpdi->lpszText = tt_text;
+					vim_free(wstr);
+				    }
+				}
+				if (wstr == NULL)
+#  endif
+				{
+				    int len;
+
+				    len = STRLEN(NameBuff) + 1;
+				    if (tt_text_len < len)
+				    {
+					tt_text = vim_realloc(tt_text, len);
+					if (tt_text != NULL)
+					    tt_text_len = len;
+				    }
+				    if (tt_text != NULL)
+					STRCPY(tt_text, NameBuff);
+				    lpdi->lpszText = tt_text;
+				}
+			    }
+			}
+		    }
+		}
+		else
+# endif
+		{
+# ifdef FEAT_TOOLBAR
 		    LPTOOLTIPTEXT	lpttt;
 		    UINT		idButton;
 		    int			idx;
@@ -831,9 +925,9 @@ init_mouse_wheel(void)
 			    lpttt->lpszText = pMenu->strings[idx];
 			}
 		    }
+# endif
 		}
 		break;
-# endif
 # ifdef FEAT_GUI_TABLINE
 	    case TCN_SELCHANGE:
 		if (gui_mch_showing_tabline()
@@ -2341,7 +2435,7 @@ gui_mch_add_menu(
 	{
 	    InsertMenu((parent == NULL) ? s_menuBar : parent->submenu_id,
 		    (UINT)pos, MF_POPUP | MF_STRING | MF_BYPOSITION,
-		    (UINT)menu->submenu_id, (LPCTSTR) menu->name);
+		    (long_u)menu->submenu_id, (LPCTSTR) menu->name);
 	}
 	else
 	{
@@ -2361,7 +2455,7 @@ gui_mch_add_menu(
 		    infow.cbSize = sizeof(infow);
 		    infow.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID
 							       | MIIM_SUBMENU;
-		    infow.dwItemData = (DWORD)menu;
+		    infow.dwItemData = (long_u)menu;
 		    infow.wID = menu->id;
 		    infow.fType = MFT_STRING;
 		    infow.dwTypeData = wn;
@@ -2384,7 +2478,7 @@ gui_mch_add_menu(
 
 		info.cbSize = sizeof(info);
 		info.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID | MIIM_SUBMENU;
-		info.dwItemData = (DWORD)menu;
+		info.dwItemData = (long_u)menu;
 		info.wID = menu->id;
 		info.fType = MFT_STRING;
 		info.dwTypeData = (LPTSTR)menu->name;
@@ -2661,7 +2755,7 @@ gui_mch_menu_grey(
 	if (menu->children == NULL)
 	    menuID = (WORD)(menu->id);
 	else
-	    menuID = (WORD)((DWORD)(menu->submenu_id) | (DWORD)0x8000);
+	    menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000);
 	menuHandle = GetDlgItem(menu->parent->tearoff_handle, menuID);
 	if (menuHandle)
 	    EnableWindow(menuHandle, !grey);
@@ -2860,7 +2954,7 @@ gui_mch_dialog(
     /* allocate some memory for dialog template */
     /* TODO should compute this really */
     pdlgtemplate = p = (PWORD)LocalAlloc(LPTR,
-					    DLG_ALLOC_SIZE + STRLEN(message));
+					DLG_ALLOC_SIZE + STRLEN(message) * 2);
 
     if (p == NULL)
 	return -1;
@@ -3281,6 +3375,7 @@ gui_mch_dialog(
 }
 
 #endif /* FEAT_GUI_DIALOG */
+
 /*
  * Put a simple element (basic class) onto a dialog template in memory.
  * return a pointer to where the next item should be added.
@@ -3344,9 +3439,9 @@ add_dialog_element(
 lpwAlign(
     LPWORD lpIn)
 {
-    ULONG ul;
-
-    ul = (ULONG)lpIn;
+    long_u ul;
+
+    ul = (long_u)lpIn;
     ul += 3;
     ul >>= 2;
     ul <<= 2;
@@ -3435,7 +3530,7 @@ tearoff_callback(
 	    if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect))
 	    {
 		(void)TrackPopupMenu(
-			 (HMENU)(LOWORD(wParam) ^ 0x8000),
+			 (HMENU)(long_u)(LOWORD(wParam) ^ 0x8000),
 			 TPM_LEFTALIGN | TPM_LEFTBUTTON,
 			 (int)rect.right - 8,
 			 (int)mp.y,
@@ -3794,7 +3889,7 @@ gui_mch_tearoff(
 	else
 	{
 	    len += (int)STRLEN(TEAROFF_SUBMENU_LABEL);
-	    menuID = (WORD)((DWORD)(menu->submenu_id) | (DWORD)0x8000);
+	    menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000);
 	}
 
 	/* Allocate menu label and fill it in */
@@ -3953,7 +4048,7 @@ get_toolbar_bitmap(vimmenu_T *menu)
 	    TBADDBITMAP tbAddBitmap;
 
 	    tbAddBitmap.hInst = NULL;
-	    tbAddBitmap.nID = (UINT)hbitmap;
+	    tbAddBitmap.nID = (long_u)hbitmap;
 
 	    i = (int)SendMessage(s_toolbarhwnd, TB_ADDBITMAP,
 			    (WPARAM)1, (LPARAM)&tbAddBitmap);
@@ -3978,7 +4073,7 @@ initialise_tabline(void)
     InitCommonControls();
 
     s_tabhwnd = CreateWindow(WC_TABCONTROL, "Vim tabline",
-	    WS_CHILD|TCS_FOCUSNEVER,
+	    WS_CHILD|TCS_FOCUSNEVER|TCS_TOOLTIPS,
 	    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
 	    CW_USEDEFAULT, s_hwnd, NULL, s_hinst, NULL);
 
@@ -4404,7 +4499,7 @@ delete_tooltip(beval)
 BevalTimerProc(hwnd, uMsg, idEvent, dwTime)
     HWND    hwnd;
     UINT    uMsg;
-    UINT    idEvent;
+    UINT_PTR    idEvent;
     DWORD   dwTime;
 {
     POINT	pt;
--- a/src/hardcopy.c
+++ b/src/hardcopy.c
@@ -2538,12 +2538,11 @@ mch_print_init(psettings, jobname, force
         /* Build CMap name - will be same for all multi-byte fonts used */
         prt_cmap[0] = NUL;
 
-        prt_custom_cmap = prt_out_mbyte && p_mbchar == NULL;
-
+        prt_custom_cmap = (p_mbchar == NULL);
         if (!prt_custom_cmap)
         {
             /* Check encoding and character set are compatible */
-            if ((p_mbenc->needs_charset&p_mbchar->has_charset) == 0)
+            if ((p_mbenc->needs_charset & p_mbchar->has_charset) == 0)
             {
                 EMSG(_("E673: Incompatible multi-byte encoding and character set."));
                 return FALSE;
@@ -2862,6 +2861,7 @@ mch_print_begin(psettings)
     struct prt_ps_resource_S res_encoding;
     char	buffer[256];
     char_u      *p_encoding;
+    char_u	*p;
 #ifdef FEAT_MBYTE
     struct prt_ps_resource_S res_cidfont;
     struct prt_ps_resource_S res_cmap;
@@ -2880,7 +2880,9 @@ mch_print_begin(psettings)
     now = time(NULL);
     p_time = ctime(&now);
     /* Note: ctime() adds a \n so we have to remove it :-( */
-    *(vim_strchr((char_u *)p_time, '\n')) = '\0';
+    p = vim_strchr((char_u *)p_time, '\n');
+    if (p != NULL)
+	*p = NUL;
     prt_dsc_textline("CreationDate", p_time);
     prt_dsc_textline("DocumentData", "Clean8Bit");
     prt_dsc_textline("Orientation", "Portrait");
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -3100,7 +3100,7 @@ enc_locale()
 	else
 	    s = p + 1;
     }
-    for (i = 0; s[i] != NUL && i < sizeof(buf) - 1; ++i)
+    for (i = 0; s[i] != NUL && s + i < buf + sizeof(buf) - 1; ++i)
     {
 	if (s[i] == '_' || s[i] == '-')
 	    buf[i] = '-';
--- a/src/menu.c
+++ b/src/menu.c
@@ -59,7 +59,7 @@ static char_u *menutrans_lookup __ARGS((
 #endif
 
 /* The character for each menu mode */
-static char_u	menu_mode_chars[] = {'n', 'v', 'o', 'i', 'c', 't'};
+static char_u	menu_mode_chars[] = {'n', 'v', 's', 'o', 'i', 'c', 't'};
 
 static char_u e_notsubmenu[] = N_("E327: Part of menu-item path is not sub-menu");
 static char_u e_othermode[] = N_("E328: Menu only exists in another mode");
@@ -1293,6 +1293,7 @@ set_context_in_menu_cmd(xp, cmd, arg, fo
 	    name = p;
 	    menu = menu->children;
 	}
+	vim_free(path_name);
 
 	xp->xp_context = expand_menus ? EXPAND_MENUNAMES : EXPAND_MENUS;
 	xp->xp_pattern = after_dot;
--- a/src/message.c
+++ b/src/message.c
@@ -529,6 +529,25 @@ msg_source(attr)
 }
 
 /*
+ * Return TRUE if not giving error messages right now:
+ * If "emsg_off" is set: no error messages at the moment.
+ * If "msg" is in 'debug': do error message but without side effects.
+ * If "emsg_skip" is set: never do error messages.
+ */
+    int
+emsg_not_now()
+{
+    if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL
+					  && vim_strchr(p_debug, 't') == NULL)
+#ifdef FEAT_EVAL
+	    || emsg_skip > 0
+#endif
+	    )
+	return TRUE;
+    return FALSE;
+}
+
+/*
  * emsg() - display an error message
  *
  * Rings the bell, if appropriate, and calls message() to do the real work
@@ -559,17 +578,8 @@ emsg(s)
     emsg_severe = FALSE;
 #endif
 
-    /*
-     * If "emsg_off" is set: no error messages at the moment.
-     * If "msg" is in 'debug': do error message but without side effects.
-     * If "emsg_skip" is set: never do error messages.
-     */
-    if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL
-					  && vim_strchr(p_debug, 't') == NULL)
-#ifdef FEAT_EVAL
-	    || emsg_skip > 0
-#endif
-	    )
+    /* Skip this if not giving error messages at the moment. */
+    if (emsg_not_now())
 	return TRUE;
 
     if (!emsg_off || vim_strchr(p_debug, 't') != NULL)
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -321,7 +321,7 @@ copy_indent(size, src)
 		++ind_done;
 	    }
 	    ++ind_len;
-	    if (round == 2)
+	    if (p != NULL)
 		*p++ = *s;
 	    ++s;
 	}
@@ -332,7 +332,7 @@ copy_indent(size, src)
 	{
 	    todo -= tab_pad;
 	    ++ind_len;
-	    if (round == 2)
+	    if (p != NULL)
 		*p++ = TAB;
 	}
 
@@ -341,7 +341,7 @@ copy_indent(size, src)
 	{
 	    todo -= (int)curbuf->b_p_ts;
 	    ++ind_len;
-	    if (round == 2)
+	    if (p != NULL)
 		*p++ = TAB;
 	}
 
@@ -350,11 +350,11 @@ copy_indent(size, src)
 	{
 	    --todo;
 	    ++ind_len;
-	    if (round == 2)
+	    if (p != NULL)
 		*p++ = ' ';
 	}
 
-	if (round == 1)
+	if (p == NULL)
 	{
 	    /* Allocate memory for the result: the copied indent, new indent
 	     * and the rest of the line. */
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -270,14 +270,15 @@ coladvance2(pos, addspaces, finetune, wc
 		/* Break a tab */
 		int	linelen = (int)STRLEN(line);
 		int	correct = wcol - col - csize + 1; /* negative!! */
-		char_u	*newline = alloc(linelen + csize);
+		char_u	*newline;
 		int	t, s = 0;
 		int	v;
 
-		/*
-		 * break a tab
-		 */
-		if (newline == NULL || -correct > csize)
+		if (-correct > csize)
+		    return FAIL;
+
+		newline = alloc(linelen + csize);
+		if (newline == NULL)
 		    return FAIL;
 
 		for (t = 0; t < linelen; t++)
@@ -5816,14 +5817,9 @@ filewritable(fname)
 emsg3(s, a1, a2)
     char_u *s, *a1, *a2;
 {
-    if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL
-					  && vim_strchr(p_debug, 't') == NULL)
-#ifdef FEAT_EVAL
-	    || emsg_skip > 0
-#endif
-	    )
+    if (emsg_not_now())
 	return TRUE;		/* no error messages at the moment */
-    vim_snprintf((char *)IObuff, IOSIZE, (char *)s, (long)a1, (long)a2);
+    vim_snprintf((char *)IObuff, IOSIZE, (char *)s, (long_u)a1, (long_u)a2);
     return emsg(IObuff);
 }
 
@@ -5836,14 +5832,8 @@ emsgn(s, n)
     char_u	*s;
     long	n;
 {
-    if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL
-					  && vim_strchr(p_debug, 't') == NULL)
-#ifdef FEAT_EVAL
-	    || emsg_skip > 0
-#endif
-	    )
+    if (emsg_not_now())
 	return TRUE;		/* no error messages at the moment */
     vim_snprintf((char *)IObuff, IOSIZE, (char *)s, n);
     return emsg(IObuff);
 }
-
--- a/src/netbeans.c
+++ b/src/netbeans.c
@@ -1641,17 +1641,30 @@ nb_do_cmd(
 	}
 	else if (streq((char *)cmd, "insertDone"))
 	{
-	    buf->bufp->b_start_eol = *args == 'T';
-	    buf->insertDone = TRUE;
-	    args += 2;
-	    buf->bufp->b_p_ro = *args == 'T';
-	    print_read_msg(buf);
+	    if (buf == NULL || buf->bufp == NULL)
+	    {
+		nbdebug(("    null bufp in insertDone"));
+	    }
+	    else
+	    {
+		buf->bufp->b_start_eol = *args == 'T';
+		buf->insertDone = TRUE;
+		args += 2;
+		buf->bufp->b_p_ro = *args == 'T';
+		print_read_msg(buf);
+	    }
 /* =====================================================================*/
 	}
 	else if (streq((char *)cmd, "saveDone"))
 	{
-	    long savedChars = atol((char *) args);
-	    print_save_msg(buf, savedChars);
+	    long savedChars = atol((char *)args);
+
+	    if (buf == NULL || buf->bufp == NULL)
+	    {
+		nbdebug(("    null bufp in saveDone"));
+	    }
+	    else
+		print_save_msg(buf, savedChars);
 /* =====================================================================*/
 	}
 	else if (streq((char *)cmd, "startDocumentListen"))
@@ -1856,12 +1869,17 @@ nb_do_cmd(
 	}
 	else if (streq((char *)cmd, "setModtime"))
 	{
-	    buf->bufp->b_mtime = atoi((char *) args);
+	    if (buf == NULL || buf->bufp == NULL)
+		nbdebug(("    null bufp in setModtime"));
+	    else
+		buf->bufp->b_mtime = atoi((char *)args);
 /* =====================================================================*/
 	}
 	else if (streq((char *)cmd, "setReadOnly"))
 	{
-	    if (streq((char *)args, "T"))
+	    if (buf == NULL || buf->bufp == NULL)
+		nbdebug(("    null bufp in setReadOnly"));
+	    else if (streq((char *)args, "T"))
 		buf->bufp->b_p_ro = TRUE;
 	    else
 		buf->bufp->b_p_ro = FALSE;
@@ -2637,7 +2655,7 @@ netbeans_file_activated(buf_T *bufp)
 	return;
 
     q = nb_quote(bufp->b_ffname);
-    if (q == NULL || bp == NULL || bufp == NULL)
+    if (q == NULL || bp == NULL)
 	return;
 
     vim_snprintf(buffer, sizeof(buffer),  "%d:fileOpened=%d \"%s\" %s %s\n",
--- a/src/normal.c
+++ b/src/normal.c
@@ -831,6 +831,12 @@ getcount:
 	    {
 		unshift_special(&ca);
 		idx = find_command(ca.cmdchar);
+		if (idx < 0)
+		{
+		    /* Just in case */
+		    clearopbeep(oap);
+		    goto normal_end;
+		}
 	    }
 	    else if ((nv_cmds[idx].cmd_flags & NV_SSS)
 					       && (mod_mask & MOD_MASK_SHIFT))
--- a/src/ops.c
+++ b/src/ops.c
@@ -3723,11 +3723,10 @@ error:
 
 end:
     if (allocated)
-    {
 	vim_free(insert_string);
-	if (regname == '=')
-	    vim_free(y_array);
-    }
+    if (regname == '=')
+	vim_free(y_array);
+
     /* If the cursor is past the end of the line put it at the end. */
     if (gchar_cursor() == NUL
 	    && curwin->w_cursor.col > 0
@@ -4967,10 +4966,6 @@ do_addsub(command, Prenum1)
 	    --col;
     }
 
-    /* truncate to max length of a number */
-    if (length >= NUMBUFLEN - 1)
-	length = NUMBUFLEN - 2;
-
     /*
      * If a number was found, and saving for undo works, replace the number.
      */
--- a/src/option.c
+++ b/src/option.c
@@ -3396,7 +3396,7 @@ set_option_default(opt_idx, opt_flags, c
 		win_comp_scroll(curwin);
 	    else
 	    {
-		*(long *)varp = (long)options[opt_idx].def_val[dvi];
+		*(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
 		/* May also set global value for local option. */
 		if (both)
 		    *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
@@ -3405,8 +3405,9 @@ set_option_default(opt_idx, opt_flags, c
 	}
 	else	/* P_BOOL */
 	{
-	    /* the cast to long is required for Manx C */
-	    *(int *)varp = (int)(long)options[opt_idx].def_val[dvi];
+	    /* the cast to long is required for Manx C, long_i is needed for
+	     * MSVC */
+	    *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
 	    /* May also set global value for local option. */
 	    if (both)
 		*(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
@@ -3488,7 +3489,7 @@ set_number_default(name, val)
 
     opt_idx = findoption((char_u *)name);
     if (opt_idx >= 0)
-	options[opt_idx].def_val[VI_DEFAULT] = (char_u *)val;
+	options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
 }
 
 #if defined(EXITFREE) || defined(PROTO)
@@ -3858,7 +3859,7 @@ set_title_defaults()
 	else
 #endif
 	    val = mch_can_restore_title();
-	options[idx1].def_val[VI_DEFAULT] = (char_u *)val;
+	options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
 	p_title = val;
     }
     idx1 = findoption((char_u *)"icon");
@@ -3870,7 +3871,7 @@ set_title_defaults()
 	else
 #endif
 	    val = mch_can_restore_icon();
-	options[idx1].def_val[VI_DEFAULT] = (char_u *)val;
+	options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
 	p_icon = val;
     }
 }
@@ -4206,7 +4207,7 @@ do_set(arg, opt_flags)
 		    if (nextchar == '!')
 			value = *(int *)(varp) ^ 1;
 		    else if (nextchar == '&')
-			value = (int)(long)options[opt_idx].def_val[
+			value = (int)(long)(long_i)options[opt_idx].def_val[
 						((flags & P_VI_DEF) || cp_val)
 						 ?  VI_DEFAULT : VIM_DEFAULT];
 		    else if (nextchar == '<')
@@ -4261,7 +4262,7 @@ do_set(arg, opt_flags)
 			 */
 			++arg;
 			if (nextchar == '&')
-			    value = (long)options[opt_idx].def_val[
+			    value = (long)(long_i)options[opt_idx].def_val[
 						((flags & P_VI_DEF) || cp_val)
 						 ?  VI_DEFAULT : VIM_DEFAULT];
 			else if (nextchar == '<')
@@ -8401,10 +8402,11 @@ optval_default(p, varp)
 	return TRUE;	    /* hidden option is always at default */
     dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
     if (p->flags & P_NUM)
-	return (*(long *)varp == (long)p->def_val[dvi]);
+	return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
     if (p->flags & P_BOOL)
-			/* the cast to long is required for Manx C */
-	return (*(int *)varp == (int)(long)p->def_val[dvi]);
+			/* the cast to long is required for Manx C, long_i is
+			 * needed for MSVC */
+	return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
     /* P_STRING */
     return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
 }
@@ -9993,7 +9995,7 @@ option_value2string(opp, opt_flags)
 	    NameBuff[0] = NUL;
 #ifdef FEAT_CRYPT
 	/* don't show the actual value of 'key', only that it's set */
-	if (opp->var == (char_u *)&p_key && *varp)
+	else if (opp->var == (char_u *)&p_key && *varp)
 	    STRCPY(NameBuff, "*****");
 #endif
 	else if (opp->flags & P_EXPAND)
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -770,14 +770,14 @@ check_str_len(char_u *str)
     if (VirtualQuery(str, &mbi, sizeof(mbi)))
     {
 	/* pre cast these (typing savers) */
-	DWORD dwStr = (DWORD)str;
-	DWORD dwBaseAddress = (DWORD)mbi.BaseAddress;
+	long_u dwStr = (long_u)str;
+	long_u dwBaseAddress = (long_u)mbi.BaseAddress;
 
 	/* get start address of page that str is on */
-	DWORD strPage = dwStr - (dwStr - dwBaseAddress) % si.dwPageSize;
+	long_u strPage = dwStr - (dwStr - dwBaseAddress) % si.dwPageSize;
 
 	/* get length from str to end of page */
-	DWORD pageLength = si.dwPageSize - (dwStr - strPage);
+	long_u pageLength = si.dwPageSize - (dwStr - strPage);
 
 	for (p = str; !IsBadReadPtr(p, pageLength);
 				  p += pageLength, pageLength = si.dwPageSize)
@@ -2625,7 +2625,7 @@ Messaging_WndProc(HWND hwnd, UINT msg, W
 #ifdef FEAT_AUTOCMD
 		else if (data->dwData == COPYDATA_REPLY)
 		{
-		    sprintf((char *)winstr, "0x%x", (unsigned)sender);
+		    sprintf((char *)winstr, PRINTF_HEX_LONG_U, (long_u)sender);
 		    apply_autocmds(EVENT_REMOTEREPLY, winstr, str,
 								TRUE, curbuf);
 		}
@@ -2834,13 +2834,13 @@ serverSendReply(name, reply)
 {
     HWND	target;
     COPYDATASTRUCT data;
-    int		n = 0;
+    long_u	n = 0;
 
     /* The "name" argument is a magic cookie obtained from expand("<client>").
      * It should be of the form 0xXXXXX - i.e. a C hex literal, which is the
      * value of the client's message window HWND.
      */
-    sscanf((char *)name, "%x", &n);
+    sscanf((char *)name, SCANF_HEX_LONG_U, &n);
     if (n == 0)
 	return -1;
 
@@ -3130,7 +3130,7 @@ int current_font_height = -12;		/* also 
  * calculation is for a vertical (height) size or a horizontal (width) one.
  */
     static int
-points_to_pixels(char_u *str, char_u **end, int vertical, int pprinter_dc)
+points_to_pixels(char_u *str, char_u **end, int vertical, long_i pprinter_dc)
 {
     int		pixels;
     int		points = 0;
@@ -3338,10 +3338,10 @@ get_logfont(
 	switch (*p++)
 	{
 	    case 'h':
-		lf->lfHeight = - points_to_pixels(p, &p, TRUE, (int)printer_dc);
+		lf->lfHeight = - points_to_pixels(p, &p, TRUE, (long_i)printer_dc);
 		break;
 	    case 'w':
-		lf->lfWidth = points_to_pixels(p, &p, FALSE, (int)printer_dc);
+		lf->lfWidth = points_to_pixels(p, &p, FALSE, (long_i)printer_dc);
 		break;
 	    case 'b':
 #ifndef MSWIN16_FASTTEXT
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -3602,7 +3602,7 @@ mch_call_shell(cmd, options)
 		*p++ = NUL;
 	    p = skipwhite(p);
 	}
-	if (i == 0)
+	if (argv == NULL)
 	{
 	    argv = (char **)alloc((unsigned)((argc + 4) * sizeof(char *)));
 	    if (argv == NULL)	    /* out of memory */
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -1288,7 +1288,7 @@ create_conin(void)
     g_hConIn =	CreateFile("CONIN$", GENERIC_READ|GENERIC_WRITE,
 			FILE_SHARE_READ|FILE_SHARE_WRITE,
 			(LPSECURITY_ATTRIBUTES) NULL,
-			OPEN_EXISTING, (DWORD)NULL, (HANDLE)NULL);
+			OPEN_EXISTING, 0, (HANDLE)NULL);
     did_create_conin = TRUE;
 }
 
--- a/src/proto/message.pro
+++ b/src/proto/message.pro
@@ -1,70 +1,71 @@
 /* message.c */
-extern int msg __ARGS((char_u *s));
-extern int verb_msg __ARGS((char_u *s));
-extern int msg_attr __ARGS((char_u *s, int attr));
-extern int msg_attr_keep __ARGS((char_u *s, int attr, int keep));
-extern char_u *msg_strtrunc __ARGS((char_u *s, int force));
-extern void trunc_string __ARGS((char_u *s, char_u *buf, int room));
-extern void reset_last_sourcing __ARGS((void));
-extern void msg_source __ARGS((int attr));
-extern int emsg __ARGS((char_u *s));
-extern int emsg2 __ARGS((char_u *s, char_u *a1));
-extern void emsg_invreg __ARGS((int name));
-extern char_u *msg_trunc_attr __ARGS((char_u *s, int force, int attr));
-extern char_u *msg_may_trunc __ARGS((int force, char_u *s));
-extern int delete_first_msg __ARGS((void));
-extern void ex_messages __ARGS((exarg_T *eap));
-extern void msg_end_prompt __ARGS((void));
-extern void wait_return __ARGS((int redraw));
-extern void set_keep_msg __ARGS((char_u *s, int attr));
-extern void set_keep_msg_from_hist __ARGS((void));
-extern void msg_start __ARGS((void));
-extern void msg_starthere __ARGS((void));
-extern void msg_putchar __ARGS((int c));
-extern void msg_putchar_attr __ARGS((int c, int attr));
-extern void msg_outnum __ARGS((long n));
-extern void msg_home_replace __ARGS((char_u *fname));
-extern void msg_home_replace_hl __ARGS((char_u *fname));
-extern int msg_outtrans __ARGS((char_u *str));
-extern int msg_outtrans_attr __ARGS((char_u *str, int attr));
-extern int msg_outtrans_len __ARGS((char_u *str, int len));
-extern char_u *msg_outtrans_one __ARGS((char_u *p, int attr));
-extern int msg_outtrans_len_attr __ARGS((char_u *msgstr, int len, int attr));
-extern void msg_make __ARGS((char_u *arg));
-extern int msg_outtrans_special __ARGS((char_u *strstart, int from));
-extern char_u *str2special __ARGS((char_u **sp, int from));
-extern void str2specialbuf __ARGS((char_u *sp, char_u *buf, int len));
-extern void msg_prt_line __ARGS((char_u *s, int list));
-extern void msg_puts __ARGS((char_u *s));
-extern void msg_puts_title __ARGS((char_u *s));
-extern void msg_puts_long_attr __ARGS((char_u *longstr, int attr));
-extern void msg_puts_long_len_attr __ARGS((char_u *longstr, int len, int attr));
-extern void msg_puts_attr __ARGS((char_u *s, int attr));
-extern void may_clear_sb_text __ARGS((void));
-extern void clear_sb_text __ARGS((void));
-extern void show_sb_text __ARGS((void));
-extern int msg_use_printf __ARGS((void));
-extern void mch_errmsg __ARGS((char *str));
-extern void mch_msg __ARGS((char *str));
-extern void msg_moremsg __ARGS((int full));
-extern void repeat_message __ARGS((void));
-extern void msg_clr_eos __ARGS((void));
-extern void msg_clr_eos_force __ARGS((void));
-extern void msg_clr_cmdline __ARGS((void));
-extern int msg_end __ARGS((void));
-extern void msg_check __ARGS((void));
-extern void verbose_enter __ARGS((void));
-extern void verbose_leave __ARGS((void));
-extern void verbose_enter_scroll __ARGS((void));
-extern void verbose_leave_scroll __ARGS((void));
-extern void verbose_stop __ARGS((void));
-extern int verbose_open __ARGS((void));
-extern void give_warning __ARGS((char_u *message, int hl));
-extern void msg_advance __ARGS((int col));
-extern int do_dialog __ARGS((int type, char_u *title, char_u *message, char_u *buttons, int dfltbutton, char_u *textfield));
-extern void display_confirm_msg __ARGS((void));
-extern int vim_dialog_yesno __ARGS((int type, char_u *title, char_u *message, int dflt));
-extern int vim_dialog_yesnocancel __ARGS((int type, char_u *title, char_u *message, int dflt));
-extern int vim_dialog_yesnoallcancel __ARGS((int type, char_u *title, char_u *message, int dflt));
-extern char_u *do_browse __ARGS((int flags, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter, buf_T *buf));
+int msg __ARGS((char_u *s));
+int verb_msg __ARGS((char_u *s));
+int msg_attr __ARGS((char_u *s, int attr));
+int msg_attr_keep __ARGS((char_u *s, int attr, int keep));
+char_u *msg_strtrunc __ARGS((char_u *s, int force));
+void trunc_string __ARGS((char_u *s, char_u *buf, int room));
+void reset_last_sourcing __ARGS((void));
+void msg_source __ARGS((int attr));
+int emsg_not_now __ARGS((void));
+int emsg __ARGS((char_u *s));
+int emsg2 __ARGS((char_u *s, char_u *a1));
+void emsg_invreg __ARGS((int name));
+char_u *msg_trunc_attr __ARGS((char_u *s, int force, int attr));
+char_u *msg_may_trunc __ARGS((int force, char_u *s));
+int delete_first_msg __ARGS((void));
+void ex_messages __ARGS((exarg_T *eap));
+void msg_end_prompt __ARGS((void));
+void wait_return __ARGS((int redraw));
+void set_keep_msg __ARGS((char_u *s, int attr));
+void set_keep_msg_from_hist __ARGS((void));
+void msg_start __ARGS((void));
+void msg_starthere __ARGS((void));
+void msg_putchar __ARGS((int c));
+void msg_putchar_attr __ARGS((int c, int attr));
+void msg_outnum __ARGS((long n));
+void msg_home_replace __ARGS((char_u *fname));
+void msg_home_replace_hl __ARGS((char_u *fname));
+int msg_outtrans __ARGS((char_u *str));
+int msg_outtrans_attr __ARGS((char_u *str, int attr));
+int msg_outtrans_len __ARGS((char_u *str, int len));
+char_u *msg_outtrans_one __ARGS((char_u *p, int attr));
+int msg_outtrans_len_attr __ARGS((char_u *msgstr, int len, int attr));
+void msg_make __ARGS((char_u *arg));
+int msg_outtrans_special __ARGS((char_u *strstart, int from));
+char_u *str2special __ARGS((char_u **sp, int from));
+void str2specialbuf __ARGS((char_u *sp, char_u *buf, int len));
+void msg_prt_line __ARGS((char_u *s, int list));
+void msg_puts __ARGS((char_u *s));
+void msg_puts_title __ARGS((char_u *s));
+void msg_puts_long_attr __ARGS((char_u *longstr, int attr));
+void msg_puts_long_len_attr __ARGS((char_u *longstr, int len, int attr));
+void msg_puts_attr __ARGS((char_u *s, int attr));
+void may_clear_sb_text __ARGS((void));
+void clear_sb_text __ARGS((void));
+void show_sb_text __ARGS((void));
+int msg_use_printf __ARGS((void));
+void mch_errmsg __ARGS((char *str));
+void mch_msg __ARGS((char *str));
+void msg_moremsg __ARGS((int full));
+void repeat_message __ARGS((void));
+void msg_clr_eos __ARGS((void));
+void msg_clr_eos_force __ARGS((void));
+void msg_clr_cmdline __ARGS((void));
+int msg_end __ARGS((void));
+void msg_check __ARGS((void));
+void verbose_enter __ARGS((void));
+void verbose_leave __ARGS((void));
+void verbose_enter_scroll __ARGS((void));
+void verbose_leave_scroll __ARGS((void));
+void verbose_stop __ARGS((void));
+int verbose_open __ARGS((void));
+void give_warning __ARGS((char_u *message, int hl));
+void msg_advance __ARGS((int col));
+int do_dialog __ARGS((int type, char_u *title, char_u *message, char_u *buttons, int dfltbutton, char_u *textfield));
+void display_confirm_msg __ARGS((void));
+int vim_dialog_yesno __ARGS((int type, char_u *title, char_u *message, int dflt));
+int vim_dialog_yesnocancel __ARGS((int type, char_u *title, char_u *message, int dflt));
+int vim_dialog_yesnoallcancel __ARGS((int type, char_u *title, char_u *message, int dflt));
+char_u *do_browse __ARGS((int flags, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter, buf_T *buf));
 /* vim: set ft=c : */
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -7054,7 +7054,7 @@ reg_submatch(no)
     int		round;
     linenr_T	lnum;
 
-    if (!can_f_submatch)
+    if (!can_f_submatch || no < 0)
 	return NULL;
 
     if (submatch_match == NULL)
@@ -7112,10 +7112,10 @@ reg_submatch(no)
 		++len;
 	    }
 
-	    if (round == 1)
+	    if (retval == NULL)
 	    {
 		retval = lalloc((long_u)len, TRUE);
-		if (s == NULL)
+		if (retval == NULL)
 		    return NULL;
 	    }
 	}
--- a/src/spell.c
+++ b/src/spell.c
@@ -5102,7 +5102,10 @@ spell_read_aff(spin, fname)
      */
     aff = (afffile_T *)getroom(spin, sizeof(afffile_T), TRUE);
     if (aff == NULL)
+    {
+	fclose(fd);
 	return NULL;
+    }
     hash_init(&aff->af_pref);
     hash_init(&aff->af_suff);
     hash_init(&aff->af_comp);
@@ -7361,7 +7364,8 @@ tree_add_word(spin, word, root, flags, r
 
 		/* Link the new node in the list, there will be one ref. */
 		np->wn_refs = 1;
-		*copyprev = np;
+		if (copyprev != NULL)
+		    *copyprev = np;
 		copyprev = &np->wn_sibling;
 
 		/* Let "node" point to the head of the copied list. */
@@ -15464,7 +15468,7 @@ spell_dump_compl(buf, pat, ic, dir, dump
 	if (pat != NULL && slang->sl_pbyts == NULL)
 	    patlen = (int)STRLEN(pat);
 	else
-	    patlen = 0;
+	    patlen = -1;
 
 	/* round 1: case-folded tree
 	 * round 2: keep-case tree */
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1371,7 +1371,8 @@ store_current_state(sp)
 		for (p = syn_buf->b_sst_first; p != NULL; p = p->sst_next)
 		    if (p->sst_next == sp)
 			break;
-		p->sst_next = sp->sst_next;
+		if (p != NULL)	/* just in case */
+		    p->sst_next = sp->sst_next;
 	    }
 	    syn_stack_free_entry(syn_buf, sp);
 	    sp = NULL;
--- a/src/testdir/test61.in
+++ b/src/testdir/test61.in
@@ -43,6 +43,13 @@ Ac:set ul=100
 :.w >>test.out
 :later 1h
 :.w >>test.out
+:"
+:" test undojoin
+Goaaaa:set ul=100
+obbbbu:.w >>test.out
+obbbb:set ul=100
+:undojoin
+occccu:.w >>test.out
 :qa!
 ENDTEST
 
--- a/src/testdir/test61.ok
+++ b/src/testdir/test61.ok
@@ -20,3 +20,5 @@ 123456
 123456789
 123456
 123456abc
+aaaa
+aaaa
--- a/src/version.h
+++ b/src/version.h
@@ -35,6 +35,6 @@
  */
 #define VIM_VERSION_NODOT	"vim70e"
 #define VIM_VERSION_SHORT	"7.0e"
-#define VIM_VERSION_MEDIUM	"7.0e05 BETA"
-#define VIM_VERSION_LONG	"VIM - Vi IMproved 7.0e05 BETA (2006 Apr 21)"
-#define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 7.0e05 BETA (2006 Apr 21, compiled "
+#define VIM_VERSION_MEDIUM	"7.0e06 BETA"
+#define VIM_VERSION_LONG	"VIM - Vi IMproved 7.0e06 BETA (2006 Apr 22)"
+#define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 7.0e06 BETA (2006 Apr 22, compiled "
--- a/src/vim.h
+++ b/src/vim.h
@@ -342,14 +342,19 @@
 typedef unsigned char	char_u;
 typedef unsigned short	short_u;
 typedef unsigned int	int_u;
-/* Make sure long_u is big enough to hold a pointer.  On Win64 longs are 32
- * bit and pointers 64 bit. */
+/* Make sure long_u is big enough to hold a pointer.
+ * On Win64 longs are 32 bit and pointers 64 bit.
+ * For printf() and scanf() we need to take care of long_u specifically. */
 #ifdef _WIN64
 typedef unsigned __int64 long_u;
 typedef		 __int64 long_i;
+# define SCANF_HEX_LONG_U  "%Ix"
+# define PRINTF_HEX_LONG_U "0x%Ix"
 #else
 typedef unsigned long	long_u;
 typedef	         long	long_i;
+# define SCANF_HEX_LONG_U  "%lx"
+# define PRINTF_HEX_LONG_U "0x%lx"
 #endif
 
 /*
@@ -1382,6 +1387,7 @@ typedef enum
 #define EMSG2(s, p)		    emsg2((char_u *)(s), (char_u *)(p))
 #define EMSG3(s, p, q)		    emsg3((char_u *)(s), (char_u *)(p), (char_u *)(q))
 #define EMSGN(s, n)		    emsgn((char_u *)(s), (long)(n))
+#define EMSGU(s, n)		    emsgu((char_u *)(s), (long_u)(n))
 #define OUT_STR(s)		    out_str((char_u *)(s))
 #define OUT_STR_NF(s)		    out_str_nf((char_u *)(s))
 #define MSG_PUTS(s)		    msg_puts((char_u *)(s))
--- a/src/window.c
+++ b/src/window.c
@@ -5077,7 +5077,7 @@ win_drag_vsep_line(dragwin, offset)
     int		n;
 
     fr = dragwin->w_frame;
-    if (fr == topframe)		/* only one window (cannot happe?) */
+    if (fr == topframe)		/* only one window (cannot happen?) */
 	return;
     curfr = fr;
     fr = fr->fr_parent;