4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
10 Patch 7.2.077 (after 7.2.076)
11 Problem: rename(from, to) doesn't work if "from" and "to" differ only in
12 case on a system that ignores case in file names.
13 Solution: Go through another file name.
17 *** ../vim-7.2.076/src/fileio.c Tue Dec 30 16:15:16 2008
18 --- src/fileio.c Wed Dec 31 14:59:59 2008
22 vim_acl_T acl; /* ACL from original file */
26 ! * When the names are identical, there is nothing to do.
28 if (fnamecmp(from, to) == 0)
32 * Fail if the "from" file doesn't exist. Avoids that "to" is deleted.
35 vim_acl_T acl; /* ACL from original file */
37 + #if defined(UNIX) || defined(CASE_INSENSITIVE_FILENAME)
38 + int use_tmp_file = FALSE;
42 ! * When the names are identical, there is nothing to do. When they refer
43 ! * to the same file (ignoring case and slash/backslash differences) but
44 ! * the file name differs we need to go through a temp file.
46 if (fnamecmp(from, to) == 0)
48 ! #ifdef CASE_INSENSITIVE_FILENAME
49 ! if (STRCMP(gettail(from), gettail(to)) != 0)
50 ! use_tmp_file = TRUE;
57 * Fail if the "from" file doesn't exist. Avoids that "to" is deleted.
63 - char tempname[MAXPATHL + 1];
65 /* It's possible for the source and destination to be the same file.
66 * This happens when "from" and "to" differ in case and are on a FAT32
70 if (mch_stat((char *)to, &st_to) >= 0
71 && st.st_dev == st_to.st_dev
72 && st.st_ino == st_to.st_ino)
74 ! /* Find a name that doesn't exist and is in the same directory.
75 ! * Move "from" to "tempname" and then to "to". */
76 ! if (STRLEN(from) >= MAXPATHL - 5)
78 ! STRCPY(tempname, from);
79 ! for (n = 123; n < 99999; ++n)
81 ! sprintf(gettail(tempname), "%d", n);
82 ! if (mch_stat(tempname, &st_to) < 0)
84 ! if (mch_rename((char *)from, tempname) == 0)
86 ! if (mch_rename(tempname, (char *)to) == 0)
88 ! /* Strange, the second step failed. Try moving the
89 ! * file back and return failure. */
90 ! mch_rename(tempname, (char *)from);
93 ! /* If it fails for one temp name it will most likely fail
94 ! * for any temp name, give up. */
104 if (mch_stat((char *)to, &st_to) >= 0
105 && st.st_dev == st_to.st_dev
106 && st.st_ino == st_to.st_ino)
107 + use_tmp_file = TRUE;
111 + #if defined(UNIX) || defined(CASE_INSENSITIVE_FILENAME)
114 + char tempname[MAXPATHL + 1];
117 + * Find a name that doesn't exist and is in the same directory.
118 + * Rename "from" to "tempname" and then rename "tempname" to "to".
120 + if (STRLEN(from) >= MAXPATHL - 5)
122 + STRCPY(tempname, from);
123 + for (n = 123; n < 99999; ++n)
125 ! sprintf((char *)gettail((char_u *)tempname), "%d", n);
126 ! if (mch_stat(tempname, &st) < 0)
128 ! if (mch_rename((char *)from, tempname) == 0)
130 ! if (mch_rename(tempname, (char *)to) == 0)
132 ! /* Strange, the second step failed. Try moving the
133 ! * file back and return failure. */
134 ! mch_rename(tempname, (char *)from);
137 + /* If it fails for one temp name it will most likely fail
138 + * for any temp name, give up. */
146 *** ../vim-7.2.076/src/version.c Tue Dec 30 16:15:16 2008
147 --- src/version.c Wed Dec 31 16:19:29 2008
151 { /* Add new patch number below this line */
157 We apologise again for the fault in the subtitles. Those responsible for
158 sacking the people who have just been sacked have been sacked.
159 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
161 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
162 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
163 \\\ download, build and distribute -- http://www.A-A-P.org ///
164 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///