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