changeset 39:410fa1a31baf v7.0023

updated for version 7.0023
author vimboss
date Sun, 19 Dec 2004 22:46:22 +0000
parents c524f99c7925
children f1d2a58883b9
files runtime/doc/autocmd.txt runtime/doc/change.txt runtime/doc/editing.txt runtime/doc/intro.txt runtime/doc/mbyte.txt runtime/doc/options.txt runtime/doc/os_mac.txt runtime/doc/pattern.txt runtime/doc/tags runtime/doc/todo.txt runtime/doc/version7.txt runtime/filetype.vim runtime/ftplugin/make.vim runtime/makemenu.vim runtime/syntax/2html.vim runtime/syntax/iss.vim runtime/syntax/netrc.vim runtime/syntax/sudoers.vim src/INSTALLpc.txt src/Make_bc5.mak src/Make_cyg.mak src/Make_ming.mak src/Make_mvc.mak src/Make_vms.mms src/auto/configure src/buffer.c src/charset.c src/configure.in src/eval.c src/ex_cmds.c src/ex_cmds2.c src/ex_docmd.c src/ex_getln.c src/fileio.c src/fold.c src/getchar.c src/gui.c src/gui_gtk.c src/gui_gtk_x11.c src/gui_kde.cc src/gui_w32.c src/gui_x11.c src/if_xcmdsrv.c src/macros.h src/main.c src/mark.c src/mbyte.c src/memline.c src/menu.c src/message.c src/misc1.c src/misc2.c src/ops.c src/option.c src/option.h src/os_amiga.c src/os_mac.c src/os_msdos.c src/os_mswin.c src/os_unix.c src/os_win32.c src/proto/ex_cmds2.pro src/proto/main.pro src/proto/memline.pro src/proto/misc1.pro src/proto/misc2.pro src/proto/option.pro src/proto/os_mswin.pro src/regexp.c src/screen.c src/tag.c src/term.c src/ui.c src/version.h src/vim.h src/vim.rc
diffstat 76 files changed, 2398 insertions(+), 1392 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -1,4 +1,4 @@
-*autocmd.txt*   For Vim version 7.0aa.  Last change: 2004 Sep 17
+*autocmd.txt*   For Vim version 7.0aa.  Last change: 2004 Dec 16
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -230,8 +230,10 @@ BufWritePost			After writing the whole b
 							*BufWriteCmd*
 BufWriteCmd			Before writing the whole buffer to a file.
 				Should do the writing of the file and reset
-				'modified' if successful.  The buffer contents
-				should not be changed.  |Cmd-event|
+				'modified' if successful, unless '+' is in
+				'cpo' and writing to another file |cpo-+|.
+				The buffer contents should not be changed.
+				|Cmd-event|
 							*FileWritePre*
 FileWritePre			Before writing to a file, when not writing the
 				whole buffer.  Use the '[ and '] marks for the
--- a/runtime/doc/change.txt
+++ b/runtime/doc/change.txt
@@ -1,4 +1,4 @@
-*change.txt*    For Vim version 7.0aa.  Last change: 2004 Nov 30
+*change.txt*    For Vim version 7.0aa.  Last change: 2004 Dec 17
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -351,7 +351,8 @@ The CTRL-A and CTRL-X commands work for 
 octal and hexadecimal numbers and alphabetic characters.  This depends on the
 'nrformats' option.
 - When 'nrformats' includes "octal", Vim considers numbers starting with a '0'
-  to be octal.  Other numbers are decimal and may have a preceding minus sign.
+  to be octal, unless the number includes a '8' or '9'.  Other numbers are
+  decimal and may have a preceding minus sign.
   If the cursor is on a number, the commands apply to that number; otherwise
   Vim uses the number to the right of the cursor.
 - When 'nrformats' includes "hex", Vim assumes numbers starting with '0x' or
@@ -365,9 +366,13 @@ octal and hexadecimal numbers and alphab
 For numbers with leading zeros (including all octal and hexadecimal numbers),
 Vim preserves the number of characters in the number when possible.  CTRL-A on
 "0077" results in "0100", CTRL-X on "0x100" results in "0x0ff".
+There is one exception: When a number that starts with a zero is found not to
+be octal (it contains a '8' or '9'), but 'nrformats' does include "octal",
+leading zeros are removed to avoid that the result may be recognized as an
+octal number.
 
 Note that when 'nrformats' includes "octal", decimal numbers with leading
-zeros are impossible because they are indistinguishable from octal numbers.
+zeros cause mistakes, because they can be confused with octal numbers.
 
 The CTRL-A command is very useful in a macro.  Example: Use the following
 steps to make a numbered list.
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -1,4 +1,4 @@
-*editing.txt*   For Vim version 7.0aa.  Last change: 2004 Oct 12
+*editing.txt*   For Vim version 7.0aa.  Last change: 2004 Dec 16
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -8,21 +8,22 @@ Editing files						*edit-files*
 
 1.  Introduction		|edit-intro|
 2.  Editing a file		|edit-a-file|
-3.  Dialogs			|edit-dialogs|
-4.  The current directory	|current-directory|
-5.  The argument list		|argument-list|
-6.  Writing			|writing|
-7.  Writing and quitting	|write-quit|
+3.  The argument list		|argument-list|
+4.  Writing			|writing|
+5.  Writing and quitting	|write-quit|
+6.  Dialogs			|edit-dialogs|
+7.  The current directory	|current-directory|
 8.  Editing binary files	|edit-binary|
 9.  Encryption			|encryption|
 10. Timestamps			|timestamps|
+11. File Searching		|file-searching|
 
 ==============================================================================
 1. Introduction						*edit-intro*
 
 Editing a file with Vim means:
 
-1. reading the file into the internal buffer
+1. reading the file into a buffer
 2. changing the buffer with editor commands
 3. writing the buffer into a file
 
@@ -30,12 +31,13 @@ 3. writing the buffer into a file
 As long as you don't write the buffer, the original file remains unchanged.
 If you start editing a file (read a file into the buffer), the file name is
 remembered as the "current file name".  This is also known as the name of the
-current buffer.
+current buffer.  It can be used with "%" on the command line |:_%|.
 
 							*alternate-file*
 If there already was a current file name, then that one becomes the alternate
-file name.  It can later be used with "#" on the command line |:_#|.  However,
-the alternate file name is not changed when |:keepalt| is used.
+file name.  It can be used with "#" on the command line |:_#| and you can use
+the |CTRL-^| command to toggle between the current and the alternate file.
+However, the alternate file name is not changed when |:keepalt| is used.
 
 							*:keepalt* *:keepa*
 :keepalt {cmd}		Execute {cmd} while keeping the current alternate file
@@ -43,12 +45,13 @@ the alternate file name is not changed w
 			with a function) may still set the alternate file
 			name.  {not in Vi}
 
-All file names are remembered in the file list.  When you enter a file name,
+All file names are remembered in the buffer list.  When you enter a file name,
 for editing (e.g., with ":e filename") or writing (e.g., with (:w file name"),
-the file name is added to the list.  You can use this list to remember which
-files you edited and to quickly switch from one file to another with the
-CTRL-^ command (e.g., to copy text).  First type the number of the file and
-then hit CTRL-^.  {Vi: only one alternate file name}
+the file name is added to the list.  You can use the buffer list to remember
+which files you edited and to quickly switch from one file to another (e.g.,
+to copy text) with the |CTRL-^| command.  First type the number of the file
+and then hit CTRL-^.  {Vi: only one alternate file name is remembered}
+
 
 CTRL-G		or				*CTRL-G* *:f* *:fi* *:file*
 :f[ile]			Prints the current file name (as typed), the
@@ -215,11 +218,10 @@ 2. Editing a file					*edit-a-file*
 			{Vi: no ++opt}
 
 :e[dit] [++opt] [+cmd] #[count]
-			Edit the [count]th alternate file name (as shown by
-			:files).  This command does the same as
-			[count] CTRL-^.  But ":e #" doesn't work if the
-			alternate buffer doesn't have a file name, while
-			CTRL-^ still works then.
+			Edit the [count]th buffer (as shown by |:files|).
+			This command does the same as [count] CTRL-^.  But ":e
+			#" doesn't work if the alternate buffer doesn't have a
+			file name, while CTRL-^ still works then.
 			Also see |++opt| and |+cmd|.
 			{Vi: no ++opt}
 
@@ -268,10 +270,10 @@ 2. Editing a file					*edit-a-file*
 			'readonly' option for this buffer.  {not in Vi}
 
 							*CTRL-^* *CTRL-6*
-[count]CTRL-^		Edit [count]th alternate file (equivalent to ":e
-			#[count]").  Without count this gets you to the
-			previously edited file.  This is a quick way to toggle
-			between two (or more) files.
+CTRL-^			Edit the alternate file (equivalent to ":e #").
+			Mostly the alternate file is the previously edited
+			file.  This is a quick way to toggle between two
+			files.
 			If the 'autowrite' or 'autowriteall' option is on and
 			the buffer was changed, write it.
 			Mostly the ^ character is positioned on the 6 key,
@@ -279,6 +281,12 @@ 2. Editing a file					*edit-a-file*
 			But on some non-US keyboards CTRL-^ is produced in
 			another way.
 
+{count}CTRL-^		Edit [count]th file in the buffer list (equivalent to
+			":e #[count]").  This is a quick way to switch between
+			files.
+			See |CTRL-^| above for further details.
+			{not in Vi}
+
 [count]]f						*]f* *[f*
 [count][f		Same as "gf".  Deprecated.
 
@@ -335,11 +343,12 @@ current file name.
 Note for systems other than Unix and MS-DOS: When using a command that
 accepts a single file name (like ":edit file") spaces in the file name are
 allowed, but trailing spaces are ignored.  This is useful on systems that
-allow file names with embedded spaces (like the Amiga).  Example: The command
-":e   Long File Name " will edit the file "Long File Name".  When using a
-command that accepts more than one file name (like ":next file1 file2")
-embedded spaces must be escaped with a backslash.
+allow file names with embedded spaces (like MS-Windows and the Amiga).
+Example: The command ":e   Long File Name " will edit the file "Long File
+Name".  When using a command that accepts more than one file name (like ":next
+file1 file2") embedded spaces must be escaped with a backslash.
 
+							*wildcard*
 Wildcards in {file} are expanded.  Which wildcards are supported depends on
 the system.  These are the common ones:
 	*	matches anything, including nothing
@@ -351,7 +360,8 @@ as a wildcard when "[" is in the 'isfnam
 is to use "path\[[]abc]".  Then the file "path[abc]" literally.
 
 					*backtick-expansion* *`-expansion*
-On Unix you can also use backticks in the file name, for example: >
+On Unix and a few other systems you can also use backticks in the file name,
+for example: >
 	:e `find . -name ver\\*.c -print`
 The backslashes before the star are required to prevent "ver*.c" to be
 expanded by the shell before executing the find program.
@@ -360,12 +370,11 @@ backticks must be around the whole item.
 directly before the first or just after the last backtick.
 
 							*`=*
-You can have the backticks expanded as a Vim expression, instead of
-an external command, by using the syntax `={expr}` e.g.: >
-	:let foo='bar'
-	:e `=foo . ".c" `
-This will edit "bar.c".  The expression can contain just about anything, thus
-this can also be used to avoid the special meaning of '"', '|', '%' and '#'.
+You can have the backticks expanded as a Vim expression, instead of an
+external command, by using the syntax `={expr}` e.g.: >
+	:e `=tempname()`
+The expression can contain just about anything, thus this can also be used to
+avoid the special meaning of '"', '|', '%' and '#'.
 
 							*++opt* *[++opt]*
 The [++opt] argument can be used to force the value of 'fileformat' or
@@ -470,241 +479,17 @@ You can encrypt files that are written b
 provides some security against others reading your files. |encryption|
 
 
-File Searching						*file-searching*
-
-{not available when compiled without the |+path_extra| feature}
-
-The file searching is currently used for the 'path', 'cdpath' and 'tags'
-options.  There are three different types of searching:
-
-1) Downward search:
-   Downward search uses the wildcards '*', '**' and possibly others
-   supported by your operating system. '*' and '**' are handled inside Vim, so
-   they work on all operating systems.
-
-   The usage of '*' is quite simple: It matches 0 or more characters.
-
-   '**' is more sophisticated:
-      - It ONLY matches directories.
-      - It matches up to 30  directories deep, so you can use it to search an
-	entire directory tree
-      - The maximum number of levels matched can be given by appending a number
-	to '**'.
-	Thus '/usr/**2' can match: >
-		/usr
-		/usr/include
-		/usr/include/sys
-		/usr/include/g++
-		/usr/lib
-		/usr/lib/X11
-		....
-<	It does NOT match '/usr/include/g++/std' as this would be three
-	levels.
-	The allowed number range is 0 ('**0' is removed) to 255.
-	If the given number is smaller than 0 it defaults to 30, if it's
-	bigger than 255 it defaults to 255.
-      - '**' can only be at the end of the path or be followed by a path
-	separator or by a number and a path separator.
-
-   You can combine '*' and '**' in any order: >
-	/usr/**/sys/*
-	/usr/*/sys/**
-	/usr/**2/sys/*
-
-2) Upward search:
-   Here you can give a directory and then search the directory tree upward for
-   a file. You could give stop-directories to limit the upward search. The
-   stop-directories are appended to the path (for the 'path' option) or to
-   the filename (for the 'tags' option) with a ';'. If you want several
-   stop-directories separate them with ';'. If you want no stop-directory
-   ("search upward till the root directory) just use ';'. >
-	/usr/include/sys;/usr
-<   will search in: >
-	   /usr/include/sys
-	   /usr/include
-	   /usr
-<
-   If you use a relative path the upward search is started in Vim's current
-   directory or in the directory of the current file (if the relative path
-   starts with './' and 'd' is not included in 'cpoptions').
-
-   If Vim's current path is /u/user_x/work/release and you do >
-	:set path=include;/u/user_x
-<  and then search for a file with |gf| the file is searched in: >
-	/u/user_x/work/release/include
-	/u/user_x/work/include
-	/u/user_x/include
-
-3) Combined up/downward search
-   If Vim's current path is /u/user_x/work/release and you do >
-	set path=**;/u/user_x
-<  and then search for a file with |gf| the file is searched in: >
-	/u/user_x/work/release/**
-	/u/user_x/work/**
-	/u/user_x/**
-<
-   BE CAREFUL! This might consume a lot of time, as the search of
-   '/u/user_x/**' includes '/u/user_x/work/**' and
-   '/u/user_x/work/release/**'.  So '/u/user_x/work/release/**' is searched
-   three and '/u/user_x/work/**' is searched two times.
-
-   In the above example you might want to set path to: >
-	:set path=**,/u/user_x/**
-<   This searches: >
-	/u/user_x/work/release/**
-	/u/user_x/**
-<   This searches the same directories, but in a different order.
-
 ==============================================================================
-3. Dialogs						*edit-dialogs*
-
-							*:confirm* *:conf*
-:conf[irm] {command}	Execute {command}, and use a dialog when an
-			operation has to be confirmed.  Can be used on the
-			":q", ":qa" and ":w" commands (the latter to over-ride
-			a read-only setting).
-
-Examples: >
-  :confirm w foo
-<	Will ask for confirmation when "foo" already exists. >
-  :confirm q
-<	Will ask for confirmation when there are changes. >
-  :confirm qa
-<	If any modified, unsaved buffers exist, you will be prompted to save
-	or abandon each one.  There are also choices to "save all" or "abandon
-	all".
-
-If you want to always use ":confirm", set the 'confirm' option.
-
-			*:browse* *:bro* *E338* *E614* *E615* *E616* *E578*
-:bro[wse] {command}	Open a file selection dialog for an argument to
-			{command}.  At present this works for |:e|, |:w|,
-			|:r|, |:saveas|, |:sp|, |:mkexrc|, |:mkvimrc| and
-			|:mksession|.
-			{only in Win32, Athena, Motif, GTK and Mac GUI}
-			When ":browse" is not possible you get an error
-			message.  If the |+browse| feature is missing or the
-			{command} doesn't support browsing, the {command} is
-			executed without a dialog.
-			":browse set" works like |:options|.
-
-The syntax is best shown via some examples: >
-	:browse e $vim/foo
-<		Open the browser in the $vim/foo directory, and edit the
-		file chosen. >
-	:browse e
-<		Open the browser in the directory specified with 'browsedir',
-		and edit the file chosen. >
-	:browse w
-<		Open the browser in the directory of the current buffer,
-		with the current buffer filename as default, and save the
-		buffer under the filename chosen. >
-	:browse w C:/bar
-<		Open the browser in the C:/bar directory, with the current
-		buffer filename as default, and save the buffer under the
-		filename chosen.
-Also see the |'browsedir'| option.
-For versions of Vim where browsing is not supported, the command is executed
-unmodified.
-
-							*browsefilter*
-For MS Windows, you can modify the filters that are used in the browse dialog.
-By setting the g:browsefilter or b:browsefilter variables, you can change the
-filters globally or locally to the buffer.  The variable is set to a string in
-the format "{filter label}\t{pattern};{pattern}\n" where {filter label} is the
-text that appears in the "Files of Type" comboBox, and {pattern} is the
-pattern which filters the filenames.  Several patterns can be given, separated
-by ';'.
-
-For Motif the same format is used, but only the very first pattern is actually
-used (Motif only offers one pattern, but you can edit it).
-
-For example, to have only Vim files in the dialog, you could use the following
-command: >
-
-     let g:browsefilter="Vim Scripts\t*.vim\nVim Startup Files\t*vimrc\n"
-
-You can override the filter setting on a per-buffer basis by setting the
-b:browsefilter variable.  You would most likely set b:browsefilter in a
-filetype plugin, so that the browse dialog would contain entries related to
-the type of file you are currently editing.  Disadvantage: This makes it
-difficult to start editing a file of a different type.  To overcome this, you
-may want to add "All Files\t*.*\n" as the final filter, so that the user can
-still access any desired file.
-
-==============================================================================
-4. The current directory				*current-directory*
-
-You may use the |:cd| and |:lcd| commands to change to another directory, so
-you will not have to type that directory name in front of the file names.  It
-also makes a difference for executing external commands, e.g. ":!ls".
-
-							*:cd* *E472*
-:cd			On non-Unix systems: Print the current directory
-			name.  On Unix systems: Change the current directory
-			to the home directory.  Use |:pwd| to print the
-			current directory on all systems.
-
-:cd {path}		Change the current directory to {path}.
-			If {path} is relative, it is searched for in the
-			directories listed in |'cdpath'|.
-			Does not change the meaning of an already opened file,
-			because its full path name is remembered.  Files from
-			the |arglist| may change though!
-			On MS-DOS this also changes the active drive.
-			To change to the directory of the current file: >
-				:cd %:h
-<
-							*:cd-* *E186*
-:cd -			Change to the previous current directory (before the
-			previous ":cd {path}" command). {not in Vi}
-
-							*:chd* *:chdir*
-:chd[ir] [path]		Same as |:cd|.
-
-							*:lc* *:lcd*
-:lc[d] {path}		Like |:cd|, but only set the current directory for the
-			current window.  The current directory for other
-			windows is not changed. {not in Vi}
-
-							*:lch* *:lchdir*
-:lch[dir]		Same as |:lcd|. {not in Vi}
-
-							*:pw* *:pwd* *E187*
-:pw[d]			Print the current directory name.  {Vi: no pwd}
-			Also see |getcwd()|.
-
-So long as no |:lcd| command has been used, all windows share the same current
-directory.  Using a command to jump to another window doesn't change anything
-for the current directory.
-When a |:lcd| command has been used for a window, the specified directory
-becomes the current directory for that window.  Windows where the |:lcd|
-command has not been used stick to the global current directory.  When jumping
-to another window the current directory will become the last specified local
-current directory.  If none was specified, the global current directory is
-used.
-When a |:cd| command is used, the current window will lose his local current
-directory and will use the global current directory from now on.
-
-After using |:cd| the full path name will be used for reading and writing
-files.  On some networked file systems this may cause problems.  The result of
-using the full path name is that the file names currently in use will remain
-referring to the same file.  Example: If you have a file a:test and a
-directory a:vim the commands ":e test" ":cd vim" ":w" will overwrite the file
-a:test and not write a:vim/test.  But if you do ":w test" the file a:vim/test
-will be written, because you gave a new file name and did not refer to a
-filename before the ":cd".
-
-==============================================================================
-5. The argument list				*argument-list* *arglist*
+3. The argument list				*argument-list* *arglist*
 
 If you give more than one file name when starting Vim, this list is remembered
 as the argument list.  You can jump to each file in this list.
 
 Do not confuse this with the buffer list, which you can see with the
 |:buffers| command.  The argument list was already present in Vi, the buffer
-list is new in Vim.  A file name in the argument list will also be present in
-the buffer list (unless it was deleted with ":bdel").
+list is new in Vim.  Every file name in the argument list will also be present
+in the buffer list (unless it was deleted with |:bdel| or |:bwipe|).  But it's
+common that names in the buffer list are not in the argument list.
 
 This subject is introduced in section |07.2| of the user manual.
 
@@ -894,11 +679,17 @@ positioned at the first non-blank in the
 is used.  If there is no last known cursor position the cursor will be in the
 first line (the last line in Ex mode).
 
+							*{arglist}*
 The wildcards in the argument list are expanded and the file names are sorted.
 Thus you can use the command "vim *.c" to edit all the C files.  From within
-Vim the command ":n *.c" does the same.  On Unix you can also use backticks,
-for example: >
-	:n `find . -name \\*.c -print`
+Vim the command ":n *.c" does the same.
+
+White space is used to separate file names.  Put a backslash before a space or
+Tab to include it in a file name.  E.g., to edit the single file "foo bar": >
+	:next foo\ bar
+
+On Unix and a few other systems you can also use backticks, for example: >
+	:next `find . -name \\*.c -print`
 The backslashes before the star are required to prevent "*.c" to be expanded
 by the shell before executing the find program.
 
@@ -988,7 +779,7 @@ flag is used for the ":substitute" comma
 "my_foo" isn't used.  ":update" writes the file only if changes were made.
 
 ==============================================================================
-6. Writing					*writing* *save-file*
+4. Writing					*writing* *save-file*
 
 Note: When the 'write' option is off, you are not able to write any file.
 
@@ -1173,7 +964,7 @@ For MS-DOS and MS-Windows the device is 
 The names can be in upper- or lowercase.
 
 ==============================================================================
-7. Writing and quitting					*write-quit*
+5. Writing and quitting					*write-quit*
 
 							*:q* *:quit*
 :q[uit]			Quit the current window.  Quit Vim if this is the last
@@ -1266,6 +1057,146 @@ MULTIPLE WINDOWS AND BUFFERS				*window-
 		{not in Vi}
 
 ==============================================================================
+6. Dialogs						*edit-dialogs*
+
+							*:confirm* *:conf*
+:conf[irm] {command}	Execute {command}, and use a dialog when an
+			operation has to be confirmed.  Can be used on the
+			":q", ":qa" and ":w" commands (the latter to over-ride
+			a read-only setting).
+
+Examples: >
+  :confirm w foo
+<	Will ask for confirmation when "foo" already exists. >
+  :confirm q
+<	Will ask for confirmation when there are changes. >
+  :confirm qa
+<	If any modified, unsaved buffers exist, you will be prompted to save
+	or abandon each one.  There are also choices to "save all" or "abandon
+	all".
+
+If you want to always use ":confirm", set the 'confirm' option.
+
+			*:browse* *:bro* *E338* *E614* *E615* *E616* *E578*
+:bro[wse] {command}	Open a file selection dialog for an argument to
+			{command}.  At present this works for |:e|, |:w|,
+			|:r|, |:saveas|, |:sp|, |:mkexrc|, |:mkvimrc| and
+			|:mksession|.
+			{only in Win32, Athena, Motif, GTK and Mac GUI}
+			When ":browse" is not possible you get an error
+			message.  If the |+browse| feature is missing or the
+			{command} doesn't support browsing, the {command} is
+			executed without a dialog.
+			":browse set" works like |:options|.
+
+The syntax is best shown via some examples: >
+	:browse e $vim/foo
+<		Open the browser in the $vim/foo directory, and edit the
+		file chosen. >
+	:browse e
+<		Open the browser in the directory specified with 'browsedir',
+		and edit the file chosen. >
+	:browse w
+<		Open the browser in the directory of the current buffer,
+		with the current buffer filename as default, and save the
+		buffer under the filename chosen. >
+	:browse w C:/bar
+<		Open the browser in the C:/bar directory, with the current
+		buffer filename as default, and save the buffer under the
+		filename chosen.
+Also see the |'browsedir'| option.
+For versions of Vim where browsing is not supported, the command is executed
+unmodified.
+
+							*browsefilter*
+For MS Windows, you can modify the filters that are used in the browse dialog.
+By setting the g:browsefilter or b:browsefilter variables, you can change the
+filters globally or locally to the buffer.  The variable is set to a string in
+the format "{filter label}\t{pattern};{pattern}\n" where {filter label} is the
+text that appears in the "Files of Type" comboBox, and {pattern} is the
+pattern which filters the filenames.  Several patterns can be given, separated
+by ';'.
+
+For Motif the same format is used, but only the very first pattern is actually
+used (Motif only offers one pattern, but you can edit it).
+
+For example, to have only Vim files in the dialog, you could use the following
+command: >
+
+     let g:browsefilter="Vim Scripts\t*.vim\nVim Startup Files\t*vimrc\n"
+
+You can override the filter setting on a per-buffer basis by setting the
+b:browsefilter variable.  You would most likely set b:browsefilter in a
+filetype plugin, so that the browse dialog would contain entries related to
+the type of file you are currently editing.  Disadvantage: This makes it
+difficult to start editing a file of a different type.  To overcome this, you
+may want to add "All Files\t*.*\n" as the final filter, so that the user can
+still access any desired file.
+
+==============================================================================
+7. The current directory				*current-directory*
+
+You may use the |:cd| and |:lcd| commands to change to another directory, so
+you will not have to type that directory name in front of the file names.  It
+also makes a difference for executing external commands, e.g. ":!ls".
+
+							*:cd* *E472*
+:cd			On non-Unix systems: Print the current directory
+			name.  On Unix systems: Change the current directory
+			to the home directory.  Use |:pwd| to print the
+			current directory on all systems.
+
+:cd {path}		Change the current directory to {path}.
+			If {path} is relative, it is searched for in the
+			directories listed in |'cdpath'|.
+			Does not change the meaning of an already opened file,
+			because its full path name is remembered.  Files from
+			the |arglist| may change though!
+			On MS-DOS this also changes the active drive.
+			To change to the directory of the current file: >
+				:cd %:h
+<
+							*:cd-* *E186*
+:cd -			Change to the previous current directory (before the
+			previous ":cd {path}" command). {not in Vi}
+
+							*:chd* *:chdir*
+:chd[ir] [path]		Same as |:cd|.
+
+							*:lc* *:lcd*
+:lc[d] {path}		Like |:cd|, but only set the current directory for the
+			current window.  The current directory for other
+			windows is not changed. {not in Vi}
+
+							*:lch* *:lchdir*
+:lch[dir]		Same as |:lcd|. {not in Vi}
+
+							*:pw* *:pwd* *E187*
+:pw[d]			Print the current directory name.  {Vi: no pwd}
+			Also see |getcwd()|.
+
+So long as no |:lcd| command has been used, all windows share the same current
+directory.  Using a command to jump to another window doesn't change anything
+for the current directory.
+When a |:lcd| command has been used for a window, the specified directory
+becomes the current directory for that window.  Windows where the |:lcd|
+command has not been used stick to the global current directory.  When jumping
+to another window the current directory will become the last specified local
+current directory.  If none was specified, the global current directory is
+used.
+When a |:cd| command is used, the current window will lose his local current
+directory and will use the global current directory from now on.
+
+After using |:cd| the full path name will be used for reading and writing
+files.  On some networked file systems this may cause problems.  The result of
+using the full path name is that the file names currently in use will remain
+referring to the same file.  Example: If you have a file a:test and a
+directory a:vim the commands ":e test" ":cd vim" ":w" will overwrite the file
+a:test and not write a:vim/test.  But if you do ":w test" the file a:vim/test
+will be written, because you gave a new file name and did not refer to a
+filename before the ":cd".
+
+==============================================================================
 8. Editing binary files					*edit-binary*
 
 Although Vim was made to edit text files, it is possible to edit binary
@@ -1454,5 +1385,91 @@ It is also possible that you modified th
 session or with another command (e.g., a filter command).  Then you will know
 which version of the file you want to keep.
 
+==============================================================================
+11. File Searching					*file-searching*
+
+{not available when compiled without the |+path_extra| feature}
+
+The file searching is currently used for the 'path', 'cdpath' and 'tags'
+options.  There are three different types of searching:
+
+1) Downward search:
+   Downward search uses the wildcards '*', '**' and possibly others
+   supported by your operating system. '*' and '**' are handled inside Vim, so
+   they work on all operating systems.
+
+   The usage of '*' is quite simple: It matches 0 or more characters.
+
+   '**' is more sophisticated:
+      - It ONLY matches directories.
+      - It matches up to 30  directories deep, so you can use it to search an
+	entire directory tree
+      - The maximum number of levels matched can be given by appending a number
+	to '**'.
+	Thus '/usr/**2' can match: >
+		/usr
+		/usr/include
+		/usr/include/sys
+		/usr/include/g++
+		/usr/lib
+		/usr/lib/X11
+		....
+<	It does NOT match '/usr/include/g++/std' as this would be three
+	levels.
+	The allowed number range is 0 ('**0' is removed) to 255.
+	If the given number is smaller than 0 it defaults to 30, if it's
+	bigger than 255 it defaults to 255.
+      - '**' can only be at the end of the path or be followed by a path
+	separator or by a number and a path separator.
+
+   You can combine '*' and '**' in any order: >
+	/usr/**/sys/*
+	/usr/*/sys/**
+	/usr/**2/sys/*
+
+2) Upward search:
+   Here you can give a directory and then search the directory tree upward for
+   a file. You could give stop-directories to limit the upward search. The
+   stop-directories are appended to the path (for the 'path' option) or to
+   the filename (for the 'tags' option) with a ';'. If you want several
+   stop-directories separate them with ';'. If you want no stop-directory
+   ("search upward till the root directory) just use ';'. >
+	/usr/include/sys;/usr
+<   will search in: >
+	   /usr/include/sys
+	   /usr/include
+	   /usr
+<
+   If you use a relative path the upward search is started in Vim's current
+   directory or in the directory of the current file (if the relative path
+   starts with './' and 'd' is not included in 'cpoptions').
+
+   If Vim's current path is /u/user_x/work/release and you do >
+	:set path=include;/u/user_x
+<  and then search for a file with |gf| the file is searched in: >
+	/u/user_x/work/release/include
+	/u/user_x/work/include
+	/u/user_x/include
+
+3) Combined up/downward search
+   If Vim's current path is /u/user_x/work/release and you do >
+	set path=**;/u/user_x
+<  and then search for a file with |gf| the file is searched in: >
+	/u/user_x/work/release/**
+	/u/user_x/work/**
+	/u/user_x/**
+<
+   BE CAREFUL! This might consume a lot of time, as the search of
+   '/u/user_x/**' includes '/u/user_x/work/**' and
+   '/u/user_x/work/release/**'.  So '/u/user_x/work/release/**' is searched
+   three and '/u/user_x/work/**' is searched two times.
+
+   In the above example you might want to set path to: >
+	:set path=**,/u/user_x/**
+<   This searches: >
+	/u/user_x/work/release/**
+	/u/user_x/**
+<   This searches the same directories, but in a different order.
+
 
  vim:tw=78:ts=8:ft=help:norl:
--- a/runtime/doc/intro.txt
+++ b/runtime/doc/intro.txt
@@ -1,4 +1,4 @@
-*intro.txt*     For Vim version 7.0aa.  Last change: 2004 Nov 18
+*intro.txt*     For Vim version 7.0aa.  Last change: 2004 Dec 16
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -278,7 +278,7 @@ the ideas from all these people: They ke
 
 
 In this documentation there are several references to other versions of Vi:
-							*Vi*
+							*Vi* *vi*
 Vi	"the original".  Without further remarks this is the version
 	of Vi that appeared in Sun OS 4.x.  ":version" returns
 	"Version 3.7, 6/7/85".  Sometimes other versions are referred
--- a/runtime/doc/mbyte.txt
+++ b/runtime/doc/mbyte.txt
@@ -1,4 +1,4 @@
-*mbyte.txt*     For Vim version 7.0aa.  Last change: 2004 Jul 05
+*mbyte.txt*     For Vim version 7.0aa.  Last change: 2004 Dec 19
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar et al.
@@ -328,6 +328,8 @@ u   unicode	same as ucs-2
 u   ucs2be	same as ucs-2 (big endian)
 u   ucs-2be	same as ucs-2 (big endian)
 u   ucs-4be	same as ucs-4 (big endian)
+    default     stands for the default value of 'encoding', depends on the
+    		environment
 
 For the UCS codes the byte order matters.  This is tricky, use UTF-8 whenever
 you can.  The default is to use big-endian (most significant byte comes
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt*	For Vim version 7.0aa.  Last change: 2004 Dec 09
+*options.txt*	For Vim version 7.0aa.  Last change: 2004 Dec 19
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -1841,6 +1841,10 @@ A jump table for the options with a shor
 			there is one).  This works very well for C programs.
 			This flag is also used for other features, such as
 			C-indenting.
+								*cpo-+*
+		+	When included, a ":write file" command will reset the
+			'modified' flag of the buffer, even though the buffer
+			itself may still be different from its file.
 			 					cpo-star*
 		*	Use ":*" in the same way as ":@".  When not included,
 			":*" is an alias for ":'<,'>", select the Visual area.
@@ -2127,7 +2131,7 @@ A jump table for the options with a shor
 	with.  See |encoding-names| for the possible values.
 
 	NOTE: Changing this option will not change the encoding of the
-	existing text in Vim.  It may cause multi-byte text to become invalid.
+	existing text in Vim.  It may cause non-ASCII text to become invalid.
 	It should normally be kept at its default value, or set when Vim
 	starts up.  See |multibyte|.
 
@@ -2338,8 +2342,9 @@ A jump table for the options with a shor
 	old short name was 'fe', which is no longer used.
 
 					*'fileencodings'* *'fencs'*
-'fileencodings' 'fencs'	string (default: "ucs-bom", "ucs-bom,utf-8,latin1"
-				    when 'encoding' is set to a Unicode value)
+'fileencodings' 'fencs'	string (default: "ucs-bom",
+				    "ucs-bom,utf-8,default,latin1" when
+				    'encoding' is set to a Unicode value)
 			global
 			{only available when compiled with the |+multi_byte|
 			feature}
@@ -2373,6 +2378,10 @@ A jump table for the options with a shor
 	An entry for an 8-bit encoding (e.g., "latin1") should be the last,
 	because Vim cannot detect an error, thus the encoding is always
 	accepted.
+	The special value "default" can be used for the encoding from the
+	environment.  This is the default value for 'encoding'.  It is useful
+	when 'encoding' is set to "utf-8" and your environment uses a
+	non-latin1 encoding, such as Russian.
 	WRONG VALUES:			WHAT'S WRONG:
 		latin1,utf-8		"latin1" will always be used
 		utf-8,ucs-bom,latin1	BOM won't be recognized in an utf-8
--- a/runtime/doc/os_mac.txt
+++ b/runtime/doc/os_mac.txt
@@ -1,4 +1,4 @@
-*os_mac.txt*    For Vim version 7.0aa.  Last change: 2004 Jul 19
+*os_mac.txt*    For Vim version 7.0aa.  Last change: 2004 Dec 13
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar et al.
@@ -71,6 +71,12 @@ Q: I can't enter non-ASCII character in 
 A: Under Window Settings, Emulation, make sure that "Escape non-ASCII
    characters" is not checked.
 
+Q: How do I start the GUI from the command line?
+A: Assuming that Vim.app is located in /Applications:
+	open /Applications/Vim.app
+   Or:
+   	/Applications/Vim.app/Contents/MacOS/Vim -g  {arguments}
+
 ==============================================================================
 4. Mac Lack						*mac-lack*
 
--- a/runtime/doc/pattern.txt
+++ b/runtime/doc/pattern.txt
@@ -1,4 +1,4 @@
-*pattern.txt*   For Vim version 7.0aa.  Last change: 2004 Sep 07
+*pattern.txt*   For Vim version 7.0aa.  Last change: 2004 Dec 18
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -153,6 +153,7 @@ The offset gives the cursor position rel
     s[-num]	[num] characters to the left of the start of the match
     b[+num]	[num] identical to s[+num] above (mnemonic: begin)
     b[-num]	[num] identical to s[-num] above (mnemonic: begin)
+    ;{pattern}  perform another searcn, see |//;|
 
 If a '-' or '+' is given but [num] is omitted, a count of one will be used.
 When including an offset with 'e', the search becomes inclusive (the
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -6579,6 +6579,7 @@ version4.txt	version4.txt	/*version4.txt
 version5.txt	version5.txt	/*version5.txt*
 version6.txt	version6.txt	/*version6.txt*
 version7.txt	version7.txt	/*version7.txt*
+vi	intro.txt	/*vi*
 vi-differences	vi_diff.txt	/*vi-differences*
 vi:	options.txt	/*vi:*
 vi_diff.txt	vi_diff.txt	/*vi_diff.txt*
@@ -6655,6 +6656,7 @@ w:var	eval.txt	/*w:var*
 warningmsg-variable	eval.txt	/*warningmsg-variable*
 white-space	pattern.txt	/*white-space*
 whitespace	pattern.txt	/*whitespace*
+wildcard	editing.txt	/*wildcard*
 win16-!start	gui_w16.txt	/*win16-!start*
 win16-clipboard	gui_w16.txt	/*win16-clipboard*
 win16-colors	gui_w16.txt	/*win16-colors*
@@ -6828,6 +6830,7 @@ zz	scroll.txt	/*zz*
 {	motion.txt	/*{*
 {Visual}	intro.txt	/*{Visual}*
 {address}	cmdline.txt	/*{address}*
+{arglist}	editing.txt	/*{arglist}*
 {char1-char2}	intro.txt	/*{char1-char2}*
 {event}	autocmd.txt	/*{event}*
 {file}	editing.txt	/*{file}*
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt*      For Vim version 7.0aa.  Last change: 2004 Dec 11
+*todo.txt*      For Vim version 7.0aa.  Last change: 2004 Dec 19
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -30,21 +30,18 @@ be worked on, but only if you sponsor Vi
 							*known-bugs*
 -------------------- Known bugs and current work -----------------------
 
-":e <cfile>" does not expand ~/file, very confusing compared to ":e ~/file".
+Win32: Cannot edit a file starting with # with --remote. (Giuseppe Bilotta,
+Oct 6 2004)
 
-When no termcap/termlib library is found, check that compiling Vim works in
-configure.  Give an clear error message ("install termcap or ncurses-dev
-package") when it doesn't.
+Add Makefile code to install *-it.1 manual pages in .../man/it/man1/*.1
 
-When doing ":w file" 'modified' is reset, but "u" sets it, while the file is
-actually unchanged.  Don't reset 'modified' when 'nocp' is set.
-
-Win32: "gvim -V100" should use dialog with scrollbar.
+Win32: "gvim -V100" should use dialog with scrollbar.  Using
+gui_mch_dialog() would be good, but need to move display_errors() to after
+creating the window, so that s_hwnd is valid.
+How to add a scrollbar to the dialog?
 
-Using CTRL-A on "08" should not work like octal. (Matthew Duggan)
-
-Cursor onder laatste regel na ":g/pat/s//>" commando waardoor regels niet meer
-wrappen. (Adri Verhoef, Dec 1)
+Win32: tearoff menu window should have a scrollbar when it's taller than the
+screen.
 
 Included NetBeans patches (Gordon Prieur, Oct 20)
     See two messages for list of changed files.  Additionally:
@@ -57,6 +54,8 @@ Included NetBeans patches (Gordon Prieur
 For version 7.0:
 
 -   Include many PATCHES:
+    -	Patch for 'breakindent' option: repeat indent for wrapped line. (Vaclav
+	Smilauer, 2004 Sep 13, fix Oct 31)
     7   Add 'taglistfiles' option, show file name and type when listing matching
 	tags name with CTRL-D completion.  Patch from Yegappan Lakshmanan.
 	2004 Jul 11
@@ -189,16 +188,19 @@ For version 7.0:
     Also see the "minigrep.vim" script on www.vim.org.
 
 
--   Edit same file on Unix and from MS-Windows: no warning for swap file.
 -   Drop the kvim support?  There is no maintenance and "yzis" is supposed to
     replace it.
 -   In the kvim/KDE source files fix the formatting.
 -   KDE version is called "kvim".  Make it "gvim", like the others?
 -   Better configure check for KDE include files from Dan Sharp.
 -   KDE GUI Input method patch. (Yasuhiro Matsumoto) (upd. Oct 25 2004)
+
+After including patches:
 -   Change ga_room into ga_maxlen, so that it doesn't need to be
     incremented/decremented each time.
--   For string variables, use length instead of NUL termination.
+-   For string variables, use length instead of NUL termination?
+	+ can include NUL characters
+	- setline() will have problems with NL vs NUL.
 -   new DATA TYPES: lists, dictionaries and function references.
 	Check old patch from Robert Webb for array support.
     Add type checking?  See ~/vim/ideas.txt.
@@ -258,11 +260,6 @@ For version 7.0:
     before some time/date can be flushed. 'undopersist' gives maximum time to
     keep undo: "3h", "1d", "2w", "1y", etc.  For the file use dot and
     extension: ".filename.un~" (like swapfile but "un~" instead of "swp").
-7   SWAP FILE CHANGE: When a dos format file was edited with ":e ++ff=unix",
-    Vim is killed and trying to recover the file, 'ff' will be dos.  Same for
-    non-default fileencoding.  (Miroslaw Dobrzanski-Neumann, Jul 17)
-    Should store the values in block 0 of the swap file, but that is an
-    incompatible change.
 7   Support WINDOW TABS.  Works like several pages, each with their own
     split windows.  Patch for GTK 1.2 passed on by Christian Michon, 2004 Jan 6.
     Also for the console!
@@ -285,6 +282,10 @@ 7   Support WINDOW TABS.  Works like sev
     - make it possible to have 'defineAnnoType' also handle terminal colors.
     - send 'balloonText' events for the cursor position (using CursorHold ?)
       in terminal mode.
+-   ECLIPSE plugin.  Problem is: the interface is very complicated.  Need to
+    implement part in Java and then connect to Vim.  Some hints from Alexandru
+    Roman, 2004 Dec 15.  Should then also work with Oracle Jdeveloper, see JSR
+    198 standard http://www.jcp.org/en/jsr/detail?id=198.
 -   STICKY CURSOR: Add a way of scrolling that leaves the cursor where it is.
     Especially when using the scrollbar.  Typing a cursor-movement command
     scrolls back to where the cursor is.
@@ -324,25 +325,9 @@ 7   Make ":startinsert" command work dir
 -   "onemore" flag in 'virtualedit': move cursor past end of line.  Patch by
     Mattias Flodin (2004 Jul 30)
 
-Win32: When setting 'encoding' in a Vim server to "utf-8", and using "vim
---remote russian" in a console, "russian" should be converted from the console
-encoding to utf-8.  Send all remote messages in utf-8?  Only on Win32?
-
 Support ":set syntax=cpp.doxygen"?  Suggested patch by Michael Geddes (9 Aug
 2004).  Should also work for 'filetype'.
 
-Patch for 'breakindent' option: repeat indent for wrapped line. (Vaclav
-Smilauer, 2004 Sep 13, fix Oct 31)
-
-":bufdo g/something/p" has the last match overwritten by the file info.
-Example by Cesar Andalou (Nov 3).
-
-Win32: In 'fileencodings' allow using "acp" for the active codepage.  Useful
-value: "ucs-bom,utf-8,acp,latin1"
-
-Win32: Cannot edit a file starting with # with --remote. (Giuseppe Bilotta,
-Oct 6 2004)
-
 For manipulating buffers without opening a new window, support Virtual
 windows.  Example:
     :virtwin let l = GetBufLine(4, 10)
@@ -360,19 +345,13 @@ Win32: In the generated batch files, use
 Mathias Michaelis (2004 Sep 6)
 Also place vimtutor.bat in %windir%?
 
-Support ":enew filename" to edit a new buffer with a name.  It's like "enew |
-file filename" but without setting the alternate file to a buffer without a
-name. (Charles Campbell)
-
 Add gui_mch_browsedir() for Motif, KDE and Mac OS/X.
 
-Add Makefile code to install *-it.1 manual pages in .../man/it/man1/*.1
-
 HTML indenting can be slow, find out why.  Any way to do some kind of
 profiling for Vim script?
 
 Mac: problem with Xcode, Vim doesn't continue until the next click.
-Apparently hanges in handle_drop().  A PostEvent() avoids it. (Da Woon Jung)
+Apparently hangs in handle_drop().  A PostEvent() avoids it. (Da Woon Jung)
 
 
 Vi incompatibility:
@@ -943,11 +922,6 @@ 9   When editing a file with 'readonly' 
     swap file.  Then using ":write" (without making any changes) doesn't give
     a warning either.  Should check for an existing swap file without creating
     one.
-7   On MS-DOS or MS-Windows, when editing the same file over a network, the
-    drive letter is different, thus an existing swap file doesn't generate a
-    warning.  Use some flag to indicate the swap file is in the same directory
-    as the original file?  Could make b0_fname[] start with a special
-    character like ">".
 7   When 'showbreak' is set, the amount of space a Tab occupies changes.
     Should work like 'showbreak' is inserted without changing the Tabs.
 7   When there is a "help.txt" window in a session file, restoring that
@@ -977,10 +951,6 @@ 8   In Visual block mode with 'lbr' set,
 9   dosinst.c: The DJGPP version can't uninstall the Uninstall registry key on
     Windows NT.  How to install a .inf file on Windows NT and how to detect
     that Windows NT is being used?
-8   When opening the same file on Unix and on MS-Windows, there is no
-    ATTENTION message, because the path in the swap file is different.  Using
-    a relative path name will cause no ATTENTION for Vim 5.8.
-    Somehow add a flag that the swap file is in the same dir as the file?
 8   When 'virtualedit' is "block,insert" and encoding is "utf-8", selecting a
     block of one double-wide character, then "d" deletes only half of it.
 8   When 'virtualedit' is set, should "I" in blockwise visual mode also insert
@@ -2658,12 +2628,14 @@ Incsearch:
 Searching:
 8   Add a mechanism for recursiveness: "\(([^()]*\@@[^()]*)\)\@r".  \@@ stands
     for "go recursive here" and \@r marks the recursive atom.
-item stack to allow matching ().  One side is "push X on
+7   Add an item stack to allow matching ().  One side is "push X on
     the stack if previous atom matched".  Other side is "match with top of
     stack, pop it when it matches".  Use "\@pX" and "\@m"?
 	Example: \((\@p).\{-}\@m\)*
 7   Add an option to accept a match at the cursor position.  Also for
     search(). (Brett)
+7   Add a flag to "/pat/" to discard an error.  Useful to continue a mapping
+    when a search fails.  Could be "/pat/E" (e is already used for an offset).
 7   Add pattern item to use properties of Unicode characters.  In Perl it's
     "\p{L}" for a letter.  See Regular Expression Pocket Reference.
 8   Would it be possible to allow ":23,45/pat/flags" to search for "pat" in
@@ -2828,9 +2800,6 @@ 8   When the edited file is a symlink, t
     twice (e.g. when using quickfix).  Also try to make the name of the backup
     file the same as the actual file?
     Use the code for resolve()?
-7   Store the options 'fileencoding', 'fileformat', etc. in the swapfile,
-    because they change what will be written to the file.  Requires adding
-    another block to the swapfile.
 7   When using 64 bit inode numbers, also store the top 32 bits.  Add another
     field for this, using part of bo_fname[], to keep it compatible.
 7   When editing a file on removable media, should put swap file somewhere
@@ -3153,8 +3122,6 @@ 9   Support ACLs on more systems.
 7   Add ModeMsgVisual, ModeMsgInsert, etc. so that each mode message can be
     highlighted differently.
 8   Allow using "**" as a wildcard in commands like ":next" and ":args".
-8   Provide a way to avoid wildcard expansion.  Use double quotes, like in the
-    shell?  :edit "my[file].txt"  (currently works if there is no "myf.txt")
 7   Add a message area for the user.  Set some option to reserve space (above
     the command line?).  Use an ":echouser" command to display the message
     (truncated to fit in the space).
--- a/runtime/doc/version7.txt
+++ b/runtime/doc/version7.txt
@@ -1,4 +1,4 @@
-*version7.txt*  For Vim version 7.0aa.  Last change: 2004 Dec 11
+*version7.txt*  For Vim version 7.0aa.  Last change: 2004 Dec 19
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -36,6 +36,20 @@ run into a problem when upgrading from V
 
 ":helpgrep" now uses a help window to display a match.
 
+In an argument list double quotes could be used to include spaces in a file
+name.  This caused a difference between ":edit" and ":next" for escaping
+double quotes and it is incompatible with some versions of Vi.
+	Command			Vim 6.x	file name	Vim 7.x file name ~
+	:edit foo\"888          'foo"888'         	'foo"888'
+	:next foo\"888          'foo888'          	'foo"888'
+	:next a\"b c\"d         'ab cd'           	'a"b' and 'c"d'
+
+A ":write file" command no longer resets the 'modified' flag of the buffer,
+unless the '+' flag is in 'cpoptions' |cpo-+|.  This was illogical, since the
+buffer is still modified compared to the original file.  And when undoing
+all changes the file would actually be marked modified.  It does mean that
+":quit" fails now.
+
 
 Minor incompatibilities:
 
@@ -61,6 +75,16 @@ Win32: The effect of the <F10> key depen
 on whether <F10> has been mapped or not.  This allows mapping <F10> without
 changing 'winaltkeys'.
 
+When using CTRL-A on "08" it became "018", which is illogical.  Now it becomes
+"9".  The leading zero(s) is(are) removed to avoid the number becoming octal
+after incrementing "009" to "010".
+
+When 'encoding' is set to a Unicode encoding, the value for 'fileencodings'
+now includes "default" before "latin1".  This means that for files with 8-bit
+encodings the default is to use the encoding specified by the environment, if
+possible.  Previously latin1 would always be used, which is wrong in a
+non-latin1 environment, such as Russian.
+
 ==============================================================================
 NEW FEATURES						*new-7*
 
@@ -303,6 +327,18 @@ When foldtext() finds no text after remo
 second line of the fold.  Helps for C-style /* */ comments where the first
 line is just "/*".
 
+When editing the same file from two systems (e.g., Unix and MS-Windows) there
+mostly was no warning for an existing swap file, because the name of the
+edited file differs (e.g., y:\dir\file vs /home/me/dir/file).  Added a flag to
+the swap file to indicate it is in the same directory as the edited file.  The
+used path then doesn't matter and the check for editing the same file is much
+more reliable.
+
+Client-server communication now supports 'encoding'.  When setting 'encoding'
+in a Vim server to "utf-8", and using "vim --remote fname" in a console,
+"fname" is converted from the console encoding to utf-8.  Also allows Vims
+with different 'encoding' settings to exchange messages.
+
 ==============================================================================
 COMPILE TIME CHANGES					*compile-changes-7*
 
@@ -506,4 +542,26 @@ When using "set laststatus=2 cmdheight=2
 line for the cmdline. (Christian Robinson)  Invoke command_height() after the
 GUI has started up.
 
+When completing a file name on the command line backslashes are required for
+white space.  Was only done for a space, not for a Tab.
+
+When configure could not find a terminal library, compiling continued for a
+long time before reporting the problem.  Added a configure check for tgetent()
+being found in a library.
+
+When the cursor is on the first char of the last line a ":g/pat/s///" command
+may cause the cursor to be displayed below the text.
+
+Win32: Editing a file with non-ASCII characters doesn't work when 'encoding'
+is "utf-8".  use _wfullpath() instead of _fullpath(). (Yu-sung Moon)
+
+When recovering the 'fileformat' and 'fileencoding' were taken from the
+original file instead of from the swapfile.  When the file didn't exist, was
+empty or the option was changed (e.g., with ":e ++fenc=cp123 file") it could
+be wrong.  Now store 'fileformat' and 'fileencoding' in the swapfile and use
+the values when recovering.
+
+":bufdo g/something/p" overwrites each last printed text line with the file
+message for the next buffer.  Temporarily clear 'shortmess' to avoid that.
+
  vim:tw=78:ts=8:ft=help:norl:
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
 " Vim support file to detect file types
 "
 " Maintainer:	Bram Moolenaar <Bram@vim.org>
-" Last Change:	2004 Nov 18
+" Last Change:	2004 Dec 17
 
 " Listen very carefully, I will say this only once
 if exists("did_load_filetypes")
@@ -893,6 +893,9 @@ au BufNewFile,BufRead .muttrc*,*/.mutt/m
 " Natural
 au BufNewFile,BufRead *.NS[ACGLMNPS]		setf natural
 
+" Netrc
+au BufNewFile,BufRead .netrc			setf netrc
+
 " Novell netware batch files
 au BufNewFile,BufRead *.ncf			setf ncf
 
@@ -1486,6 +1489,9 @@ au BufNewFile,BufRead *.stp			setf stp
 " Standard ML
 au BufNewFile,BufRead *.sml			setf sml
 
+" Sudoers
+au BufNewFile,BufRead /etc/sudoers,sudoers.tmp	setf sudoers
+
 " Tads (or Nroff)
 au BufNewFile,BufRead *.t
 	\ if !<SID>FTnroff() | setf tads | endif
--- a/runtime/ftplugin/make.vim
+++ b/runtime/ftplugin/make.vim
@@ -1,7 +1,7 @@
 " Vim filetype plugin file
 " Language:	Make
 " Maintainer:	Bram Moolenaar <Bram@vim.org>
-" Last Change:	2003 May 04
+" Last Change:	2004 Dec 17
 
 " Only do this when not done yet for this buffer
 if exists("b:did_ftplugin")
@@ -23,3 +23,6 @@ setlocal com=sO:#\ -,mO:#\ \ ,b:#
 
 " Set 'commentstring' to put the marker after a #.
 setlocal commentstring=#\ %s
+
+" Including files.
+let &l:include = '^\s*include'
--- a/runtime/makemenu.vim
+++ b/runtime/makemenu.vim
@@ -1,6 +1,6 @@
 " Script to define the syntax menu in synmenu.vim
 " Maintainer:	Bram Moolenaar <Bram@vim.org>
-" Last Change:	2004 Nov 20
+" Last Change:	2004 Dec 17
 
 " This is used by "make menu" in the src directory.
 edit <sfile>:p:h/synmenu.vim
@@ -407,6 +407,7 @@ SynMenu Sh-S.Standard\ ML:sml
 SynMenu Sh-S.Stored\ Procedures:stp
 SynMenu Sh-S.Strace:strace
 SynMenu Sh-S.Subversion\ commit:svn
+SynMenu Sh-S.Sudoers:sudoers
 
 SynMenu TUV.TADS:tads
 SynMenu TUV.Tags:tags
--- a/runtime/syntax/2html.vim
+++ b/runtime/syntax/2html.vim
@@ -1,6 +1,6 @@
 " Vim syntax support file
 " Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2004 Oct 15
+" Last Change: 2004 Dec 14
 "	       (modified by David Ne\v{c}as (Yeti) <yeti@physics.muni.cz>)
 "	       (XHTML support by Panagiotis Issaris <takis@lumumba.luc.ac.be>)
 
@@ -211,7 +211,11 @@ let s:old_magic = &magic
 set magic
 
 if exists("use_xhtml")
-  exe "normal! a<?xml version=\"1.0\"?>\n\e"
+  if s:html_encoding != ""
+    exe "normal!  a<?xml version=\"1.0\" encoding=\"" . s:html_encoding . "\"?>\n\e"
+  else
+    exe "normal! a<?xml version=\"1.0\"?>\n\e"
+  endif
   let s:tag_close = '/>'
 else
   let s:tag_close = '>'
@@ -230,8 +234,8 @@ endif
 
 " HTML header, with the title and generator ;-). Left free space for the CSS,
 " to be filled at the end.
-exe "normal! a<html>\n<head>\n<title>\e"
-exe "normal! a" . expand("%:p:~") . "</title>\n\e"
+exe "normal! a<html>\n\e"
+exe "normal! a<head>\n<title>" . expand("%:p:~") . "</title>\n\e"
 exe "normal! a<meta name=\"Generator\" content=\"Vim/" . v:version/100 . "." . v:version %100 . '"' . s:tag_close . "\n\e"
 if s:html_encoding != ""
   exe "normal! a<meta http-equiv=\"content-type\" content=\"text/html; charset=" . s:html_encoding . '"' . s:tag_close . "\n\e"
@@ -477,11 +481,19 @@ while s:idlist != ""
 endwhile
 
 " Add hyperlinks
-%s+\(http://\S\{-}\)\(\([.,;:}]\=\(\s\|$\)\)\|[\\"'<>]\|&gt;\|&lt;\|&quot;\)+<A HREF="\1">\1</A>\2+ge
+%s+\(https\=://\S\{-}\)\(\([.,;:}]\=\(\s\|$\)\)\|[\\"'<>]\|&gt;\|&lt;\|&quot;\)+<a href="\1">\1</a>\2+ge
 
 " The DTD
 if exists("html_use_css")
-  exe "normal! gg0i<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n\e"
+  if exists("use_xhtml")
+    exe "normal! gg$a\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\e"
+  else
+    exe "normal! gg0i<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n\e"
+  endif
+endif
+
+if exists("use_xhtml") 
+  exe "normal! gg/<html/e\na xmlns=\"http://www.w3.org/1999/xhtml\"\e"
 endif
 
 " Cleanup
--- a/runtime/syntax/iss.vim
+++ b/runtime/syntax/iss.vim
@@ -2,7 +2,12 @@
 " Language:             Inno Setup File (iss file) and My InnoSetup extension
 " Maintainer:           Jason Mills (jmills@cs.mun.ca)
 " Previous Maintainer:  Dominique Stéphan (dominique@mggen.com)
-" Last Change:          2004 Jul 13
+" Last Change:          2004 Dec 14
+"
+" Todo:
+"  - The paramter String: is matched as flag string (because of case ignore).
+"  - Pascal scripting syntax is not recognized.
+"  - Embedded double quotes confuse string matches. e.g. "asfd""asfa"
 
 " For version 5.x: Clear all syntax items
 " For version 6.x: Quit when a syntax file was already loaded
@@ -19,36 +24,37 @@ syn case ignore
 syn region issPreProc start="^\s*#" end="$"
 
 " Section
-syn region issHeader            start="\[" end="\]"
+syn region issSection	start="\[" end="\]"
 
 " Label in the [Setup] Section
-syn match  issLabel             "^[^=]\+="
+syn match  issDirective	"^[^=]\+="
 
 " URL
-syn match  issURL       "http[s]\=:\/\/.*$"
+syn match  issURL	"http[s]\=:\/\/.*$"
 
-" syn match  issName    "[^: ]\+:"
-syn match  issName      "Name:"
-syn match  issName      "MinVersion:\|OnlyBelowVersion:\|Languages:"
-syn match  issName      "Source:\|DestDir:\|DestName:\|CopyMode:"
-syn match  issName      "Attribs:\|Permissions:\|FontInstall:\|Flags:"
-syn match  issName      "FileName:\|Parameters:\|WorkingDir:\|HotKey:\|Comment:"
-syn match  issName      "IconFilename:\|IconIndex:"
-syn match  issName      "Section:\|Key:\|String:"
-syn match  issName      "Root:\|SubKey:\|ValueType:\|ValueName:\|ValueData:"
-syn match  issName      "RunOnceId:"
-syn match  issName      "Type:"
-syn match  issName      "Components:\|Description:\|GroupDescription:\|Types:\|ExtraDiskSpaceRequired:"
-syn match  issName      "StatusMsg:\|RunOnceId:\|Tasks:"
-syn match  issName      "MessagesFile:\|LicenseFile:\|InfoBeforeFile:\|InfoAfterFile:"
+" Parameters used for any section.
+" syn match  issParam"[^: ]\+:"
+syn match  issParam	"Name:"
+syn match  issParam	"MinVersion:\|OnlyBelowVersion:\|Languages:"
+syn match  issParam	"Source:\|DestDir:\|DestName:\|CopyMode:"
+syn match  issParam	"Attribs:\|Permissions:\|FontInstall:\|Flags:"
+syn match  issParam	"FileName:\|Parameters:\|WorkingDir:\|HotKey:\|Comment:"
+syn match  issParam	"IconFilename:\|IconIndex:"
+syn match  issParam	"Section:\|Key:\|String:"
+syn match  issParam	"Root:\|SubKey:\|ValueType:\|ValueName:\|ValueData:"
+syn match  issParam	"RunOnceId:"
+syn match  issParam	"Type:\|Excludes:"
+syn match  issParam	"Components:\|Description:\|GroupDescription:\|Types:\|ExtraDiskSpaceRequired:"
+syn match  issParam	"StatusMsg:\|RunOnceId:\|Tasks:"
+syn match  issParam	"MessagesFile:\|LicenseFile:\|InfoBeforeFile:\|InfoAfterFile:"
 
-syn match  issComment   "^;.*$"
+syn match  issComment	"^\s*;.*$"
 
 " folder constant
-syn match  issFolder    "{[^{]*}"
+syn match  issFolder	"{[^{]*}"
 
 " string
-syn region issString    start=+"+  end=+"+ contains=issFolder
+syn region issString	start=+"+ end=+"+ contains=issFolder
 
 " [Dirs]
 syn keyword issDirsFlags deleteafterinstall uninsalwaysuninstall uninsneveruninstall
@@ -63,6 +69,8 @@ syn keyword issFilesFlags isreadme onlyi
 syn keyword issFilesFlags promptifolder recursesubdirs regserver regtypelib restartreplace
 syn keyword issFilesFlags sharedfile skipifsourcedoesntexist sortfilesbyextension touch 
 syn keyword issFilesFlags uninsremovereadonly uninsrestartdelete uninsneveruninstall
+syn keyword issFilesFlags replacesameversion nocompression noencryption noregerror
+
 
 " [Icons]
 syn keyword issIconsFlags closeonexit createonlyiffileexists dontcloseonexit 
@@ -108,30 +116,30 @@ if version >= 508 || !exists("did_iss_sy
   endif
 
    " The default methods for highlighting.  Can be overridden later
-   HiLink issHeader     Special
-   HiLink issComment    Comment
-   HiLink issLabel      Type
-   HiLink issName       Type
-   HiLink issFolder     Special
-   HiLink issString     String
-   HiLink issValue      String
-   HiLink issURL        Include
-   HiLink issPreProc    PreProc 
+   HiLink issSection	Special
+   HiLink issComment	Comment
+   HiLink issDirective	Type
+   HiLink issParam	Type
+   HiLink issFolder	Special
+   HiLink issString	String
+   HiLink issURL	Include
+   HiLink issPreProc	PreProc 
 
-   HiLink issDirsFlags          Keyword
-   HiLink issFilesCopyMode      Keyword
-   HiLink issFilesAttribs       Keyword
-   HiLink issFilesFlags         Keyword
-   HiLink issIconsFlags         Keyword
-   HiLink issINIFlags           Keyword
-   HiLink issRegRootKey         Keyword
-   HiLink issRegValueType       Keyword
-   HiLink issRegFlags           Keyword
-   HiLink issRunFlags           Keyword
-   HiLink issTypesFlags         Keyword
-   HiLink issComponentsFlags    Keyword
-   HiLink issInstallDeleteType  Keyword
-   HiLink issTasksFlags         Keyword
+   HiLink issDirsFlags		Keyword
+   HiLink issFilesCopyMode	Keyword
+   HiLink issFilesAttribs	Keyword
+   HiLink issFilesPermissions	Keyword
+   HiLink issFilesFlags		Keyword
+   HiLink issIconsFlags		Keyword
+   HiLink issINIFlags		Keyword
+   HiLink issRegRootKey		Keyword
+   HiLink issRegValueType	Keyword
+   HiLink issRegFlags		Keyword
+   HiLink issRunFlags		Keyword
+   HiLink issTypesFlags		Keyword
+   HiLink issComponentsFlags	Keyword
+   HiLink issInstallDeleteType	Keyword
+   HiLink issTasksFlags		Keyword
 
   delcommand HiLink
 endif
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/netrc.vim
@@ -0,0 +1,55 @@
+" Vim syntax file
+" Maintainer:	    Nikolai Weibull <source@pcppopper.org>
+" URL:		    http://www.pcppopper.org/
+" Latest Revision:  2004-12-16
+" arch-tag:	    4f6ecb37-d10c-4eca-add0-77991559414a
+
+if version < 600
+  syntax clear
+elseif exists("b:current_syntax")
+  finish
+endif
+
+" Keywords
+syn keyword netrcKeyword      machine password nextgroup=netrcName skipwhite skipnl
+syn keyword netrcKeyword      login nextgroup=netrcName,netrcSpecial skipwhite skipnl
+syn keyword netrcKeyword      default
+syn keyword netrcKeyword      macdef nextgroup=netrcInit,netrcMacroName skipwhite skipnl
+syn region  netrcMacro	      contained start='.' end='^$'
+
+" Names
+syn match   netrcName	      contained display '\S\+'
+syn match   netrcName	      contained display '"[^\\"]*\(\\.[^\\"]*\)*'
+syn match   netrcMacroName    contained display '\S\+' nextgroup=netrcMacro skipwhite skipnl
+syn match   netrcMacroName    contained display '"[^\\"]*\(\\.[^\\"]*\)*' nextgroup=netrcMacro skipwhite skipnl
+
+" Special
+syn keyword netrcSpecial      contained anonymous
+syn match   netrcInit	      contained '\<init$' nextgroup=netrcMacro skipwhite skipnl
+
+syn sync fromstart
+
+" 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_netrc_syn_inits")
+  if version < 508
+    let did_netrc_syn_inits = 1
+    command -nargs=+ HiLink hi link <args>
+  else
+    command -nargs=+ HiLink hi def link <args>
+  endif
+
+  HiLink netrcKeyword	Keyword
+  HiLink netrcMacro	PreProc
+  HiLink netrcName	String
+  HiLink netrcMacroName	String
+  HiLink netrcSpecial	Special
+  HiLink netrcInit	Special
+
+  delcommand HiLink
+endif
+
+let b:current_syntax = "netrc"
+
+" vim: set sts=2 sw=2:
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/sudoers.vim
@@ -0,0 +1,290 @@
+" Vim syntax file
+" Language:	    sudoers(5) configuration files.
+" Maintainer:	    Nikolai Weibull <source@pcppopper.org>
+" URL:		    http://www.pcppopper.org/
+" Latest Revision:  2004-12-17
+" arch-tag:	    02fc3bc8-4308-466f-b83e-718a7487b198
+
+if version < 600
+  syntax clear
+elseif exists("b:current_syntax")
+  finish
+endif
+
+" TODO: instead of 'skipnl', we would like to match a specific group that would
+" match \\$ and then continue with the nextgroup, actually, the skipnl doesn't
+" work...
+" TODO: treat 'ALL' like a special (yay, a bundle of new rules!!!)
+
+" User Specs
+syn match   sudoersUserSpec '^' nextgroup=@sudoersUserInSpec skipwhite
+
+syn match   sudoersSpecEquals	      contained '=' nextgroup=@sudoersCmndSpecList skipwhite
+
+syn cluster sudoersCmndSpecList	      contains=sudoersUserRunasBegin,sudoersPASSWD,@sudoersCmndInSpec
+
+" Todo
+syn keyword sudoersTodo		      contained TODO FIXME XXX NOTE
+
+" Comments
+syn region  sudoersComment	      matchgroup=sudoersComment start='#' end='$' contains=sudoersTodo
+
+" Aliases
+syn keyword sudoersAlias	      User_Alias Runas_Alias nextgroup=sudoersUserAlias skipwhite skipnl
+syn keyword sudoersAlias	      Host_Alias nextgroup=sudoersHostAlias skipwhite skipnl
+syn keyword sudoersAlias	      Cmnd_Alias nextgroup=sudoersCmndAlias skipwhite skipnl
+
+" Names
+syn match   sudoersUserAlias	      contained '\<\u[A-Z0-9_]*\>'  nextgroup=sudoersUserAliasEquals  skipwhite skipnl
+syn match   sudoersUserNameInList     contained '\<\l\+\>'	    nextgroup=@sudoersUserList	      skipwhite skipnl
+syn match   sudoersUIDInList	      contained '#\d\+\>'	    nextgroup=@sudoersUserList	      skipwhite skipnl
+syn match   sudoersGroupInList	      contained '%\l\+\>'	    nextgroup=@sudoersUserList	      skipwhite skipnl
+syn match   sudoersUserNetgroupInList contained '+\l\+\>'	    nextgroup=@sudoersUserList	      skipwhite skipnl
+syn match   sudoersUserAliasInList    contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersUserList	      skipwhite skipnl
+
+syn match   sudoersUserName	      contained '\<\l\+\>'	    nextgroup=@sudoersParameter	      skipwhite skipnl
+syn match   sudoersUID		      contained '#\d\+\>'	    nextgroup=@sudoersParameter	      skipwhite skipnl
+syn match   sudoersGroup	      contained '%\l\+\>'	    nextgroup=@sudoersParameter	      skipwhite skipnl
+syn match   sudoersUserNetgroup	      contained '+\l\+\>'	    nextgroup=@sudoersParameter	      skipwhite skipnl
+syn match   sudoersUserAliasRef	      contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersParameter	      skipwhite skipnl
+
+syn match   sudoersUserNameInSpec     contained '\<\l\+\>'	    nextgroup=@sudoersUserSpec	      skipwhite skipnl
+syn match   sudoersUIDInSpec	      contained '#\d\+\>'	    nextgroup=@sudoersUserSpec	      skipwhite skipnl
+syn match   sudoersGroupInSpec	      contained '%\l\+\>'	    nextgroup=@sudoersUserSpec	      skipwhite skipnl
+syn match   sudoersUserNetgroupInSpec contained '+\l\+\>'	    nextgroup=@sudoersUserSpec	      skipwhite skipnl
+syn match   sudoersUserAliasInSpec    contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersUserSpec	      skipwhite skipnl
+
+syn match   sudoersUserNameInRunas    contained '\<\l\+\>'	    nextgroup=@sudoersUserRunas	      skipwhite skipnl
+syn match   sudoersUIDInRunas	      contained '#\d\+\>'	    nextgroup=@sudoersUserRunas	      skipwhite skipnl
+syn match   sudoersGroupInRunas	      contained '%\l\+\>'	    nextgroup=@sudoersUserRunas	      skipwhite skipnl
+syn match   sudoersUserNetgroupInRunas contained '+\l\+\>'	    nextgroup=@sudoersUserRunas	      skipwhite skipnl
+syn match   sudoersUserAliasInRunas   contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersUserRunas	      skipwhite skipnl
+
+syn match   sudoersHostAlias	      contained '\<\u[A-Z0-9_]*\>'  nextgroup=sudoersHostAliasEquals  skipwhite skipnl
+syn match   sudoersHostNameInList     contained '\<\l\+\>'	    nextgroup=@sudoersHostList	      skipwhite skipnl
+syn match   sudoersIPAddrInList	      contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}' nextgroup=@sudoersHostList skipwhite skipnl
+syn match   sudoersNetworkInList      contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}\%(/\%(\%(\d\{1,3}\.\)\{3}\d\{1,3}\|\d\+\)\)\=' nextgroup=@sudoersHostList skipwhite skipnl
+syn match   sudoersHostNetgroupInList contained '+\l\+\>'	    nextgroup=@sudoersHostList	      skipwhite skipnl
+syn match   sudoersHostAliasInList    contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersHostList	      skipwhite skipnl
+
+syn match   sudoersHostName	      contained '\<\l\+\>'	    nextgroup=@sudoersParameter	      skipwhite skipnl
+syn match   sudoersIPAddr	      contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}' nextgroup=@sudoersParameter skipwhite skipnl
+syn match   sudoersNetwork	      contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}\%(/\%(\%(\d\{1,3}\.\)\{3}\d\{1,3}\|\d\+\)\)\=' nextgroup=@sudoersParameter skipwhite skipnl
+syn match   sudoersHostNetgroup	      contained '+\l\+\>'	    nextgroup=@sudoersParameter	      skipwhite skipnl
+syn match   sudoersHostAliasRef	      contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersParameter	      skipwhite skipnl
+
+syn match   sudoersHostNameInSpec     contained '\<\l\+\>'	    nextgroup=@sudoersHostSpec	      skipwhite skipnl
+syn match   sudoersIPAddrInSpec	      contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}' nextgroup=@sudoersHostSpec skipwhite skipnl
+syn match   sudoersNetworkInSpec      contained '\%(\d\{1,3}\.\)\{3}\d\{1,3}\%(/\%(\%(\d\{1,3}\.\)\{3}\d\{1,3}\|\d\+\)\)\=' nextgroup=@sudoersHostSpec skipwhite skipnl
+syn match   sudoersHostNetgroupInSpec contained '+\l\+\>'	    nextgroup=@sudoersHostSpec	      skipwhite skipnl
+syn match   sudoersHostAliasInSpec    contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersHostSpec	      skipwhite skipnl
+
+syn match   sudoersCmndAlias	      contained '\<\u[A-Z0-9_]*\>'  nextgroup=sudoersCmndAliasEquals  skipwhite skipnl
+syn match   sudoersCmndNameInList     contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=@sudoersCmndList,sudoersCommandEmpty,sudoersCommandArgs skipwhite
+syn match   sudoersCmndAliasInList    contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersCmndList	      skipwhite skipnl
+
+syn match   sudoersCmndNameInSpec     contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=@sudoersCmndSpec,sudoersCommandEmptyInSpec,sudoersCommandArgsInSpec skipwhite
+syn match   sudoersCmndAliasInSpec    contained '\<\u[A-Z0-9_]*\>'  nextgroup=@sudoersCmndSpec	      skipwhite skipnl
+
+" Delimiters
+syn match   sudoersUserAliasEquals  contained '=' nextgroup=@sudoersUserInList	skipwhite skipnl
+syn match   sudoersUserListComma    contained ',' nextgroup=@sudoersUserInList	skipwhite skipnl
+syn match   sudoersUserListColon    contained ':' nextgroup=sudoersUserAlias	skipwhite skipnl
+syn cluster sudoersUserList	    contains=sudoersUserListComma,sudoersUserListColon
+
+syn match   sudoersUserSpecComma    contained ',' nextgroup=@sudoersUserInSpec	skipwhite skipnl
+syn cluster sudoersUserSpec	    contains=sudoersUserSpecComma,@sudoersHostInSpec
+
+syn match   sudoersUserRunasBegin   contained '(' nextgroup=@sudoersUserInRunas skipwhite skipnl
+syn match   sudoersUserRunasComma   contained ',' nextgroup=@sudoersUserInRunas	skipwhite skipnl
+syn match   sudoersUserRunasEnd	    contained ')' nextgroup=sudoersPASSWD,@sudoersCmndInSpec skipwhite skipnl
+syn cluster sudoersUserRunas	    contains=sudoersUserRunasComma,@sudoersUserInRunas,sudoersUserRunasEnd
+
+
+syn match   sudoersHostAliasEquals  contained '=' nextgroup=@sudoersHostInList	skipwhite skipnl
+syn match   sudoersHostListComma    contained ',' nextgroup=@sudoersHostInList	skipwhite skipnl
+syn match   sudoersHostListColon    contained ':' nextgroup=sudoersHostAlias	skipwhite skipnl
+syn cluster sudoersHostList	    contains=sudoersHostListComma,sudoersHostListColon
+
+syn match   sudoersHostSpecComma    contained ',' nextgroup=@sudoersHostInSpec	skipwhite skipnl
+syn cluster sudoersHostSpec	    contains=sudoersHostSpecComma,sudoersSpecEquals
+
+
+syn match   sudoersCmndAliasEquals  contained '=' nextgroup=@sudoersCmndInList	skipwhite skipnl
+syn match   sudoersCmndListComma    contained ',' nextgroup=@sudoersCmndInList	skipwhite skipnl
+syn match   sudoersCmndListColon    contained ':' nextgroup=sudoersCmndAlias	skipwhite skipnl
+syn cluster sudoersCmndList	    contains=sudoersCmndListComma,sudoersCmndListColon
+
+syn match   sudoersCmndSpecComma    contained ',' nextgroup=@sudoersCmndSpecList skipwhite skipnl
+syn match   sudoersCmndSpecColon    contained ':' nextgroup=@sudoersUserInSpec	skipwhite skipnl
+syn cluster sudoersCmndSpec	    contains=sudoersCmndSpecComma,sudoersCmndSpecColon
+
+" Lists
+syn cluster sudoersUserInList	    contains=sudoersUserNegationInList,sudoersUserNameInList,sudoersUIDInList,sudoersGroupInList,sudoersUserNetgroupInList,sudoersUserAliasInList
+syn cluster sudoersHostInList	    contains=sudoersHostNegationInList,sudoersHostNameInList,sudoersIPAddrInList,sudoersNetworkInList,sudoersHostNetgroupInList,sudoersHostAliasInList
+syn cluster sudoersCmndInList	    contains=sudoersCmndNegationInList,sudoersCmndNameInList,sudoersCmndAliasInList
+
+syn cluster sudoersUser		    contains=sudoersUserNegation,sudoersUserName,sudoersUID,sudoersGroup,sudoersUserNetgroup,sudoersUserAliasRef
+syn cluster sudoersHost		    contains=sudoersHostNegation,sudoersHostName,sudoersIPAddr,sudoersNetwork,sudoersHostNetgroup,sudoersHostAliasRef
+
+syn cluster sudoersUserInSpec	    contains=sudoersUserNegationInSpec,sudoersUserNameInSpec,sudoersUIDInSpec,sudoersGroupInSpec,sudoersUserNetgroupInSpec,sudoersUserAliasInSpec
+syn cluster sudoersHostInSpec	    contains=sudoersHostNegationInSpec,sudoersHostNameInSpec,sudoersIPAddrInSpec,sudoersNetworkInSpec,sudoersHostNetgroupInSpec,sudoersHostAliasInSpec
+syn cluster sudoersUserInRunas	    contains=sudoersUserNegationInRunas,sudoersUserNameInRunas,sudoersUIDInRunas,sudoersGroupInRunas,sudoersUserNetgroupInRunas,sudoersUserAliasInRunas
+syn cluster sudoersCmndInSpec	    contains=sudoersCmndNegationInSpec,sudoersCmndNameInSpec,sudoersCmndAliasInSpec
+
+" Operators
+syn match   sudoersUserNegationInList contained '!\+' nextgroup=@sudoersUserInList  skipwhite skipnl
+syn match   sudoersHostNegationInList contained '!\+' nextgroup=@sudoersHostInList  skipwhite skipnl
+syn match   sudoersCmndNegationInList contained '!\+' nextgroup=@sudoersCmndInList  skipwhite skipnl
+
+syn match   sudoersUserNegation	      contained '!\+' nextgroup=@sudoersUser	    skipwhite skipnl
+syn match   sudoersHostNegation	      contained '!\+' nextgroup=@sudoersHost	    skipwhite skipnl
+
+syn match   sudoersUserNegationInSpec contained '!\+' nextgroup=@sudoersUserInSpec  skipwhite skipnl
+syn match   sudoersHostNegationInSpec contained '!\+' nextgroup=@sudoersHostInSpec  skipwhite skipnl
+syn match   sudoersUserNegationInRunas contained '!\+' nextgroup=@sudoersUserInRunas skipwhite skipnl
+syn match   sudoersCmndNegationInSpec contained '!\+' nextgroup=@sudoersCmndInSpec  skipwhite skipnl
+
+" Arguments
+syn match   sudoersCommandArgs	    contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersCommandArgs,@sudoersCmndList skipwhite
+syn match   sudoersCommandEmpty	    contained '""' nextgroup=@sudoersCmndList skipwhite skipnl
+
+syn match   sudoersCommandArgsInSpec contained '[^[:space:],:=\\]\+\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersCommandArgsInSpec,@sudoersCmndSpec skipwhite
+syn match   sudoersCommandEmptyInSpec contained '""' nextgroup=@sudoersCmndSpec skipwhite skipnl
+
+" Default Entries
+syn keyword sudoersDefaultEntry	Defaults nextgroup=sudoersDefaultTypeAt,sudoersDefaultTypeColon,sudoersDefaultTypeGreaterThan,@sudoersParameter skipwhite skipnl
+syn match   sudoersDefaultTypeAt	  contained '@' nextgroup=@sudoersHost skipwhite skipnl
+syn match   sudoersDefaultTypeColon	  contained ':' nextgroup=@sudoersUser skipwhite skipnl
+syn match   sudoersDefaultTypeGreaterThan contained '>' nextgroup=@sudoersUser skipwhite skipnl
+
+" TODO: could also deal with special characters here
+syn keyword sudoersBooleanParameter contained long_opt_prompt ignore_dot mail_always mail_badpass mail_no_user mail_no_perms tty_tickets lecture authenticate root_sudo log_host log_year shell_noargs set_home always_set_home path_info preserve_groups fqdn insults requiretty env_editor rootpw runaspw targetpw set_logname stay_setuid env_reset use_loginclass nextgroup=sudoersParameterListComma skipwhite skipnl
+syn keyword sudoersIntegerParameter contained passwd_tries loglinelen timestamp_timeout passwd_timeout umask nextgroup=sudoersIntegerParameterEquals skipwhite skipnl
+syn keyword sudoersStringParameter  contained mailsub badpass_message timestampdir timestampowner passprompt runas_default syslog_goodpri syslog_badpri editor logfile syslog mailerpath mailerflags mailto exempt_group verifypw listpw nextgroup=sudoersStringParameterEquals skipwhite skipnl
+syn keyword sudoersListParameter    contained env_check env_delete env_keep nextgroup=sudoersListParameterEquals skipwhite skipnl
+
+syn match   sudoersParameterListComma contained ',' nextgroup=@sudoersParameter skipwhite skipnl
+
+syn cluster sudoersParameter	    contains=sudoersBooleanParameter,sudoersIntegerParameterEquals,sudoersStringParameter,sudoersListParameter
+
+syn match   sudoersIntegerParameterEquals contained '[+-]\==' nextgroup=sudoersIntegerValue skipwhite skipnl
+syn match   sudoersStringParameterEquals  contained '[+-]\==' nextgroup=sudoersStringValue  skipwhite skipnl
+syn match   sudoersListParameterEquals	  contained '[+-]\==' nextgroup=sudoersListValue    skipwhite skipnl
+
+syn match   sudoersIntegerValue	contained '\d\+' nextgroup=sudoersParameterListComma skipwhite skipnl
+syn match   sudoersStringValue	contained '[^[:space:],:=\\]*\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersParameterListComma skipwhite skipnl
+syn region  sudoersStringValue	contained start=+"+ skip=+\\"+ end=+"+ nextgroup=sudoersParameterListComma skipwhite skipnl
+syn match   sudoersListValue	contained '[^[:space:],:=\\]*\%(\\[[:space:],:=\\][^[:space:],:=\\]*\)*' nextgroup=sudoersParameterListComma skipwhite skipnl
+syn region  sudoersListValue	contained start=+"+ skip=+\\"+ end=+"+ nextgroup=sudoersParameterListComma skipwhite skipnl
+
+" Special for specs
+syn match   sudoersPASSWD	      contained '\%(NO\)\=PASSWD:' nextgroup=@sudoersCmndInSpec skipwhite
+
+" 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_sudoers_syn_inits")
+  if version < 508
+    let did_sudoers_syn_inits = 1
+    command -nargs=+ HiLink hi link <args>
+  else
+    command -nargs=+ HiLink hi def link <args>
+  endif
+
+  HiLink sudoersSpecEquals		Operator
+  HiLink sudoersTodo			Todo
+  HiLink sudoersComment			Comment
+  HiLink sudoersAlias			Keyword
+  HiLink sudoersUserAlias		Identifier
+  HiLink sudoersUserNameInList		String
+  HiLink sudoersUIDInList		Number
+  HiLink sudoersGroupInList             PreProc
+  HiLink sudoersUserNetgroupInList      PreProc
+  HiLink sudoersUserAliasInList         PreProc
+  HiLink sudoersUserName		String
+  HiLink sudoersUID			Number
+  HiLink sudoersGroup			PreProc
+  HiLink sudoersUserNetgroup		PreProc
+  HiLink sudoersUserAliasRef            PreProc
+  HiLink sudoersUserNameInSpec		String
+  HiLink sudoersUIDInSpec		Number
+  HiLink sudoersGroupInSpec		PreProc
+  HiLink sudoersUserNetgroupInSpec	PreProc
+  HiLink sudoersUserAliasInSpec		PreProc
+  HiLink sudoersUserNameInRunas		String
+  HiLink sudoersUIDInRunas		Number
+  HiLink sudoersGroupInRunas		PreProc
+  HiLink sudoersUserNetgroupInRunas	PreProc
+  HiLink sudoersUserAliasInRunas	PreProc
+  HiLink sudoersHostAlias               Identifier
+  HiLink sudoersHostNameInList          String
+  HiLink sudoersIPAddrInList            Number
+  HiLink sudoersNetworkInList           Number
+  HiLink sudoersHostNetgroupInList      PreProc
+  HiLink sudoersHostAliasInList         PreProc
+  HiLink sudoersHostName		String
+  HiLink sudoersIPAddr			Number
+  HiLink sudoersNetwork			Number
+  HiLink sudoersHostNetgroup		PreProc
+  HiLink sudoersHostAliasRef            PreProc
+  HiLink sudoersHostNameInSpec          String
+  HiLink sudoersIPAddrInSpec            Number
+  HiLink sudoersNetworkInSpec           Number
+  HiLink sudoersHostNetgroupInSpec      PreProc
+  HiLink sudoersHostAliasInSpec         PreProc
+  HiLink sudoersCmndAlias		Identifier
+  HiLink sudoersCmndNameInList		String
+  HiLink sudoersCmndAliasInList         PreProc
+  HiLink sudoersCmndNameInSpec		String
+  HiLink sudoersCmndAliasInSpec         PreProc
+  HiLink sudoersUserAliasEquals		Operator
+  HiLink sudoersUserListComma           Delimiter
+  HiLink sudoersUserListColon           Delimiter
+  HiLink sudoersUserSpecComma           Delimiter
+  HiLink sudoersUserRunasBegin		Delimiter
+  HiLink sudoersUserRunasComma		Delimiter
+  HiLink sudoersUserRunasEnd		Delimiter
+  HiLink sudoersHostAliasEquals         Operator
+  HiLink sudoersHostListComma           Delimiter
+  HiLink sudoersHostListColon           Delimiter
+  HiLink sudoersHostSpecComma           Delimiter
+  HiLink sudoersCmndAliasEquals         Operator
+  HiLink sudoersCmndListComma           Delimiter
+  HiLink sudoersCmndListColon           Delimiter
+  HiLink sudoersCmndSpecComma           Delimiter
+  HiLink sudoersCmndSpecColon           Delimiter
+  HiLink sudoersUserNegationInList      Operator
+  HiLink sudoersHostNegationInList      Operator
+  HiLink sudoersCmndNegationInList      Operator
+  HiLink sudoersUserNegation		Operator
+  HiLink sudoersHostNegation		Operator
+  HiLink sudoersUserNegationInSpec	Operator
+  HiLink sudoersHostNegationInSpec	Operator
+  HiLink sudoersUserNegationInRunas	Operator
+  HiLink sudoersCmndNegationInSpec	Operator
+  HiLink sudoersCommandArgs		String
+  HiLink sudoersCommandEmpty		Special
+  HiLink sudoersDefaultEntry		Keyword
+  HiLink sudoersDefaultTypeAt		Special
+  HiLink sudoersDefaultTypeColon	Special
+  HiLink sudoersDefaultTypeGreaterThan	Special
+  HiLink sudoersBooleanParameter        Identifier
+  HiLink sudoersIntegerParameter        Identifier
+  HiLink sudoersStringParameter         Identifier
+  HiLink sudoersListParameter           Identifier
+  HiLink sudoersParameterListComma      Delimiter
+  HiLink sudoersIntegerParameterEquals  Operator
+  HiLink sudoersStringParameterEquals   Operator
+  HiLink sudoersListParameterEquals     Operator
+  HiLink sudoersIntegerValue            Number
+  HiLink sudoersStringValue             String
+  HiLink sudoersListValue               String
+  HiLink sudoersPASSWD			Special
+
+  delcommand HiLink
+endif
+
+let b:current_syntax = "sudoers"
+
+" vim: set sts=2 sw=2:
--- a/src/INSTALLpc.txt
+++ b/src/INSTALLpc.txt
@@ -29,7 +29,7 @@ Summary:
 ren Make_bc3.mak Makefile; make      16 bit, Borland C++ and Turbo C++
 ren Make_tcc.mak Makefile; make	     16 bit, Turbo C
 make -f Make_djg.mak		     32 bit, DJGPP 2.0
-make -f Make_bc5.mak		     32 bit, Borland C++ 5.0 (edit it to
+make -f Make_bc5.mak		     32 bit, Borland C++ 5.x (edit it to
 					     define DOS)
 
 Warning: Be sure to use the right make.exe.  Microsoft C make doesn't work;
@@ -58,9 +58,11 @@ warning (about an argument to signal()).
 Make_bc5.mak is for those that have Borland C++ 5.0 or later.  At the top of
 the file, there are some variables you can change to make either a 32-bit
 Windows exe (GUI or console mode), or a 16-bit MS-DOS version.
+NOTE: multi-byte support is broken in the Borland libraries, not everything
+will work properly!  Esp. handling multi-byte file names.
 
-If you get all kinds of strange error messages when compiling, try adding <CR>
-characters at the end of each line.
+If you get all kinds of strange error messages when compiling, try adding
+changing the file format from "unix" to "dos".
 
 
 2. Win32 (Windows NT and Windows 95)
--- a/src/Make_bc5.mak
+++ b/src/Make_bc5.mak
@@ -53,6 +53,9 @@
 #		of Ruby will cause a compile error on these systems.
 #   DYNAMIC_RUBY no or yes: use yes to load the Ruby DLL dynamically (no)
 # MBYTE		no or yes: set to yes for multi-byte support (yes)
+#               NOTE: multi-byte support is broken in the Borland libraries,
+#               not everything will work properly!  Esp. handling multi-byte
+#               file names.
 # IME		no or yes: set to yes for multi-byte IME support (yes)
 #   DYNAMIC_IME no or yes: set to yes to load imm32.dll dynamically (yes)
 # GETTEXT	no or yes: set to yes for multi-language support (yes)
--- a/src/Make_cyg.mak
+++ b/src/Make_cyg.mak
@@ -1,6 +1,6 @@
 #
 # Makefile for VIM on Win32, using Cygnus gcc
-# Last updated by Dan Sharp.  Last Change: 2004 Jul 01
+# Last updated by Dan Sharp.  Last Change: 2004 Dec 17
 #
 # This compiles Vim as a Windows application.  If you want Vim to run as a
 # Cygwin application use the Makefile (just like on Unix).
@@ -25,7 +25,7 @@
 #   DYNAMIC_IME no or yes: set to yes to load imm32.dll dynamically (yes)
 # OLE		no or yes: set to yes to make OLE gvim (no)
 # DEBUG		no or yes: set to yes if you wish a DEBUGging build (no)
-# CPUNR		i386 through pentium4: select -mcpu argument to compile with (i386)
+# CPUNR		No longer supported, use ARCH.
 # ARCH		i386 through pentium4: select -march argument to compile with (i386)
 # USEDLL	no or yes: set to yes to use the Runtime library DLL (no)
 #		For USEDLL=yes the cygwin1.dll is required to run Vim.
@@ -67,12 +67,6 @@ ifndef ARCH
 ARCH = i386
 endif
 
-ifndef CPUNR
-# Setting -march implicitly sets -mcpu to the same value,
-# so reflect that in the defaults here.
-CPUNR = $(ARCH)
-endif
-
 ifndef WINVER
 WINVER = 0x0400
 endif
@@ -96,7 +90,7 @@ endif
 
 DEFINES = -DWIN32 -DHAVE_PATHDEF -DFEAT_$(FEATURES) \
 	  -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER)
-INCLUDES = -mcpu=$(CPUNR) -march=$(ARCH) -Iproto
+INCLUDES = -march=$(ARCH) -Iproto
 
 #>>>>> name of the compiler and linker, name of lib directory
 CC = gcc
@@ -260,7 +254,7 @@ ifeq ($(OPTIMIZE), SIZE)
 OPTFLAG = -Os
 else
 ifeq ($(OPTIMIZE), MAXSPEED)
-OPTFLAG = -O3 -fomit-frame-pointer -freg-struct-return -malign-double
+OPTFLAG = -O3 -fomit-frame-pointer -freg-struct-return
 else
 OPTFLAG = -O2
 endif
@@ -428,7 +422,7 @@ uninstal.exe: uninstal.c
 	$(CC) $(CFLAGS) -o uninstal.exe uninstal.c $(LIBS)
 
 $(OUTDIR):
-	mkdir $(OUTDIR)
+	mkdir -p $(OUTDIR)
 
 tags:
 	command /c ctags *.c $(INCL)
--- a/src/Make_ming.mak
+++ b/src/Make_ming.mak
@@ -31,9 +31,7 @@ GUI=yes
 # FEATURES=[TINY | SMALL  | NORMAL | BIG | HUGE]
 # set to TINY to make minimal version (few features)
 FEATURES=BIG
-# set to one of i386, i486, i586, i686 as the *target* processor
-CPUNR=i686
-# set to same choices as 'CPUNR', but will prevent running on 'lower' cpus:
+# set to one of i386, i486, i586, i686 as the minimum target processor
 ARCH=i386
 # set to yes to cross-compile from unix; no=native Windows
 CROSS=no
@@ -242,7 +240,7 @@ endif
 #>>>>> end of choices
 ###########################################################################
 
-CFLAGS = -Iproto $(DEFINES) -pipe -w -march=$(ARCH) -mcpu=$(CPUNR) -Wall
+CFLAGS = -Iproto $(DEFINES) -pipe -w -march=$(ARCH) -Wall
 
 ifdef GETTEXT
 DEFINES +=-DHAVE_GETTEXT -DHAVE_LOCALE_H
@@ -334,7 +332,7 @@ CFLAGS += -Os
 else
 ifeq ($(OPTIMIZE), MAXSPEED)
 CFLAGS += -O3
-CFLAGS += -fomit-frame-pointer -freg-struct-return -malign-double
+CFLAGS += -fomit-frame-pointer -freg-struct-return
 else  # SPEED
 CFLAGS += -O2
 endif
@@ -549,7 +547,7 @@ INCL = vim.h feature.h os_win32.h os_dos
 	$(WINDRES) $(OUTDIR)/vimres.res $(OUTDIR)/vimrc.o
 
 $(OUTDIR):
-	mkdir $(OUTDIR)
+	mkdir -p $(OUTDIR)
 
 $(OUTDIR)/ex_docmd.o:	ex_docmd.c $(INCL) ex_cmds.h
 	$(CC) -c $(CFLAGS) ex_docmd.c -o $(OUTDIR)/ex_docmd.o
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -637,7 +637,7 @@ all:	$(VIM) vimrun.exe install.exe unins
 $(VIM).exe: $(VIM)
 
 $(OUTDIR):
-	if not exist $(OUTDIR)/nul    mkdir $(OUTDIR)
+	if not exist $(OUTDIR)/nul  mkdir $(OUTDIR)
 
 install.exe: dosinst.c
 	$(CC) /nologo -DNDEBUG -DWIN32 dosinst.c kernel32.lib shell32.lib ole32.lib advapi32.lib uuid.lib
--- a/src/Make_vms.mms
+++ b/src/Make_vms.mms
@@ -2,9 +2,9 @@
 # Makefile for Vim on OpenVMS
 #
 # Maintainer:   Zoltan Arpadffy <arpadffy@polarhome.com>
-# Last change:  2004 May 04
+# Last change:  2004 Dec 16
 #
-# This has script been tested on VMS 6.2 to 7.3 on DEC Alpha and VAX
+# This has script been tested on VMS 6.2 to 7.3 on DEC Alpha, VAX and IA64
 # with MMS and MMK
 #
 # The following could be built:
@@ -454,4 +454,282 @@ ruby_env :
 	-@ !
 .ENDIF
 
-
+buffer.obj : buffer.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h version.h
+charset.obj : charset.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+diff.obj : diff.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+digraph.obj : digraph.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+edit.obj : edit.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+eval.obj : eval.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h version.h
+ex_cmds.obj : ex_cmds.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h version.h
+ex_cmds2.obj : ex_cmds2.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h version.h
+ex_docmd.obj : ex_docmd.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+ex_eval.obj : ex_eval.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+ex_getln.obj : ex_getln.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+fileio.obj : fileio.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+fold.obj : fold.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+getchar.obj : getchar.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+if_cscope.obj : if_cscope.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h if_cscope.h
+if_xcmdsrv.obj : if_xcmdsrv.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h version.h
+main.obj : main.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h farsi.c arabic.c
+mark.obj : mark.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+memfile.obj : memfile.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+memline.obj : memline.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+menu.obj : menu.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+message.obj : message.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+misc1.obj : misc1.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h version.h
+misc2.obj : misc2.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+move.obj : move.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+mbyte.obj : mbyte.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+normal.obj : normal.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+ops.obj : ops.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+option.obj : option.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+os_unix.obj : os_unix.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h os_unixx.h
+os_vms.obj : os_vms.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h os_unixx.h
+pathdef.obj : pathdef.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+quickfix.obj : quickfix.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+regexp.obj : regexp.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+screen.obj : screen.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+search.obj : search.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+syntax.obj : syntax.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+tag.obj : tag.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+term.obj : term.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+termlib.obj : termlib.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+ui.obj : ui.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+undo.obj : undo.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+version.obj : version.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h version.h
+window.obj : window.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+gui.obj : gui.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+gui_gtk.obj : gui_gtk.c gui_gtk_f.h vim.h [.auto]config.h feature.h \
+ os_unix.h   ascii.h keymap.h term.h macros.h structs.h \
+ regexp.h gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h \
+ proto.h globals.h farsi.h arabic.h [-.pixmaps]stock_icons.h
+gui_gtk_f.obj : gui_gtk_f.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h gui_gtk_f.h
+gui_motif.obj : gui_motif.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h [-.pixmaps]alert.xpm [-.pixmaps]error.xpm \
+ [-.pixmaps]generic.xpm [-.pixmaps]info.xpm [-.pixmaps]quest.xpm
+gui_athena.obj : gui_athena.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h gui_at_sb.h
+gui_gtk_x11.obj : gui_gtk_x11.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h gui_gtk_f.h [-.runtime]vim32x32.xpm \
+ [-.runtime]vim16x16.xpm [-.runtime]vim48x48.xpm
+gui_x11.obj : gui_x11.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h [-.runtime]vim32x32.xpm \
+ [-.runtime]vim16x16.xpm [-.runtime]vim48x48.xpm [-.pixmaps]tb_new.xpm \
+ [-.pixmaps]tb_open.xpm [-.pixmaps]tb_close.xpm [-.pixmaps]tb_save.xpm \
+ [-.pixmaps]tb_print.xpm [-.pixmaps]tb_cut.xpm [-.pixmaps]tb_copy.xpm \
+ [-.pixmaps]tb_paste.xpm [-.pixmaps]tb_find.xpm \
+ [-.pixmaps]tb_find_next.xpm [-.pixmaps]tb_find_prev.xpm \
+ [-.pixmaps]tb_find_help.xpm [-.pixmaps]tb_exit.xpm \
+ [-.pixmaps]tb_undo.xpm [-.pixmaps]tb_redo.xpm [-.pixmaps]tb_help.xpm \
+ [-.pixmaps]tb_macro.xpm [-.pixmaps]tb_make.xpm \
+ [-.pixmaps]tb_save_all.xpm [-.pixmaps]tb_jump.xpm \
+ [-.pixmaps]tb_ctags.xpm [-.pixmaps]tb_load_session.xpm \
+ [-.pixmaps]tb_save_session.xpm [-.pixmaps]tb_new_session.xpm \
+ [-.pixmaps]tb_blank.xpm [-.pixmaps]tb_maximize.xpm \
+ [-.pixmaps]tb_split.xpm [-.pixmaps]tb_minimize.xpm \
+ [-.pixmaps]tb_shell.xpm [-.pixmaps]tb_replace.xpm \
+ [-.pixmaps]tb_vsplit.xpm [-.pixmaps]tb_maxwidth.xpm \
+ [-.pixmaps]tb_minwidth.xpm
+gui_at_sb.obj : gui_at_sb.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h gui_at_sb.h
+gui_at_fs.obj : gui_at_fs.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h gui_at_sb.h
+pty.obj : pty.c vim.h [.auto]config.h feature.h os_unix.h   \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
+ [.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+hangulin.obj : hangulin.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+if_perl.obj : [.auto]if_perl.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+if_perlsfio.obj : if_perlsfio.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+if_python.obj : if_python.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+if_tcl.obj : if_tcl.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+if_ruby.obj : if_ruby.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h version.h
+if_sniff.obj : if_sniff.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h os_unixx.h
+gui_beval.obj : gui_beval.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
+workshop.obj : workshop.c [.auto]config.h integration.h vim.h feature.h \
+ os_unix.h ascii.h keymap.h term.h macros.h structs.h \
+ regexp.h gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h \
+ proto.h globals.h farsi.h arabic.h version.h workshop.h
+wsdebug.obj : wsdebug.c
+integration.obj : integration.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h integration.h
+netbeans.obj : netbeans.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h version.h
--- a/src/auto/configure
+++ b/src/auto/configure
@@ -6932,15 +6932,36 @@ fi
 if test -n "$with_tlib"; then
   echo "$ac_t""$with_tlib" 1>&6
   LIBS="$LIBS -l$with_tlib"
-else
-  echo "$ac_t""automatic terminal library selection" 1>&6
+  echo $ac_n "checking for linking with $with_tlib library""... $ac_c" 1>&6
+echo "configure:6937: checking for linking with $with_tlib library" >&5
+  cat > conftest.$ac_ext <<EOF
+#line 6939 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:6946: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  echo "$ac_t""OK" 1>&6
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  { echo "configure: error: FAILED" 1>&2; exit 1; }
+fi
+rm -f conftest*
+    olibs="$LIBS"
+else
+  echo "$ac_t""empty: automatic terminal library selection" 1>&6
             case "`uname -s 2>/dev/null`" in
 	OSF1)	tlibs="ncurses curses termlib termcap";;
 	*)	tlibs="ncurses termlib termcap curses";;
   esac
   for libname in $tlibs; do
     echo $ac_n "checking for tgetent in -l${libname}""... $ac_c" 1>&6
-echo "configure:6944: checking for tgetent in -l${libname}" >&5
+echo "configure:6965: checking for tgetent in -l${libname}" >&5
 ac_lib_var=`echo ${libname}'_'tgetent | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6948,7 +6969,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l${libname}  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6952 "configure"
+#line 6973 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6959,7 +6980,7 @@ int main() {
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:6963: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6991,7 +7012,7 @@ fi
   res="FAIL"
 else
   cat > conftest.$ac_ext <<EOF
-#line 6995 "configure"
+#line 7016 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -6999,7 +7020,7 @@ else
 #endif
 main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }
 EOF
-if { (eval echo configure:7003: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7024: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   res="OK"
 else
@@ -7018,15 +7039,43 @@ fi
       LIBS="$olibs"
     fi
   done
-fi
-if test "x$olibs" != "x$LIBS"; then
-  echo $ac_n "checking whether we talk terminfo""... $ac_c" 1>&6
-echo "configure:7025: checking whether we talk terminfo" >&5
-  if test "$cross_compiling" = yes; then
+  if test "x$olibs" = "x$LIBS"; then
+    echo "$ac_t""no terminal library found" 1>&6
+  fi
+fi
+
+if test "x$olibs" = "x$LIBS"; then
+  echo $ac_n "checking for tgetent()""... $ac_c" 1>&6
+echo "configure:7050: checking for tgetent()" >&5
+  cat > conftest.$ac_ext <<EOF
+#line 7052 "configure"
+#include "confdefs.h"
+
+int main() {
+char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");
+; return 0; }
+EOF
+if { (eval echo configure:7059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  echo "$ac_t""yes" 1>&6
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  { echo "configure: error: NOT FOUND!
+      You need to install a terminal library; for example ncurses.
+      Or specify the name of the library with --with-tlib." 1>&2; exit 1; }
+fi
+rm -f conftest*
+fi
+
+echo $ac_n "checking whether we talk terminfo""... $ac_c" 1>&6
+echo "configure:7074: checking whether we talk terminfo" >&5
+if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program." 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 7030 "configure"
+#line 7079 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -7035,7 +7084,7 @@ else
 main()
 {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
 EOF
-if { (eval echo configure:7039: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7088: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   echo "$ac_t""no -- we are in termcap land" 1>&6
 else
@@ -7050,18 +7099,15 @@ fi
 rm -fr conftest*
 fi
 
-else
-  echo "$ac_t""none found" 1>&6
-fi
 
 if test "x$olibs" != "x$LIBS"; then
   echo $ac_n "checking what tgetent() returns for an unknown terminal""... $ac_c" 1>&6
-echo "configure:7060: checking what tgetent() returns for an unknown terminal" >&5
+echo "configure:7106: checking what tgetent() returns for an unknown terminal" >&5
   if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program." 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 7065 "configure"
+#line 7111 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -7070,7 +7116,7 @@ else
 main()
 {char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
 EOF
-if { (eval echo configure:7074: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   echo "$ac_t""zero" 1>&6; cat >> confdefs.h <<\EOF
 #define TGETENT_ZERO_ERR 0
@@ -7088,9 +7134,9 @@ fi
 fi
 
 echo $ac_n "checking whether termcap.h contains ospeed""... $ac_c" 1>&6
-echo "configure:7092: checking whether termcap.h contains ospeed" >&5
+echo "configure:7138: checking whether termcap.h contains ospeed" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7094 "configure"
+#line 7140 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -7101,7 +7147,7 @@ int main() {
 ospeed = 20000
 ; return 0; }
 EOF
-if { (eval echo configure:7105: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7151: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_OSPEED 1
@@ -7113,9 +7159,9 @@ else
   rm -rf conftest*
   echo "$ac_t""no" 1>&6
 	echo $ac_n "checking whether ospeed can be extern""... $ac_c" 1>&6
-echo "configure:7117: checking whether ospeed can be extern" >&5
+echo "configure:7163: checking whether ospeed can be extern" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 7119 "configure"
+#line 7165 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -7127,7 +7173,7 @@ int main() {
 ospeed = 20000
 ; return 0; }
 EOF
-if { (eval echo configure:7131: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7177: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define OSPEED_EXTERN 1
@@ -7145,9 +7191,9 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking whether termcap.h contains UP, BC and PC""... $ac_c" 1>&6
-echo "configure:7149: checking whether termcap.h contains UP, BC and PC" >&5
+echo "configure:7195: checking whether termcap.h contains UP, BC and PC" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7151 "configure"
+#line 7197 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -7158,7 +7204,7 @@ int main() {
 if (UP == 0 && BC == 0) PC = 1
 ; return 0; }
 EOF
-if { (eval echo configure:7162: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7208: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_UP_BC_PC 1
@@ -7170,9 +7216,9 @@ else
   rm -rf conftest*
   echo "$ac_t""no" 1>&6
 	echo $ac_n "checking whether UP, BC and PC can be extern""... $ac_c" 1>&6
-echo "configure:7174: checking whether UP, BC and PC can be extern" >&5
+echo "configure:7220: checking whether UP, BC and PC can be extern" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 7176 "configure"
+#line 7222 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -7184,7 +7230,7 @@ int main() {
 if (UP == 0 && BC == 0) PC = 1
 ; return 0; }
 EOF
-if { (eval echo configure:7188: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define UP_BC_PC_EXTERN 1
@@ -7202,9 +7248,9 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking whether tputs() uses outfuntype""... $ac_c" 1>&6
-echo "configure:7206: checking whether tputs() uses outfuntype" >&5
+echo "configure:7252: checking whether tputs() uses outfuntype" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7208 "configure"
+#line 7254 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -7215,7 +7261,7 @@ int main() {
 extern int xx(); tputs("test", 1, (outfuntype)xx)
 ; return 0; }
 EOF
-if { (eval echo configure:7219: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7265: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_OUTFUNTYPE 1
@@ -7230,9 +7276,9 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking whether sys/select.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:7234: checking whether sys/select.h and sys/time.h may both be included" >&5
+echo "configure:7280: checking whether sys/select.h and sys/time.h may both be included" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7236 "configure"
+#line 7282 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -7242,7 +7288,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:7246: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7292: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 			cat >> confdefs.h <<\EOF
@@ -7259,7 +7305,7 @@ rm -f conftest*
 
 
 echo $ac_n "checking for /dev/ptc""... $ac_c" 1>&6
-echo "configure:7263: checking for /dev/ptc" >&5
+echo "configure:7309: checking for /dev/ptc" >&5
 if test -r /dev/ptc; then
   cat >> confdefs.h <<\EOF
 #define HAVE_DEV_PTC 1
@@ -7271,17 +7317,17 @@ else
 fi
 
 echo $ac_n "checking for SVR4 ptys""... $ac_c" 1>&6
-echo "configure:7275: checking for SVR4 ptys" >&5
+echo "configure:7321: checking for SVR4 ptys" >&5
 if test -c /dev/ptmx ; then
   cat > conftest.$ac_ext <<EOF
-#line 7278 "configure"
+#line 7324 "configure"
 #include "confdefs.h"
 
 int main() {
 ptsname(0);grantpt(0);unlockpt(0);
 ; return 0; }
 EOF
-if { (eval echo configure:7285: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7331: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_SVR4_PTYS 1
@@ -7299,14 +7345,14 @@ else
 fi
 
 echo $ac_n "checking for ptyranges""... $ac_c" 1>&6
-echo "configure:7303: checking for ptyranges" >&5
+echo "configure:7349: checking for ptyranges" >&5
 if test -d /dev/ptym ; then
   pdir='/dev/ptym'
 else
   pdir='/dev'
 fi
 cat > conftest.$ac_ext <<EOF
-#line 7310 "configure"
+#line 7356 "configure"
 #include "confdefs.h"
 #ifdef M_UNIX
    yes;
@@ -7340,13 +7386,13 @@ else
 fi
 
 echo $ac_n "checking default tty permissions/group""... $ac_c" 1>&6
-echo "configure:7344: checking default tty permissions/group" >&5
+echo "configure:7390: checking default tty permissions/group" >&5
 rm -f conftest_grp
 if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 7350 "configure"
+#line 7396 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -7378,7 +7424,7 @@ main()
 }
 
 EOF
-if { (eval echo configure:7382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7428: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     if test -f conftest_grp; then
@@ -7409,12 +7455,12 @@ rm -f conftest_grp
 
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:7413: checking return type of signal handlers" >&5
+echo "configure:7459: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7418 "configure"
+#line 7464 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -7431,7 +7477,7 @@ int main() {
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:7435: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7481: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -7463,9 +7509,9 @@ EOF
 fi
 
 echo $ac_n "checking for struct sigcontext""... $ac_c" 1>&6
-echo "configure:7467: checking for struct sigcontext" >&5
+echo "configure:7513: checking for struct sigcontext" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7469 "configure"
+#line 7515 "configure"
 #include "confdefs.h"
 
 #include <signal.h>
@@ -7479,7 +7525,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:7483: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7529: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 		cat >> confdefs.h <<\EOF
@@ -7495,12 +7541,12 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking getcwd implementation""... $ac_c" 1>&6
-echo "configure:7499: checking getcwd implementation" >&5
+echo "configure:7545: checking getcwd implementation" >&5
 if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 7504 "configure"
+#line 7550 "configure"
 #include "confdefs.h"
 
 char *dagger[] = { "IFS=pwd", 0 };
@@ -7512,7 +7558,7 @@ main()
   return getcwd(buffer, 500) ? 0 : 1;
 }
 EOF
-if { (eval echo configure:7516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7562: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   echo "$ac_t""it is usable" 1>&6
 else
@@ -7537,12 +7583,12 @@ for ac_func in bcmp fchdir fchown fseeko
 	strnicmp strpbrk strtol tgetent towlower towupper usleep utime utimes
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7541: checking for $ac_func" >&5
+echo "configure:7587: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7546 "configure"
+#line 7592 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7565,7 +7611,7 @@ choke me
 
 ; return 0; }
 EOF
-if { (eval echo configure:7569: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7591,9 +7637,9 @@ done
 
 
 echo $ac_n "checking for st_blksize""... $ac_c" 1>&6
-echo "configure:7595: checking for st_blksize" >&5
+echo "configure:7641: checking for st_blksize" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7597 "configure"
+#line 7643 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -7605,7 +7651,7 @@ int main() {
 	n = (int)st.st_blksize;
 ; return 0; }
 EOF
-if { (eval echo configure:7609: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7655: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_ST_BLKSIZE 1
@@ -7620,18 +7666,18 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking whether stat() ignores a trailing slash""... $ac_c" 1>&6
-echo "configure:7624: checking whether stat() ignores a trailing slash" >&5
+echo "configure:7670: checking whether stat() ignores a trailing slash" >&5
 if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 7629 "configure"
+#line 7675 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 main() {struct stat st;  exit(stat("configure/", &st) != 0); }
 EOF
-if { (eval echo configure:7635: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7681: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define STAT_IGNORES_SLASH 1
@@ -7648,11 +7694,11 @@ fi
 
 
 echo $ac_n "checking for iconv_open()""... $ac_c" 1>&6
-echo "configure:7652: checking for iconv_open()" >&5
+echo "configure:7698: checking for iconv_open()" >&5
 save_LIBS="$LIBS"
 LIBS="$LIBS -liconv"
 cat > conftest.$ac_ext <<EOF
-#line 7656 "configure"
+#line 7702 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_ICONV_H
@@ -7663,7 +7709,7 @@ int main() {
 iconv_open("fr", "to");
 ; return 0; }
 EOF
-if { (eval echo configure:7667: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7713: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes; with -liconv" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_ICONV 1
@@ -7675,7 +7721,7 @@ else
   rm -rf conftest*
   LIBS="$save_LIBS"
     cat > conftest.$ac_ext <<EOF
-#line 7679 "configure"
+#line 7725 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_ICONV_H
@@ -7686,7 +7732,7 @@ int main() {
 iconv_open("fr", "to");
 ; return 0; }
 EOF
-if { (eval echo configure:7690: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_ICONV 1
@@ -7704,9 +7750,9 @@ rm -f conftest*
 
 
 echo $ac_n "checking for nl_langinfo(CODESET)""... $ac_c" 1>&6
-echo "configure:7708: checking for nl_langinfo(CODESET)" >&5
+echo "configure:7754: checking for nl_langinfo(CODESET)" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7710 "configure"
+#line 7756 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_LANGINFO_H
@@ -7717,7 +7763,7 @@ int main() {
 char *cs = nl_langinfo(CODESET);
 ; return 0; }
 EOF
-if { (eval echo configure:7721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7767: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_NL_LANGINFO_CODESET 1
@@ -7732,7 +7778,7 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking --disable-acl argument""... $ac_c" 1>&6
-echo "configure:7736: checking --disable-acl argument" >&5
+echo "configure:7782: checking --disable-acl argument" >&5
 # Check whether --enable-acl or --disable-acl was given.
 if test "${enable_acl+set}" = set; then
   enableval="$enable_acl"
@@ -7744,7 +7790,7 @@ fi
 if test "$enable_acl" = "yes"; then
 echo "$ac_t""no" 1>&6
 echo $ac_n "checking for acl_get_file in -lposix1e""... $ac_c" 1>&6
-echo "configure:7748: checking for acl_get_file in -lposix1e" >&5
+echo "configure:7794: checking for acl_get_file in -lposix1e" >&5
 ac_lib_var=`echo posix1e'_'acl_get_file | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7752,7 +7798,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lposix1e  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7756 "configure"
+#line 7802 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7763,7 +7809,7 @@ int main() {
 acl_get_file()
 ; return 0; }
 EOF
-if { (eval echo configure:7767: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7813: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7782,7 +7828,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_l
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for acl_get_file in -lacl""... $ac_c" 1>&6
-echo "configure:7786: checking for acl_get_file in -lacl" >&5
+echo "configure:7832: checking for acl_get_file in -lacl" >&5
 ac_lib_var=`echo acl'_'acl_get_file | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7790,7 +7836,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lacl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7794 "configure"
+#line 7840 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7801,7 +7847,7 @@ int main() {
 acl_get_file()
 ; return 0; }
 EOF
-if { (eval echo configure:7805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7818,7 +7864,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_l
   echo "$ac_t""yes" 1>&6
   LIBS="$LIBS -lacl"
 		  echo $ac_n "checking for fgetxattr in -lattr""... $ac_c" 1>&6
-echo "configure:7822: checking for fgetxattr in -lattr" >&5
+echo "configure:7868: checking for fgetxattr in -lattr" >&5
 ac_lib_var=`echo attr'_'fgetxattr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7826,7 +7872,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lattr  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7830 "configure"
+#line 7876 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7837,7 +7883,7 @@ int main() {
 fgetxattr()
 ; return 0; }
 EOF
-if { (eval echo configure:7841: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7887: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7865,9 +7911,9 @@ fi
 
 
 echo $ac_n "checking for POSIX ACL support""... $ac_c" 1>&6
-echo "configure:7869: checking for POSIX ACL support" >&5
+echo "configure:7915: checking for POSIX ACL support" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7871 "configure"
+#line 7917 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -7881,7 +7927,7 @@ acl = acl_get_file("foo", ACL_TYPE_ACCES
 	acl_free(acl);
 ; return 0; }
 EOF
-if { (eval echo configure:7885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_POSIX_ACL 1
@@ -7896,9 +7942,9 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking for Solaris ACL support""... $ac_c" 1>&6
-echo "configure:7900: checking for Solaris ACL support" >&5
+echo "configure:7946: checking for Solaris ACL support" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7902 "configure"
+#line 7948 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_SYS_ACL_H
@@ -7909,7 +7955,7 @@ acl("foo", GETACLCNT, 0, NULL);
 	
 ; return 0; }
 EOF
-if { (eval echo configure:7913: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_SOLARIS_ACL 1
@@ -7924,9 +7970,9 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking for AIX ACL support""... $ac_c" 1>&6
-echo "configure:7928: checking for AIX ACL support" >&5
+echo "configure:7974: checking for AIX ACL support" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7930 "configure"
+#line 7976 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_SYS_ACL_H
@@ -7948,7 +7994,7 @@ aclsize = sizeof(struct acl);
 	
 ; return 0; }
 EOF
-if { (eval echo configure:7952: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_AIX_ACL 1
@@ -7966,7 +8012,7 @@ else
 fi
 
 echo $ac_n "checking --disable-gpm argument""... $ac_c" 1>&6
-echo "configure:7970: checking --disable-gpm argument" >&5
+echo "configure:8016: checking --disable-gpm argument" >&5
 # Check whether --enable-gpm or --disable-gpm was given.
 if test "${enable_gpm+set}" = set; then
   enableval="$enable_gpm"
@@ -7979,13 +8025,13 @@ fi
 if test "$enable_gpm" = "yes"; then
   echo "$ac_t""no" 1>&6
     echo $ac_n "checking for gpm""... $ac_c" 1>&6
-echo "configure:7983: checking for gpm" >&5
+echo "configure:8029: checking for gpm" >&5
 if eval "test \"`echo '$''{'vi_cv_have_gpm'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   olibs="$LIBS" ; LIBS="-lgpm"
 	cat > conftest.$ac_ext <<EOF
-#line 7989 "configure"
+#line 8035 "configure"
 #include "confdefs.h"
 #include <gpm.h>
 	    #include <linux/keyboard.h>
@@ -7993,7 +8039,7 @@ int main() {
 Gpm_GetLibVersion(NULL);
 ; return 0; }
 EOF
-if { (eval echo configure:7997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8043: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   	    	    vi_cv_have_gpm=yes
 else
@@ -8020,12 +8066,12 @@ else
 fi
 
 echo $ac_n "checking for vsnprintf()""... $ac_c" 1>&6
-echo "configure:8024: checking for vsnprintf()" >&5
+echo "configure:8070: checking for vsnprintf()" >&5
 if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 8029 "configure"
+#line 8075 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -8046,7 +8092,7 @@ else
 	}
 	    
 EOF
-if { (eval echo configure:8050: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:8096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   cat >> confdefs.h <<\EOF
 #define HAVE_VSNPRINTF 1
@@ -8064,16 +8110,16 @@ fi
 
 
 echo $ac_n "checking for rename""... $ac_c" 1>&6
-echo "configure:8068: checking for rename" >&5
+echo "configure:8114: checking for rename" >&5
 cat > conftest.$ac_ext <<EOF
-#line 8070 "configure"
+#line 8116 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main() {
 rename("this", "that")
 ; return 0; }
 EOF
-if { (eval echo configure:8077: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8123: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_RENAME 1
@@ -8088,9 +8134,9 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking for sysctl""... $ac_c" 1>&6
-echo "configure:8092: checking for sysctl" >&5
+echo "configure:8138: checking for sysctl" >&5
 cat > conftest.$ac_ext <<EOF
-#line 8094 "configure"
+#line 8140 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/sysctl.h>
@@ -8105,7 +8151,7 @@ int main() {
 	
 ; return 0; }
 EOF
-if { (eval echo configure:8109: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8155: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_SYSCTL 1
@@ -8120,9 +8166,9 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking for sysinfo""... $ac_c" 1>&6
-echo "configure:8124: checking for sysinfo" >&5
+echo "configure:8170: checking for sysinfo" >&5
 cat > conftest.$ac_ext <<EOF
-#line 8126 "configure"
+#line 8172 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/sysinfo.h>
@@ -8135,7 +8181,7 @@ int main() {
 	
 ; return 0; }
 EOF
-if { (eval echo configure:8139: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8185: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_SYSINFO 1
@@ -8150,9 +8196,9 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking for sysconf""... $ac_c" 1>&6
-echo "configure:8154: checking for sysconf" >&5
+echo "configure:8200: checking for sysconf" >&5
 cat > conftest.$ac_ext <<EOF
-#line 8156 "configure"
+#line 8202 "configure"
 #include "confdefs.h"
 #include <unistd.h>
 int main() {
@@ -8161,7 +8207,7 @@ int main() {
 	
 ; return 0; }
 EOF
-if { (eval echo configure:8165: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8211: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_SYSCONF 1
@@ -8177,7 +8223,7 @@ rm -f conftest*
 
 
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:8181: checking size of int" >&5
+echo "configure:8227: checking size of int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8185,7 +8231,7 @@ else
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 8189 "configure"
+#line 8235 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 		main()
@@ -8196,7 +8242,7 @@ else
 		  exit(0);
 		}
 EOF
-if { (eval echo configure:8200: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:8246: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -8217,7 +8263,7 @@ EOF
 
 
 echo $ac_n "checking whether memmove/bcopy/memcpy handle overlaps""... $ac_c" 1>&6
-echo "configure:8221: checking whether memmove/bcopy/memcpy handle overlaps" >&5
+echo "configure:8267: checking whether memmove/bcopy/memcpy handle overlaps" >&5
 bcopy_test_prog='
 main() {
   char buf[10];
@@ -8237,11 +8283,11 @@ if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 8241 "configure"
+#line 8287 "configure"
 #include "confdefs.h"
 #define mch_memmove(s,d,l) memmove(d,s,l) $bcopy_test_prog
 EOF
-if { (eval echo configure:8245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:8291: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   cat >> confdefs.h <<\EOF
 #define USEMEMMOVE 1
@@ -8255,11 +8301,11 @@ else
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 8259 "configure"
+#line 8305 "configure"
 #include "confdefs.h"
 #define mch_memmove(s,d,l) bcopy(d,s,l) $bcopy_test_prog
 EOF
-if { (eval echo configure:8263: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:8309: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   cat >> confdefs.h <<\EOF
 #define USEBCOPY 1
@@ -8273,11 +8319,11 @@ else
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 8277 "configure"
+#line 8323 "configure"
 #include "confdefs.h"
 #define mch_memmove(s,d,l) memcpy(d,s,l) $bcopy_test_prog
 EOF
-if { (eval echo configure:8281: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:8327: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   cat >> confdefs.h <<\EOF
 #define USEMEMCPY 1
@@ -8309,19 +8355,19 @@ if test "$enable_multibyte" = "yes"; the
     CFLAGS="$CFLAGS -I$x_includes"
     LDFLAGS="$X_LIBS $LDFLAGS -lX11"
     echo $ac_n "checking whether X_LOCALE needed""... $ac_c" 1>&6
-echo "configure:8313: checking whether X_LOCALE needed" >&5
+echo "configure:8359: checking whether X_LOCALE needed" >&5
     cat > conftest.$ac_ext <<EOF
-#line 8315 "configure"
+#line 8361 "configure"
 #include "confdefs.h"
 #include <X11/Xlocale.h>
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:8322: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8368: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat > conftest.$ac_ext <<EOF
-#line 8325 "configure"
+#line 8371 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -8332,7 +8378,7 @@ int main() {
 _Xsetlocale()
 ; return 0; }
 EOF
-if { (eval echo configure:8336: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 		cat >> confdefs.h <<\EOF
@@ -8359,7 +8405,7 @@ rm -f conftest*
 fi
 
 echo $ac_n "checking for _xpg4_setrunelocale in -lxpg4""... $ac_c" 1>&6
-echo "configure:8363: checking for _xpg4_setrunelocale in -lxpg4" >&5
+echo "configure:8409: checking for _xpg4_setrunelocale in -lxpg4" >&5
 ac_lib_var=`echo xpg4'_'_xpg4_setrunelocale | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -8367,7 +8413,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lxpg4  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 8371 "configure"
+#line 8417 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -8378,7 +8424,7 @@ int main() {
 _xpg4_setrunelocale()
 ; return 0; }
 EOF
-if { (eval echo configure:8382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8428: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -8400,7 +8446,7 @@ fi
 
 
 echo $ac_n "checking how to create tags""... $ac_c" 1>&6
-echo "configure:8404: checking how to create tags" >&5
+echo "configure:8450: checking how to create tags" >&5
 test -f tags && mv tags tags.save
 if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&5 2>&1; then
   TAGPRG="ctags"
@@ -8417,7 +8463,7 @@ test -f tags.save && mv tags.save tags
 echo "$ac_t""$TAGPRG" 1>&6 
 
 echo $ac_n "checking how to run man with a section nr""... $ac_c" 1>&6
-echo "configure:8421: checking how to run man with a section nr" >&5
+echo "configure:8467: checking how to run man with a section nr" >&5
 MANDEF="man"
 (eval man -s 2 read) < /dev/null > /dev/null 2>&5 && MANDEF="man -s"
 echo "$ac_t""$MANDEF" 1>&6
@@ -8429,7 +8475,7 @@ EOF
 fi
 
 echo $ac_n "checking --disable-nls argument""... $ac_c" 1>&6
-echo "configure:8433: checking --disable-nls argument" >&5
+echo "configure:8479: checking --disable-nls argument" >&5
 # Check whether --enable-nls or --disable-nls was given.
 if test "${enable_nls+set}" = set; then
   enableval="$enable_nls"
@@ -8444,7 +8490,7 @@ if test "$enable_nls" = "yes"; then
   # Extract the first word of "msgfmt", so it can be a program name with args.
 set dummy msgfmt; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:8448: checking for $ac_word" >&5
+echo "configure:8494: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_MSGFMT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8471,19 +8517,19 @@ else
 fi
 
   echo $ac_n "checking for NLS""... $ac_c" 1>&6
-echo "configure:8475: checking for NLS" >&5
+echo "configure:8521: checking for NLS" >&5
   if test -f po/Makefile; then
     have_gettext="no"
     if test -n "$MSGFMT"; then
       cat > conftest.$ac_ext <<EOF
-#line 8480 "configure"
+#line 8526 "configure"
 #include "confdefs.h"
 #include <libintl.h>
 int main() {
 gettext("Test");
 ; return 0; }
 EOF
-if { (eval echo configure:8487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8533: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""gettext() works" 1>&6; have_gettext="yes"
 else
@@ -8493,14 +8539,14 @@ else
   olibs=$LIBS
 	  LIBS="$LIBS -lintl"
 	  cat > conftest.$ac_ext <<EOF
-#line 8497 "configure"
+#line 8543 "configure"
 #include "confdefs.h"
 #include <libintl.h>
 int main() {
 gettext("Test");
 ; return 0; }
 EOF
-if { (eval echo configure:8504: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8550: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""gettext() works with -lintl" 1>&6; have_gettext="yes"
 else
@@ -8526,12 +8572,12 @@ EOF
             for ac_func in bind_textdomain_codeset
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8530: checking for $ac_func" >&5
+echo "configure:8576: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8535 "configure"
+#line 8581 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8554,7 +8600,7 @@ choke me
 
 ; return 0; }
 EOF
-if { (eval echo configure:8558: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8604: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -8579,9 +8625,9 @@ fi
 done
 
             echo $ac_n "checking for _nl_msg_cat_cntr""... $ac_c" 1>&6
-echo "configure:8583: checking for _nl_msg_cat_cntr" >&5
+echo "configure:8629: checking for _nl_msg_cat_cntr" >&5
       cat > conftest.$ac_ext <<EOF
-#line 8585 "configure"
+#line 8631 "configure"
 #include "confdefs.h"
 #include <libintl.h>
 		extern int _nl_msg_cat_cntr;
@@ -8589,7 +8635,7 @@ int main() {
 ++_nl_msg_cat_cntr;
 ; return 0; }
 EOF
-if { (eval echo configure:8593: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8639: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_NL_MSG_CAT_CNTR 1
@@ -8612,17 +8658,17 @@ fi
 
 ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6
-echo "configure:8616: checking for dlfcn.h" >&5
+echo "configure:8662: checking for dlfcn.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8621 "configure"
+#line 8667 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8626: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8672: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8643,17 +8689,17 @@ else
   echo "$ac_t""no" 1>&6
 ac_safe=`echo "dl.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dl.h""... $ac_c" 1>&6
-echo "configure:8647: checking for dl.h" >&5
+echo "configure:8693: checking for dl.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8652 "configure"
+#line 8698 "configure"
 #include "confdefs.h"
 #include <dl.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8657: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8703: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8682,9 +8728,9 @@ if test x${DLL} = xdlfcn.h; then
 EOF
 
   echo $ac_n "checking for dlopen()""... $ac_c" 1>&6
-echo "configure:8686: checking for dlopen()" >&5
+echo "configure:8732: checking for dlopen()" >&5
   cat > conftest.$ac_ext <<EOF
-#line 8688 "configure"
+#line 8734 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -8694,7 +8740,7 @@ int main() {
       
 ; return 0; }
 EOF
-if { (eval echo configure:8698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8744: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6;
 	      cat >> confdefs.h <<\EOF
@@ -8707,11 +8753,11 @@ else
   rm -rf conftest*
   echo "$ac_t""no" 1>&6;
 	      echo $ac_n "checking for dlopen() in -ldl""... $ac_c" 1>&6
-echo "configure:8711: checking for dlopen() in -ldl" >&5
+echo "configure:8757: checking for dlopen() in -ldl" >&5
 	      olibs=$LIBS
 	      LIBS="$LIBS -ldl"
 	      cat > conftest.$ac_ext <<EOF
-#line 8715 "configure"
+#line 8761 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -8721,7 +8767,7 @@ int main() {
 		 
 ; return 0; }
 EOF
-if { (eval echo configure:8725: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8771: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6;
 			  cat >> confdefs.h <<\EOF
@@ -8739,9 +8785,9 @@ rm -f conftest*
 fi
 rm -f conftest*
       echo $ac_n "checking for dlsym()""... $ac_c" 1>&6
-echo "configure:8743: checking for dlsym()" >&5
+echo "configure:8789: checking for dlsym()" >&5
   cat > conftest.$ac_ext <<EOF
-#line 8745 "configure"
+#line 8791 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -8751,7 +8797,7 @@ int main() {
       
 ; return 0; }
 EOF
-if { (eval echo configure:8755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6;
 	      cat >> confdefs.h <<\EOF
@@ -8764,11 +8810,11 @@ else
   rm -rf conftest*
   echo "$ac_t""no" 1>&6;
 	      echo $ac_n "checking for dlsym() in -ldl""... $ac_c" 1>&6
-echo "configure:8768: checking for dlsym() in -ldl" >&5
+echo "configure:8814: checking for dlsym() in -ldl" >&5
 	      olibs=$LIBS
 	      LIBS="$LIBS -ldl"
 	      cat > conftest.$ac_ext <<EOF
-#line 8772 "configure"
+#line 8818 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -8778,7 +8824,7 @@ int main() {
 		 
 ; return 0; }
 EOF
-if { (eval echo configure:8782: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8828: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6;
 			  cat >> confdefs.h <<\EOF
@@ -8801,9 +8847,9 @@ elif test x${DLL} = xdl.h; then
 EOF
 
   echo $ac_n "checking for shl_load()""... $ac_c" 1>&6
-echo "configure:8805: checking for shl_load()" >&5
+echo "configure:8851: checking for shl_load()" >&5
   cat > conftest.$ac_ext <<EOF
-#line 8807 "configure"
+#line 8853 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -8813,7 +8859,7 @@ int main() {
      
 ; return 0; }
 EOF
-if { (eval echo configure:8817: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8863: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6;
 	  cat >> confdefs.h <<\EOF
@@ -8826,11 +8872,11 @@ else
   rm -rf conftest*
   echo "$ac_t""no" 1>&6;
 	  echo $ac_n "checking for shl_load() in -ldld""... $ac_c" 1>&6
-echo "configure:8830: checking for shl_load() in -ldld" >&5
+echo "configure:8876: checking for shl_load() in -ldld" >&5
 	  olibs=$LIBS
 	  LIBS="$LIBS -ldld"
 	  cat > conftest.$ac_ext <<EOF
-#line 8834 "configure"
+#line 8880 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -8840,7 +8886,7 @@ int main() {
 	     
 ; return 0; }
 EOF
-if { (eval echo configure:8844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8890: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6;
 		  cat >> confdefs.h <<\EOF
@@ -8862,17 +8908,17 @@ for ac_hdr in setjmp.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:8866: checking for $ac_hdr" >&5
+echo "configure:8912: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8871 "configure"
+#line 8917 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8876: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8922: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8909,7 +8955,7 @@ fi
 if test "x$MACOSX" = "xyes" && test "x$CARBON" = "xyes" \
 	&& test "x$GUITYPE" != "xCARBONGUI"; then
   echo $ac_n "checking whether we need -framework Carbon""... $ac_c" 1>&6
-echo "configure:8913: checking whether we need -framework Carbon" >&5
+echo "configure:8959: checking whether we need -framework Carbon" >&5
     if test "x$enable_multibyte" = "xyes" || test "x$features" == "xbig" \
 	|| test "x$features" = "xhuge"; then
     LIBS="$LIBS -framework Carbon"
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2976,22 +2976,13 @@ maketitle()
 		    off += 2;
 #endif
 		/* remove the file name */
-		p = gettail(buf + off);
+		p = gettail_sep(buf + off);
 		if (p == buf + off)
-		{
 		    /* must be a help buffer */
 		    STRCPY(buf + off, _("help"));
-		}
 		else
-		{
-		    while (p > buf + off + 1 && vim_ispathsep(p[-1]))
-			--p;
-#ifdef VMS
-		    /* path separator is part of the path */
-		    ++p;
-#endif
 		    *p = NUL;
-		}
+
 		/* translate unprintable chars */
 		p = transstr(buf + off);
 		STRNCPY(buf + off, p, IOSIZE - off);
--- a/src/charset.c
+++ b/src/charset.c
@@ -819,12 +819,7 @@ win_linetabsize(wp, p, len)
     for (s = p; *s != NUL && (len == MAXCOL || s < p + len); )
     {
 	col += win_lbr_chartabsize(wp, s, col, NULL);
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    s += (*mb_ptr2len_check)(s);
-	else
-#endif
-	    ++s;
+	mb_ptr_adv(s);
     }
     return (int)col;
 }
@@ -967,12 +962,7 @@ lbr_chartabsize_adv(s, col)
     int		retval;
 
     retval = lbr_chartabsize(*s, col);
-#ifdef FEAT_MBYTE
-    if (has_mbyte)
-	*s += (*mb_ptr2len_check)(*s);
-    else
-#endif
-	++*s;
+    mb_ptr_adv(*s);
     return retval;
 }
 
@@ -1054,12 +1044,7 @@ win_lbr_chartabsize(wp, s, col, headp)
 	for (;;)
 	{
 	    ps = s;
-# ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		s += (*mb_ptr2len_check)(s);
-	    else
-# endif
-		++s;
+	    mb_ptr_adv(s);
 	    c = *s;
 	    if (!(c != NUL
 		    && (vim_isbreak(c)
@@ -1263,12 +1248,7 @@ getvcol(wp, pos, start, cursor, end)
 		break;
 
 	    vcol += incr;
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		ptr += (*mb_ptr2len_check)(ptr);
-	    else
-#endif
-		++ptr;
+	    mb_ptr_adv(ptr);
 	}
     }
     else
@@ -1289,12 +1269,7 @@ getvcol(wp, pos, start, cursor, end)
 		break;
 
 	    vcol += incr;
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		ptr += (*mb_ptr2len_check)(ptr);
-	    else
-#endif
-		++ptr;
+	    mb_ptr_adv(ptr);
 	}
     }
     if (start != NULL)
@@ -1571,6 +1546,7 @@ vim_str2nr(start, hexp, len, dooct, dohe
     int		    hex = 0;		/* default is decimal */
     int		    negative = FALSE;
     unsigned long   un = 0;
+    int		    n;
 
     if (ptr[0] == '-')
     {
@@ -1578,17 +1554,29 @@ vim_str2nr(start, hexp, len, dooct, dohe
 	++ptr;
     }
 
-    if (ptr[0] == '0')			/* could be hex or octal */
+    /* Recognize hex and octal. */
+    if (ptr[0] == '0' && ptr[1] != '8' && ptr[1] != '9')
     {
 	hex = ptr[1];
 	if (dohex && (hex == 'X' || hex == 'x') && vim_isxdigit(ptr[2]))
 	    ptr += 2;			/* hexadecimal */
 	else
 	{
-	    if (dooct && VIM_ISDIGIT(hex))
-		hex = '0';		/* octal */
-	    else
-		hex = 0;		/* 0 by itself is decimal */
+	    hex = 0;			/* default is decimal */
+	    if (dooct)
+	    {
+		/* Don't interpret "0", "08" or "0129" as octal. */
+		for (n = 1; VIM_ISDIGIT(ptr[n]); ++n)
+		{
+		    if (ptr[n] > '7')
+		    {
+			hex = 0;	/* can't be octal */
+			break;
+		    }
+		    if (ptr[n] > '0')
+			hex = '0';	/* assume octal */
+		}
+	    }
 	}
     }
 
--- a/src/configure.in
+++ b/src/configure.in
@@ -2356,8 +2356,12 @@ AC_ARG_WITH(tlib, [  --with-tlib=library
 if test -n "$with_tlib"; then
   AC_MSG_RESULT($with_tlib)
   LIBS="$LIBS -l$with_tlib"
+  AC_MSG_CHECKING(for linking with $with_tlib library)
+  AC_TRY_LINK([], [], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED))
+  dnl Need to check for tgetent() below.
+  olibs="$LIBS"
 else
-  AC_MSG_RESULT([automatic terminal library selection])
+  AC_MSG_RESULT([empty: automatic terminal library selection])
   dnl  On HP-UX 10.10 termcap or termlib should be used instead of
   dnl  curses, because curses is much slower.
   dnl  Newer versions of ncurses are preferred over anything.
@@ -2386,10 +2390,23 @@ main() {char *s; s=(char *)tgoto("%p1%d"
       LIBS="$olibs"
     fi
   done
+  if test "x$olibs" = "x$LIBS"; then
+    AC_MSG_RESULT(no terminal library found)
+  fi
 fi
-if test "x$olibs" != "x$LIBS"; then
-  AC_MSG_CHECKING(whether we talk terminfo)
-  AC_TRY_RUN([
+
+if test "x$olibs" = "x$LIBS"; then
+  AC_MSG_CHECKING([for tgetent()])
+  AC_TRY_LINK([], 
+      [char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist");],
+	AC_MSG_RESULT(yes),
+	AC_MSG_ERROR([NOT FOUND!
+      You need to install a terminal library; for example ncurses.
+      Or specify the name of the library with --with-tlib.]))
+fi
+
+AC_MSG_CHECKING(whether we talk terminfo)
+AC_TRY_RUN([
 #ifdef HAVE_TERMCAP_H
 # include <termcap.h>
 #endif
@@ -2398,9 +2415,6 @@ main()
 	  AC_MSG_RESULT([no -- we are in termcap land]),
 	  AC_MSG_RESULT([yes -- terminfo spoken here]); AC_DEFINE(TERMINFO),
 	  AC_MSG_ERROR(failed to compile test program.))
-else
-  AC_MSG_RESULT(none found)
-fi
 
 if test "x$olibs" != "x$LIBS"; then
   AC_MSG_CHECKING(what tgetent() returns for an unknown terminal)
--- a/src/eval.c
+++ b/src/eval.c
@@ -2571,7 +2571,7 @@ get_string_var(arg, retvar, evaluate)
     /*
      * Find the end of the string, skipping backslashed characters.
      */
-    for (p = *arg + 1; *p && *p != '"'; ++p)
+    for (p = *arg + 1; *p && *p != '"'; mb_ptr_adv(p))
     {
 	if (*p == '\\' && p[1] != NUL)
 	{
@@ -2581,10 +2581,6 @@ get_string_var(arg, retvar, evaluate)
 	    if (*p == '<')
 		extra += 2;
 	}
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
 
     if (*p != '"')
@@ -4736,6 +4732,7 @@ f_getcwd(argvars, retvar)
 /*
  * "getfontname()" function
  */
+/*ARGSUSED*/
     static void
 f_getfontname(argvars, retvar)
     VAR		argvars;
@@ -6437,7 +6434,7 @@ f_resolve(argvars, retvar)
 	    is_relative_to_current = TRUE;
 
 	len = STRLEN(p);
-	if (len > 0 && vim_ispathsep(p[len-1]))
+	if (len > 0 && after_pathsep(p, p + len))
 	    has_trailing_pathsep = TRUE;
 
 	q = getnextcomp(p);
@@ -6579,10 +6576,8 @@ f_resolve(argvars, retvar)
 	if (!has_trailing_pathsep)
 	{
 	    q = p + STRLEN(p);
-	    while ((q > p + 2 || (q == p + 2 && !vim_ispathsep(*p)))
-		   && vim_ispathsep(q[-1]))
-		--q;
-	    *q = NUL;
+	    if (after_pathsep(p, q))
+		*gettail_sep(p) = NUL;
 	}
 
 	retvar->var_val.var_string = p;
@@ -10854,7 +10849,7 @@ shortpath_for_invalid_fname(fname, bufp,
     plen = len2;
 
     l = 0;
-    if (vim_ispathsep(*s))
+    if (after_pathsep(pbuf2, s + 1))
     {
 	--s;
 	++slen;
@@ -10864,7 +10859,7 @@ shortpath_for_invalid_fname(fname, bufp,
     do
     {
 	/* Go back one path-seperator */
-	while (s > pbuf2 && !vim_ispathsep(*s))
+	while (s > pbuf2 && !after_pathsep(pbuf2, s + 1))
 	{
 	    --s;
 	    ++slen;
@@ -10936,7 +10931,7 @@ shortpath_for_partial(fnamep, bufp, fnam
      * of the path to return.
      */
     sepcount = 0;
-    for (p = *fnamep + *fnamelen - 1; p >= *fnamep; --p)
+    for (p = *fnamep; p < *fnamep + *fnamelen; mb_ptr_adv(p))
 	if (vim_ispathsep(*p))
 	    ++sepcount;
 
@@ -10965,6 +10960,11 @@ shortpath_for_partial(fnamep, bufp, fnam
 
     /* Count the paths backward to find the beginning of the desired string. */
     for (p = tfname + len - 1; p >= tfname; --p)
+    {
+#ifdef FEAT_MBYTE
+	if (has_mbyte)
+	    p -= mb_head_off(tfname, p);
+#endif
 	if (vim_ispathsep(*p))
 	{
 	    if (sepcount == 0 || (hasTilde && sepcount == 1))
@@ -10972,6 +10972,7 @@ shortpath_for_partial(fnamep, bufp, fnam
 	    else
 		sepcount --;
 	}
+    }
     if (hasTilde)
     {
 	--p;
@@ -11047,7 +11048,7 @@ repeat:
 	}
 
 	/* When "/." or "/.." is used: force expansion to get rid of it. */
-	for (p = *fnamep; *p != NUL; ++p)
+	for (p = *fnamep; *p != NUL; mb_ptr_adv(p))
 	{
 	    if (vim_ispathsep(*p)
 		    && p[1] == '.'
@@ -11155,15 +11156,15 @@ repeat:
 	valid |= VALID_HEAD;
 	*usedlen += 2;
 	s = get_past_head(*fnamep);
-	while (tail > s && vim_ispathsep(tail[-1]))
+	while (tail > s && after_pathsep(s, tail))
 	    --tail;
 	*fnamelen = (int)(tail - *fnamep);
 #ifdef VMS
 	if (*fnamelen > 0)
 	    *fnamelen += 1; /* the path separator is part of the path */
 #endif
-	while (tail > s && !vim_ispathsep(tail[-1]))
-	    --tail;
+	while (tail > s && !after_pathsep(s, tail))
+	    mb_ptr_back(*fnamep, tail);
     }
 
     /* ":8" - shortname  */
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3599,12 +3599,7 @@ do_sub(eap)
 	    }
 	    if (cmd[0] == '\\' && cmd[1] != 0)	/* skip escaped characters */
 		++cmd;
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		cmd += (*mb_ptr2len_check)(cmd);
-	    else
-#endif
-		++cmd;
+	    mb_ptr_adv(cmd);
 	}
 
 	if (!eap->skip)
@@ -4498,6 +4493,10 @@ global_exe(cmd)
     else
 	check_cursor();	/* cursor may be beyond the end of the line */
 
+    /* the cursor may not have moved in the text but a change in a previous
+     * line may move it on the screen */
+    changed_line_abv_curs();
+
     /* If it looks like no message was written, allow overwriting the
      * command with the report for number of changes. */
     if (msg_col == 0 && msg_scrolled == 0)
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -1014,28 +1014,34 @@ buf_write_all(buf, forceit)
  * Code to handle the argument list.
  */
 
+static char_u	*do_one_arg __ARGS((char_u *str));
+static int	do_arglist __ARGS((char_u *str, int what, int after));
+static void	alist_check_arg_idx __ARGS((void));
+static int	editing_arg_idx __ARGS((win_T *win));
+#ifdef FEAT_LISTCMDS
+static int	alist_add_list __ARGS((int count, char_u **files, int after));
+#endif
+#define AL_SET	1
+#define AL_ADD	2
+#define AL_DEL	3
+
 /*
- * Isolate one argument, taking quotes and backticks.
- * Changes the argument in-place, puts a NUL after it.
- * Quotes are removed, backticks remain.
+ * Isolate one argument, taking backticks.
+ * Changes the argument in-place, puts a NUL after it.  Backticks remain.
  * Return a pointer to the start of the next argument.
  */
-    char_u *
+    static char_u *
 do_one_arg(str)
     char_u *str;
 {
     char_u	*p;
-    int		inquote;
     int		inbacktick;
 
-    inquote = FALSE;
     inbacktick = FALSE;
     for (p = str; *str; ++str)
     {
-	/*
-	 * for MSDOS et.al. a backslash is part of a file name.
-	 * Only skip ", space and tab.
-	 */
+	/* When the backslash is used for escaping the special meaning of a
+	 * character we need to keep it until wildcard expansion. */
 	if (rem_backslash(str))
 	{
 	    *p++ = *str++;
@@ -1043,15 +1049,12 @@ do_one_arg(str)
 	}
 	else
 	{
-	    /* An item ends at a space not in quotes or backticks */
-	    if (!inquote && !inbacktick && vim_isspace(*str))
+	    /* An item ends at a space not in backticks */
+	    if (!inbacktick && vim_isspace(*str))
 		break;
-	    if (!inquote && *str == '`')
+	    if (*str == '`')
 		inbacktick ^= TRUE;
-	    if (!inbacktick && *str == '"')
-		inquote ^= TRUE;
-	    else
-		*p++ = *str;
+	    *p++ = *str;
 	}
     }
     str = skipwhite(str);
@@ -1060,16 +1063,6 @@ do_one_arg(str)
     return str;
 }
 
-static int do_arglist __ARGS((char_u *str, int what, int after));
-static void alist_check_arg_idx __ARGS((void));
-static int editing_arg_idx __ARGS((win_T *win));
-#ifdef FEAT_LISTCMDS
-static int alist_add_list __ARGS((int count, char_u **files, int after));
-#endif
-#define AL_SET	1
-#define AL_ADD	2
-#define AL_DEL	3
-
 #if defined(FEAT_GUI) || defined(FEAT_CLIENTSERVER) || defined(PROTO)
 /*
  * Redefine the argument list.
@@ -1619,6 +1612,7 @@ ex_listdo(eap)
     char_u	*save_ei = NULL;
     char_u	*new_ei;
 #endif
+    char_u	*p_shm_save;
 
 #ifndef FEAT_WINDOWS
     if (eap->cmdidx == CMD_windo)
@@ -1674,7 +1668,15 @@ ex_listdo(eap)
 		/* Don't call do_argfile() when already there, it will try
 		 * reloading the file. */
 		if (curwin->w_arg_idx != i || !editing_arg_idx(curwin))
+		{
+		    /* Clear 'shm' to avoid that the file message overwrites
+		     * any output from the command. */
+		    p_shm_save = vim_strsave(p_shm);
+		    set_option_value((char_u *)"shm", 0L, (char_u *)"", 0);
 		    do_argfile(eap, i);
+		    set_option_value((char_u *)"shm", 0L, p_shm_save, 0);
+		    vim_free(p_shm_save);
+		}
 		if (curwin->w_arg_idx != i)
 		    break;
 		++i;
@@ -1717,7 +1719,15 @@ ex_listdo(eap)
 			break;
 		if (buf == NULL)
 		    break;
+
+		/* Go to the next buffer.  Clear 'shm' to avoid that the file
+		 * message overwrites any output from the command. */
+		p_shm_save = vim_strsave(p_shm);
+		set_option_value((char_u *)"shm", 0L, (char_u *)"", 0);
 		goto_buffer(eap, DOBUF_FIRST, FORWARD, next_fnum);
+		set_option_value((char_u *)"shm", 0L, p_shm_save, 0);
+		vim_free(p_shm_save);
+
 		/* If autocommands took us elsewhere, quit here */
 		if (curbuf->b_fnum != next_fnum)
 		    break;
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3145,12 +3145,7 @@ set_one_cmd_context(xp, buff)
 		    return NULL;    /* It's a comment */
 		}
 	    }
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		p += (*mb_ptr2len_check)(p);
-	    else
-#endif
-		++p;
+	    mb_ptr_adv(p);
 	}
     }
 
@@ -3203,12 +3198,7 @@ set_one_cmd_context(xp, buff)
 		}
 		in_quote = !in_quote;
 	    }
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		p += (*mb_ptr2len_check)(p);
-	    else
-#endif
-		++p;
+	    mb_ptr_adv(p);
 	}
 
 	/*
@@ -4312,12 +4302,7 @@ skip_cmd_arg(p, rembs)
 	    else
 		++p;
 	}
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p);
-	else
-#endif
-	    ++p;
+	mb_ptr_adv(p);
     }
     return p;
 }
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -494,6 +494,10 @@ getcmdline(firstc, count, indent)
 		i = (int)(xpc.xp_pattern - ccline.cmdbuff);
 		while (--j > i)
 		{
+#ifdef FEAT_MBYTE
+		    if (has_mbyte)
+			j -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + j);
+#endif
 		    if (vim_ispathsep(ccline.cmdbuff[j]))
 		    {
 			found = TRUE;
@@ -3490,12 +3494,7 @@ sm_gettail(s)
 	    t = p;
 	    had_sep = FALSE;
 	}
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p);
-	else
-#endif
-	    ++p;
+	mb_ptr_adv(p);
     }
     return t;
 }
@@ -4173,7 +4172,7 @@ ExpandRTDir(pat, num_file, file, dirname
 	    break;
 	if (e - 4 > s && STRNICMP(e - 4, ".vim", 4) == 0)
 	{
-	    for (s = e - 4; s > all; --s)
+	    for (s = e - 4; s > all; mb_ptr_back(all, s))
 		if (*s == '\n' || vim_ispathsep(*s))
 		    break;
 	    ++s;
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -370,13 +370,8 @@ readfile(fname, sfname, from, lines_to_s
      */
     if (fname != NULL && *fname != NUL)
     {
-	p = fname + STRLEN(fname) - 1;
-	if ((vim_ispathsep(*p)
-#ifdef FEAT_MBYTE
-		    /* Do not use a multi-byte char as path separator. */
-		    && (!has_mbyte || (*mb_head_off)(fname, p) == 0)
-#endif
-	    ) || STRLEN(fname) >= MAXPATHL)
+	p = fname + STRLEN(fname);
+	if (after_pathsep(fname, p) || STRLEN(fname) >= MAXPATHL)
 	{
 	    filemess(curbuf, fname, (char_u *)_("Illegal file name"), 0);
 	    msg_end();
@@ -2801,7 +2796,8 @@ buf_write(buf, fname, sfname, start, end
 		    ml_timestamp(buf);
 		    buf->b_flags &= ~BF_WRITE_MASK;
 		}
-		if (reset_changed && buf->b_changed)
+		if (reset_changed && buf->b_changed
+			&& (overwriting || vim_strchr(p_cpo, CPO_PLUS) != NULL))
 		    /* Buffer still changed, the autocommands didn't work
 		     * properly. */
 		    return FAIL;
@@ -3526,7 +3522,7 @@ buf_write(buf, fname, sfname, start, end
      * the original file.
      * Don't do this if there is a backup file and we are exiting.
      */
-    if (reset_changed && !newfile && !otherfile(ffname)
+    if (reset_changed && !newfile && overwriting
 					      && !(exiting && backup != NULL))
     {
 	ml_preserve(buf, FALSE);
@@ -4192,11 +4188,14 @@ restore_backup:
 	keep_msg_attr = 0;
     }
 
+    /* When written everything correctly: reset 'modified'.  Unless not
+     * writing to the original file and '+' is not in 'cpoptions'. */
     if (reset_changed && whole
 #ifdef FEAT_MBYTE
 	    && !write_info.bw_conv_error
 #endif
-	    )		/* when written everything correctly */
+	    && (overwriting || vim_strchr(p_cpo, CPO_PLUS) != NULL)
+	    )
     {
 	unchanged(buf, TRUE);
 	u_unchanged(buf);
@@ -5383,7 +5382,7 @@ buf_modname(shortname, fname, ext, prepe
 	    vim_free(retval);
 	    return NULL;
 	}
-	if (!vim_ispathsep(retval[fnamelen - 1]))
+	if (!after_pathsep(retval, retval + fnamelen))
 	{
 	    retval[fnamelen++] = PATHSEP;
 	    retval[fnamelen] = NUL;
@@ -5410,7 +5409,7 @@ buf_modname(shortname, fname, ext, prepe
      * Then truncate what is after the '/', '\' or ':' to 8 characters for
      * MSDOS and 26 characters for AMIGA, a lot more for UNIX.
      */
-    for (ptr = retval + fnamelen; ptr >= retval; ptr--)
+    for (ptr = retval + fnamelen; ptr >= retval; mb_ptr_back(retval, ptr))
     {
 #ifndef RISCOS
 	if (*ext == '.'
--- a/src/fold.c
+++ b/src/fold.c
@@ -2070,12 +2070,7 @@ foldtext_cleanup(str)
 	}
 	else
 	{
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		s += (*mb_ptr2len_check)(s);
-	    else
-#endif
-		++s;
+	    mb_ptr_adv(s);
 	}
     }
 }
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1514,7 +1514,7 @@ vgetc()
 		continue;
 	    }
 #endif
-#ifdef HAVE_GTK2
+#if defined(HAVE_GTK2) && defined(FEAT_MENU)
 	    /* GTK: <F10> normally selects the menu, but it's passed until
 	     * here to allow mapping it.  Intercept and invoke the GTK
 	     * behavior if it's not mapped. */
--- a/src/gui.c
+++ b/src/gui.c
@@ -3852,12 +3852,7 @@ scroll_line_len(lnum)
 	for (;;)
 	{
 	    w = chartabsize(p, col);
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		p += (*mb_ptr2len_check)(p);
-	    else
-#endif
-		++p;
+	    mb_ptr_adv(p);
 	    if (*p == NUL)		/* don't count the last character */
 		break;
 	    col += w;
--- a/src/gui_gtk.c
+++ b/src/gui_gtk.c
@@ -2014,7 +2014,7 @@ split_button_string(char_u *button_strin
     if (array != NULL)
     {
 	array[count++] = (char *)button_string;
-	for (p = button_string; *p != NUL; ++p)
+	for (p = button_string; *p != NUL; mb_ptr_adv(p))
 	{
 	    if (*p == DLG_BUTTON_SEP)
 	    {
@@ -2023,10 +2023,6 @@ split_button_string(char_u *button_strin
 	    }
 	    else if (*p == DLG_HOTKEY_CHAR)
 		*p = '_';
-#ifdef FEAT_MBYTE
-	    else if (has_mbyte)
-		p += (*mb_ptr2len_check)(p) - 1;
-#endif
 	}
 	array[count] = NULL; /* currently not relied upon, but doesn't hurt */
     }
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -4792,6 +4792,7 @@ gui_mch_get_font(char_u *name, int repor
     return font;
 }
 
+#if defined(FEAT_EVAL) || defined(PROTO)
 /*
  * Return the name of font "font" in allocated memory.
  */
@@ -4799,7 +4800,7 @@ gui_mch_get_font(char_u *name, int repor
     char_u *
 gui_mch_get_fontname(GuiFont font, char_u *name)
 {
-#ifdef HAVE_GTK2
+# ifdef HAVE_GTK2
     if (font != NOFONT)
     {
 	char	*name = pango_font_description_to_string(font);
@@ -4812,13 +4813,14 @@ gui_mch_get_fontname(GuiFont font, char_
 	    return s;
 	}
     }
-#else
+# else
     /* Don't know how to get the name, return what we got. */
     if (name != NULL)
 	return vim_strsave(name);
-#endif
+# endif
     return NULL;
 }
+#endif
 
 #if !defined(HAVE_GTK2) || defined(PROTO)
 /*
--- a/src/gui_kde.cc
+++ b/src/gui_kde.cc
@@ -40,8 +40,8 @@ extern "C" {
 #undef mputs
 
 #if 1
-#define dbf( format, args... ) { printf( "%s" " : " format "\n" , __FUNCTION__ , ## args ); fflush(stdout); }
-#define db()       { printf( "%s\n", __FUNCTION__ );fflush(stdout); }
+#define dbf(format, args...) { printf("%s" " : " format "\n" , __FUNCTION__ , ## args ); fflush(stdout); }
+#define db()       { printf("%s\n", __FUNCTION__ );fflush(stdout); }
 #else
 #define dbf(format, args... )
 #define db()
@@ -165,163 +165,184 @@ const char *kdeicons[] = {
 /*
  * creates a blank pixmap using tb_blank
  */
-	QPixmap
+    QPixmap
 pixmap_create_from_xpm(char **xpm)//{{{
 {
-	return(QPixmap((const char **)xpm));
+    return (QPixmap((const char **)xpm));
 }//}}}
 
 /*
  * creates a pixmap by using a built-in number
  */
-	QPixmap
+    QPixmap
 pixmap_create_by_num(int pixmap_num)//{{{
 {
 #ifdef FEAT_KDETOOLBAR
-	if (pixmap_num >= 0 && (unsigned)pixmap_num < (sizeof(kdeicons)
-				/ sizeof(kdeicons[0])) - 1) {
+    if (pixmap_num >= 0 && (unsigned)pixmap_num < (sizeof(kdeicons)
+						   / sizeof(kdeicons[0])) - 1)
+    {
 
-		KIconLoader *il = kapp->iconLoader(); //new KIconLoader();
-		QString icon;
-		icon=QString(kdeicons[pixmap_num]);
-		return il->loadIcon(icon,KIcon::MainToolbar);
-	}
+	KIconLoader *il = kapp->iconLoader(); //new KIconLoader();
+	QString icon;
+	icon = QString(kdeicons[pixmap_num]);
+	return il->loadIcon(icon, KIcon::MainToolbar);
+    }
+    return QPixmap();
+#else
+    if (pixmap_num >= 0 && (unsigned)pixmap_num < (sizeof(built_in_pixmaps)
+					   / sizeof(built_in_pixmaps[0])) - 1)
+	return pixmap_create_from_xpm(built_in_pixmaps[pixmap_num]);
+    else
 	return QPixmap();
-#else
-	if (pixmap_num >= 0 && (unsigned)pixmap_num < (sizeof(built_in_pixmaps)
-				/ sizeof(built_in_pixmaps[0])) - 1)
-		return pixmap_create_from_xpm(built_in_pixmaps[pixmap_num]);
-	else return QPixmap();
 #endif
 }//}}}
 
 /*
  * Creates a pixmap by using the pixmap "name" found in 'runtimepath'/bitmaps/
  */
-	QPixmap
+    QPixmap
 pixmap_create_by_dir(char_u *name)//{{{
 {
-	char_u full_pathname[MAXPATHL + 1];
+    char_u full_pathname[MAXPATHL + 1];
 
-	if (gui_find_bitmap(name, full_pathname, "xpm") == OK) {
-		return QPixmap((const char *)full_pathname);
-	}
-	else return QPixmap();
+    if (gui_find_bitmap(name, full_pathname, "xpm") == OK)
+    {
+	return QPixmap((const char *)full_pathname);
+    }
+    else
+	return QPixmap();
 }//}}}
 
 
-	QPixmap
+    QPixmap
 pixmap_create_from_file(char_u *file)
 {
-	return QPixmap((const char*)file);
+    return QPixmap((const char *)file);
 }
 #endif
 
-	void
+    void
 gui_mch_add_menu(vimmenu_T * menu, int idx)//{{{
 {
 #ifdef FEAT_MENU
-	QPopupMenu *me;
-	vimmenu_T *parent = menu->parent;
+    QPopupMenu *me;
+    vimmenu_T *parent = menu->parent;
 
-	if (menu_is_popup(menu->name)) {
-		menu->widget = new QPopupMenu(vmw , (const char *) menu->name);
-		QObject::connect( menu->widget, SIGNAL(activated(int)), vmw, SLOT(menu_activated(int)) );
-		return;
-	}
+    if (menu_is_popup(menu->name))
+    {
+	menu->widget = new QPopupMenu(vmw , (const char *)menu->name);
+	QObject::connect(menu->widget, SIGNAL(activated(int)), vmw,
+						   SLOT(menu_activated(int)));
+	return;
+    }
 
-	if (!menu_is_menubar(menu->name))
-		return;
+    if (!menu_is_menubar(menu->name))
+	return;
 
-	if (parent) {
-		idx++; // for tearoffs to be first in menus
-		me = new QPopupMenu(parent->widget, (const char *) menu->name);
-		parent->widget->insertItem( QString((const char *)menu->name), me, (int)me, idx);
-	} else {
-		me = new QPopupMenu(vmw->menuBar() , (const char *) menu->name);
-		vmw->menuBar()->insertItem( QString((const char *)menu->name), me , (int) me, idx);
-	}
+    if (parent)
+    {
+	idx++; // for tearoffs to be first in menus
+	me = new QPopupMenu(parent->widget, (const char *)menu->name);
+	parent->widget->insertItem(QString((const char *)menu->name), me,
+								(int)me, idx);
+    }
+    else
+    {
+	me = new QPopupMenu(vmw->menuBar() , (const char *)menu->name);
+	vmw->menuBar()->insertItem(QString((const char *)menu->name), me,
+								(int)me, idx);
+    }
 
-	me->setCaption((const char*)( menu->dname  ));
-	if (vmw->have_tearoff) me->insertTearOffHandle(0,0);
-	QObject::connect( me, SIGNAL(activated(int)), vmw, SLOT(menu_activated(int)) );
-	menu->widget = me;
+    me->setCaption((const char *)(menu->dname));
+    if (vmw->have_tearoff)
+	me->insertTearOffHandle(0, 0);
+    QObject::connect(me, SIGNAL(activated(int)), vmw,
+						   SLOT(menu_activated(int)));
+    menu->widget = me;
 #endif
 }//}}}
 
 
-	void
+    void
 gui_mch_add_menu_item(vimmenu_T * menu, int idx)//{{{
 {
 #ifdef FEAT_MENU
-	vimmenu_T *parent = menu->parent;
+    vimmenu_T *parent = menu->parent;
 #ifdef FEAT_TOOLBAR
-	if (menu_is_toolbar(parent->name)) {
-		QPixmap pix;
-		if ( menu_is_separator(menu->name) )
-		{
-			vmw->toolBar()->insertSeparator();
-			return;
-		}
-		if (menu->iconfile != NULL) {
-			pix = pixmap_create_from_file(menu->iconfile);
-		}
-		if (!menu->icon_builtin) {
-			pix = pixmap_create_by_dir(menu->name);
-		}
-		if (pix.isNull() && menu->iconidx >= 0) {
-			pix = pixmap_create_by_num(menu->iconidx);
-		}
+    if (menu_is_toolbar(parent->name))
+    {
+	QPixmap pix;
+
+	if (menu_is_separator(menu->name))
+	{
+	    vmw->toolBar()->insertSeparator();
+	    return;
+	}
+	if (menu->iconfile != NULL)
+	{
+	    pix = pixmap_create_from_file(menu->iconfile);
+	}
+	if (!menu->icon_builtin)
+	{
+	    pix = pixmap_create_by_dir(menu->name);
+	}
+	if (pix.isNull() && menu->iconidx >= 0)
+	{
+	    pix = pixmap_create_by_num(menu->iconidx);
+	}
 #ifndef FEAT_KDETOOLBAR
-		if (pix.isNull()) {
-			pix = pixmap_create_from_xpm(tb_blank_xpm);
-		}
+	if (pix.isNull())
+	{
+	    pix = pixmap_create_from_xpm(tb_blank_xpm);
+	}
 #endif
-		if (pix.isNull()) return; // failed
-		vmw->toolBar()->insertButton (
-				pix,
-				(int) menu , // id
-				true,
-				(char *) (menu->strings[MENU_INDEX_TIP]) , // tooltip or text
-				idx
-				);
-		menu->parent=parent;
-		return;
-	}
+	if (pix.isNull())
+	    return; // failed
+	vmw->toolBar()->insertButton(
+		pix,
+		(int)menu, // id
+		true,
+		(char *)(menu->strings[MENU_INDEX_TIP]), // tooltip or text
+		idx);
+	menu->parent=parent;
+	return;
+    }
 #endif // FEAT_TOOLBAR
 
-	idx++;
-	if ( menu_is_separator(menu->name) ) {
-		parent->widget->insertSeparator();
-		return;
-	}
-	parent->widget->insertItem(QString((const char *)menu->name), (int)menu, idx );
+    idx++;
+    if (menu_is_separator(menu->name))
+    {
+	parent->widget->insertSeparator();
+	return;
+    }
+    parent->widget->insertItem(QString((const char *)menu->name), (int)menu, idx);
 #endif
 }//}}}
 
 
-	void
+    void
 gui_mch_set_text_area_pos(int x, int y, int w, int h)//{{{
 {
-	int X = 0;
-	int Y = 0;
-	if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
+    int X = 0;
+    int Y = 0;
+
+    if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
 #if QT_VERSION>=300
-		       	&& !vmw->menuBar()->isTopLevelMenu()
+	    && !vmw->menuBar()->isTopLevelMenu()
 #endif
-			)
-		Y += vmw->menuBar()->height();
+       )
+	Y += vmw->menuBar()->height();
 #ifdef FEAT_TOOLBAR
-	if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
-			vmw->toolBar()->barPos()==KToolBar::Top)
-		Y += vmw->toolBar()->height();
+    if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
+				   && vmw->toolBar()->barPos()==KToolBar::Top)
+	Y += vmw->toolBar()->height();
 
-	if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
-			vmw->toolBar()->barPos()==KToolBar::Left)
-		X += vmw->toolBar()->width();
+    if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
+				  && vmw->toolBar()->barPos()==KToolBar::Left)
+	X += vmw->toolBar()->width();
 #endif // FEAT_TOOLBAR
 
-	gui.w->setGeometry(x+X,y+Y,w,h);
+    gui.w->setGeometry(x + X, y + Y, w, h);
 }//}}}
 
 
@@ -329,24 +350,29 @@ gui_mch_set_text_area_pos(int x, int y, 
 /*
  * Enable or disable mnemonics for the toplevel menus.
  */
-	void
+    void
 gui_gtk_set_mnemonics(int enable)//{{{ // TO BE REMOVED
 {
 }//}}}
 
-	void
+    void
 toggle_tearoffs(vimmenu_T *menu, int enable)//{{{
 {
-	while (menu != NULL) {
-		if (!menu_is_popup(menu->name)) {
-			if (menu->widget != 0) {
-				if (enable) menu->widget->insertTearOffHandle(0,0);
-				else menu->widget->removeItem(0);
-			}
-			toggle_tearoffs(menu->children, enable);
-		}
-		menu = menu->next;
+    while (menu != NULL)
+    {
+	if (!menu_is_popup(menu->name))
+	{
+	    if (menu->widget != 0)
+	    {
+		if (enable)
+		    menu->widget->insertTearOffHandle(0,0);
+		else
+		    menu->widget->removeItem(0);
+	    }
+	    toggle_tearoffs(menu->children, enable);
 	}
+	menu = menu->next;
+    }
 }//}}}
 
 	void
@@ -362,20 +388,21 @@ gui_mch_toggle_tearoffs(int enable)//{{{
 /*
  * Destroy the machine specific menu widget.
  */
-	void
+    void
 gui_mch_destroy_menu(vimmenu_T * menu)//{{{
 {
 #ifdef FEAT_TOOLBAR
-	if (menu->parent && menu_is_toolbar(menu->parent->name)) {
-		vmw->toolBar()->removeItem( (int) menu );
-		return;
-	}
+    if (menu->parent && menu_is_toolbar(menu->parent->name))
+    {
+	vmw->toolBar()->removeItem((int)menu);
+	return;
+    }
 #endif
-	if (menu->parent)
-		menu->parent->widget->removeItem((int)menu);
-	if (menu->widget)
-		delete menu->widget;
-	menu->widget = 0;
+    if (menu->parent)
+	menu->parent->widget->removeItem((int)menu);
+    if (menu->widget)
+	delete menu->widget;
+    menu->widget = 0;
 }//}}}
 #endif /* FEAT_MENU */
 
@@ -384,68 +411,78 @@ gui_mch_destroy_menu(vimmenu_T * menu)//
  * Scrollbar stuff.
  */
 
-	void
-gui_mch_set_scrollbar_thumb(scrollbar_T * sb, long val, long size, long max)//{{{
+    void
+gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max)//{{{
 {
-	if (!sb->w) return;
+    if (!sb->w)
+	return;
 
-	sb->w->setRange(0, max+1-size);
-	sb->w->setValue(val);
+    sb->w->setRange(0, max + 1 - size);
+    sb->w->setValue(val);
 
-	sb->w->setLineStep(1);
-	sb->w->setPageStep(size);
+    sb->w->setLineStep(1);
+    sb->w->setPageStep(size);
 }//}}}
 
-	void
-gui_mch_set_scrollbar_pos(scrollbar_T * sb, int x, int y, int w, int h)//{{{
+    void
+gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h)//{{{
 {
-	if (!sb->w) return;
-	//we add the menubar and toolbar height/width
-	int X = 0;
-	int Y = 0;
+    if (!sb->w)
+	return;
+    //we add the menubar and toolbar height/width
+    int X = 0;
+    int Y = 0;
 
-	if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
+    if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
 #if QT_VERSION>=300
-		       	&& !vmw->menuBar()->isTopLevelMenu()
+					  && !vmw->menuBar()->isTopLevelMenu()
 #endif
-			)
-		Y += vmw->menuBar()->height();
+       )
+	Y += vmw->menuBar()->height();
 #ifdef FEAT_TOOLBAR
-	if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
-			vmw->toolBar()->barPos()==KToolBar::Top)
-		Y += vmw->toolBar()->height();
+    if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
+				   && vmw->toolBar()->barPos()==KToolBar::Top)
+	Y += vmw->toolBar()->height();
 
-	if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
-			vmw->toolBar()->barPos()==KToolBar::Left)
-		X += vmw->toolBar()->width();
+    if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
+				  && vmw->toolBar()->barPos()==KToolBar::Left)
+	X += vmw->toolBar()->width();
 #endif //FEAT_TOOLBAR
-	if (sb->w->orientation() == Qt::Vertical) {
-		bool leftscroll=gui.which_scrollbars[SBAR_LEFT];
-		bool rightscroll=gui.which_scrollbars[SBAR_RIGHT];
-		if (x<20)  leftscroll=true;
-		else rightscroll=true;
-		if (x<20) sb->w->setGeometry(X,y+Y,w,h);
-		else sb->w->setGeometry(vmw->width()-w-1+X, y+Y,w,h);
-	} else {
-		sb->w->setGeometry(x+X,y+Y,w,h);
-	}
+    if (sb->w->orientation() == Qt::Vertical)
+    {
+	bool leftscroll=gui.which_scrollbars[SBAR_LEFT];
+	bool rightscroll=gui.which_scrollbars[SBAR_RIGHT];
+
+	if (x < 20)
+	    leftscroll = true;
+	else
+	    rightscroll = true;
+	if (x < 20)
+	    sb->w->setGeometry(X, y+Y, w, h);
+	else
+	    sb->w->setGeometry(vmw->width() - w - 1 + X, y + Y, w, h);
+    }
+    else
+    {
+	sb->w->setGeometry(x + X, y + Y, w, h);
+    }
 }//}}}
 
 /* SBAR_VERT or SBAR_HORIZ */
-	void
-gui_mch_create_scrollbar(scrollbar_T * sb, int orient)//{{{
+    void
+gui_mch_create_scrollbar(scrollbar_T *sb, int orient)//{{{
 {
-	sbpool->create(sb,orient);
-	if (orient==SBAR_VERT)
-		gui.scrollbar_width = sb->w->sizeHint().width();
-	else
-		gui.scrollbar_height = sb->w->sizeHint().height();
+    sbpool->create(sb,orient);
+    if (orient == SBAR_VERT)
+	gui.scrollbar_width = sb->w->sizeHint().width();
+    else
+	gui.scrollbar_height = sb->w->sizeHint().height();
 }//}}}
 
-	void
+    void
 gui_mch_destroy_scrollbar(scrollbar_T * sb)//{{{
 {
-	sbpool->destroy(sb);
+    sbpool->destroy(sb);
 }//}}}
 
 #if defined(FEAT_BROWSE) || defined(PROTO)
@@ -464,7 +501,7 @@ gui_mch_destroy_scrollbar(scrollbar_T * 
  * filter			not used (file name filter)
  */
 /*ARGSUSED*/
-char_u *
+    char_u *
 gui_mch_browse(int saving,//{{{
 		char_u * title,
 		char_u * dflt,
@@ -472,36 +509,37 @@ gui_mch_browse(int saving,//{{{
 		char_u * initdir,
 		char_u * filter)
 {
-	char * filt_glob;
+    char *filt_glob;
 
-	if (filter != (char_u *) 0x0 )
-	{
-		filter = vim_strsave(filter);
-		strtok((char *) filter, "(");
-		filt_glob = strtok(0L, ")");
-	}
-	else
-		filt_glob = (char *) filter;
+    if (filter != (char_u *)0x0)
+    {
+	filter = vim_strsave(filter);
+	strtok((char *)filter, "(");
+	filt_glob = strtok(0L, ")");
+    }
+    else
+	filt_glob = (char *)filter;
 
-	gui_mch_mousehide(FALSE);
+    gui_mch_mousehide(FALSE);
 
-	QString s;
-	if (!saving)
-		s = KFileDialog::getOpenFileName( (char *) initdir, (char *) filt_glob, vmw, (char *) title );
-	else
-		s = KFileDialog::getSaveFileName( );
-
-	if (filter)
-		vim_free(filter);
+    QString s;
+    if (!saving)
+	s = KFileDialog::getOpenFileName((char *)initdir, (char *)filt_glob,
+							  vmw, (char *)title);
+    else
+	s = KFileDialog::getSaveFileName();
 
-	if (s.isNull())
-		return NULL;
-	QCString unistring = vmw->codec->fromUnicode(s);
-	char_u * s2 = (char_u *)(const char*)unistring;
-	if (s2)
-		s2 = vim_strsave( s2 );
+    if (filter)
+	vim_free(filter);
 
-	return s2;
+    if (s.isNull())
+	return NULL;
+    QCString unistring = vmw->codec->fromUnicode(s);
+    char_u *s2 = (char_u *)(const char *)unistring;
+    if (s2)
+	s2 = vim_strsave(s2);
+
+    return s2;
 }//}}}
 
 #endif	/* FEAT_BROWSE */
@@ -511,9 +549,9 @@ gui_mch_browse(int saving,//{{{
 /* ARGSUSED */
     int
 gui_mch_dialog(int type,		/* type of dialog *///{{{
-		char_u * title,		/* title of dialog */
-		char_u * message,	/* message text */
-		char_u * buttons,	/* names of buttons */
+		char_u *title,		/* title of dialog */
+		char_u *message,	/* message text */
+		char_u *buttons,	/* names of buttons */
 		int def_but,		/* default button */
 		char_u *textfield)
 {
@@ -546,8 +584,8 @@ gui_make_popup (char_u *pathname)//{{{
 
 
 /* Find and Replace implementations */
-	void
-gui_mch_find_dialog(exarg_T * eap)//{{{
+    void
+gui_mch_find_dialog(exarg_T *eap)//{{{
 {
     // char_u* entry_text;
     //int exact_word=FALSE;
@@ -555,8 +593,9 @@ gui_mch_find_dialog(exarg_T * eap)//{{{
 
     vmw->finddlg->setCaseSensitive(true);
 
-    /*    if (entry_text!=NULL) {
-	  vmw->finddlg->setText(QString((char*)entry_text));
+    /*    if (entry_text!=NULL)
+     *    {
+	  vmw->finddlg->setText(QString((char *)entry_text));
     // exact match should go there, hopefully KDE old KEdFind/KEdReplace will be replaced in KDE 4 as pple wanted KDE 3's Find/Replace to be kept
     }*/ // Don't use it, KDE keeps old search in memory and vim give \\Csearch, which is difficult to handle
     //   vim_free(entry_text);
@@ -564,25 +603,26 @@ gui_mch_find_dialog(exarg_T * eap)//{{{
     vmw->finddlg->show();
 }//}}}
 
-	void
-gui_mch_replace_dialog(exarg_T * eap)//{{{
+    void
+gui_mch_replace_dialog(exarg_T *eap)//{{{
 {
-	//  char_u* entry_text;
-	//int exact_word=FALSE;
+    //  char_u* entry_text;
+    //int exact_word=FALSE;
 
-	//    entry_text = get_find_dialog_text(eap->arg,&exact_word);
+    //    entry_text = get_find_dialog_text(eap->arg,&exact_word);
 
-	/*    if (entry_text!=NULL) {
-	      vmw->repldlg->setText(QString((char*)entry_text));
-	// exact match should go there, hopefully KDE old KEdFind/KEdReplace will be replaced in KDE 4 as pple wanted KDE 3's Find/Replace to be kept
-	}*/
-	//vim_free(entry_text);
+    /*    if (entry_text!=NULL)
+     *    {
+     vmw->repldlg->setText(QString((char *)entry_text));
+    // exact match should go there, hopefully KDE old KEdFind/KEdReplace will be replaced in KDE 4 as pple wanted KDE 3's Find/Replace to be kept
+    }*/
+    //vim_free(entry_text);
 
-	vmw->repldlg->show();
+    vmw->repldlg->show();
 }//}}}
 
-	void
+    void
 ex_helpfind(exarg_T *eap)//{{{
 {
-	do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp");
+    do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp");
 }//}}}
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -2562,7 +2562,7 @@ gui_mch_dialog(
 	type = 0;
 
     /* allocate some memory for dialog template */
-    /* TODO should compute this really*/
+    /* TODO should compute this really */
     pdlgtemplate = p = (PWORD)LocalAlloc(LPTR, DLG_ALLOC_SIZE);
 
     if (p == NULL)
--- a/src/gui_x11.c
+++ b/src/gui_x11.c
@@ -1992,6 +1992,7 @@ gui_mch_get_font(name, giveErrorIfMissin
  * Return the name of font "font" in allocated memory.
  * Don't know how to get the actual name, thus use the provided name.
  */
+/*ARGSUSED*/
     char_u *
 gui_mch_get_fontname(font, name)
     GuiFont font;
--- a/src/if_xcmdsrv.c
+++ b/src/if_xcmdsrv.c
@@ -103,10 +103,14 @@ static PendingCommand *pendingCommands =
  *
  * Each command and each result takes the form of ASCII text.  For a
  * command, the text consists of a nul character followed by several
- * nul-terminated ASCII strings.  The first string consists of the
- * single letter "c" for an expression, or "k" for keystrokes.  Subsequent
- * strings have the form "option value" where the following options are
- * supported:
+ * nul-terminated ASCII strings.  The first string consists of a
+ * single letter:
+ * "c" for an expression
+ * "k" for keystrokes
+ * "r" for reply
+ * "n" for notification.
+ * Subsequent strings have the form "option value" where the following options
+ * are supported:
  *
  * -r commWindow serial
  *
@@ -120,6 +124,10 @@ static PendingCommand *pendingCommands =
  *	"Name" gives the name of the application for which the command is
  *	intended.  This option must be present.
  *
+ * -E encoding
+ *	Encoding name used for the text.  This is the 'encoding' of the
+ *	sender.  The receiver may want to do conversion to his 'encoding'.
+ *
  * -s script
  *	"Script" is the script to be executed.  This option must be
  *	present.  Taken as a series of keystrokes in a "k" command where
@@ -453,11 +461,19 @@ serverSendToVim(dpy, name, cmd,  result,
      * Send the command to target interpreter by appending it to the
      * comm window in the communication window.
      */
-    length = STRLEN(name) + STRLEN(cmd) + 10;
-    property = (char_u *)alloc((unsigned) length + 30);
+    length = STRLEN(name) + STRLEN(cmd) + 14;
+#ifdef FEAT_MBYTE
+    length += STRLEN(p_enc);
+#endif
+    property = (char_u *)alloc((unsigned)length + 30);
 
+#ifdef FEAT_MBYTE
+    sprintf((char *)property, "%c%c%c-n %s%c-E %s%c-s %s",
+		      0, asExpr ? 'c' : 'k', 0, name, 0, p_enc, 0, cmd);
+#else
     sprintf((char *)property, "%c%c%c-n %s%c-s %s",
 		      0, asExpr ? 'c' : 'k', 0, name, 0, cmd);
+#endif
     if (name == loosename)
 	vim_free(loosename);
     /* Add a back reference to our comm window */
@@ -751,7 +767,7 @@ serverStrToWin(str)
 }
 
 /*
- * Send a reply string to client with id "name".
+ * Send a reply string (notification) to client with id "name".
  * Return -1 if the window is invalid.
  */
     int
@@ -773,11 +789,19 @@ serverSendReply(name, str)
     if (!WindowValid(dpy, win))
 	return -1;
 
-    length = STRLEN(str) + 7;
-    if ((property = (char_u *)alloc((unsigned) length + 30)) != NULL)
+    length = STRLEN(str) + 11;
+#ifdef FEAT_MBYTE
+    length += STRLEN(p_enc);
+#endif
+    if ((property = (char_u *)alloc((unsigned)length + 30)) != NULL)
     {
-	sprintf((char *)property, "%c%c%c-n %s%c-w %x",
-			  0, 'n', 0, str, 0, (unsigned int)commWindow);
+#ifdef FEAT_MBYTE
+	sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x",
+			    0, 0, p_enc, 0, str, 0, (unsigned int)commWindow);
+#else
+	sprintf((char *)property, "%cn%c-n %s%c-w %x",
+			    0, 0, str, 0, (unsigned int)commWindow);
+#endif
 	length += STRLEN(property + length);
 	res = AppendPropCarefully(dpy, win, commProperty, property, length + 1);
 	vim_free(property);
@@ -1129,6 +1153,7 @@ serverEventProc(dpy, eventPtr)
     int		result, actualFormat, code;
     long_u	numItems, bytesAfter;
     Atom	actualType;
+    char_u	*tofree;
 
     if (eventPtr != NULL)
     {
@@ -1180,6 +1205,7 @@ serverEventProc(dpy, eventPtr)
 	    char_u	*name, *script, *serial, *end, *res;
 	    Bool	asKeys = *p == 'k';
 	    garray_T	reply;
+	    char_u	*enc;
 
 	    /*
 	     * This is an incoming command from some other application.
@@ -1192,6 +1218,7 @@ serverEventProc(dpy, eventPtr)
 	    resWindow = None;
 	    serial = (char_u *)"";
 	    script = NULL;
+	    enc = NULL;
 	    while (p - propInfo < numItems && *p == '-')
 	    {
 		switch (p[1])
@@ -1220,6 +1247,10 @@ serverEventProc(dpy, eventPtr)
 			if (p[2] == ' ')
 			    script = p + 3;
 			break;
+		    case 'E':
+			if (p[2] == ' ')
+			    enc = p + 3;
+			break;
 		}
 		while (*p != 0)
 		    p++;
@@ -1236,18 +1267,26 @@ serverEventProc(dpy, eventPtr)
 	    if (resWindow != None)
 	    {
 		ga_init2(&reply, 1, 100);
+#ifdef FEAT_MBYTE
+		ga_grow(&reply, 50 + STRLEN(p_enc));
+		sprintf(reply.ga_data, "%cr%c-E %s%c-s %s%c-r ",
+						   0, 0, p_enc, 0, serial, 0);
+#else
 		ga_grow(&reply, 50);
 		sprintf(reply.ga_data, "%cr%c-s %s%c-r ", 0, 0, serial, 0);
+#endif
 		reply.ga_len = 10 + STRLEN(serial);
 		reply.ga_room -= reply.ga_len;
 	    }
 	    res = NULL;
 	    if (serverName != NULL && STRICMP(name, serverName) == 0)
 	    {
+		script = serverConvert(enc, script, &tofree);
 		if (asKeys)
 		    server_to_input_buf(script);
 		else
 		    res = eval_client_expr_to_string(script);
+		vim_free(tofree);
 	    }
 	    if (resWindow != None)
 	    {
@@ -1262,14 +1301,16 @@ serverEventProc(dpy, eventPtr)
 		ga_append(&reply, NUL);
 		(void)AppendPropCarefully(dpy, resWindow, commProperty,
 					   reply.ga_data, reply.ga_len);
+		ga_clear(&reply);
 	    }
 	    vim_free(res);
 	}
 	else if (*p == 'r' && p[1] == 0)
 	{
-	    int	    serial, gotSerial;
-	    char_u  *res;
-	    PendingCommand *pcPtr;
+	    int		    serial, gotSerial;
+	    char_u	    *res;
+	    PendingCommand  *pcPtr;
+	    char_u	    *enc;
 
 	    /*
 	     * This is a reply to some command that we sent out.  Iterate
@@ -1280,6 +1321,7 @@ serverEventProc(dpy, eventPtr)
 	    gotSerial = 0;
 	    res = (char_u *)"";
 	    code = 0;
+	    enc = NULL;
 	    while ((p-propInfo) < numItems && *p == '-')
 	    {
 		switch (p[1])
@@ -1288,6 +1330,10 @@ serverEventProc(dpy, eventPtr)
 			if (p[2] == ' ')
 			    res = p + 3;
 			break;
+		    case 'E':
+			if (p[2] == ' ')
+			    enc = p + 3;
+			break;
 		    case 's':
 			if (sscanf((char *)p + 2, " %d", &serial) == 1)
 			    gotSerial = 1;
@@ -1316,7 +1362,12 @@ serverEventProc(dpy, eventPtr)
 
 		pcPtr->code = code;
 		if (res != NULL)
-		    pcPtr->result = vim_strsave(res);
+		{
+		    res = serverConvert(enc, res, &tofree);
+		    if (tofree == NULL)
+			res = vim_strsave(res);
+		    pcPtr->result = res;
+		}
 		else
 		    pcPtr->result = vim_strsave((char_u *)"");
 		break;
@@ -1330,6 +1381,7 @@ serverEventProc(dpy, eventPtr)
 	    char_u	*str;
 	    char_u	winstr[30];
 	    struct	ServerReply *r;
+	    char_u	*enc;
 
 	    /*
 	     * This is a (n)otification.  Sent with serverreply_send in VimL.
@@ -1338,6 +1390,7 @@ serverEventProc(dpy, eventPtr)
 	    p += 2;
 	    gotWindow = 0;
 	    str = (char_u *)"";
+	    enc = NULL;
 	    while ((p-propInfo) < numItems && *p == '-')
 	    {
 		switch (p[1])
@@ -1346,6 +1399,10 @@ serverEventProc(dpy, eventPtr)
 			if (p[2] == ' ')
 			    str = p + 3;
 			break;
+		    case 'E':
+			if (p[2] == ' ')
+			    enc = p + 3;
+			break;
 		    case 'w':
 			if (sscanf((char *)p + 2, " %x", &u) == 1)
 			{
@@ -1361,6 +1418,7 @@ serverEventProc(dpy, eventPtr)
 
 	    if (!gotWindow)
 		continue;
+	    str = serverConvert(enc, str, &tofree);
 	    if ((r = ServerReplyFind(win, SROP_Add)) != NULL)
 	    {
 		ga_concat(&(r->strings), str);
@@ -1370,7 +1428,7 @@ serverEventProc(dpy, eventPtr)
 	    sprintf((char *)winstr, "0x%x", (unsigned int)win);
 	    apply_autocmds(EVENT_REMOTEREPLY, winstr, str, TRUE, curbuf);
 #endif
-
+	    vim_free(tofree);
 	}
 	else
 	{
--- a/src/macros.h
+++ b/src/macros.h
@@ -253,3 +253,21 @@
 /* Without the 'numberwidth' option line numbers are always 7 chars. */
 # define number_width(x) 7
 #endif
+
+#ifndef FEAT_MBYTE
+# define after_pathsep(b, p) vim_ispathsep(*((p) - 1))
+#endif
+
+/*
+ * mb_ptr_adv(): advance a pointer to the next character, taking care of
+ * multi-byte characters if needed.
+ * mb_ptr_back(): backup a pointer to the previous character, taking care of
+ * multi-byte characters if needed.
+ */
+#ifdef FEAT_MBYTE
+# define mb_ptr_adv(p) p += has_mbyte ? (*mb_ptr2len_check)(p) : 1
+# define mb_ptr_back(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1
+#else
+# define mb_ptr_adv(p) ++p
+# define mb_ptr_back(s, p) --p
+#endif
--- a/src/main.c
+++ b/src/main.c
@@ -2228,11 +2228,12 @@ main_loop(cmdwin)
 getout_preserve_modified(exitval)
     int		exitval;
 {
-#if defined(UNIX)
-    /* Ignore SIGHUP, because a dropped connection may make Vim exit and then
-     * get a SIGHUP while exiting, which causes various reentrent problems. */
+# if defined(SIGHUP) && defined(SIG_IGN)
+    /* Ignore SIGHUP, because a dropped connection causes a read error, which
+     * makes Vim exit and then handling SIGHUP causes various reentrance
+     * problems. */
     signal(SIGHUP, SIG_IGN);
-#endif
+# endif
 
     ml_close_notmod();		    /* close all not-modified buffers */
     ml_sync_all(FALSE, FALSE);	    /* preserve all swap files */
@@ -3220,6 +3221,42 @@ eval_client_expr_to_string(expr)
     return res;
 }
 
+/*
+ * If conversion is needed, convert "data" from "client_enc" to 'encoding' and
+ * return an allocated string.  Otherwise return "data".
+ * "*tofree" is set to the result when it needs to be freed later.
+ */
+/*ARGSUSED*/
+    char_u *
+serverConvert(client_enc, data, tofree)
+    char_u *client_enc;
+    char_u *data;
+    char_u **tofree;
+{
+    char_u	*res = data;
+
+    *tofree = NULL;
+# ifdef FEAT_MBYTE
+    if (client_enc != NULL && p_enc != NULL)
+    {
+	vimconv_T	vimconv;
+
+	vimconv.vc_type = CONV_NONE;
+	if (convert_setup(&vimconv, client_enc, p_enc) != FAIL
+					      && vimconv.vc_type != CONV_NONE)
+	{
+	    res = string_convert(&vimconv, data, NULL);
+	    if (res == NULL)
+		res = data;
+	    else
+		*tofree = res;
+	}
+	convert_setup(&vimconv, NULL, NULL);
+    }
+# endif
+    return res;
+}
+
 
 /*
  * Make our basic server name: use the specified "arg" if given, otherwise use
--- a/src/mark.c
+++ b/src/mark.c
@@ -630,15 +630,11 @@ mark_line(mp, lead_len)
 	return NULL;
     /* Truncate the line to fit it in the window */
     len = 0;
-    for (p = s; *p != NUL; ++p)
+    for (p = s; *p != NUL; mb_ptr_adv(p))
     {
 	len += ptr2cells(p);
 	if (len >= Columns - lead_len)
 	    break;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
     *p = NUL;
     return s;
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -680,7 +680,7 @@ codepage_invalid:
     /* When using Unicode, set default for 'fileencodings'. */
     if (enc_utf8 && !option_was_set((char_u *)"fencs"))
 	set_string_option_direct((char_u *)"fencs", -1,
-				 (char_u *)"ucs-bom,utf-8,latin1", OPT_FREE);
+			  (char_u *)"ucs-bom,utf-8,default,latin1", OPT_FREE);
 #if defined(HAVE_BIND_TEXTDOMAIN_CODESET) && defined(FEAT_GETTEXT)
     /* GNU gettext 0.10.37 supports this feature: set the codeset used for
      * translated messages independently from the current locale. */
@@ -2590,7 +2590,7 @@ mb_prevptr(line, p)
     char_u *p;
 {
     if (p > line)
-	p = p - (*mb_head_off)(line, p - 1) - 1;
+	mb_ptr_back(line, p);
     return p;
 }
 
@@ -2746,6 +2746,17 @@ enc_canonize(enc)
     char_u	*p, *s;
     int		i;
 
+# ifdef FEAT_MBYTE
+    if (STRCMP(enc, "default") == 0)
+    {
+	/* Use the default encoding as it's found by set_init_1(). */
+	r = get_encoding_default();
+	if (r == NULL)
+	    r = (char_u *)"latin1";
+	return vim_strsave(r);
+    }
+# endif
+
     /* copy "enc" to allocted memory, with room for two '-' */
     r = alloc((unsigned)(STRLEN(enc) + 3));
     if (r != NULL)
--- a/src/memline.c
+++ b/src/memline.c
@@ -125,9 +125,10 @@ struct data_block
 #define INDEX_SIZE  (sizeof(unsigned))	    /* size of one db_index entry */
 #define HEADER_SIZE (sizeof(DATA_BL) - INDEX_SIZE)  /* size of data block header */
 
-#define B0_FNAME_SIZE	900
-#define B0_UNAME_SIZE	40
-#define B0_HNAME_SIZE	40
+#define B0_FNAME_SIZE_ORG	900	/* what it was in older versions */
+#define B0_FNAME_SIZE		898
+#define B0_UNAME_SIZE		40
+#define B0_HNAME_SIZE		40
 /*
  * Restrict the numbers to 32 bits, otherwise most compilers will complain.
  * This won't detect a 64 bit machine that only swaps a byte in the top 32
@@ -160,13 +161,39 @@ struct block0
     char_u	b0_pid[4];	/* process id of creator (or 0) */
     char_u	b0_uname[B0_UNAME_SIZE]; /* name of user (uid if no name) */
     char_u	b0_hname[B0_HNAME_SIZE]; /* host name (if it has a name) */
-    char_u	b0_fname[B0_FNAME_SIZE]; /* name of file being edited */
+    char_u	b0_fname[B0_FNAME_SIZE_ORG]; /* name of file being edited */
     long	b0_magic_long;	/* check for byte order of long */
     int		b0_magic_int;	/* check for byte order of int */
     short	b0_magic_short;	/* check for byte order of short */
     char_u	b0_magic_char;	/* check for last char */
 };
-#define   b0_dirty b0_fname[B0_FNAME_SIZE-1]
+
+/*
+ * Note: b0_fname and b0_flags are put at the end of the file name.  For very
+ * long file names in older versions of Vim they are invalid.
+ * The 'fileencoding' comes before b0_flags, with a NUL in front.  But only
+ * when there is room, for very long file names it's omitted.
+ */
+#define B0_DIRTY	0x55
+#define b0_dirty	b0_fname[B0_FNAME_SIZE_ORG-1]
+
+/*
+ * The b0_flags field is new in Vim 7.0.
+ */
+#define b0_flags	b0_fname[B0_FNAME_SIZE_ORG-2]
+
+/* The lowest two bits contain the fileformat.  Zero means it's not set
+ * (compatible with Vim 6.x), otherwise it's EOL_UNIX + 1, EOL_DOS + 1 or
+ * EOL_MAC + 1. */
+#define B0_FF_MASK	3
+
+/* Swap file is in directory of edited file.  Used to find the file from
+ * different mount points. */
+#define B0_SAME_DIR	4
+
+/* The 'fileencoding' is at the end of b0_fname[], with a NUL in front of it.
+ * When empty there is only the NUL. */
+#define B0_HAS_FENC	8
 
 #define STACK_INCR	5	/* nr of entries added to ml_stack at a time */
 
@@ -187,7 +214,12 @@ static linenr_T	lowest_marked = 0;
 #define ML_FLUSH	0x02	    /* flush locked block */
 #define ML_SIMPLE(x)	(x & 0x10)  /* DEL, INS or FIND */
 
+static void ml_upd_block0 __ARGS((buf_T *buf, int setfname));
 static void set_b0_fname __ARGS((ZERO_BL *, buf_T *buf));
+static void set_b0_dir_flag __ARGS((ZERO_BL *b0p, buf_T *buf));
+#ifdef FEAT_MBYTE
+static void add_b0_fenc __ARGS((ZERO_BL *b0p, buf_T *buf));
+#endif
 static time_t swapfile_info __ARGS((char_u *));
 static int recov_file_names __ARGS((char_u **, char_u *, int prepend_dot));
 static int ml_append_int __ARGS((buf_T *, linenr_T, char_u *, colnr_T, int, int));
@@ -282,7 +314,8 @@ ml_open()
 
     b0p->b0_id[0] = BLOCK0_ID0;
     b0p->b0_id[1] = BLOCK0_ID1;
-    b0p->b0_dirty = curbuf->b_changed ? 0x55 : 0;
+    b0p->b0_dirty = curbuf->b_changed ? B0_DIRTY : 0;
+    b0p->b0_flags = get_fileformat(curbuf) + 1;
     b0p->b0_magic_long = (long)B0_MAGIC_LONG;
     b0p->b0_magic_int = (int)B0_MAGIC_INT;
     b0p->b0_magic_short = (short)B0_MAGIC_SHORT;
@@ -433,6 +466,7 @@ ml_setname(buf)
 #else
 	    mf_set_ffname(mfp);
 #endif
+	    ml_upd_block0(buf, FALSE);
 	    break;
 	}
 	vim_free(fname);	    /* this fname didn't work, try another */
@@ -507,6 +541,8 @@ ml_open_file(buf)
 	     */
 	    mf_fullname(mfp);
 #endif
+	    ml_upd_block0(buf, FALSE);
+
 	    /* Flush block zero, so others can read it */
 	    if (mf_sync(mfp, MFS_ZERO) == OK)
 		break;
@@ -608,19 +644,34 @@ ml_close_notmod()
 ml_timestamp(buf)
     buf_T	*buf;
 {
+    ml_upd_block0(buf, TRUE);
+}
+
+/*
+ * Update the timestamp or the B0_SAME_DIR flag of the .swp file.
+ */
+    static void
+ml_upd_block0(buf, setfname)
+    buf_T	*buf;
+    int		setfname;
+{
     memfile_T	*mfp;
     bhdr_T	*hp;
     ZERO_BL	*b0p;
 
     mfp = buf->b_ml.ml_mfp;
-
     if (mfp == NULL || (hp = mf_get(mfp, (blocknr_T)0, 1)) == NULL)
 	return;
     b0p = (ZERO_BL *)(hp->bh_data);
     if (b0p->b0_id[0] != BLOCK0_ID0 || b0p->b0_id[1] != BLOCK0_ID1)
-	EMSG(_("E304: ml_timestamp: Didn't get block 0??"));
+	EMSG(_("E304: ml_upd_block0(): Didn't get block 0??"));
     else
-	set_b0_fname(b0p, buf);
+    {
+	if (setfname)
+	    set_b0_fname(b0p, buf);
+	else
+	    set_b0_dir_flag(b0p, buf);
+    }
     mf_put(mfp, hp, TRUE, FALSE);
 }
 
@@ -641,9 +692,14 @@ set_b0_fname(b0p, buf)
     else
     {
 #if defined(MSDOS) || defined(MSWIN) || defined(AMIGA) || defined(RISCOS)
-	/* systems that cannot translate "~user" back into a path: copy the
-	 * file name unmodified */
+	/* Systems that cannot translate "~user" back into a path: copy the
+	 * file name unmodified.  Do use slashes instead of backslashes for
+	 * portability. */
 	STRNCPY(b0p->b0_fname, buf->b_ffname, B0_FNAME_SIZE);
+	b0p->b0_fname[B0_FNAME_SIZE - 1] = NUL;
+# ifdef BACKSLASH_IN_FILENAME
+	forward_slash(b0p->b0_fname);
+# endif
 #else
 	size_t	flen, ulen;
 	char_u	uname[B0_UNAME_SIZE];
@@ -662,7 +718,10 @@ set_b0_fname(b0p, buf)
 	    /* If there is no user name or it is too long, don't use "~/" */
 	    if (get_user_name(uname, B0_UNAME_SIZE) == FAIL
 			 || (ulen = STRLEN(uname)) + flen > B0_FNAME_SIZE - 1)
+	    {
 		STRNCPY(b0p->b0_fname, buf->b_ffname, B0_FNAME_SIZE);
+		b0p->b0_fname[B0_FNAME_SIZE - 1] = NUL;
+	    }
 	    else
 	    {
 		mch_memmove(b0p->b0_fname + ulen + 1, b0p->b0_fname + 1, flen);
@@ -691,9 +750,56 @@ set_b0_fname(b0p, buf)
 	    buf->b_orig_mode = 0;
 	}
     }
+
+#ifdef FEAT_MBYTE
+    /* Also add the 'fileencoding' if there is room. */
+    add_b0_fenc(b0p, curbuf);
+#endif
 }
 
 /*
+ * Update the B0_SAME_DIR flag of the swap file.  It's set if the file and the
+ * swapfile for "buf" are in the same directory.
+ * This is fail safe: if we are not sure the directories are equal the flag is
+ * not set.
+ */
+    static void
+set_b0_dir_flag(b0p, buf)
+    ZERO_BL	*b0p;
+    buf_T	*buf;
+{
+    if (same_directory(buf->b_ml.ml_mfp->mf_fname, buf->b_ffname))
+	b0p->b0_flags |= B0_SAME_DIR;
+    else
+	b0p->b0_flags &= ~B0_SAME_DIR;
+}
+
+#ifdef FEAT_MBYTE
+/*
+ * When there is room, add the 'fileencoding' to block zero.
+ */
+    static void
+add_b0_fenc(b0p, buf)
+    ZERO_BL	*b0p;
+    buf_T	*buf;
+{
+    int		n;
+
+    n = STRLEN(buf->b_p_fenc);
+    if (STRLEN(b0p->b0_fname) + n + 1 > B0_FNAME_SIZE)
+	b0p->b0_flags &= ~B0_HAS_FENC;
+    else
+    {
+	mch_memmove((char *)b0p->b0_fname + B0_FNAME_SIZE - n,
+					    (char *)buf->b_p_fenc, (size_t)n);
+	*(b0p->b0_fname + B0_FNAME_SIZE - n - 1) = NUL;
+	b0p->b0_flags |= B0_HAS_FENC;
+    }
+}
+#endif
+
+
+/*
  * try to recover curbuf from the .swp file
  */
     void
@@ -704,6 +810,8 @@ ml_recover()
     char_u	*fname;
     bhdr_T	*hp = NULL;
     ZERO_BL	*b0p;
+    int		b0_ff;
+    char_u	*b0_fenc = NULL;
     PTR_BL	*pp;
     DATA_BL	*dp;
     infoptr_T	*ip;
@@ -926,6 +1034,17 @@ ml_recover()
 	EMSG(_("E308: Warning: Original file may have been changed"));
     }
     out_flush();
+
+    /* Get the 'fileformat' and 'fileencoding' from block zero. */
+    b0_ff = (b0p->b0_flags & B0_FF_MASK);
+    if (b0p->b0_flags & B0_HAS_FENC)
+    {
+	for (p = b0p->b0_fname + B0_FNAME_SIZE;
+				       p > b0p->b0_fname && p[-1] != NUL; --p)
+	    ;
+	b0_fenc = vim_strnsave(p, b0p->b0_fname + B0_FNAME_SIZE - p);
+    }
+
     mf_put(mfp, hp, FALSE, FALSE);	/* release block 0 */
     hp = NULL;
 
@@ -948,6 +1067,16 @@ ml_recover()
 	    ml_delete((linenr_T)1, FALSE);
     }
 
+    /* Use the 'fileformat' and 'fileencoding' as stored in the swap file. */
+    if (b0_ff != 0)
+	set_fileformat(b0_ff - 1, OPT_LOCAL);
+    if (b0_fenc != NULL)
+    {
+	set_option_value((char_u *)"fenc", 0L, b0_fenc, OPT_LOCAL);
+	vim_free(b0_fenc);
+    }
+    unchanged(curbuf, TRUE);
+
     bnum = 1;		/* start with block 1 */
     page_count = 1;	/* which is 1 page */
     lnum = 0;		/* append after line 0 in curbuf */
@@ -1295,7 +1424,7 @@ recover_names(fname, list, nr)
 	    {
 #if defined(UNIX) || defined(WIN3264)
 		p = dir_name + STRLEN(dir_name);
-		if (vim_ispathsep(p[-1]) && p[-1] == p[-2])
+		if (after_pathsep(dir_name, p) && p[-1] == p[-2])
 		{
 		    /* Ends with '//', Use Full path for swap name */
 		    tail = make_percent_swname(dir_name, *fname);
@@ -1441,7 +1570,7 @@ make_percent_swname(dir, name)
     char_u	*dir;
     char_u	*name;
 {
-    char_u *d, *s, *f, *p;
+    char_u *d, *s, *f;
 
     f = fix_fname(name != NULL ? name : (char_u *) "");
     d = NULL;
@@ -1450,9 +1579,10 @@ make_percent_swname(dir, name)
 	s = alloc((unsigned)(STRLEN(f) + 1));
 	if (s != NULL)
 	{
-	    for (d = s, p = f; *p; p++, d++)
-		*d = vim_ispathsep(*p) ? '%' : *p;
-	    *d = 0;
+	    STRCPY(s, f);
+	    for (d = s; *d != NUL; mb_ptr_adv(d))
+		if (vim_ispathsep(*d))
+		    *d = '%';
 	    d = concat_fnames(dir, s, TRUE);
 	    vim_free(s);
 	}
@@ -3266,7 +3396,7 @@ makeswapname(buf, dir_name)
 
 #if defined(UNIX) || defined(WIN3264)  /* Need _very_ long file names */
     s = dir_name + STRLEN(dir_name);
-    if (vim_ispathsep(s[-1]) && s[-1] == s[-2])
+    if (after_pathsep(dir_name, s) && s[-1] == s[-2])
     {			       /* Ends with '//', Use Full path */
 	r = NULL;
 	if ((s = make_percent_swname(dir_name, buf->b_fname)) != NULL)
@@ -3617,18 +3747,33 @@ findswapname(buf, dirp, old_fname)
 		    if (read(fd, (char *)&b0, sizeof(b0)) == sizeof(b0))
 		    {
 			/*
-			 * The name in the swap file may be "~user/path/file".
-			 * Expand it first.
+			 * If the swapfile has the same directory as the
+			 * buffer don't compare the directory names, they can
+			 * have a different mountpoint.
 			 */
-			expand_env(b0.b0_fname, NameBuff, MAXPATHL);
+			if (b0.b0_flags & B0_SAME_DIR)
+			{
+			    if (fnamecmp(gettail(buf->b_ffname),
+						   gettail(b0.b0_fname)) != 0
+				    || !same_directory(fname, buf->b_ffname))
+				differ = TRUE;
+			}
+			else
+			{
+			    /*
+			     * The name in the swap file may be
+			     * "~user/path/file".  Expand it first.
+			     */
+			    expand_env(b0.b0_fname, NameBuff, MAXPATHL);
 #ifdef CHECK_INODE
-			if (fnamecmp_ino(buf->b_ffname, NameBuff,
-						     char_to_long(b0.b0_ino)))
-			    differ = TRUE;
+			    if (fnamecmp_ino(buf->b_ffname, NameBuff,
+					char_to_long(b0.b0_ino)))
+				differ = TRUE;
 #else
-			if (fnamecmp(NameBuff, buf->b_ffname) != 0)
-			    differ = TRUE;
+			    if (fnamecmp(NameBuff, buf->b_ffname) != 0)
+				differ = TRUE;
 #endif
+			}
 		    }
 		    close(fd);
 		}
@@ -3956,10 +4101,15 @@ char_to_long(s)
     return retval;
 }
 
+/*
+ * Set the flags in the first block of the swap file:
+ * - file is modified or not: buf->b_changed
+ * - 'fileformat'
+ * - 'fileencoding'
+ */
     void
-ml_setdirty(buf, flag)
+ml_setflags(buf)
     buf_T	*buf;
-    int		flag;
 {
     bhdr_T	*hp;
     ZERO_BL	*b0p;
@@ -3971,7 +4121,12 @@ ml_setdirty(buf, flag)
 	if (hp->bh_bnum == 0)
 	{
 	    b0p = (ZERO_BL *)(hp->bh_data);
-	    b0p->b0_dirty = flag ? 0x55 : 0;
+	    b0p->b0_dirty = buf->b_changed ? B0_DIRTY : 0;
+	    b0p->b0_flags = (b0p->b0_flags & ~B0_FF_MASK)
+						  | (get_fileformat(buf) + 1);
+#ifdef FEAT_MBYTE
+	    add_b0_fenc(b0p, buf);
+#endif
 	    hp->bh_flags |= BH_DIRTY;
 	    mf_sync(buf->b_ml.ml_mfp, MFS_ZERO);
 	    break;
--- a/src/menu.c
+++ b/src/menu.c
@@ -146,12 +146,7 @@ ex_menu(eap)
 	{
 	    if (*arg == '\\')
 		mch_memmove(arg, arg + 1, STRLEN(arg));
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		arg += (*mb_ptr2len_check)(arg);
-	    else
-#endif
-		++arg;
+	    mb_ptr_adv(arg);
 	}
 	if (*arg != NUL)
 	{
@@ -681,17 +676,13 @@ add_menu_path(menu_path, menuarg, pri_ta
 
 		    STRCPY(tearpath, menu_path);
 		    idx = (int)(next_name - path_name - 1);
-		    for (s = tearpath; *s && s < tearpath + idx; ++s)
+		    for (s = tearpath; *s && s < tearpath + idx; mb_ptr_adv(s))
 		    {
 			if ((*s == '\\' || *s == Ctrl_V) && s[1])
 			{
 			    ++idx;
 			    ++s;
 			}
-#  ifdef FEAT_MBYTE
-			if (has_mbyte)
-			    s += (*mb_ptr2len_check)(s) - 1;
-#  endif
 		    }
 		    tearpath[idx] = NUL;
 		    gui_add_tearoff(tearpath, pri_tab, pri_idx);
@@ -1410,7 +1401,7 @@ menu_name_skip(name)
 {
     char_u  *p;
 
-    for (p = name; *p && *p != '.'; p++)
+    for (p = name; *p && *p != '.'; mb_ptr_adv(p))
     {
 	if (*p == '\\' || *p == Ctrl_V)
 	{
@@ -1418,10 +1409,6 @@ menu_name_skip(name)
 	    if (*p == NUL)
 		break;
 	}
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;	/* skip multibyte char */
-#endif
     }
     if (*p)
 	*p++ = NUL;
--- a/src/message.c
+++ b/src/message.c
@@ -2897,12 +2897,7 @@ msg_show_console_dialog(message, buttons
 	    }
 
 	    /* advance to the next character */
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		r += (*mb_ptr2len_check)(r);
-	    else
-#endif
-		++r;
+	    mb_ptr_adv(r);
 	}
 
 	if (copy)
@@ -2910,12 +2905,7 @@ msg_show_console_dialog(message, buttons
 	    *msgp++ = ':';
 	    *msgp++ = ' ';
 	    *msgp = NUL;
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		hotkp += (*mb_ptr2len_check)(hotkp);
-	    else
-#endif
-		++hotkp;
+	    mb_ptr_adv(hotkp);
 	    *hotkp = NUL;
 	}
 	else
@@ -3148,11 +3138,8 @@ do_browse(flags, title, dflt, ext, initd
 	    if (fname != NULL && *fname != NUL && !mch_isdir(fname))
 	    {
 		/* Remove the file name. */
-		char_u	    *s = get_past_head(fname);
-		char_u	    *tail = gettail(fname);
+		char_u	    *tail = gettail_sep(fname);
 
-		while (tail > s && vim_ispathsep(tail[-1]))
-		    --tail;
 		if (tail == fname)
 		    *tail++ = '.';	/* use current dir */
 		*tail = NUL;
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -1006,8 +1006,7 @@ open_line(dir, flags, old_indent)
 
 			    while (old_size < repl_size && p > leader)
 			    {
-				--p;
-				p -= mb_head_off(leader, p);
+				mb_ptr_back(leader, p);
 				old_size += ptr2cells(p);
 			    }
 			    l = lead_repl_len - (endp - p);
@@ -1741,12 +1740,7 @@ plines_win_col(wp, lnum, column)
     while (*s != NUL && --column >= 0)
     {
 	col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL);
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    s += (*mb_ptr2len_check)(s);
-	else
-#endif
-	    ++s;
+	mb_ptr_adv(s);
     }
 
     /*
@@ -2451,7 +2445,7 @@ changed()
 	    }
 	}
 	curbuf->b_changed = TRUE;
-	ml_setdirty(curbuf, TRUE);
+	ml_setflags(curbuf);
 #ifdef FEAT_WINDOWS
 	check_status(curbuf);
 #endif
@@ -2788,7 +2782,7 @@ unchanged(buf, ff)
     if (buf->b_changed || (ff && file_ff_differs(buf)))
     {
 	buf->b_changed = 0;
-	ml_setdirty(buf, FALSE);
+	ml_setflags(buf);
 	if (ff)
 	    save_file_ff(buf);
 #ifdef FEAT_WINDOWS
@@ -3520,15 +3514,16 @@ expand_env_esc(src, dst, dstlen, esc)
 	    {
 		STRCPY(dst, var);
 		dstlen -= (int)STRLEN(var);
-		dst += STRLEN(var);
+		c = STRLEN(var);
 		/* if var[] ends in a path separator and tail[] starts
 		 * with it, skip a character */
-		if (*var != NUL && vim_ispathsep(dst[-1])
+		if (*var != NUL && after_pathsep(dst, dst + c)
 #if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA)
 			&& dst[-1] != ':'
 #endif
 			&& vim_ispathsep(*tail))
 		    ++tail;
+		dst += c;
 		src = tail;
 		copy_char = FALSE;
 	    }
@@ -3667,7 +3662,7 @@ vim_getenv(name, mustfree)
 #ifndef MACOS_CLASSIC
 	    /* With MacOS path (with  colons) the final colon is required */
 	    /* to avoid confusion between absoulute and relative path */
-	    if (pend > p && vim_ispathsep(*(pend - 1)))
+	    if (pend > p && after_pathsep(p, pend))
 		--pend;
 #endif
 
@@ -3789,7 +3784,7 @@ remove_tail(p, pend, name)
 
     if (newend >= p
 	    && fnamencmp(newend, name, len - 1) == 0
-	    && (newend == p || vim_ispathsep(*(newend - 1))))
+	    && (newend == p || after_pathsep(p, newend)))
 	return newend;
     return pend;
 }
@@ -3809,9 +3804,9 @@ remove_tail_with_ext(p, pend, ext)
     char_u	*newend = pend - len;
 
     if (newend >= p && fnamencmp(newend, ext, len - 1) == 0)
-	while (newend != p && !vim_ispathsep(*(newend - 1)))
-	    --newend;
-    if (newend == p || vim_ispathsep(*(newend - 1)))
+	while (newend != p && !after_pathsep(newend))
+	    mb_ptr_back(newend);
+    if (newend == p || after_pathsep(newend))
 	return newend;
     return pend;
 }
@@ -4122,17 +4117,35 @@ gettail(fname)
     {
 	if (vim_ispathsep(*p2))
 	    p1 = p2 + 1;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p2 += (*mb_ptr2len_check)(p2);
-	else
-#endif
-	    ++p2;
+	mb_ptr_adv(p2);
     }
     return p1;
 }
 
 /*
+ * Get pointer to tail of "fname", including path separators.  Putting a NUL
+ * here leaves the directory name.  Takes care of "c:/" and "//".
+ * Always returns a valid pointer.
+ */
+    char_u *
+gettail_sep(fname)
+    char_u	*fname;
+{
+    char_u	*p;
+    char_u	*t;
+
+    p = get_past_head(fname);	/* don't remove the '/' from "c:/file" */
+    t = gettail(fname);
+    while (t > p && after_pathsep(fname, t))
+	--t;
+#ifdef VMS
+    /* path separator is part of the path */
+    ++t;
+#endif
+    return t;
+}
+
+/*
  * get the next path component (just after the next path separator).
  */
     char_u *
@@ -4140,18 +4153,12 @@ getnextcomp(fname)
     char_u *fname;
 {
     while (*fname && !vim_ispathsep(*fname))
-	++fname;
+	mb_ptr_adv(fname);
     if (*fname)
 	++fname;
     return fname;
 }
 
-#if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
-	|| defined(FEAT_SESSION) || defined(MSWIN) \
-	|| ((defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)) \
-			    && (defined(FEAT_WINDOWS) || defined(FEAT_DND))) \
-	|| defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG) \
-	|| defined(PROTO)
 /*
  * Get a pointer to one character past the head of a path name.
  * Unix: after "/"; DOS: after "c:\"; Amiga: after "disk:/"; Mac: no head.
@@ -4185,7 +4192,6 @@ get_past_head(path)
 
     return retval;
 }
-#endif
 
 /*
  * return TRUE if 'c' is a path separator.
@@ -4299,7 +4305,7 @@ concat_fnames(fname1, fname2, sep)
 add_pathsep(p)
     char_u	*p;
 {
-    if (*p != NUL && !vim_ispathsep(*(p + STRLEN(p) - 1)))
+    if (*p != NUL && !after_pathsep(p, p + STRLEN(p)))
 	STRCAT(p, PATHSEPSTR);
 }
 
@@ -7653,9 +7659,10 @@ get_lisp_indent()
     void
 prepare_to_exit()
 {
-#if defined(UNIX)
-    /* Ignore SIGHUP, because a dropped connection may make Vim exit and then
-     * get a SIGHUP while exiting, which causes various reentrent problems. */
+#if defined(SIGHUP) && defined(SIG_IGN)
+    /* Ignore SIGHUP, because a dropped connection causes a read error, which
+     * makes Vim exit and then handling SIGHUP causes various reentrance
+     * problems. */
     signal(SIGHUP, SIG_IGN);
 #endif
 
@@ -7904,7 +7911,7 @@ static int expand_backtick __ARGS((garra
     static int _cdecl
 pstrcmp(const void *a, const void *b)
 {
-    return (pathcmp(*(char **)a, *(char **)b));
+    return (pathcmp(*(char **)a, *(char **)b, -1));
 }
 
 # ifndef WIN3264
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -200,12 +200,7 @@ coladvance2(pos, addspaces, finetune, wc
 	    /* Count a tab for what it's worth (if list mode not on) */
 #ifdef FEAT_LINEBREAK
 	    csize = win_lbr_chartabsize(curwin, ptr, col, &head);
-# ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		ptr += (*mb_ptr2len_check)(ptr);
-	    else
-# endif
-		++ptr;
+	    mb_ptr_adv(ptr);
 #else
 	    csize = lbr_chartabsize_adv(&ptr, col);
 #endif
@@ -1451,12 +1446,7 @@ vim_strrchr(string, c)
     {
 	if (*string == c)
 	    retval = string;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    string += (*mb_ptr2len_check)(string);
-	else
-#endif
-	    ++string;
+	mb_ptr_adv(string);
     }
     return retval;
 }
@@ -1479,12 +1469,7 @@ vim_strpbrk(s, charset)
     {
 	if (vim_strchr(charset, *s) != NULL)
 	    return s;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    s += (*mb_ptr2len_check)(s);
-	else
-#endif
-	    ++s;
+	mb_ptr_adv(s);
     }
     return NULL;
 }
@@ -2645,6 +2630,46 @@ get_real_state()
     return State;
 }
 
+#if defined(FEAT_MBYTE) || defined(PROTO)
+/*
+ * Return TRUE if "p" points to just after a path separator.
+ * Take care of multi-byte characters.
+ * "b" must point to the start of the file name
+ */
+    int
+after_pathsep(b, p)
+    char_u	*b;
+    char_u	*p;
+{
+    return vim_ispathsep(p[-1])
+			     && (!has_mbyte || (*mb_head_off)(b, p - 1) == 0);
+}
+#endif
+
+/*
+ * Return TRUE if file names "f1" and "f2" are in the same directory.
+ * "f1" may be a short name, "f2" must be a full path.
+ */
+    int
+same_directory(f1, f2)
+    char_u	*f1;
+    char_u	*f2;
+{
+    char_u	ffname[MAXPATHL];
+    char_u	*t1;
+    char_u	*t2;
+
+    /* safety check */
+    if (f1 == NULL || f2 == NULL)
+	return FALSE;
+
+    (void)vim_FullName(f1, ffname, MAXPATHL, FALSE);
+    t1 = gettail_sep(ffname);
+    t2 = gettail_sep(f2);
+    return (t1 - ffname == t2 - f2
+	     && pathcmp((char *)ffname, (char *)f2, (int)(t1 - ffname)) == 0);
+}
+
 #if defined(FEAT_SESSION) || defined(MSWIN) || defined(FEAT_GUI_MAC) \
 	|| ((defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)) \
 			&& ( defined(FEAT_WINDOWS) || defined(FEAT_DND)) ) \
@@ -2659,18 +2684,12 @@ get_real_state()
 vim_chdirfile(fname)
     char_u	*fname;
 {
-    char_u	temp_string[MAXPATHL];
-    char_u	*p;
-    char_u	*t;
-
-    STRCPY(temp_string, fname);
-    p = get_past_head(temp_string);
-    t = gettail(temp_string);
-    while (t > p && vim_ispathsep(t[-1]))
-	--t;
-    *t = NUL; /* chop off end of string */
-
-    return mch_chdir((char *)temp_string) == 0 ? OK : FAIL;
+    char_u	dir[MAXPATHL];
+
+    STRNCPY(dir, fname, MAXPATHL);
+    dir[MAXPATHL - 1] = NUL;
+    *gettail_sep(dir) = NUL;
+    return mch_chdir((char *)dir) == 0 ? OK : FAIL;
 }
 #endif
 
@@ -5196,16 +5215,18 @@ sort_strings(files, count)
 #if !defined(NO_EXPANDPATH) || defined(PROTO)
 /*
  * Compare path "p[]" to "q[]".
+ * If "maxlen" >= 0 compare "p[maxlen]" to "q[maxlen]"
  * Return value like strcmp(p, q), but consider path separators.
  */
     int
-pathcmp(p, q)
+pathcmp(p, q, maxlen)
     const char *p, *q;
+    int maxlen;
 {
     int		i;
     const char	*s;
 
-    for (i = 0; ; ++i)
+    for (i = 0; maxlen < 0 || i < maxlen; ++i)
     {
 	/* End of "p": check if "q" also ends or just has a slash. */
 	if (p[i] == NUL)
@@ -5245,13 +5266,16 @@ pathcmp(p, q)
     }
 
     /* ignore a trailing slash, but not "//" or ":/" */
-    if (s[i + 1] == NUL && i > 0 && !vim_ispathsep(s[i - 1])
+    if (i >= maxlen
+	    || (s[i + 1] == NUL
+		&& i > 0
+		&& !after_pathsep((char_u *)s, (char_u *)s + i)
 #ifdef BACKSLASH_IN_FILENAME
-	    && (s[i] == '/' || s[i] == '\\')
+		&& (s[i] == '/' || s[i] == '\\')
 #else
-	    && s[i] == '/'
+		&& s[i] == '/'
 #endif
-       )
+	       ))
 	return 0;   /* match with trailing slash */
     if (s == q)
 	return -1;	    /* no match */
--- a/src/ops.c
+++ b/src/ops.c
@@ -2488,7 +2488,7 @@ op_change(oap)
 
 #ifdef FEAT_VISUALEXTRA
     /*
-     * In Visual block mode, handle copying the next text to all lines of the
+     * In Visual block mode, handle copying the new text to all lines of the
      * block.
      */
     if (oap->block_mode && oap->start.lnum != oap->end.lnum)
@@ -3946,13 +3946,12 @@ do_join(insert_space)
 #ifdef FEAT_MBYTE
 	if (has_mbyte)
 	{
-	    next = curr + currsize - 1;
-	    next -= (*mb_head_off)(curr, next);
+	    next = curr + currsize;
+	    mb_ptr_back(curr, next);
 	    endcurr1 = (*mb_ptr2char)(next);
 	    if (next > curr)
 	    {
-		--next;
-		next -= (*mb_head_off)(curr, next);
+		mb_ptr_back(curr, next);
 		endcurr2 = (*mb_ptr2char)(next);
 	    }
 	}
@@ -4614,12 +4613,7 @@ block_prep(oap, bdp, lnum, is_del)
 	}
 #endif
 	prev_pstart = pstart;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    pstart += (*mb_ptr2len_check)(pstart);
-	else
-#endif
-	    ++pstart;
+	mb_ptr_adv(pstart);
     }
     bdp->start_char_vcols = incr;
     if (bdp->start_vcol < oap->start_vcol)	/* line too short */
@@ -4994,10 +4988,12 @@ do_addsub(command, Prenum1)
 	length -= (int)STRLEN(buf2);
 
 	/*
-	 * adjust number of zeros to the new number of digits, so the
-	 * total length of the number remains the same
+	 * Adjust number of zeros to the new number of digits, so the
+	 * total length of the number remains the same.
+	 * Don't do this when
+	 * the result may look like an octal number.
 	 */
-	if (firstdigit == '0')
+	if (firstdigit == '0' && !(dooct && hex == 0))
 	    while (length-- > 0)
 		*ptr++ = '0';
 	*ptr = NUL;
--- a/src/option.c
+++ b/src/option.c
@@ -4722,7 +4722,7 @@ did_set_string_option(opt_idx, varp, new
      * separator (slash and/or backslash), wildcards and characters that are
      * often illegal in a file name. */
     else if ((options[opt_idx].flags & P_NFNAME)
-				   && vim_strpbrk(*varp, "/\\*?[|<>") != NULL)
+			 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
     {
 	errmsg = e_invarg;
     }
@@ -4951,11 +4951,15 @@ did_set_string_option(opt_idx, varp, new
 		/* No comma allowed in 'fileencoding'; catches confusing it
 		 * with 'fileencodings'. */
 		errmsg = e_invarg;
+	    else
+	    {
 # ifdef FEAT_TITLE
-	    else
 		/* May show a "+" in the title now. */
 		need_maketitle = TRUE;
 # endif
+		/* Add 'fileencoding' to the swap file. */
+		ml_setflags(curbuf);
+	    }
 	}
 	if (errmsg == NULL)
 	{
@@ -5075,6 +5079,8 @@ did_set_string_option(opt_idx, varp, new
 #ifdef FEAT_TITLE
 	    need_maketitle = TRUE;
 #endif
+	    /* update flag in swap file */
+	    ml_setflags(curbuf);
 	}
     }
 
@@ -5275,12 +5281,7 @@ did_set_string_option(opt_idx, varp, new
 	{
 	    if (ptr2cells(s) != 1)
 		errmsg = (char_u *)N_("E595: contains unprintable or wide character");
-# ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		s += (*mb_ptr2len_check)(s);
-	    else
-# endif
-		++s;
+	    mb_ptr_adv(s);
 	}
     }
 #endif
@@ -7313,6 +7314,19 @@ get_highlight_default()
     return (char_u *)NULL;
 }
 
+#if defined(FEAT_MBYTE) || defined(PROTO)
+    char_u *
+get_encoding_default()
+{
+    int i;
+
+    i = findoption((char_u *)"enc");
+    if (i >= 0)
+	return options[i].def_val[VI_DEFAULT];
+    return (char_u *)NULL;
+}
+#endif
+
 /*
  * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
  */
@@ -8902,20 +8916,13 @@ ExpandOldSetting(num_file, file)
 #ifdef BACKSLASH_IN_FILENAME
     /* For MS-Windows et al. we don't double backslashes at the start and
      * before a file name character. */
-    for (var = buf; *var != NUL; )
-    {
+    for (var = buf; *var != NUL; mb_ptr_adv(var))
 	if (var[0] == '\\' && var[1] == '\\'
 		&& expand_option_idx >= 0
 		&& (options[expand_option_idx].flags & P_EXPAND)
 		&& vim_isfilec(var[2])
 		&& (var[2] != '\\' || (var == buf && var[4] != '\\')))
 	    mch_memmove(var, var + 1, STRLEN(var));
-#ifdef FEAT_MBYTE
-	else if (has_mbyte)
-	    var += (*mb_ptr2len_check)(var) - 1;
-#endif
-	++var;
-    }
 #endif
 
     *file[0] = buf;
@@ -9025,13 +9032,11 @@ langmap_set()
 
     for (p = p_langmap; p[0] != NUL; )
     {
-	for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';'; ++p2)
+	for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
+							       mb_ptr_adv(p2))
 	{
 	    if (p2[0] == '\\' && p2[1] != NUL)
 		++p2;
-#ifdef FEAT_MBYTE
-	    p2 += (*mb_ptr2len_check)(p2) - 1;
-#endif
 	}
 	if (p2[0] == ';')
 	    ++p2;	    /* abcd;ABCD form, p2 points to A */
@@ -9048,11 +9053,7 @@ langmap_set()
 #endif
 	    if (p2 == NULL)
 	    {
-#ifdef FEAT_MBYTE
-		p += (*mb_ptr2len_check)(p);
-#else
-		++p;
-#endif
+		mb_ptr_adv(p);
 		if (p[0] == '\\')
 		    ++p;
 #ifdef FEAT_MBYTE
@@ -9080,11 +9081,7 @@ langmap_set()
 	    langmap_mapchar[from & 255] = to;
 
 	    /* Advance to next pair */
-#ifdef FEAT_MBYTE
-	    p += (*mb_ptr2len_check)(p);
-#else
-	    ++p;
-#endif
+	    mb_ptr_adv(p);
 	    if (p2 == NULL)
 	    {
 		if (p[0] == ',')
@@ -9095,11 +9092,7 @@ langmap_set()
 	    }
 	    else
 	    {
-#ifdef FEAT_MBYTE
-		p2 += (*mb_ptr2len_check)(p2);
-#else
-		++p2;
-#endif
+		mb_ptr_adv(p2);
 		if (*p == ';')
 		{
 		    p = p2;
--- a/src/option.h
+++ b/src/option.h
@@ -161,9 +161,10 @@
 #define CPO_FILTER	'!'
 #define CPO_MATCH	'%'
 #define CPO_STAR	'*'	/* ":*" means ":@" */
+#define CPO_PLUS	'+'	/* ":write file" resets 'modified' */
 #define CPO_SPECI	'<'	/* don't recognize <> in mappings */
 #define CPO_DEFAULT	"aABceFs"
-#define CPO_ALL		"aAbBcCdDeEfFgiIjJkKlLmMnoOprRsStuvwWxy$!%*<"
+#define CPO_ALL		"aAbBcCdDeEfFgiIjJkKlLmMnoOprRsStuvwWxy$!%*+<"
 
 /* characters for p_ww option: */
 #define WW_ALL		"bshl<>[],~"
--- a/src/os_amiga.c
+++ b/src/os_amiga.c
@@ -1501,7 +1501,7 @@ sortcmp(a, b)
     char *s = *(char **)a;
     char *t = *(char **)b;
 
-    return pathcmp(s, t);
+    return pathcmp(s, t, -1);
 }
 
 /*
@@ -1511,16 +1511,12 @@ sortcmp(a, b)
 mch_has_exp_wildcard(p)
     char_u *p;
 {
-    for ( ; *p; ++p)
+    for ( ; *p; mb_ptr_adv(p))
     {
 	if (*p == '\\' && p[1] != NUL)
 	    ++p;
 	else if (vim_strchr((char_u *)"*?[(#", *p) != NULL)
 	    return TRUE;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
     return FALSE;
 }
@@ -1529,7 +1525,7 @@ mch_has_exp_wildcard(p)
 mch_has_wildcard(p)
     char_u *p;
 {
-    for ( ; *p; ++p)
+    for ( ; *p; mb_ptr_adv(p))
     {
 	if (*p == '\\' && p[1] != NUL)
 	    ++p;
@@ -1543,10 +1539,6 @@ mch_has_wildcard(p)
 						, *p) != NULL
 		    || (*p == '~' && p[1] != NUL))
 		return TRUE;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
     return FALSE;
 }
--- a/src/os_mac.c
+++ b/src/os_mac.c
@@ -299,7 +299,7 @@ mac_expandpath(
 pstrcmp(a, b)
     const void *a, *b;
 {
-    return (pathcmp(*(char **)a, *(char **)b));
+    return (pathcmp(*(char **)a, *(char **)b, -1));
 }
 
     static int
@@ -1008,12 +1008,7 @@ slash_adjust(p)
     {
 	if (*p == '/')
 	    *p = ':';
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p);
-	else
-#endif
-	    ++p;
+	mb_ptr_adv(p);
     }
 #endif
 }
@@ -1207,16 +1202,12 @@ mch_call_shell(cmd, options)
 mch_has_exp_wildcard(p)
     char_u	*p;
 {
-    for ( ; *p; ++p)
+    for ( ; *p; mb_ptr_adv(p))
     {
 	if (*p == '\\' && p[1] != NUL)
 	    ++p;
 	else if (vim_strchr((char_u *)WILDCHAR_LIST, *p) != NULL)
 	    return TRUE;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
     return FALSE;
 }
--- a/src/os_msdos.c
+++ b/src/os_msdos.c
@@ -1700,12 +1700,7 @@ slash_adjust(char_u *p)
 	{
 	    if (*p == '\\')
 		*p = '/';
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		p += (*mb_ptr2len_check)(p);
-	    else
-#endif
-		++p;
+	    mb_ptr_adv(p);
 	}
     else
 #endif
@@ -1713,12 +1708,7 @@ slash_adjust(char_u *p)
     {
 	if (*p == psepcN)
 	    *p = psepc;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p);
-	else
-#endif
-	    ++p;
+	mb_ptr_adv(p);
     }
 }
 
@@ -2034,15 +2024,11 @@ mch_breakcheck(void)
     int
 mch_has_exp_wildcard(char_u *p)
 {
-    for ( ; *p; ++p)
+    for ( ; *p; mb_ptr_adv(p))
     {
 	if (vim_strchr((char_u *)"?*[", *p) != NULL
 		|| (*p == '~' && p[1] != NUL))
 	    return TRUE;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
     return FALSE;
 }
@@ -2054,7 +2040,7 @@ mch_has_exp_wildcard(char_u *p)
     int
 mch_has_wildcard(char_u *p)
 {
-    for ( ; *p; ++p)
+    for ( ; *p; mb_ptr_adv(p))
     {
 	if (vim_strchr((char_u *)
 #  ifdef VIM_BACKTICK
@@ -2065,10 +2051,6 @@ mch_has_wildcard(char_u *p)
 						, *p) != NULL
 		|| (*p == '~' && p[1] != NUL))
 	    return TRUE;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
     return FALSE;
 }
@@ -2138,7 +2120,7 @@ mch_rename(const char *OldFile, const ch
 	 * filena~1.txt.  If we rename filena~1.txt to filena~1.txt~
 	 * (i.e., we're making a backup while writing it), the SFN
 	 * for filena~1.txt~ will be filena~1.txt, by default, which
-	 * will cause all sorts of problems later in buf_write.  So, we
+	 * will cause all sorts of problems later in buf_write().  So, we
 	 * create an empty file called filena~1.txt and the system will have
 	 * to find some other SFN for filena~1.txt~, such as filena~2.txt
 	 */
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -364,9 +364,9 @@ mch_can_restore_icon()
 
 
 /*
- * Get absolute file name into buffer 'buf' of length 'len' bytes,
- * turning all '/'s into '\\'s and getting the correct case of each
- * component of the file name.  Append a backslash to a directory name.
+ * Get absolute file name into buffer "buf" of length "len" bytes,
+ * turning all '/'s into '\\'s and getting the correct case of each component
+ * of the file name.  Append a (back)slash to a directory name.
  * When 'shellslash' set do it the other way around.
  * Return OK or FAIL.
  */
@@ -384,19 +384,55 @@ mch_FullName(
 	nResult = mch_dirname(buf, len);
     else
 #endif
-	if (_fullpath(buf, fname, len - 1) == NULL)
     {
-	STRNCPY(buf, fname, len);   /* failed, use the relative path name */
-	buf[len - 1] = NUL;
-#ifndef USE_FNAME_CASE
-	slash_adjust(buf);
+	if (enc_codepage >= 0 && (int)GetACP() != enc_codepage
+# ifdef __BORLANDC__
+		/* Wide functions of Borland C 5.5 do not work on Windows 98. */
+		&& g_PlatformId == VER_PLATFORM_WIN32_NT
+# endif
+	   )
+	{
+	    WCHAR	*wname;
+	    WCHAR	wbuf[MAX_PATH];
+	    char_u	*cname = NULL;
+
+	    /* Use the wide function:
+	     * - convert the fname from 'encoding' to UCS2.
+	     * - invoke _wfullpath()
+	     * - convert the result from UCS2 to 'encoding'.
+	     */
+	    wname = enc_to_ucs2(fname, NULL);
+	    if (wname != NULL && _wfullpath(wbuf, wname, MAX_PATH - 1) != NULL)
+	    {
+		cname = ucs2_to_enc((short_u *)wbuf, NULL);
+		if (cname != NULL)
+		{
+		    STRNCPY(buf, cname, len);
+		    buf[len - 1] = NUL;
+		    nResult = OK;
+		}
+	    }
+	    vim_free(wname);
+	    vim_free(cname);
+	}
+#ifdef FEAT_MBYTE
+	if (nResult == FAIL)	    /* fall back to non-wide function */
 #endif
+	{
+	    if (_fullpath(buf, fname, len - 1) == NULL)
+	    {
+		STRNCPY(buf, fname, len);   /* failed, use relative path name */
+		buf[len - 1] = NUL;
+	    }
+	    else
+		nResult = OK;
+	}
     }
-    else
-	nResult = OK;
 
 #ifdef USE_FNAME_CASE
     fname_case(buf, len);
+#else
+    slash_adjust(buf);
 #endif
 
     return nResult;
@@ -420,7 +456,7 @@ mch_isFullName(char_u *fname)
     if (mch_FullName(fname, szName, _MAX_PATH, FALSE) == FAIL)
 	return FALSE;
 
-    return pathcmp(fname, szName) == 0;
+    return pathcmp(fname, szName, -1) == 0;
 }
 
 /*
@@ -441,12 +477,7 @@ slash_adjust(p)
 	{
 	    if (*p == psepcN)
 		*p = psepc;
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		p += (*mb_ptr2len_check)(p);
-	    else
-#endif
-		++p;
+	    mb_ptr_adv(p);
 	}
 }
 
@@ -464,11 +495,7 @@ vim_stat(const char *name, struct stat *
     buf[_MAX_PATH] = NUL;
     p = buf + strlen(buf);
     if (p > buf)
-	--p;
-#ifdef FEAT_MBYTE
-    if (p > buf && has_mbyte)
-	p -= (*mb_head_off)(buf, p);
-#endif
+	mb_ptr_back(buf, p);
     if (p > buf && (*p == '\\' || *p == '/') && p[-1] != ':')
 	*p = NUL;
 #ifdef FEAT_MBYTE
@@ -588,15 +615,11 @@ display_errors()
     int
 mch_has_exp_wildcard(char_u *p)
 {
-    for ( ; *p; ++p)
+    for ( ; *p; mb_ptr_adv(p))
     {
 	if (vim_strchr((char_u *)"?*[", *p) != NULL
 		|| (*p == '~' && p[1] != NUL))
 	    return TRUE;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
     return FALSE;
 }
@@ -608,7 +631,7 @@ mch_has_exp_wildcard(char_u *p)
     int
 mch_has_wildcard(char_u *p)
 {
-    for ( ; *p; ++p)
+    for ( ; *p; mb_ptr_adv(p))
     {
 	if (vim_strchr((char_u *)
 #  ifdef VIM_BACKTICK
@@ -619,10 +642,6 @@ mch_has_wildcard(char_u *p)
 						, *p) != NULL
 		|| (*p == '~' && p[1] != NUL))
 	    return TRUE;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
     return FALSE;
 }
@@ -2420,6 +2439,7 @@ HWND message_window = 0;	    /* window t
 #define COPYDATA_EXPR		10
 #define COPYDATA_RESULT		11
 #define COPYDATA_ERROR_RESULT	12
+#define COPYDATA_ENCODING	20
 
 /* This is a structure containing a server HWND and its name. */
 struct server_id
@@ -2428,6 +2448,25 @@ struct server_id
     char_u *name;
 };
 
+/* Last received 'encoding' that the client uses. */
+static char_u	*client_enc = NULL;
+
+/*
+ * Tell the other side what encoding we are using.
+ * Errors are ignored.
+ */
+    static void
+serverSendEnc(HWND target)
+{
+    COPYDATASTRUCT data;
+
+    data.dwData = COPYDATA_ENCODING;
+    data.cbData = STRLEN(p_enc) + 1;
+    data.lpData = p_enc;
+    (void)SendMessage(target, WM_COPYDATA, (WPARAM)message_window,
+							     (LPARAM)(&data));
+}
+
 /*
  * Clean up on exit. This destroys the hidden message window.
  */
@@ -2463,6 +2502,9 @@ Messaging_WndProc(HWND hwnd, UINT msg, W
     {
 	/* This is a message from another Vim. The dwData member of the
 	 * COPYDATASTRUCT determines the type of message:
+	 *   COPYDATA_ENCODING:
+	 *	The encoding that the client uses. Following messages will
+	 *	use this encoding, convert if needed.
 	 *   COPYDATA_KEYS:
 	 *	A key sequence. We are a server, and a client wants these keys
 	 *	adding to the input queue.
@@ -2485,16 +2527,26 @@ Messaging_WndProc(HWND hwnd, UINT msg, W
 	char_u		*res;
 	char_u		winstr[30];
 	int		retval;
+	char_u		*str;
+	char_u		*tofree;
 
 	switch (data->dwData)
 	{
+	case COPYDATA_ENCODING:
+	    /* Remember the encoding that the client uses. */
+	    vim_free(client_enc);
+	    client_enc = enc_canonize((char_u *)data->lpData);
+	    return 1;
+
 	case COPYDATA_KEYS:
 	    /* Remember who sent this, for <client> */
 	    clientWindow = sender;
 
 	    /* Add the received keys to the input buffer.  The loop waiting
 	     * for the user to do something should check the input buffer. */
-	    server_to_input_buf((char_u *)(data->lpData));
+	    str = serverConvert(client_enc, (char_u *)data->lpData, &tofree);
+	    server_to_input_buf(str);
+	    vim_free(tofree);
 
 # ifdef FEAT_GUI
 	    /* Wake up the main GUI loop. */
@@ -2507,7 +2559,10 @@ Messaging_WndProc(HWND hwnd, UINT msg, W
 	    /* Remember who sent this, for <client> */
 	    clientWindow = sender;
 
-	    res = eval_client_expr_to_string(data->lpData);
+	    str = serverConvert(client_enc, (char_u *)data->lpData, &tofree);
+	    res = eval_client_expr_to_string(str);
+	    vim_free(tofree);
+
 	    if (res == NULL)
 	    {
 		res = vim_strsave(_(e_invexprmsg));
@@ -2518,6 +2573,7 @@ Messaging_WndProc(HWND hwnd, UINT msg, W
 	    reply.lpData = res;
 	    reply.cbData = STRLEN(res) + 1;
 
+	    serverSendEnc(sender);
 	    retval = SendMessage(sender, WM_COPYDATA, (WPARAM)message_window,
 							    (LPARAM)(&reply));
 	    vim_free(res);
@@ -2528,15 +2584,20 @@ Messaging_WndProc(HWND hwnd, UINT msg, W
 	case COPYDATA_ERROR_RESULT:
 	    if (data->lpData != NULL)
 	    {
-		save_reply(sender, data->lpData,
+		str = serverConvert(client_enc, (char_u *)data->lpData,
+								     &tofree);
+		if (tofree == NULL)
+		    str = vim_strsave(str);
+		if (save_reply(sender, str,
 			   (data->dwData == COPYDATA_REPLY ?  0 :
 			   (data->dwData == COPYDATA_RESULT ? 1 :
-							      2)));
+							      2))) == FAIL)
+		    vim_free(str);
 #ifdef FEAT_AUTOCMD
-		if (data->dwData == COPYDATA_REPLY)
+		else if (data->dwData == COPYDATA_REPLY)
 		{
 		    sprintf((char *)winstr, "0x%x", (unsigned)sender);
-		    apply_autocmds(EVENT_REMOTEREPLY, winstr, data->lpData,
+		    apply_autocmds(EVENT_REMOTEREPLY, winstr, str,
 								TRUE, curbuf);
 		}
 #endif
@@ -2762,6 +2823,7 @@ serverSendReply(name, reply)
     data.cbData = STRLEN(reply) + 1;
     data.lpData = reply;
 
+    serverSendEnc(target);
     if (SendMessage(target, WM_COPYDATA, (WPARAM)message_window,
 							     (LPARAM)(&data)))
 	return 0;
@@ -2797,6 +2859,7 @@ serverSendToVim(name, cmd, result, ptarg
     data.cbData = STRLEN(cmd) + 1;
     data.lpData = cmd;
 
+    serverSendEnc(target);
     if (SendMessage(target, WM_COPYDATA, (WPARAM)message_window,
 							(LPARAM)(&data)) == 0)
 	return -1;
@@ -2850,6 +2913,9 @@ static garray_T reply_list = {0, 0, size
 /* Flag which is used to wait for a reply */
 static int reply_received = 0;
 
+/*
+ * Store a reply.  "reply" must be allocated memory (or NULL).
+ */
     static int
 save_reply(HWND server, char_u *reply, int expr)
 {
@@ -2860,7 +2926,7 @@ save_reply(HWND server, char_u *reply, i
 
     rep = REPLY_ITEM(REPLY_COUNT);
     rep->server = server;
-    rep->reply = vim_strsave(reply);
+    rep->reply = reply;
     rep->expr_result = expr;
     if (rep->reply == NULL)
 	return FAIL;
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2189,12 +2189,7 @@ slash_adjust(p)
     {
 	if (*p == psepcN)
 	    *p = psepc;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p);
-	else
-#endif
-	    ++p;
+	mb_ptr_adv(p);
     }
 }
 #endif
@@ -4513,7 +4508,7 @@ RealWaitForChar(fd, msec, check_for_gpm)
 pstrcmp(a, b)
     const void *a, *b;
 {
-    return (pathcmp(*(char **)a, *(char **)b));
+    return (pathcmp(*(char **)a, *(char **)b, -1));
 }
 
 /*
@@ -4794,10 +4789,10 @@ mch_expand_wildcards(num_pat, pat, num_f
 		    if (((*file)[*num_file] = alloc(len + 2)) != NULL)
 		    {
 			STRCPY((*file)[*num_file], p);
-			if (!vim_ispathsep((*file)[*num_file][len - 1]))
+			if (!after_pathsep((*file)[*num_file] + len))
 			{
 			    (*file)[*num_file][len] = psepc;
-			    (*file)[*num_file][len + 1] = 0;
+			    (*file)[*num_file][len + 1] = NUL;
 			}
 		    }
 		}
@@ -5259,7 +5254,7 @@ save_patterns(num_pat, pat, num_file, fi
 mch_has_exp_wildcard(p)
     char_u  *p;
 {
-    for ( ; *p; ++p)
+    for ( ; *p; mb_ptr_adv(p))
     {
 #ifndef OS2
 	if (*p == '\\' && p[1] != NUL)
@@ -5278,10 +5273,6 @@ mch_has_exp_wildcard(p)
 #endif
 						, *p) != NULL)
 	    return TRUE;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
     return FALSE;
 }
@@ -5294,7 +5285,7 @@ mch_has_exp_wildcard(p)
 mch_has_wildcard(p)
     char_u  *p;
 {
-    for ( ; *p; ++p)
+    for ( ; *p; mb_ptr_adv(p))
     {
 #ifndef OS2
 	if (*p == '\\' && p[1] != NUL)
@@ -5318,10 +5309,6 @@ mch_has_wildcard(p)
 						, *p) != NULL
 		|| (*p == '~' && p[1] != NUL))
 	    return TRUE;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
     return FALSE;
 }
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -4345,9 +4345,9 @@ mch_rename(
      * filename.asc.txt by its SFN, filena~1.txt.  If we rename filena~1.txt
      * to filena~1.txt~ (i.e., we're making a backup while writing it), the
      * SFN for filena~1.txt~ will be filena~1.txt, by default, which will
-     * cause all sorts of problems later in buf_write.  So, we create an empty
-     * file called filena~1.txt and the system will have to find some other
-     * SFN for filena~1.txt~, such as filena~2.txt
+     * cause all sorts of problems later in buf_write().  So, we create an
+     * empty file called filena~1.txt and the system will have to find some
+     * other SFN for filena~1.txt~, such as filena~2.txt
      */
     if ((hf = CreateFile(pszOldFile, GENERIC_WRITE, 0, NULL, CREATE_NEW,
 		    FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
@@ -4538,15 +4538,12 @@ getout:
     int
 mch_open(char *name, int flags, int mode)
 {
+    /* _wopen() does not work with Borland C 5.5: creates a read-only file. */
+# ifndef __BORLANDC__
     WCHAR	*wn;
     int		f;
 
-    if (enc_codepage >= 0 && (int)GetACP() != enc_codepage
-# ifdef __BORLANDC__
-	    /* Wide functions of Borland C 5.5 do not work on Windows 98. */
-	    && g_PlatformId == VER_PLATFORM_WIN32_NT
-# endif
-       )
+    if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
     {
 	wn = enc_to_ucs2(name, NULL);
 	if (wn != NULL)
@@ -4560,6 +4557,7 @@ mch_open(char *name, int flags, int mode
 	     * the _wopen() fails for missing wide functions. */
 	}
     }
+# endif
 
     return open(name, flags, mode);
 }
--- a/src/proto/ex_cmds2.pro
+++ b/src/proto/ex_cmds2.pro
@@ -18,7 +18,6 @@ int can_abandon __ARGS((buf_T *buf, int 
 int check_changed_any __ARGS((int hidden));
 int check_fname __ARGS((void));
 int buf_write_all __ARGS((buf_T *buf, int forceit));
-char_u *do_one_arg __ARGS((char_u *str));
 void set_arglist __ARGS((char_u *str));
 void check_arg_idx __ARGS((win_T *win));
 void ex_args __ARGS((exarg_T *eap));
--- a/src/proto/main.pro
+++ b/src/proto/main.pro
@@ -9,6 +9,7 @@ void time_pop __ARGS((void *tp));
 void time_msg __ARGS((char *msg, void *tv_start));
 void server_to_input_buf __ARGS((char_u *str));
 char_u *eval_client_expr_to_string __ARGS((char_u *expr));
+char_u *serverConvert __ARGS((char_u *client_enc, char_u *data, char_u **tofree));
 int toF_TyA __ARGS((int c));
 int fkmap __ARGS((int c));
 void conv_to_pvim __ARGS((void));
--- a/src/proto/memline.pro
+++ b/src/proto/memline.pro
@@ -25,7 +25,7 @@ void ml_setmarked __ARGS((linenr_T lnum)
 linenr_T ml_firstmarked __ARGS((void));
 void ml_clearmarked __ARGS((void));
 char_u *get_file_in_dir __ARGS((char_u *fname, char_u *dname));
-void ml_setdirty __ARGS((buf_T *buf, int flag));
+void ml_setflags __ARGS((buf_T *buf));
 long ml_find_line_or_offset __ARGS((buf_T *buf, linenr_T line, long *offp));
 void goto_byte __ARGS((long cnt));
 /* vim: set ft=c : */
--- a/src/proto/misc1.pro
+++ b/src/proto/misc1.pro
@@ -55,6 +55,7 @@ void home_replace __ARGS((buf_T *buf, ch
 char_u *home_replace_save __ARGS((buf_T *buf, char_u *src));
 int fullpathcmp __ARGS((char_u *s1, char_u *s2, int checkname));
 char_u *gettail __ARGS((char_u *fname));
+char_u *gettail_sep __ARGS((char_u *fname));
 char_u *getnextcomp __ARGS((char_u *fname));
 char_u *get_past_head __ARGS((char_u *path));
 int vim_ispathsep __ARGS((int c));
--- a/src/proto/misc2.pro
+++ b/src/proto/misc2.pro
@@ -66,6 +66,8 @@ void set_fileformat __ARGS((int t, int o
 int default_fileformat __ARGS((void));
 int call_shell __ARGS((char_u *cmd, int opt));
 int get_real_state __ARGS((void));
+int after_pathsep __ARGS((char_u *b, char_u *p));
+int same_directory __ARGS((char_u *f1, char_u *f2));
 int vim_chdirfile __ARGS((char_u *fname));
 int illegal_slash __ARGS((char *name));
 char_u *parse_shape_opt __ARGS((int what));
@@ -86,7 +88,7 @@ char_u *find_file_in_path_option __ARGS(
 int vim_chdir __ARGS((char_u *new_dir));
 int get_user_name __ARGS((char_u *buf, int len));
 void sort_strings __ARGS((char_u **files, int count));
-int pathcmp __ARGS((const char *p, const char *q));
+int pathcmp __ARGS((const char *p, const char *q, int maxlen));
 char_u *parse_list_options __ARGS((char_u *option_str, option_table_T *table, int table_size));
 void msg_str __ARGS((char_u *s, char_u *arg));
 /* vim: set ft=c : */
--- a/src/proto/option.pro
+++ b/src/proto/option.pro
@@ -22,6 +22,7 @@ int get_option_value __ARGS((char_u *nam
 void set_option_value __ARGS((char_u *name, long number, char_u *string, int opt_flags));
 char_u *get_term_code __ARGS((char_u *tname));
 char_u *get_highlight_default __ARGS((void));
+char_u *get_encoding_default __ARGS((void));
 int makeset __ARGS((FILE *fd, int opt_flags, int local_only));
 int makefoldset __ARGS((FILE *fd));
 void clear_termoptions __ARGS((void));
--- a/src/proto/os_mswin.pro
+++ b/src/proto/os_mswin.pro
@@ -58,5 +58,5 @@ void serverForeground __ARGS((char_u *na
 char_u *serverGetReply __ARGS((HWND server, int *expr_res, int remove, int wait));
 void serverProcessPendingMessages __ARGS((void));
 char *charset_id2name __ARGS((int id));
-int get_logfont __ARGS((LOGFONT *lf, char_u *name, HDC printer_dc));
+int get_logfont __ARGS((LOGFONT *lf, char_u *name, HDC printer_dc, int verbose));
 /* vim: set ft=c : */
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -497,14 +497,7 @@ skip_anyof(p)
 	    {
 		++p;
 		if (*p != ']' && *p != NUL)
-		{
-#ifdef FEAT_MBYTE
-		    if (has_mbyte)
-			p += (*mb_ptr2len_check)(p);
-		    else
-#endif
-			++p;
-		}
+		    mb_ptr_adv(p);
 	    }
 	else if (*p == '\\'
 		&& (vim_strchr(REGEXP_INRANGE, p[1]) != NULL
@@ -755,7 +748,7 @@ skip_regexp(startp, dirc, magic, newp)
     else
 	mymagic = MAGIC_OFF;
 
-    for (; p[0] != NUL; ++p)
+    for (; p[0] != NUL; mb_ptr_adv(p))
     {
 	if (p[0] == dirc)	/* found end of regexp */
 	    break;
@@ -789,10 +782,6 @@ skip_regexp(startp, dirc, magic, newp)
 	    else if (*p == 'V')
 		mymagic = MAGIC_NONE;
 	}
-#ifdef FEAT_MBYTE
-	else if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
     return p;
 }
@@ -2935,7 +2924,8 @@ vim_regexec(rmp, line, col)
     return (vim_regexec_both(line, col) != 0);
 }
 
-#if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) || defined(PROTO)
+#if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
+	|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
 /*
  * Like vim_regexec(), but consider a "\n" in "line" to be a line break.
  */
@@ -3105,12 +3095,7 @@ vim_regexec_both(line, col)
 	{
 	    if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)
 		break;		/* Found it. */
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		s += (*mb_ptr2len_check)(s);
-	    else
-#endif
-		++s;
+	    mb_ptr_adv(s);
 	}
 	if (s == NULL)		/* Not present. */
 	    goto theend;
@@ -3338,21 +3323,8 @@ regtry(prog, col)
 }
 
 #ifdef FEAT_MBYTE
-/* multi-byte: advance reginput with a function */
-# define ADVANCE_REGINPUT() advance_reginput()
-
-static void advance_reginput __ARGS((void));
 static int reg_prev_class __ARGS((void));
 
-    static void
-advance_reginput()
-{
-    if (has_mbyte)
-	reginput += (*mb_ptr2len_check)(reginput);
-    else
-	++reginput;
-}
-
 /*
  * Get class of previous character.
  */
@@ -3365,10 +3337,8 @@ reg_prev_class()
     return -1;
 }
 
-#else
-/* No multi-byte: It's too simple to make a function for. */
-# define ADVANCE_REGINPUT() ++reginput
 #endif
+#define ADVANCE_REGINPUT() mb_ptr_adv(reginput)
 
 /*
  * The arguments from BRACE_LIMITS are stored here.  They are actually local
@@ -4270,13 +4240,7 @@ regmatch(scan)
 				return FALSE;
 			}
 			else
-			{
-			    --reginput;
-#ifdef FEAT_MBYTE
-			    if (has_mbyte)
-				reginput -= (*mb_head_off)(regline, reginput);
-#endif
-			}
+			    mb_ptr_back(regline, reginput);
 		    }
 		}
 		else
@@ -4466,12 +4430,6 @@ regmatch(scan)
     return FALSE;
 }
 
-#ifdef FEAT_MBYTE
-# define ADVANCE_P(x) if (has_mbyte) x += (*mb_ptr2len_check)(x); else ++x
-#else
-# define ADVANCE_P(x) ++x
-#endif
-
 /*
  * regrepeat - repeatedly match something simple, return how many.
  * Advances reginput (and reglnum) to just after the matched chars.
@@ -4500,7 +4458,7 @@ regrepeat(p, maxcount)
 	    while (*scan != NUL && count < maxcount)
 	    {
 		++count;
-		ADVANCE_P(scan);
+		mb_ptr_adv(scan);
 	    }
 	    if (!WITH_NL(OP(p)) || reglnum == reg_maxline || count == maxcount)
 		break;
@@ -4522,7 +4480,7 @@ regrepeat(p, maxcount)
 	{
 	    if (vim_isIDc(*scan) && (testval || !VIM_ISDIGIT(*scan)))
 	    {
-		ADVANCE_P(scan);
+		mb_ptr_adv(scan);
 	    }
 	    else if (*scan == NUL)
 	    {
@@ -4551,7 +4509,7 @@ regrepeat(p, maxcount)
 	{
 	    if (vim_iswordp(scan) && (testval || !VIM_ISDIGIT(*scan)))
 	    {
-		ADVANCE_P(scan);
+		mb_ptr_adv(scan);
 	    }
 	    else if (*scan == NUL)
 	    {
@@ -4580,7 +4538,7 @@ regrepeat(p, maxcount)
 	{
 	    if (vim_isfilec(*scan) && (testval || !VIM_ISDIGIT(*scan)))
 	    {
-		ADVANCE_P(scan);
+		mb_ptr_adv(scan);
 	    }
 	    else if (*scan == NUL)
 	    {
@@ -4618,7 +4576,7 @@ regrepeat(p, maxcount)
 	    }
 	    else if (ptr2cells(scan) == 1 && (testval || !VIM_ISDIGIT(*scan)))
 	    {
-		ADVANCE_P(scan);
+		mb_ptr_adv(scan);
 	    }
 	    else if (reg_line_lbr && *scan == '\n' && WITH_NL(OP(p)))
 		++scan;
@@ -5975,7 +5933,7 @@ vim_regsub_both(source, dest, copy, magi
 	    eval_result = eval_to_string(source + 2, NULL);
 	    if (eval_result != NULL)
 	    {
-		for (s = eval_result; *s != NUL; ++s)
+		for (s = eval_result; *s != NUL; mb_ptr_adv(s))
 		{
 		    /* Change NL to CR, so that it becomes a line break.
 		     * Skip over a backslashed character. */
@@ -5983,10 +5941,6 @@ vim_regsub_both(source, dest, copy, magi
 			*s = CAR;
 		    else if (*s == '\\' && s[1] != NUL)
 			++s;
-#ifdef FEAT_MBYTE
-		    if (has_mbyte)
-			s += (*mb_ptr2len_check)(s) - 1;
-#endif
 		}
 
 		dst += STRLEN(eval_result);
--- a/src/screen.c
+++ b/src/screen.c
@@ -2779,11 +2779,8 @@ win_line(wp, lnum, startrow, endrow)
 	    vcol += c;
 #ifdef FEAT_MBYTE
 	    prev_ptr = ptr;
-	    if (has_mbyte)
-		ptr += (*mb_ptr2len_check)(ptr);
-	    else
-#endif
-		++ptr;
+#endif
+	    mb_ptr_adv(ptr);
 	}
 
 #ifdef FEAT_VIRTUALEDIT
@@ -3640,7 +3637,9 @@ win_line(wp, lnum, startrow, endrow)
 			&& ((wp->w_p_list && lcs_eol > 0)
 			    || ((fromcol >= 0 || fromcol_prev >= 0)
 				&& tocol > vcol
+#ifdef FEAT_VISUAL
 				&& VIsual_mode != Ctrl_V
+#endif
 				&& (
 # ifdef FEAT_RIGHTLEFT
 				    wp->w_p_rl ? (col >= 0) :
@@ -4772,16 +4771,8 @@ status_match_len(xp, s)
 #endif
 		)
 	    ++s;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	{
-	    len += ptr2cells(s);
-	    s += (*mb_ptr2len_check)(s);
-	}
-	else
-#endif
-	    len += ptr2cells(s++);
-
+	len += ptr2cells(s++);
+	mb_ptr_adv(s);
     }
 
     return len;
@@ -4827,7 +4818,12 @@ win_redr_status_matches(xp, num_matches,
     if (matches == NULL)	/* interrupted completion? */
 	return;
 
-    buf = alloc((unsigned)Columns + 1);
+#ifdef FEAT_MBYTE
+    if (has_mbyte)
+	buf = alloc((unsigned)Columns * MB_MAXBYTES + 1);
+    else
+#endif
+	buf = alloc((unsigned)Columns + 1);
     if (buf == NULL)
 	return;
 
--- a/src/tag.c
+++ b/src/tag.c
@@ -3258,7 +3258,7 @@ simplify_filename(filename)
 		tail = p + 1;
 		if (p[1] != NUL)
 		    while (vim_ispathsep(*tail))
-			++tail;
+			mb_ptr_adv(tail);
 		else if (p > start)
 		    --p;		/* strip preceding path separator */
 		movetail(p, tail);
@@ -3270,7 +3270,7 @@ simplify_filename(filename)
 	    /* Skip to after ".." or "../" or "..///". */
 	    tail = p + 2;
 	    while (vim_ispathsep(*tail))
-		++tail;
+		mb_ptr_adv(tail);
 
 	    if (components > 0)		/* strip one preceding component */
 	    {
@@ -3296,8 +3296,8 @@ simplify_filename(filename)
 
 		    --p;
 		    /* Skip back to after previous '/'. */
-		    while (p > start && !vim_ispathsep(p[-1]))
-			--p;
+		    while (p > start && !after_pathsep(start, p))
+			mb_ptr_back(start, p);
 
 		    if (!do_strip)
 		    {
--- a/src/term.c
+++ b/src/term.c
@@ -3400,6 +3400,7 @@ cursor_off()
     }
 }
 
+#if defined(CURSOR_SHAPE) || defined(PROTO)
 /*
  * Set cursor shape to match Insert mode.
  */
@@ -3424,6 +3425,7 @@ term_cursor_shape()
 	showing_insert_mode = FALSE;
     }
 }
+#endif
 
 /*
  * Set scrolling region for window 'wp'.
--- a/src/ui.c
+++ b/src/ui.c
@@ -2952,12 +2952,7 @@ vcol2col(wp, lnum, vcol)
     {
 	++col;
 	count += win_lbr_chartabsize(wp, ptr, count, NULL);
-# ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    ptr += (*mb_ptr2len_check)(ptr);
-	else
-# endif
-	    ++ptr;
+	mb_ptr_adv(ptr);
     }
     return col;
 }
--- a/src/version.h
+++ b/src/version.h
@@ -36,5 +36,5 @@
 #define VIM_VERSION_NODOT	"vim70aa"
 #define VIM_VERSION_SHORT	"7.0aa"
 #define VIM_VERSION_MEDIUM	"7.0aa ALPHA"
-#define VIM_VERSION_LONG	"VIM - Vi IMproved 7.0aa ALPHA (2004 Dec 9)"
-#define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 7.0aa ALPHA (2004 Dec 9, compiled "
+#define VIM_VERSION_LONG	"VIM - Vi IMproved 7.0aa ALPHA (2004 Dec 17)"
+#define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 7.0aa ALPHA (2004 Dec 17, compiled "
--- a/src/vim.h
+++ b/src/vim.h
@@ -320,12 +320,12 @@
 # endif
 #endif
 #ifdef BACKSLASH_IN_FILENAME
-# define PATH_ESC_CHARS ((char_u *)" *?[{`%#")
+# define PATH_ESC_CHARS ((char_u *)" \t*?[{`%#")
 #else
 # ifdef COLON_AS_PATHSEP
-#  define PATH_ESC_CHARS ((char_u *)" *?[{`$%#/")
+#  define PATH_ESC_CHARS ((char_u *)" \t*?[{`$%#/")
 # else
-#  define PATH_ESC_CHARS ((char_u *)" *?[{`$\\%#'\"|")
+#  define PATH_ESC_CHARS ((char_u *)" \t*?[{`$\\%#'\"|")
 # endif
 #endif
 
--- a/src/vim.rc
+++ b/src/vim.rc
@@ -9,25 +9,13 @@
 //   Icon and version information for the Win32 version of Vim
 //   Must be in DOS format <CR><NL>!
 
-#ifdef __MINGW32__
-# include <windows.h>
-# ifndef VS_FFI_FILEFLAGSMASK
-#  define VS_FFI_FILEFLAGSMASK    0x0000003FL
-# endif
-# ifndef VOS__WINDOWS32
-#  define VOS__WINDOWS32	  0x00000004L
-# endif
-#else
-# include <winver.h>
-#endif
+#include <winver.h>
 #include "version.h"
 #include "gui_w32_rc.h"
-#if defined(__BORLANDC__) || defined(__CYGWIN32__)
+#if defined(__BORLANDC__) || defined(__CYGWIN32__) || defined(__MINGW32__)
 # include <winresrc.h>
 #else
-# ifndef __MINGW32__
-#  include <winres.h>
-# endif
+# include <winres.h>
 #endif
 
 //