updated for version 7.1-282
diff --git a/src/GvimExt/Makefile b/src/GvimExt/Makefile
index 69e4270..2488025 100644
--- a/src/GvimExt/Makefile
+++ b/src/GvimExt/Makefile
@@ -24,7 +24,7 @@
 gvimext.obj: gvimext.h
 
 .cpp.obj:
-    $(cc) $(cflags) -DFEAT_GETTEXT $(cvarsdll) $*.cpp
+    $(cc) $(cflags) -DFEAT_GETTEXT $(cvarsmt) $*.cpp
 
 gvimext.res: gvimext.rc
     $(rc) $(rcflags) $(rcvars)  gvimext.rc
diff --git a/src/INSTALLpc.txt b/src/INSTALLpc.txt
index a13dce0..f256ac1 100644
--- a/src/INSTALLpc.txt
+++ b/src/INSTALLpc.txt
@@ -82,9 +82,8 @@
 |ms-platform-sdk|, |dotnet-1.1-redist|, |dotnet-1.1-sdk|,
 and |windbg-download|.
 
-It's easier to download Visual C++ 2005 Express Edition, |msvc-2005-express|.
-The advantage of the VC 2003 Toolkit is that it will be freely available
-long after VC 2005 Express Edition stops being free in November 2006.
+It's easier to download Visual C++ 2008 Express Edition, |msvc-2008-express|,
+which is freely available in perpetuity.
 
 The free Code::Blocks IDE works with the VC2003 Toolkit, as described at
     http://wiki.codeblocks.org/index.php?title=Integrating_Microsoft_Visual_Toolkit_2003_with_Code::Blocks_IDE
@@ -152,6 +151,14 @@
     http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/default.aspx
 
 
+Visual C++ 2008 Express Edition       *msvc-2008-express*
+-------------------------------
+
+Visual C++ 2008 Express Edition can be downloaded for free from:
+    http://msdn2.microsoft.com/en-us/express/default.aspx
+This includes the IDE and the debugger. You can build Vim with Make_mvc.mak.
+
+
 2. MinGW
 ========
 
diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
index b407fbe..34c87a5 100644
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -1,6 +1,7 @@
 # Makefile for Vim on Win32 (Windows NT/2000/XP/2003 and Windows 95/98/Me)
 # and Win64, using the Microsoft Visual C++ compilers. Known to work with
-# VC5, VC6 (VS98), VC7.0 (VS2002), VC7.1 (VS2003), and VC8 (VS2005).
+# VC5, VC6 (VS98), VC7.0 (VS2002), VC7.1 (VS2003), VC8 (VS2005),
+# and VC9 (VS2008).
 #
 # To build using other Windows compilers, see INSTALLpc.txt
 #
@@ -285,7 +286,8 @@
 # need shell32.lib for ExtractIcon()
 # gdi32.lib and comdlg32.lib for printing support
 # ole32.lib and uuid.lib are needed for FEAT_SHORTCUT
-CON_LIB = advapi32.lib shell32.lib gdi32.lib comdlg32.lib ole32.lib uuid.lib
+CON_LIB = oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib \
+          comdlg32.lib ole32.lib uuid.lib /machine:$(CPU) /nodefaultlib
 !if "$(DELAYLOAD)" == "yes"
 CON_LIB = $(CON_LIB) /DELAYLOAD:comdlg32.dll /DELAYLOAD:ole32.dll DelayImp.lib
 !endif
@@ -331,6 +333,7 @@
 !endif
 !if "$(_NMAKE_VER)" == "6.00.8168.0"
 MSVCVER = 6.0
+CPU = ix86
 !endif
 !if "$(_NMAKE_VER)" == "7.00.9466"
 MSVCVER = 7.0
@@ -344,6 +347,9 @@
 !if "$(_NMAKE_VER)" == "8.00.50727.762"
 MSVCVER = 8.0
 !endif
+!if "$(_NMAKE_VER)" == "9.00.20706.01"
+MSVCVER = 9.0
+!endif
 !endif
 
 # Abort bulding VIM if version of VC is unrecognised.
@@ -352,13 +358,13 @@
 !message Cannot determine Visual C version being used.  If you are using the
 !message Windows SDK then you must have the environment variable MSVCVER set to
 !message your version of the VC compiler.  If you are not using the Express
-!message version of Visual C you van either set MSVCVER or update this makefile
-!message to handle the new value for _NMAKE_VER.
+!message version of Visual C, you can either set MSVCVER or update this makefile
+!message to handle the new value for _NMAKE_VER, "$(_NMAKE_VER)".
 !error Make aborted.
 !endif
 
 # Convert processor ID to MVC-compatible number
-!if "$(MSVCVER)" != "8.0"
+!if ("$(MSVCVER)" != "8.0") && ("$(MSVCVER)" != "9.0")
 !if "$(CPUNR)" == "i386"
 CPUARG = /G3
 !elseif "$(CPUNR)" == "i486"
@@ -373,7 +379,7 @@
 CPUARG =
 !endif
 !else
-# VC8 only allows specifying SSE architecture
+# VC8/9 only allows specifying SSE architecture
 !if "$(CPUNR)" == "pentium4"
 CPUARG = /arch:SSE2
 !endif
@@ -391,7 +397,7 @@
 !else # MAXSPEED
 OPTFLAG = /Ox
 !endif
-!if "$(MSVCVER)" == "8.0"
+!if ("$(MSVCVER)" == "8.0") || ("$(MSVCVER)" == "9.0")
 # Use link time code generation if not worried about size
 !if "$(OPTIMIZE)" != "SPACE"
 OPTFLAG = $(OPTFLAG) /GL
@@ -404,11 +410,11 @@
 LIBC = msvcrt.lib
 ! else
 LIBC = libcmt.lib
-CFLAGS = $(CFLAGS) /MT
+CFLAGS = $(CFLAGS) /Zl /MT
 ! endif
 !else  # DEBUG
 VIM = vimd
-! if "$(CPU)" == "i386"
+! if ("$(CPU)" == "i386") || ("$(CPU)" == "ix86")
 DEBUGINFO = /ZI
 ! endif
 CFLAGS = $(CFLAGS) -D_DEBUG -DDEBUG /Od
@@ -424,7 +430,7 @@
 LIBC = $(LIBC) msvcrtd.lib
 ! else
 LIBC = $(LIBC) libcmtd.lib
-CFLAGS = $(CFLAGS) /MTd
+CFLAGS = $(CFLAGS) /Zl /MTd
 ! endif
 !endif # DEBUG
 
@@ -534,7 +540,7 @@
 	$(OUTDIR)\gui_w32.obj \
 	$(OUTDIR)\os_w32exe.obj
 GUI_LIB = \
-	oldnames.lib kernel32.lib gdi32.lib version.lib $(IME_LIB) \
+	gdi32.lib version.lib $(IME_LIB) \
 	winspool.lib comctl32.lib advapi32.lib shell32.lib \
 	/machine:$(CPU) /nodefaultlib
 !else
@@ -757,7 +763,7 @@
 
 # Report link time code generation progress if used. 
 !ifdef NODEBUG
-!if "$(MSVCVER)" == "8.0"
+!if ("$(MSVCVER)" == "8.0") || ("$(MSVCVER)" == "9.0")
 !if "$(OPTIMIZE)" != "SPACE"
 LINKARGS1 = $(LINKARGS1) /LTCG:STATUS
 !endif
diff --git a/src/dosinst.c b/src/dosinst.c
index 9226b63..c4ed7f6 100644
--- a/src/dosinst.c
+++ b/src/dosinst.c
@@ -1365,7 +1365,7 @@
 
 	    printf("Creating \"Edit with Vim\" popup menu entry\n");
 
-	    fprintf(fd, "HKEY_CLASSES_ROOT\\CLSID\\%s\n", vim_ext_clsid);
+	    fprintf(fd, "[HKEY_CLASSES_ROOT\\CLSID\\%s]\n", vim_ext_clsid);
 	    fprintf(fd, "@=\"%s\"\n", vim_ext_name);
 	    fprintf(fd, "[HKEY_CLASSES_ROOT\\CLSID\\%s\\InProcServer32]\n",
 							       vim_ext_clsid);
diff --git a/src/if_ole.cpp b/src/if_ole.cpp
index fad2097..b2057f9 100644
--- a/src/if_ole.cpp
+++ b/src/if_ole.cpp
@@ -34,6 +34,12 @@
 extern HWND vim_parent_hwnd;
 }
 
+#if _MSC_VER < 1300
+/* Work around old versions of basetsd.h which wrongly declares
+ * UINT_PTR as unsigned long */
+# define UINT_PTR UINT
+#endif
+
 #include "if_ole.h"	// Interface definitions
 #include "iid_ole.c"	// UUID definitions (compile here)
 
@@ -107,7 +113,7 @@
     STDMETHOD(SendKeys)(BSTR keys);
     STDMETHOD(Eval)(BSTR expr, BSTR *result);
     STDMETHOD(SetForeground)(void);
-    STDMETHOD(GetHwnd)(UINT *result);
+    STDMETHOD(GetHwnd)(UINT_PTR *result);
 
 private:
     // Constructor is private - create using CVim::Create()
@@ -288,9 +294,9 @@
 }
 
 STDMETHODIMP
-CVim::GetHwnd(UINT *result)
+CVim::GetHwnd(UINT_PTR *result)
 {
-    *result = (UINT) s_hwnd;
+    *result = (UINT_PTR)s_hwnd;
     return S_OK;
 }
 
diff --git a/src/if_ole.h b/src/if_ole.h
index 30191b8..0b48b92 100644
--- a/src/if_ole.h
+++ b/src/if_ole.h
@@ -79,7 +79,7 @@
 	virtual HRESULT STDMETHODCALLTYPE SetForeground( void) = 0;
 
 	virtual HRESULT STDMETHODCALLTYPE GetHwnd(
-	    /* [retval][out] */ UINT __RPC_FAR *result) = 0;
+	    /* [retval][out] */ UINT_PTR __RPC_FAR *result) = 0;
 
     };
 
@@ -143,7 +143,7 @@
 
 	HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetHwnd )(
 	    IVim __RPC_FAR * This,
-	    /* [retval][out] */ UINT __RPC_FAR *result);
+	    /* [retval][out] */ UINT_PTR __RPC_FAR *result);
 
 	END_INTERFACE
     } IVimVtbl;
@@ -236,7 +236,7 @@
 
 HRESULT STDMETHODCALLTYPE IVim_GetHwnd_Proxy(
     IVim __RPC_FAR * This,
-    /* [retval][out] */ UINT __RPC_FAR *result);
+    /* [retval][out] */ UINT_PTR __RPC_FAR *result);
 
 
 void __RPC_STUB IVim_GetHwnd_Stub(
diff --git a/src/if_ole.idl b/src/if_ole.idl
index 83cde3a..3629faf 100644
--- a/src/if_ole.idl
+++ b/src/if_ole.idl
@@ -20,7 +20,7 @@
 	HRESULT SendKeys([in]BSTR keys);
 	HRESULT Eval([in]BSTR expr, [out, retval]BSTR* result);
 	HRESULT SetForeground(void);
-	HRESULT GetHwnd([out, retval]UINT* result);
+	HRESULT GetHwnd([out, retval]UINT_PTR* result);
 };
 
 // Component and type library definitions
diff --git a/src/os_win32.c b/src/os_win32.c
index b0502b2..54837ec 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -2856,7 +2856,7 @@
 	windgoto((int)Rows - 1, 0);
 	g_fForceExit = TRUE;
 
-	sprintf((char *)IObuff, _("Vim: Caught %s event\n"),
+	vim_snprintf((char *)IObuff, IOSIZE, _("Vim: Caught %s event\n"),
 		(dwCtrlType == CTRL_CLOSE_EVENT
 		     ? _("close")
 		     : dwCtrlType == CTRL_LOGOFF_EVENT
@@ -3282,12 +3282,13 @@
     {
 	/* we use "command" or "cmd" to start the shell; slow but easy */
 	char_u *newcmd;
-
-	newcmd = lalloc((long_u) (
+	long_u cmdlen =  (
 #ifdef FEAT_GUI_W32
 		STRLEN(vimrun_path) +
 #endif
-		STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10), TRUE);
+		STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10);
+
+	newcmd = lalloc(cmdlen, TRUE);
 	if (newcmd != NULL)
 	{
 	    char_u *cmdbase = (*cmd == '"' ? cmd + 1 : cmd);
@@ -3373,14 +3374,15 @@
 		if (!s_dont_use_vimrun)
 		    /* Use vimrun to execute the command.  It opens a console
 		     * window, which can be closed without killing Vim. */
-		    sprintf((char *)newcmd, "%s%s%s %s %s",
+                    vim_snprintf((char *)newcmd, cmdlen, "%s%s%s %s %s",
 			    vimrun_path,
 			    (msg_silent != 0 || (options & SHELL_DOOUT))
 								 ? "-s " : "",
 			    p_sh, p_shcf, cmd);
 		else
 #endif
-		    sprintf((char *)newcmd, "%s %s %s", p_sh, p_shcf, cmd);
+                    vim_snprintf((char *)newcmd, cmdlen, "%s %s %s",
+							   p_sh, p_shcf, cmd);
 		x = mch_system((char *)newcmd, options);
 	    }
 	    vim_free(newcmd);
@@ -4664,12 +4666,29 @@
 # endif
        )
     {
+# if defined(DEBUG) && _MSC_VER > 1200
+	/* Work around an annoying assertion in the Microsoft debug CRT
+	 * when mode's text/binary setting doesn't match _get_fmode(). */
+	char newMode = mode[strlen(mode) - 1];
+	int oldMode = 0;
+
+	_get_fmode(&oldMode);
+	if (newMode == 't')
+	    _set_fmode(_O_TEXT);
+	else if (newMode == 'b')
+	    _set_fmode(_O_BINARY);
+# endif
 	wn = enc_to_ucs2(name, NULL);
 	wm = enc_to_ucs2(mode, NULL);
 	if (wn != NULL && wm != NULL)
 	    f = _wfopen(wn, wm);
 	vim_free(wn);
 	vim_free(wm);
+
+# if defined(DEBUG) && _MSC_VER > 1200
+	_set_fmode(oldMode);
+# endif
+
 	if (f != NULL)
 	    return f;
 	/* Retry with non-wide function (for Windows 98). Can't use
diff --git a/src/version.c b/src/version.c
index 29951a8..9e73bb9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -667,6 +667,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    282,
+/**/
     281,
 /**/
     280,