To: vim-dev@vim.org Subject: Patch 5.5.060 (extra) Fcc: outbox From: Bram Moolenaar ------------ Patch 5.5.060 (extra) Problem: Dos 32 bit: When a directory in 'backupdir' doesn't exist, ":w" causes the file to be renamed to "axlqwqhy.ba~". (Matzdorf) Solution: The code to work around a LFN bug in Windows 95 doesn't handle a non-existing target name correctly. When renaming fails, make sure the file has its original name. Also do this for the Win32 version, although it's unlikely that it runs into this problem. Files: src/os_msdos.c, src/os_win32.c *** ../vim-5.5.59/src/os_msdos.c Wed Sep 22 10:06:26 1999 --- src/os_msdos.c Tue Dec 7 10:27:47 1999 *************** *** 1970,1975 **** --- 1970,1980 ---- retval = rename(TempFile, NewFile); close(fd); mch_remove((char_u *)OldFile); + + /* If renaming to NewFile failed, rename TempFile back to OldFile, so + * that it looks like nothing happened. */ + if (retval) + rename(TempFile, OldFile); } vim_free(TempFile); *** ../vim-5.5.59/src/os_win32.c Wed Sep 22 10:06:28 1999 --- src/os_win32.c Tue Dec 7 10:38:47 1999 *************** *** 3835,3841 **** --- 3835,3847 ---- /* rename the temp file to the new file */ if (!MoveFile(szTempFile, pszNewFile)) + { + /* Renaming failed. Rename the file back to its old name, so that it + * looks like nothing happened. */ + (void)MoveFile(szTempFile, pszOldFile); + return -7; + } /* Seems to be left around on Novell filesystems */ DeleteFile(szTempFile); *** ../vim-5.5.59/src/version.c Mon Dec 6 19:42:48 1999 --- src/version.c Tue Dec 7 10:44:01 1999 *************** *** 420,420 **** --- 420,421 ---- { /* Add new patch number below this line */ + 60, -- ARTHUR: Right! Knights! Forward! ARTHUR leads a charge toward the castle. Various shots of them battling on, despite being hit by a variety of farm animals. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /