updated for version 7.0023
diff --git a/src/INSTALLpc.txt b/src/INSTALLpc.txt
index 1e7d329..0514639 100644
--- a/src/INSTALLpc.txt
+++ b/src/INSTALLpc.txt
@@ -29,7 +29,7 @@
 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 @@
 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)
diff --git a/src/Make_bc5.mak b/src/Make_bc5.mak
index 271820d..75b0f1d 100644
--- 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)
diff --git a/src/Make_cyg.mak b/src/Make_cyg.mak
index b869230..f2e4c5a 100644
--- 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 @@
 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 @@
 
 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 @@
 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 @@
 	$(CC) $(CFLAGS) -o uninstal.exe uninstal.c $(LIBS)
 
 $(OUTDIR):
-	mkdir $(OUTDIR)
+	mkdir -p $(OUTDIR)
 
 tags:
 	command /c ctags *.c $(INCL)
diff --git a/src/Make_ming.mak b/src/Make_ming.mak
index 2c8755c..4074a88 100644
--- a/src/Make_ming.mak
+++ b/src/Make_ming.mak
@@ -31,9 +31,7 @@
 # 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 @@
 #>>>>> 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 @@
 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 @@
 	$(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
diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
index 63a99f2..90dd888 100644
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -637,7 +637,7 @@
 $(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
diff --git a/src/Make_vms.mms b/src/Make_vms.mms
index f1ce93a..5379353 100644
--- 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 @@
 	-@ !
 .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
diff --git a/src/auto/configure b/src/auto/configure
index e30c2dd..ddab041 100755
--- a/src/auto/configure
+++ b/src/auto/configure
@@ -6932,15 +6932,36 @@
 if test -n "$with_tlib"; then
   echo "$ac_t""$with_tlib" 1>&6
   LIBS="$LIBS -l$with_tlib"
+  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 "$ac_t""automatic terminal library selection" 1>&6
+  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 @@
   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 @@
 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 @@
   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 @@
 #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 @@
       LIBS="$olibs"
     fi
   done
+  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 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_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 @@
 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 @@
 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 @@
 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
 
 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 @@
 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 @@
   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 @@
 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 @@
 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 @@
 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 @@
   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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 
 ; 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 @@
 
 
 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 @@
 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 @@
 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 @@
 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 @@
 }
 
 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 @@
 
 
 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 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 @@
 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 @@
 
 ; 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 @@
 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 @@
   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 @@
 	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 @@
 
 ; 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 @@
 
 
 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 @@
 	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 @@
 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 @@
 
 
 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 @@
 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 @@
   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 @@
 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 @@
 
 
 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 @@
 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 @@
 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 @@
 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 @@
   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 @@
 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 @@
 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 @@
   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 @@
 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 @@
   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 @@
   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 @@
 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 @@
 
 
 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_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 @@
 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 @@
 	
 ; 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 @@
 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 @@
 	
 ; 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 	}
 	    
 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 @@
 
 
 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 @@
 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 @@
 	
 ; 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 @@
 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 @@
 	
 ; 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 @@
 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 @@
 	
 ; 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 @@
 
 
 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 @@
   { 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 @@
 		  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 @@
 
 
 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 @@
   { 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 @@
   { 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 @@
   { 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 @@
     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 @@
 _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 @@
 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 @@
   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 @@
 _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 @@
 
 
 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 @@
 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 @@
 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 @@
   # 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 @@
 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 @@
   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 @@
             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 @@
 
 ; 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 @@
 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 @@
 ++_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 @@
 
 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 @@
   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 @@
 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 @@
       
 ; 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 @@
   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 @@
 		 
 ; 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 @@
 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 @@
       
 ; 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 @@
   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 @@
 		 
 ; 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 @@
 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 @@
      
 ; 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 @@
   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 @@
 	     
 ; 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 @@
 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 @@
 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"
diff --git a/src/buffer.c b/src/buffer.c
index f02c00d..19dcb59 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2976,22 +2976,13 @@
 		    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);
diff --git a/src/charset.c b/src/charset.c
index 0900d80..336eec6 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -819,12 +819,7 @@
     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 @@
     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 @@
 	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 @@
 		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 @@
 		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 @@
     int		    hex = 0;		/* default is decimal */
     int		    negative = FALSE;
     unsigned long   un = 0;
+    int		    n;
 
     if (ptr[0] == '-')
     {
@@ -1578,17 +1554,29 @@
 	++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 */
+		}
+	    }
 	}
     }
 
diff --git a/src/configure.in b/src/configure.in
index 070c41b..f2fdcd1 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -2356,8 +2356,12 @@
 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 @@
       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 @@
 	  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)
diff --git a/src/eval.c b/src/eval.c
index b5b4b79..e06fd16 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2571,7 +2571,7 @@
     /*
      * 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 @@
 	    if (*p == '<')
 		extra += 2;
 	}
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
 
     if (*p != '"')
@@ -4736,6 +4732,7 @@
 /*
  * "getfontname()" function
  */
+/*ARGSUSED*/
     static void
 f_getfontname(argvars, retvar)
     VAR		argvars;
@@ -6437,7 +6434,7 @@
 	    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 @@
 	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 @@
     plen = len2;
 
     l = 0;
-    if (vim_ispathsep(*s))
+    if (after_pathsep(pbuf2, s + 1))
     {
 	--s;
 	++slen;
@@ -10864,7 +10859,7 @@
     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 @@
      * 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 @@
 
     /* 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 @@
 	    else
 		sepcount --;
 	}
+    }
     if (hasTilde)
     {
 	--p;
@@ -11047,7 +11048,7 @@
 	}
 
 	/* 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 @@
 	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  */
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 7ed48b9..c78c643 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3599,12 +3599,7 @@
 	    }
 	    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 @@
     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)
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index b9919b6..6c919ff 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -1014,28 +1014,34 @@
  * 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 @@
 	}
 	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 @@
     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 @@
     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 @@
 		/* 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 @@
 			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;
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 3126c6a..a668c99 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3145,12 +3145,7 @@
 		    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 @@
 		}
 		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 @@
 	    else
 		++p;
 	}
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p);
-	else
-#endif
-	    ++p;
+	mb_ptr_adv(p);
     }
     return p;
 }
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 5c7686a..8c15302 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -494,6 +494,10 @@
 		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 @@
 	    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 @@
 	    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;
diff --git a/src/fileio.c b/src/fileio.c
index c37c96a..d33718d 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -370,13 +370,8 @@
      */
     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 @@
 		    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 @@
      * 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 @@
 	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 @@
 	    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 @@
      * 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 == '.'
diff --git a/src/fold.c b/src/fold.c
index bb268fb..b1c7031 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -2070,12 +2070,7 @@
 	}
 	else
 	{
-#ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		s += (*mb_ptr2len_check)(s);
-	    else
-#endif
-		++s;
+	    mb_ptr_adv(s);
 	}
     }
 }
diff --git a/src/getchar.c b/src/getchar.c
index dd52ac4..8328e19 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1514,7 +1514,7 @@
 		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. */
diff --git a/src/gui.c b/src/gui.c
index 8701d08..32ae3bf 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -3852,12 +3852,7 @@
 	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;
diff --git a/src/gui_gtk.c b/src/gui_gtk.c
index f4287ec..e5b4259 100644
--- a/src/gui_gtk.c
+++ b/src/gui_gtk.c
@@ -2014,7 +2014,7 @@
     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 @@
 	    }
 	    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 */
     }
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 34bbed5..ffd702c 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -4792,6 +4792,7 @@
     return font;
 }
 
+#if defined(FEAT_EVAL) || defined(PROTO)
 /*
  * Return the name of font "font" in allocated memory.
  */
@@ -4799,7 +4800,7 @@
     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 @@
 	    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)
 /*
diff --git a/src/gui_kde.cc b/src/gui_kde.cc
index 499db77..1ac8db9 100644
--- a/src/gui_kde.cc
+++ b/src/gui_kde.cc
@@ -40,8 +40,8 @@
 #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 @@
 /*
  * 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);
-	}
-	return QPixmap();
+	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();
+    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);
-		}
-#ifndef FEAT_KDETOOLBAR
-		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 (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);
+	}
+#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;
+    }
 #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()
-#if QT_VERSION>=300
-		       	&& !vmw->menuBar()->isTopLevelMenu()
-#endif
-			)
-		Y += vmw->menuBar()->height();
-#ifdef FEAT_TOOLBAR
-	if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
-			vmw->toolBar()->barPos()==KToolBar::Top)
-		Y += vmw->toolBar()->height();
+    int X = 0;
+    int Y = 0;
 
-	if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
-			vmw->toolBar()->barPos()==KToolBar::Left)
-		X += vmw->toolBar()->width();
+    if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
+#if QT_VERSION>=300
+	    && !vmw->menuBar()->isTopLevelMenu()
+#endif
+       )
+	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::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 @@
 /*
  * 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 @@
 /*
  * 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 @@
  * 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 @@
  * 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 @@
 		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( );
+    QString s;
+    if (!saving)
+	s = KFileDialog::getOpenFileName((char *)initdir, (char *)filt_glob,
+							  vmw, (char *)title);
+    else
+	s = KFileDialog::getSaveFileName();
 
-	if (filter)
-		vim_free(filter);
+    if (filter)
+	vim_free(filter);
 
-	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 (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;
+    return s2;
 }//}}}
 
 #endif	/* FEAT_BROWSE */
@@ -511,9 +549,9 @@
 /* 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 @@
 
 
 /* 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 @@
 
     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 @@
     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");
 }//}}}
diff --git a/src/gui_w32.c b/src/gui_w32.c
index 461dcef..cf07b26 100644
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -2562,7 +2562,7 @@
 	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)
diff --git a/src/gui_x11.c b/src/gui_x11.c
index 90e6fbd..03300e4 100644
--- a/src/gui_x11.c
+++ b/src/gui_x11.c
@@ -1992,6 +1992,7 @@
  * 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;
diff --git a/src/if_xcmdsrv.c b/src/if_xcmdsrv.c
index fe127a4..b24101f 100644
--- a/src/if_xcmdsrv.c
+++ b/src/if_xcmdsrv.c
@@ -103,10 +103,14 @@
  *
  * 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 @@
  *	"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 @@
      * 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 @@
 }
 
 /*
- * 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 @@
     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 @@
     int		result, actualFormat, code;
     long_u	numItems, bytesAfter;
     Atom	actualType;
+    char_u	*tofree;
 
     if (eventPtr != NULL)
     {
@@ -1180,6 +1205,7 @@
 	    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 @@
 	    resWindow = None;
 	    serial = (char_u *)"";
 	    script = NULL;
+	    enc = NULL;
 	    while (p - propInfo < numItems && *p == '-')
 	    {
 		switch (p[1])
@@ -1220,6 +1247,10 @@
 			if (p[2] == ' ')
 			    script = p + 3;
 			break;
+		    case 'E':
+			if (p[2] == ' ')
+			    enc = p + 3;
+			break;
 		}
 		while (*p != 0)
 		    p++;
@@ -1236,18 +1267,26 @@
 	    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 @@
 		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 @@
 	    gotSerial = 0;
 	    res = (char_u *)"";
 	    code = 0;
+	    enc = NULL;
 	    while ((p-propInfo) < numItems && *p == '-')
 	    {
 		switch (p[1])
@@ -1288,6 +1330,10 @@
 			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 @@
 
 		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 @@
 	    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 @@
 	    p += 2;
 	    gotWindow = 0;
 	    str = (char_u *)"";
+	    enc = NULL;
 	    while ((p-propInfo) < numItems && *p == '-')
 	    {
 		switch (p[1])
@@ -1346,6 +1399,10 @@
 			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 @@
 
 	    if (!gotWindow)
 		continue;
+	    str = serverConvert(enc, str, &tofree);
 	    if ((r = ServerReplyFind(win, SROP_Add)) != NULL)
 	    {
 		ga_concat(&(r->strings), str);
@@ -1370,7 +1428,7 @@
 	    sprintf((char *)winstr, "0x%x", (unsigned int)win);
 	    apply_autocmds(EVENT_REMOTEREPLY, winstr, str, TRUE, curbuf);
 #endif
-
+	    vim_free(tofree);
 	}
 	else
 	{
diff --git a/src/macros.h b/src/macros.h
index 43bddba..9596796 100644
--- 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
diff --git a/src/main.c b/src/main.c
index 5791bb6..1335970 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2228,11 +2228,12 @@
 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 @@
     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
diff --git a/src/mark.c b/src/mark.c
index ea941e5..6a149bf 100644
--- a/src/mark.c
+++ b/src/mark.c
@@ -630,15 +630,11 @@
 	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;
diff --git a/src/mbyte.c b/src/mbyte.c
index 0710966..e739a5b 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -680,7 +680,7 @@
     /* 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 @@
     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 @@
     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)
diff --git a/src/memline.c b/src/memline.c
index a3bd9d7..13f35c2 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -125,9 +125,10 @@
 #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 @@
     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 @@
 #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 @@
 
     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 @@
 #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 @@
 	     */
 	    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_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 @@
     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 @@
 	    /* 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 @@
 	    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 @@
     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 @@
 	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_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 @@
 	    {
 #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 @@
     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 @@
 	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 @@
 
 #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 @@
 		    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 @@
     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 @@
 	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;
diff --git a/src/menu.c b/src/menu.c
index a64745b..aeb3c61 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -146,12 +146,7 @@
 	{
 	    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 @@
 
 		    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 @@
 {
     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 @@
 	    if (*p == NUL)
 		break;
 	}
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;	/* skip multibyte char */
-#endif
     }
     if (*p)
 	*p++ = NUL;
diff --git a/src/message.c b/src/message.c
index caf7ac0..6a23864 100644
--- a/src/message.c
+++ b/src/message.c
@@ -2897,12 +2897,7 @@
 	    }
 
 	    /* 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 @@
 	    *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 @@
 	    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;
diff --git a/src/misc1.c b/src/misc1.c
index 4dc5a41..891fbb5 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -1006,8 +1006,7 @@
 
 			    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 @@
     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 @@
 	    }
 	}
 	curbuf->b_changed = TRUE;
-	ml_setdirty(curbuf, TRUE);
+	ml_setflags(curbuf);
 #ifdef FEAT_WINDOWS
 	check_status(curbuf);
 #endif
@@ -2788,7 +2782,7 @@
     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 @@
 	    {
 		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 @@
 #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 @@
 
     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 @@
     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 @@
     {
 	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 @@
     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 @@
 
     return retval;
 }
-#endif
 
 /*
  * return TRUE if 'c' is a path separator.
@@ -4299,7 +4305,7 @@
 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 @@
     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 _cdecl
 pstrcmp(const void *a, const void *b)
 {
-    return (pathcmp(*(char **)a, *(char **)b));
+    return (pathcmp(*(char **)a, *(char **)b, -1));
 }
 
 # ifndef WIN3264
diff --git a/src/misc2.c b/src/misc2.c
index 47ff4a4..7a85026 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -200,12 +200,7 @@
 	    /* 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 @@
     {
 	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 @@
     {
 	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 @@
     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 @@
 vim_chdirfile(fname)
     char_u	*fname;
 {
-    char_u	temp_string[MAXPATHL];
-    char_u	*p;
-    char_u	*t;
+    char_u	dir[MAXPATHL];
 
-    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;
+    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 @@
 #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 @@
     }
 
     /* 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 */
diff --git a/src/ops.c b/src/ops.c
index 2980f93..dec5d07 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -2488,7 +2488,7 @@
 
 #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 @@
 #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 @@
 	}
 #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 @@
 	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;
diff --git a/src/option.c b/src/option.c
index d3e47eb..6b59683 100644
--- a/src/option.c
+++ b/src/option.c
@@ -4722,7 +4722,7 @@
      * 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 @@
 		/* No comma allowed in 'fileencoding'; catches confusing it
 		 * with 'fileencodings'. */
 		errmsg = e_invarg;
-# ifdef FEAT_TITLE
 	    else
+	    {
+# ifdef FEAT_TITLE
 		/* 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 @@
 #ifdef FEAT_TITLE
 	    need_maketitle = TRUE;
 #endif
+	    /* update flag in swap file */
+	    ml_setflags(curbuf);
 	}
     }
 
@@ -5275,12 +5281,7 @@
 	{
 	    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 @@
     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 @@
 #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 @@
 
     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 @@
 #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_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 @@
 	    }
 	    else
 	    {
-#ifdef FEAT_MBYTE
-		p2 += (*mb_ptr2len_check)(p2);
-#else
-		++p2;
-#endif
+		mb_ptr_adv(p2);
 		if (*p == ';')
 		{
 		    p = p2;
diff --git a/src/option.h b/src/option.h
index 566a561..8ef8536 100644
--- 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<>[],~"
diff --git a/src/os_amiga.c b/src/os_amiga.c
index f462ccc..772bdcf 100644
--- a/src/os_amiga.c
+++ b/src/os_amiga.c
@@ -1501,7 +1501,7 @@
     char *s = *(char **)a;
     char *t = *(char **)b;
 
-    return pathcmp(s, t);
+    return pathcmp(s, t, -1);
 }
 
 /*
@@ -1511,16 +1511,12 @@
 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_wildcard(p)
     char_u *p;
 {
-    for ( ; *p; ++p)
+    for ( ; *p; mb_ptr_adv(p))
     {
 	if (*p == '\\' && p[1] != NUL)
 	    ++p;
@@ -1543,10 +1539,6 @@
 						, *p) != NULL
 		    || (*p == '~' && p[1] != NUL))
 		return TRUE;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
     return FALSE;
 }
diff --git a/src/os_mac.c b/src/os_mac.c
index d1eb03d..cc656f0 100644
--- a/src/os_mac.c
+++ b/src/os_mac.c
@@ -299,7 +299,7 @@
 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 @@
     {
 	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_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;
 }
diff --git a/src/os_msdos.c b/src/os_msdos.c
index 1056fe0..41d5877 100644
--- a/src/os_msdos.c
+++ b/src/os_msdos.c
@@ -1700,12 +1700,7 @@
 	{
 	    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 @@
     {
 	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 @@
     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 @@
     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 @@
 						, *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 @@
 	 * 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
 	 */
diff --git a/src/os_mswin.c b/src/os_mswin.c
index 409803f..cea1054 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -364,9 +364,9 @@
 
 
 /*
- * 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 @@
 	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 @@
     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 @@
 	{
 	    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 @@
     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 @@
     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 @@
     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 @@
 						, *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 @@
 #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 @@
     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 @@
     {
 	/* 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 @@
 	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 @@
 	    /* 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 @@
 	    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 @@
 	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 @@
     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 @@
     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 @@
 /* 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 @@
 
     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;
diff --git a/src/os_unix.c b/src/os_unix.c
index e808d6e..0dbc1cb 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2189,12 +2189,7 @@
     {
 	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 @@
 pstrcmp(a, b)
     const void *a, *b;
 {
-    return (pathcmp(*(char **)a, *(char **)b));
+    return (pathcmp(*(char **)a, *(char **)b, -1));
 }
 
 /*
@@ -4794,10 +4789,10 @@
 		    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 @@
 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 @@
 #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_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 @@
 						, *p) != NULL
 		|| (*p == '~' && p[1] != NUL))
 	    return TRUE;
-#ifdef FEAT_MBYTE
-	if (has_mbyte)
-	    p += (*mb_ptr2len_check)(p) - 1;
-#endif
     }
     return FALSE;
 }
diff --git a/src/os_win32.c b/src/os_win32.c
index 23a31f3..40544b2 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -4345,9 +4345,9 @@
      * 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 @@
     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 @@
 	     * the _wopen() fails for missing wide functions. */
 	}
     }
+# endif
 
     return open(name, flags, mode);
 }
diff --git a/src/proto/ex_cmds2.pro b/src/proto/ex_cmds2.pro
index adf2d8f..c66c702 100644
--- a/src/proto/ex_cmds2.pro
+++ b/src/proto/ex_cmds2.pro
@@ -18,7 +18,6 @@
 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));
diff --git a/src/proto/main.pro b/src/proto/main.pro
index 7e965fb..bd75174 100644
--- a/src/proto/main.pro
+++ b/src/proto/main.pro
@@ -9,6 +9,7 @@
 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));
diff --git a/src/proto/memline.pro b/src/proto/memline.pro
index 36d1086..4e0382a 100644
--- a/src/proto/memline.pro
+++ b/src/proto/memline.pro
@@ -25,7 +25,7 @@
 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 : */
diff --git a/src/proto/misc1.pro b/src/proto/misc1.pro
index feb968a..61b975f 100644
--- a/src/proto/misc1.pro
+++ b/src/proto/misc1.pro
@@ -55,6 +55,7 @@
 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));
diff --git a/src/proto/misc2.pro b/src/proto/misc2.pro
index 6419740..eb042f0 100644
--- a/src/proto/misc2.pro
+++ b/src/proto/misc2.pro
@@ -66,6 +66,8 @@
 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 @@
 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 : */
diff --git a/src/proto/option.pro b/src/proto/option.pro
index c0a567b..c0c5504 100644
--- a/src/proto/option.pro
+++ b/src/proto/option.pro
@@ -22,6 +22,7 @@
 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));
diff --git a/src/proto/os_mswin.pro b/src/proto/os_mswin.pro
index c9e495d..de96a04 100644
--- a/src/proto/os_mswin.pro
+++ b/src/proto/os_mswin.pro
@@ -58,5 +58,5 @@
 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 : */
diff --git a/src/regexp.c b/src/regexp.c
index 23e31af..2e82854 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -497,14 +497,7 @@
 	    {
 		++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 @@
     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 @@
 	    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 @@
     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 @@
 	{
 	    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 @@
 }
 
 #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 @@
     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 @@
 				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 @@
     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 @@
 	    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 @@
 	{
 	    if (vim_isIDc(*scan) && (testval || !VIM_ISDIGIT(*scan)))
 	    {
-		ADVANCE_P(scan);
+		mb_ptr_adv(scan);
 	    }
 	    else if (*scan == NUL)
 	    {
@@ -4551,7 +4509,7 @@
 	{
 	    if (vim_iswordp(scan) && (testval || !VIM_ISDIGIT(*scan)))
 	    {
-		ADVANCE_P(scan);
+		mb_ptr_adv(scan);
 	    }
 	    else if (*scan == NUL)
 	    {
@@ -4580,7 +4538,7 @@
 	{
 	    if (vim_isfilec(*scan) && (testval || !VIM_ISDIGIT(*scan)))
 	    {
-		ADVANCE_P(scan);
+		mb_ptr_adv(scan);
 	    }
 	    else if (*scan == NUL)
 	    {
@@ -4618,7 +4576,7 @@
 	    }
 	    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 @@
 	    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 @@
 			*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);
diff --git a/src/screen.c b/src/screen.c
index 88b17d4..abd9be7 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -2779,11 +2779,8 @@
 	    vcol += c;
 #ifdef FEAT_MBYTE
 	    prev_ptr = ptr;
-	    if (has_mbyte)
-		ptr += (*mb_ptr2len_check)(ptr);
-	    else
 #endif
-		++ptr;
+	    mb_ptr_adv(ptr);
 	}
 
 #ifdef FEAT_VIRTUALEDIT
@@ -3640,7 +3637,9 @@
 			&& ((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 @@
 #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 @@
     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;
 
diff --git a/src/tag.c b/src/tag.c
index b83eaf4..442717f 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -3258,7 +3258,7 @@
 		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 @@
 	    /* 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 @@
 
 		    --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)
 		    {
diff --git a/src/term.c b/src/term.c
index a83f506..8144fad 100644
--- a/src/term.c
+++ b/src/term.c
@@ -3400,6 +3400,7 @@
     }
 }
 
+#if defined(CURSOR_SHAPE) || defined(PROTO)
 /*
  * Set cursor shape to match Insert mode.
  */
@@ -3424,6 +3425,7 @@
 	showing_insert_mode = FALSE;
     }
 }
+#endif
 
 /*
  * Set scrolling region for window 'wp'.
diff --git a/src/ui.c b/src/ui.c
index ac88dc6..dd410c5 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -2952,12 +2952,7 @@
     {
 	++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;
 }
diff --git a/src/version.h b/src/version.h
index e8f1078..7596af6 100644
--- 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 "
diff --git a/src/vim.h b/src/vim.h
index 798d80d..f8ee4e2 100644
--- 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
 
diff --git a/src/vim.rc b/src/vim.rc
index 27d35a9..4ceb638 100644
--- 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
 
 //