|
1 To: [email protected] |
|
2 Subject: Patch 7.2.294 |
|
3 Fcc: outbox |
|
4 From: Bram Moolenaar <[email protected]> |
|
5 Mime-Version: 1.0 |
|
6 Content-Type: text/plain; charset=UTF-8 |
|
7 Content-Transfer-Encoding: 8bit |
|
8 ------------ |
|
9 |
|
10 Patch 7.2.294 |
|
11 Problem: When using TEMPDIRS dir name could get too long. |
|
12 Solution: Overwrite tail instead of appending each time. Use mkdtemp() when |
|
13 available. (James Vega) |
|
14 Files: src/auto/configure, src/config.h.in, src/configure.in, src/fileio.c |
|
15 |
|
16 |
|
17 *** ../vim-7.2.293/src/auto/configure 2009-09-11 13:44:33.000000000 +0200 |
|
18 --- src/auto/configure 2009-11-17 12:03:15.000000000 +0100 |
|
19 *************** |
|
20 *** 14019,14027 **** |
|
21 |
|
22 |
|
23 |
|
24 for ac_func in bcmp fchdir fchown fseeko fsync ftello getcwd getpseudotty \ |
|
25 getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \ |
|
26 ! memset nanosleep opendir putenv qsort readlink select setenv \ |
|
27 setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \ |
|
28 sigvec strcasecmp strerror strftime stricmp strncasecmp \ |
|
29 strnicmp strpbrk strtol tgetent towlower towupper iswupper \ |
|
30 --- 14019,14028 ---- |
|
31 |
|
32 |
|
33 |
|
34 + |
|
35 for ac_func in bcmp fchdir fchown fseeko fsync ftello getcwd getpseudotty \ |
|
36 getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \ |
|
37 ! memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \ |
|
38 setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \ |
|
39 sigvec strcasecmp strerror strftime stricmp strncasecmp \ |
|
40 strnicmp strpbrk strtol tgetent towlower towupper iswupper \ |
|
41 *** ../vim-7.2.293/src/config.h.in 2009-05-21 23:25:38.000000000 +0200 |
|
42 --- src/config.h.in 2009-11-11 17:40:21.000000000 +0100 |
|
43 *************** |
|
44 *** 157,162 **** |
|
45 --- 157,163 ---- |
|
46 #undef HAVE_LSTAT |
|
47 #undef HAVE_MEMCMP |
|
48 #undef HAVE_MEMSET |
|
49 + #undef HAVE_MKDTEMP |
|
50 #undef HAVE_NANOSLEEP |
|
51 #undef HAVE_OPENDIR |
|
52 #undef HAVE_FLOAT_FUNCS |
|
53 *** ../vim-7.2.293/src/configure.in 2009-09-11 13:44:33.000000000 +0200 |
|
54 --- src/configure.in 2009-11-11 17:40:21.000000000 +0100 |
|
55 *************** |
|
56 *** 2635,2641 **** |
|
57 dnl Check for functions in one big call, to reduce the size of configure |
|
58 AC_CHECK_FUNCS(bcmp fchdir fchown fseeko fsync ftello getcwd getpseudotty \ |
|
59 getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \ |
|
60 ! memset nanosleep opendir putenv qsort readlink select setenv \ |
|
61 setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \ |
|
62 sigvec strcasecmp strerror strftime stricmp strncasecmp \ |
|
63 strnicmp strpbrk strtol tgetent towlower towupper iswupper \ |
|
64 --- 2635,2641 ---- |
|
65 dnl Check for functions in one big call, to reduce the size of configure |
|
66 AC_CHECK_FUNCS(bcmp fchdir fchown fseeko fsync ftello getcwd getpseudotty \ |
|
67 getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \ |
|
68 ! memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \ |
|
69 setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \ |
|
70 sigvec strcasecmp strerror strftime stricmp strncasecmp \ |
|
71 strnicmp strpbrk strtol tgetent towlower towupper iswupper \ |
|
72 *** ../vim-7.2.293/src/fileio.c 2009-09-11 17:24:01.000000000 +0200 |
|
73 --- src/fileio.c 2009-11-11 18:01:22.000000000 +0100 |
|
74 *************** |
|
75 *** 146,151 **** |
|
76 --- 146,152 ---- |
|
77 # endif |
|
78 #endif |
|
79 static int move_lines __ARGS((buf_T *frombuf, buf_T *tobuf)); |
|
80 + static void vim_settempdir __ARGS((char_u *tempdir)); |
|
81 #ifdef FEAT_AUTOCMD |
|
82 static char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buffer name"); |
|
83 #endif |
|
84 *************** |
|
85 *** 6987,6992 **** |
|
86 --- 6988,7020 ---- |
|
87 #endif |
|
88 |
|
89 /* |
|
90 + * Directory "tempdir" was created. Expand this name to a full path and put |
|
91 + * it in "vim_tempdir". This avoids that using ":cd" would confuse us. |
|
92 + * "tempdir" must be no longer than MAXPATHL. |
|
93 + */ |
|
94 + static void |
|
95 + vim_settempdir(tempdir) |
|
96 + char_u *tempdir; |
|
97 + { |
|
98 + char_u *buf; |
|
99 + |
|
100 + buf = alloc((unsigned)MAXPATHL + 2); |
|
101 + if (buf != NULL) |
|
102 + { |
|
103 + if (vim_FullName(tempdir, buf, MAXPATHL, FALSE) == FAIL) |
|
104 + STRCPY(buf, tempdir); |
|
105 + # ifdef __EMX__ |
|
106 + if (vim_strchr(buf, '/') != NULL) |
|
107 + STRCAT(buf, "/"); |
|
108 + else |
|
109 + # endif |
|
110 + add_pathsep(buf); |
|
111 + vim_tempdir = vim_strsave(buf); |
|
112 + vim_free(buf); |
|
113 + } |
|
114 + } |
|
115 + |
|
116 + /* |
|
117 * vim_tempname(): Return a unique name that can be used for a temp file. |
|
118 * |
|
119 * The temp file is NOT created. |
|
120 *************** |
|
121 *** 7007,7014 **** |
|
122 #ifdef TEMPDIRNAMES |
|
123 static char *(tempdirs[]) = {TEMPDIRNAMES}; |
|
124 int i; |
|
125 - long nr; |
|
126 - long off; |
|
127 # ifndef EEXIST |
|
128 struct stat st; |
|
129 # endif |
|
130 --- 7035,7040 ---- |
|
131 *************** |
|
132 *** 7027,7032 **** |
|
133 --- 7053,7064 ---- |
|
134 */ |
|
135 for (i = 0; i < (int)(sizeof(tempdirs) / sizeof(char *)); ++i) |
|
136 { |
|
137 + size_t itmplen; |
|
138 + # ifndef HAVE_MKDTEMP |
|
139 + long nr; |
|
140 + long off; |
|
141 + # endif |
|
142 + |
|
143 /* expand $TMP, leave room for "/v1100000/999999999" */ |
|
144 expand_env((char_u *)tempdirs[i], itmp, TEMPNAMELEN - 20); |
|
145 if (mch_isdir(itmp)) /* directory exists */ |
|
146 *************** |
|
147 *** 7040,7046 **** |
|
148 --- 7072,7085 ---- |
|
149 else |
|
150 # endif |
|
151 add_pathsep(itmp); |
|
152 + itmplen = STRLEN(itmp); |
|
153 |
|
154 + # ifdef HAVE_MKDTEMP |
|
155 + /* Leave room for filename */ |
|
156 + STRCAT(itmp, "vXXXXXX"); |
|
157 + if (mkdtemp((char *)itmp) != NULL) |
|
158 + vim_settempdir(itmp); |
|
159 + # else |
|
160 /* Get an arbitrary number of up to 6 digits. When it's |
|
161 * unlikely that it already exists it will be faster, |
|
162 * otherwise it doesn't matter. The use of mkdir() avoids any |
|
163 *************** |
|
164 *** 7052,7110 **** |
|
165 for (off = 0; off < 10000L; ++off) |
|
166 { |
|
167 int r; |
|
168 ! #if defined(UNIX) || defined(VMS) |
|
169 mode_t umask_save; |
|
170 ! #endif |
|
171 |
|
172 ! sprintf((char *)itmp + STRLEN(itmp), "v%ld", nr + off); |
|
173 ! # ifndef EEXIST |
|
174 /* If mkdir() does not set errno to EEXIST, check for |
|
175 * existing file here. There is a race condition then, |
|
176 * although it's fail-safe. */ |
|
177 if (mch_stat((char *)itmp, &st) >= 0) |
|
178 continue; |
|
179 ! # endif |
|
180 ! #if defined(UNIX) || defined(VMS) |
|
181 /* Make sure the umask doesn't remove the executable bit. |
|
182 * "repl" has been reported to use "177". */ |
|
183 umask_save = umask(077); |
|
184 ! #endif |
|
185 r = vim_mkdir(itmp, 0700); |
|
186 ! #if defined(UNIX) || defined(VMS) |
|
187 (void)umask(umask_save); |
|
188 ! #endif |
|
189 if (r == 0) |
|
190 { |
|
191 ! char_u *buf; |
|
192 ! |
|
193 ! /* Directory was created, use this name. |
|
194 ! * Expand to full path; When using the current |
|
195 ! * directory a ":cd" would confuse us. */ |
|
196 ! buf = alloc((unsigned)MAXPATHL + 1); |
|
197 ! if (buf != NULL) |
|
198 ! { |
|
199 ! if (vim_FullName(itmp, buf, MAXPATHL, FALSE) |
|
200 ! == FAIL) |
|
201 ! STRCPY(buf, itmp); |
|
202 ! # ifdef __EMX__ |
|
203 ! if (vim_strchr(buf, '/') != NULL) |
|
204 ! STRCAT(buf, "/"); |
|
205 ! else |
|
206 ! # endif |
|
207 ! add_pathsep(buf); |
|
208 ! vim_tempdir = vim_strsave(buf); |
|
209 ! vim_free(buf); |
|
210 ! } |
|
211 break; |
|
212 } |
|
213 ! # ifdef EEXIST |
|
214 /* If the mkdir() didn't fail because the file/dir exists, |
|
215 * we probably can't create any dir here, try another |
|
216 * place. */ |
|
217 if (errno != EEXIST) |
|
218 ! # endif |
|
219 break; |
|
220 } |
|
221 if (vim_tempdir != NULL) |
|
222 break; |
|
223 } |
|
224 --- 7091,7131 ---- |
|
225 for (off = 0; off < 10000L; ++off) |
|
226 { |
|
227 int r; |
|
228 ! # if defined(UNIX) || defined(VMS) |
|
229 mode_t umask_save; |
|
230 ! # endif |
|
231 |
|
232 ! sprintf((char *)itmp + itmplen, "v%ld", nr + off); |
|
233 ! # ifndef EEXIST |
|
234 /* If mkdir() does not set errno to EEXIST, check for |
|
235 * existing file here. There is a race condition then, |
|
236 * although it's fail-safe. */ |
|
237 if (mch_stat((char *)itmp, &st) >= 0) |
|
238 continue; |
|
239 ! # endif |
|
240 ! # if defined(UNIX) || defined(VMS) |
|
241 /* Make sure the umask doesn't remove the executable bit. |
|
242 * "repl" has been reported to use "177". */ |
|
243 umask_save = umask(077); |
|
244 ! # endif |
|
245 r = vim_mkdir(itmp, 0700); |
|
246 ! # if defined(UNIX) || defined(VMS) |
|
247 (void)umask(umask_save); |
|
248 ! # endif |
|
249 if (r == 0) |
|
250 { |
|
251 ! vim_settempdir(itmp); |
|
252 break; |
|
253 } |
|
254 ! # ifdef EEXIST |
|
255 /* If the mkdir() didn't fail because the file/dir exists, |
|
256 * we probably can't create any dir here, try another |
|
257 * place. */ |
|
258 if (errno != EEXIST) |
|
259 ! # endif |
|
260 break; |
|
261 } |
|
262 + # endif /* HAVE_MKDTEMP */ |
|
263 if (vim_tempdir != NULL) |
|
264 break; |
|
265 } |
|
266 *** ../vim-7.2.293/src/version.c 2009-11-11 17:30:05.000000000 +0100 |
|
267 --- src/version.c 2009-11-17 11:54:49.000000000 +0100 |
|
268 *************** |
|
269 *** 683,684 **** |
|
270 --- 683,686 ---- |
|
271 { /* Add new patch number below this line */ |
|
272 + /**/ |
|
273 + 294, |
|
274 /**/ |
|
275 |
|
276 -- |
|
277 ARTHUR: Now stand aside worthy adversary. |
|
278 BLACK KNIGHT: (Glancing at his shoulder) 'Tis but a scratch. |
|
279 ARTHUR: A scratch? Your arm's off. |
|
280 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD |
|
281 |
|
282 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ |
|
283 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ |
|
284 \\\ download, build and distribute -- http://www.A-A-P.org /// |
|
285 \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |