]> git.pld-linux.org Git - packages/vim.git/blame - 7.2.076
- new
[packages/vim.git] / 7.2.076
CommitLineData
16604d53
ER
1To: vim-dev@vim.org
2Subject: Patch 7.2.076
3Fcc: outbox
4From: Bram Moolenaar <Bram@moolenaar.net>
5Mime-Version: 1.0
6Content-Type: text/plain; charset=ISO-8859-1
7Content-Transfer-Encoding: 8bit
8------------
9
10Patch 7.2.076
11Problem: rename(from, to) deletes the file if "from" and "to" are not equal
12 but still refer to the same file. E.g., on a FAT32 filesystem
13 under Unix.
14Solution: Go through another file name.
15Files: src/fileio.c
16
17
18*** ../vim-7.2.075/src/fileio.c Fri Nov 28 21:26:50 2008
19--- src/fileio.c Tue Dec 30 16:04:44 2008
20***************
21*** 6119,6124 ****
22--- 6119,6165 ----
23 if (mch_stat((char *)from, &st) < 0)
24 return -1;
25
26+ #ifdef UNIX
27+ {
28+ struct stat st_to;
29+ char tempname[MAXPATHL + 1];
30+
31+ /* It's possible for the source and destination to be the same file.
32+ * This happens when "from" and "to" differ in case and are on a FAT32
33+ * filesystem. In that case go through a temp file name. */
34+ if (mch_stat((char *)to, &st_to) >= 0
35+ && st.st_dev == st_to.st_dev
36+ && st.st_ino == st_to.st_ino)
37+ {
38+ /* Find a name that doesn't exist and is in the same directory.
39+ * Move "from" to "tempname" and then to "to". */
40+ if (STRLEN(from) >= MAXPATHL - 5)
41+ return -1;
42+ STRCPY(tempname, from);
43+ for (n = 123; n < 99999; ++n)
44+ {
45+ sprintf(gettail(tempname), "%d", n);
46+ if (mch_stat(tempname, &st_to) < 0)
47+ {
48+ if (mch_rename((char *)from, tempname) == 0)
49+ {
50+ if (mch_rename(tempname, (char *)to) == 0)
51+ return 0;
52+ /* Strange, the second step failed. Try moving the
53+ * file back and return failure. */
54+ mch_rename(tempname, (char *)from);
55+ return -1;
56+ }
57+ /* If it fails for one temp name it will most likely fail
58+ * for any temp name, give up. */
59+ return -1;
60+ }
61+ }
62+ return -1;
63+ }
64+ }
65+ #endif
66+
67 /*
68 * Delete the "to" file, this is required on some systems to make the
69 * mch_rename() work, on other systems it makes sure that we don't have
70*** ../vim-7.2.075/src/version.c Wed Dec 24 14:24:41 2008
71--- src/version.c Tue Dec 30 16:09:51 2008
72***************
73*** 678,679 ****
74--- 678,681 ----
75 { /* Add new patch number below this line */
76+ /**/
77+ 76,
78 /**/
79
80--
81FATAL ERROR! SYSTEM HALTED! - Press any key to continue doing nothing.
82
83 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
84/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
85\\\ download, build and distribute -- http://www.A-A-P.org ///
86 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
This page took 0.051615 seconds and 4 git commands to generate.