Mercurial > vim
annotate src/misc1.c @ 18759:592c7b56db69 v8.1.2369
patch 8.1.2369: cannot build with quickfix and without text properties
Commit: https://github.com/vim/vim/commit/a2c2ae473ab8789ceba9706713441a365dec685e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 30 20:58:46 2019 +0100
patch 8.1.2369: cannot build with quickfix and without text properties
Problem: Cannot build with quickfix and without text properties.
Solution: Fix typo. (Naruhiko Nishino)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 30 Nov 2019 21:00:04 +0100 |
parents | 6ad15a9b7c89 |
children | 80b40bd5ec1a |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
10002
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * misc1.c: functions that didn't seem to fit elsewhere | |
12 */ | |
13 | |
14 #include "vim.h" | |
15 #include "version.h" | |
16 | |
17781
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17452
diff
changeset
|
17 #if defined(MSWIN) |
14133
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
18 # include <lm.h> |
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
19 #endif |
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
20 |
15814
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
21 #define URL_SLASH 1 /* path_is_url() has found "://" */ |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
22 #define URL_BACKSLASH 2 /* path_is_url() has found ":\\" */ |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
23 |
17781
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17452
diff
changeset
|
24 // All user names (for ~user completion as done by shell). |
3744 | 25 static garray_T ga_users; |
26 | |
7 | 27 /* |
5403 | 28 * get_leader_len() returns the length in bytes of the prefix of the given |
29 * string which introduces a comment. If this string is not a comment then | |
30 * 0 is returned. | |
7 | 31 * When "flags" is not NULL, it is set to point to the flags of the recognized |
32 * comment leader. | |
33 * "backward" must be true for the "O" command. | |
3562 | 34 * If "include_space" is set, include trailing whitespace while calculating the |
35 * length. | |
7 | 36 */ |
37 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
38 get_leader_len( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
39 char_u *line, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
40 char_u **flags, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
41 int backward, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
42 int include_space) |
7 | 43 { |
44 int i, j; | |
3562 | 45 int result; |
7 | 46 int got_com = FALSE; |
47 int found_one; | |
48 char_u part_buf[COM_MAX_LEN]; /* buffer for one option part */ | |
49 char_u *string; /* pointer to comment string */ | |
50 char_u *list; | |
2809 | 51 int middle_match_len = 0; |
52 char_u *prev_list; | |
2813 | 53 char_u *saved_flags = NULL; |
7 | 54 |
3562 | 55 result = i = 0; |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
56 while (VIM_ISWHITE(line[i])) /* leading white space is ignored */ |
7 | 57 ++i; |
58 | |
59 /* | |
60 * Repeat to match several nested comment strings. | |
61 */ | |
2809 | 62 while (line[i] != NUL) |
7 | 63 { |
64 /* | |
65 * scan through the 'comments' option for a match | |
66 */ | |
67 found_one = FALSE; | |
68 for (list = curbuf->b_p_com; *list; ) | |
69 { | |
2809 | 70 /* Get one option part into part_buf[]. Advance "list" to next |
71 * one. Put "string" at start of string. */ | |
72 if (!got_com && flags != NULL) | |
73 *flags = list; /* remember where flags started */ | |
74 prev_list = list; | |
7 | 75 (void)copy_option_part(&list, part_buf, COM_MAX_LEN, ","); |
76 string = vim_strchr(part_buf, ':'); | |
77 if (string == NULL) /* missing ':', ignore this part */ | |
78 continue; | |
79 *string++ = NUL; /* isolate flags from string */ | |
80 | |
2809 | 81 /* If we found a middle match previously, use that match when this |
82 * is not a middle or end. */ | |
83 if (middle_match_len != 0 | |
84 && vim_strchr(part_buf, COM_MIDDLE) == NULL | |
85 && vim_strchr(part_buf, COM_END) == NULL) | |
86 break; | |
87 | |
88 /* When we already found a nested comment, only accept further | |
89 * nested comments. */ | |
7 | 90 if (got_com && vim_strchr(part_buf, COM_NEST) == NULL) |
91 continue; | |
92 | |
2809 | 93 /* When 'O' flag present and using "O" command skip this one. */ |
7 | 94 if (backward && vim_strchr(part_buf, COM_NOBACK) != NULL) |
95 continue; | |
96 | |
2809 | 97 /* Line contents and string must match. |
7 | 98 * When string starts with white space, must have some white space |
99 * (but the amount does not need to match, there might be a mix of | |
2809 | 100 * TABs and spaces). */ |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
101 if (VIM_ISWHITE(string[0])) |
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
102 { |
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
103 if (i == 0 || !VIM_ISWHITE(line[i - 1])) |
4352 | 104 continue; /* missing white space */ |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
105 while (VIM_ISWHITE(string[0])) |
7 | 106 ++string; |
107 } | |
108 for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j) | |
109 ; | |
110 if (string[j] != NUL) | |
2809 | 111 continue; /* string doesn't match */ |
112 | |
113 /* When 'b' flag used, there must be white space or an | |
114 * end-of-line after the string in the line. */ | |
7 | 115 if (vim_strchr(part_buf, COM_BLANK) != NULL |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
116 && !VIM_ISWHITE(line[i + j]) && line[i + j] != NUL) |
7 | 117 continue; |
118 | |
2809 | 119 /* We have found a match, stop searching unless this is a middle |
120 * comment. The middle comment can be a substring of the end | |
121 * comment in which case it's better to return the length of the | |
122 * end comment and its flags. Thus we keep searching with middle | |
123 * and end matches and use an end match if it matches better. */ | |
124 if (vim_strchr(part_buf, COM_MIDDLE) != NULL) | |
125 { | |
126 if (middle_match_len == 0) | |
127 { | |
128 middle_match_len = j; | |
129 saved_flags = prev_list; | |
130 } | |
131 continue; | |
132 } | |
133 if (middle_match_len != 0 && j > middle_match_len) | |
134 /* Use this match instead of the middle match, since it's a | |
135 * longer thus better match. */ | |
136 middle_match_len = 0; | |
137 | |
138 if (middle_match_len == 0) | |
139 i += j; | |
7 | 140 found_one = TRUE; |
141 break; | |
142 } | |
143 | |
2809 | 144 if (middle_match_len != 0) |
145 { | |
146 /* Use the previously found middle match after failing to find a | |
147 * match with an end. */ | |
148 if (!got_com && flags != NULL) | |
149 *flags = saved_flags; | |
150 i += middle_match_len; | |
151 found_one = TRUE; | |
152 } | |
153 | |
154 /* No match found, stop scanning. */ | |
7 | 155 if (!found_one) |
156 break; | |
157 | |
3562 | 158 result = i; |
159 | |
2809 | 160 /* Include any trailing white space. */ |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
161 while (VIM_ISWHITE(line[i])) |
7 | 162 ++i; |
163 | |
3562 | 164 if (include_space) |
165 result = i; | |
166 | |
2809 | 167 /* If this comment doesn't nest, stop here. */ |
168 got_com = TRUE; | |
7 | 169 if (vim_strchr(part_buf, COM_NEST) == NULL) |
170 break; | |
171 } | |
3562 | 172 return result; |
173 } | |
174 | |
175 /* | |
176 * Return the offset at which the last comment in line starts. If there is no | |
177 * comment in the whole line, -1 is returned. | |
178 * | |
179 * When "flags" is not null, it is set to point to the flags describing the | |
180 * recognized comment leader. | |
181 */ | |
182 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
183 get_last_leader_offset(char_u *line, char_u **flags) |
3562 | 184 { |
185 int result = -1; | |
186 int i, j; | |
187 int lower_check_bound = 0; | |
188 char_u *string; | |
189 char_u *com_leader; | |
190 char_u *com_flags; | |
191 char_u *list; | |
192 int found_one; | |
193 char_u part_buf[COM_MAX_LEN]; /* buffer for one option part */ | |
194 | |
195 /* | |
196 * Repeat to match several nested comment strings. | |
197 */ | |
198 i = (int)STRLEN(line); | |
199 while (--i >= lower_check_bound) | |
200 { | |
201 /* | |
202 * scan through the 'comments' option for a match | |
203 */ | |
204 found_one = FALSE; | |
205 for (list = curbuf->b_p_com; *list; ) | |
206 { | |
207 char_u *flags_save = list; | |
208 | |
209 /* | |
210 * Get one option part into part_buf[]. Advance list to next one. | |
211 * put string at start of string. | |
212 */ | |
213 (void)copy_option_part(&list, part_buf, COM_MAX_LEN, ","); | |
214 string = vim_strchr(part_buf, ':'); | |
215 if (string == NULL) /* If everything is fine, this cannot actually | |
216 * happen. */ | |
217 continue; | |
218 *string++ = NUL; /* Isolate flags from string. */ | |
219 com_leader = string; | |
220 | |
221 /* | |
222 * Line contents and string must match. | |
223 * When string starts with white space, must have some white space | |
224 * (but the amount does not need to match, there might be a mix of | |
225 * TABs and spaces). | |
226 */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
227 if (VIM_ISWHITE(string[0])) |
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
228 { |
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
229 if (i == 0 || !VIM_ISWHITE(line[i - 1])) |
3562 | 230 continue; |
15119
6e9f37bf987b
patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents:
15046
diff
changeset
|
231 while (VIM_ISWHITE(*string)) |
3562 | 232 ++string; |
233 } | |
234 for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j) | |
235 /* do nothing */; | |
236 if (string[j] != NUL) | |
237 continue; | |
238 | |
239 /* | |
240 * When 'b' flag used, there must be white space or an | |
241 * end-of-line after the string in the line. | |
242 */ | |
243 if (vim_strchr(part_buf, COM_BLANK) != NULL | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
244 && !VIM_ISWHITE(line[i + j]) && line[i + j] != NUL) |
3562 | 245 continue; |
15119
6e9f37bf987b
patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents:
15046
diff
changeset
|
246 |
15127
31a0127813cb
patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents:
15119
diff
changeset
|
247 if (vim_strchr(part_buf, COM_MIDDLE) != NULL) |
31a0127813cb
patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents:
15119
diff
changeset
|
248 { |
31a0127813cb
patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents:
15119
diff
changeset
|
249 // For a middlepart comment, only consider it to match if |
31a0127813cb
patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents:
15119
diff
changeset
|
250 // everything before the current position in the line is |
31a0127813cb
patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents:
15119
diff
changeset
|
251 // whitespace. Otherwise we would think we are inside a |
31a0127813cb
patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents:
15119
diff
changeset
|
252 // comment if the middle part appears somewhere in the middle |
31a0127813cb
patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents:
15119
diff
changeset
|
253 // of the line. E.g. for C the "*" appears often. |
15119
6e9f37bf987b
patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents:
15046
diff
changeset
|
254 for (j = 0; VIM_ISWHITE(line[j]) && j <= i; j++) |
6e9f37bf987b
patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents:
15046
diff
changeset
|
255 ; |
6e9f37bf987b
patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents:
15046
diff
changeset
|
256 if (j < i) |
6e9f37bf987b
patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents:
15046
diff
changeset
|
257 continue; |
3562 | 258 } |
259 | |
260 /* | |
261 * We have found a match, stop searching. | |
262 */ | |
263 found_one = TRUE; | |
264 | |
265 if (flags) | |
266 *flags = flags_save; | |
267 com_flags = flags_save; | |
268 | |
269 break; | |
270 } | |
271 | |
272 if (found_one) | |
273 { | |
274 char_u part_buf2[COM_MAX_LEN]; /* buffer for one option part */ | |
275 int len1, len2, off; | |
276 | |
277 result = i; | |
278 /* | |
279 * If this comment nests, continue searching. | |
280 */ | |
281 if (vim_strchr(part_buf, COM_NEST) != NULL) | |
282 continue; | |
283 | |
284 lower_check_bound = i; | |
285 | |
286 /* Let's verify whether the comment leader found is a substring | |
287 * of other comment leaders. If it is, let's adjust the | |
288 * lower_check_bound so that we make sure that we have determined | |
289 * the comment leader correctly. | |
290 */ | |
291 | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
292 while (VIM_ISWHITE(*com_leader)) |
3562 | 293 ++com_leader; |
294 len1 = (int)STRLEN(com_leader); | |
295 | |
296 for (list = curbuf->b_p_com; *list; ) | |
297 { | |
298 char_u *flags_save = list; | |
299 | |
300 (void)copy_option_part(&list, part_buf2, COM_MAX_LEN, ","); | |
301 if (flags_save == com_flags) | |
302 continue; | |
303 string = vim_strchr(part_buf2, ':'); | |
304 ++string; | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
305 while (VIM_ISWHITE(*string)) |
3562 | 306 ++string; |
307 len2 = (int)STRLEN(string); | |
308 if (len2 == 0) | |
309 continue; | |
310 | |
311 /* Now we have to verify whether string ends with a substring | |
312 * beginning the com_leader. */ | |
313 for (off = (len2 > i ? i : len2); off > 0 && off + len1 > len2;) | |
314 { | |
315 --off; | |
316 if (!STRNCMP(string + off, com_leader, len2 - off)) | |
317 { | |
318 if (i - off < lower_check_bound) | |
319 lower_check_bound = i - off; | |
320 } | |
321 } | |
322 } | |
323 } | |
324 } | |
325 return result; | |
7 | 326 } |
327 | |
328 /* | |
329 * Return the number of window lines occupied by buffer line "lnum". | |
330 */ | |
331 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
332 plines(linenr_T lnum) |
7 | 333 { |
334 return plines_win(curwin, lnum, TRUE); | |
335 } | |
336 | |
337 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
338 plines_win( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
339 win_T *wp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
340 linenr_T lnum, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
341 int winheight) /* when TRUE limit to window height */ |
7 | 342 { |
343 #if defined(FEAT_DIFF) || defined(PROTO) | |
344 /* Check for filler lines above this buffer line. When folded the result | |
345 * is one line anyway. */ | |
346 return plines_win_nofill(wp, lnum, winheight) + diff_check_fill(wp, lnum); | |
347 } | |
348 | |
349 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
350 plines_nofill(linenr_T lnum) |
7 | 351 { |
352 return plines_win_nofill(curwin, lnum, TRUE); | |
353 } | |
354 | |
355 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
356 plines_win_nofill( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
357 win_T *wp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
358 linenr_T lnum, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
359 int winheight) /* when TRUE limit to window height */ |
7 | 360 { |
361 #endif | |
362 int lines; | |
363 | |
364 if (!wp->w_p_wrap) | |
365 return 1; | |
366 | |
367 if (wp->w_width == 0) | |
368 return 1; | |
369 | |
370 #ifdef FEAT_FOLDING | |
371 /* A folded lines is handled just like an empty line. */ | |
372 /* NOTE: Caller must handle lines that are MAYBE folded. */ | |
373 if (lineFolded(wp, lnum) == TRUE) | |
374 return 1; | |
375 #endif | |
376 | |
377 lines = plines_win_nofold(wp, lnum); | |
378 if (winheight > 0 && lines > wp->w_height) | |
379 return (int)wp->w_height; | |
380 return lines; | |
381 } | |
382 | |
383 /* | |
384 * Return number of window lines physical line "lnum" will occupy in window | |
385 * "wp". Does not care about folding, 'wrap' or 'diff'. | |
386 */ | |
387 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
388 plines_win_nofold(win_T *wp, linenr_T lnum) |
7 | 389 { |
390 char_u *s; | |
391 long col; | |
392 int width; | |
393 | |
394 s = ml_get_buf(wp->w_buffer, lnum, FALSE); | |
395 if (*s == NUL) /* empty line */ | |
396 return 1; | |
397 col = win_linetabsize(wp, s, (colnr_T)MAXCOL); | |
398 | |
399 /* | |
400 * If list mode is on, then the '$' at the end of the line may take up one | |
401 * extra column. | |
402 */ | |
403 if (wp->w_p_list && lcs_eol != NUL) | |
404 col += 1; | |
405 | |
406 /* | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2162
diff
changeset
|
407 * Add column offset for 'number', 'relativenumber' and 'foldcolumn'. |
7 | 408 */ |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
409 width = wp->w_width - win_col_off(wp); |
7 | 410 if (width <= 0) |
411 return 32000; | |
412 if (col <= width) | |
413 return 1; | |
414 col -= width; | |
415 width += win_col_off2(wp); | |
416 return (col + (width - 1)) / width + 1; | |
417 } | |
418 | |
419 /* | |
420 * Like plines_win(), but only reports the number of physical screen lines | |
421 * used from the start of the line to the given column number. | |
422 */ | |
423 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
424 plines_win_col(win_T *wp, linenr_T lnum, long column) |
7 | 425 { |
426 long col; | |
427 char_u *s; | |
428 int lines = 0; | |
429 int width; | |
5995 | 430 char_u *line; |
7 | 431 |
432 #ifdef FEAT_DIFF | |
433 /* Check for filler lines above this buffer line. When folded the result | |
434 * is one line anyway. */ | |
435 lines = diff_check_fill(wp, lnum); | |
436 #endif | |
437 | |
438 if (!wp->w_p_wrap) | |
439 return lines + 1; | |
440 | |
441 if (wp->w_width == 0) | |
442 return lines + 1; | |
443 | |
5995 | 444 line = s = ml_get_buf(wp->w_buffer, lnum, FALSE); |
7 | 445 |
446 col = 0; | |
447 while (*s != NUL && --column >= 0) | |
448 { | |
5995 | 449 col += win_lbr_chartabsize(wp, line, s, (colnr_T)col, NULL); |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
450 MB_PTR_ADV(s); |
7 | 451 } |
452 | |
453 /* | |
454 * If *s is a TAB, and the TAB is not displayed as ^I, and we're not in | |
455 * INSERT mode, then col must be adjusted so that it represents the last | |
456 * screen position of the TAB. This only fixes an error when the TAB wraps | |
457 * from one screen line to the next (when 'columns' is not a multiple of | |
458 * 'ts') -- webb. | |
459 */ | |
460 if (*s == TAB && (State & NORMAL) && (!wp->w_p_list || lcs_tab1)) | |
5995 | 461 col += win_lbr_chartabsize(wp, line, s, (colnr_T)col, NULL) - 1; |
7 | 462 |
463 /* | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2162
diff
changeset
|
464 * Add column offset for 'number', 'relativenumber', 'foldcolumn', etc. |
7 | 465 */ |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
466 width = wp->w_width - win_col_off(wp); |
1023 | 467 if (width <= 0) |
468 return 9999; | |
469 | |
470 lines += 1; | |
471 if (col > width) | |
472 lines += (col - width) / (width + win_col_off2(wp)) + 1; | |
473 return lines; | |
7 | 474 } |
475 | |
476 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
477 plines_m_win(win_T *wp, linenr_T first, linenr_T last) |
7 | 478 { |
479 int count = 0; | |
480 | |
481 while (first <= last) | |
482 { | |
483 #ifdef FEAT_FOLDING | |
484 int x; | |
485 | |
486 /* Check if there are any really folded lines, but also included lines | |
487 * that are maybe folded. */ | |
488 x = foldedCount(wp, first, NULL); | |
489 if (x > 0) | |
490 { | |
491 ++count; /* count 1 for "+-- folded" line */ | |
492 first += x; | |
493 } | |
494 else | |
495 #endif | |
496 { | |
497 #ifdef FEAT_DIFF | |
498 if (first == wp->w_topline) | |
499 count += plines_win_nofill(wp, first, TRUE) + wp->w_topfill; | |
500 else | |
501 #endif | |
502 count += plines_win(wp, first, TRUE); | |
503 ++first; | |
504 } | |
505 } | |
506 return (count); | |
507 } | |
508 | |
509 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
510 gchar_pos(pos_T *pos) |
7 | 511 { |
13082
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
512 char_u *ptr; |
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
513 |
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
514 /* When searching columns is sometimes put at the end of a line. */ |
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
515 if (pos->col == MAXCOL) |
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
516 return NUL; |
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
517 ptr = ml_get_pos(pos); |
7 | 518 if (has_mbyte) |
519 return (*mb_ptr2char)(ptr); | |
520 return (int)*ptr; | |
521 } | |
522 | |
523 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
524 gchar_cursor(void) |
7 | 525 { |
526 if (has_mbyte) | |
527 return (*mb_ptr2char)(ml_get_cursor()); | |
528 return (int)*ml_get_cursor(); | |
529 } | |
530 | |
531 /* | |
532 * Write a character at the current cursor position. | |
533 * It is directly written into the block. | |
534 */ | |
535 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
536 pchar_cursor(int c) |
7 | 537 { |
538 *(ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE) | |
539 + curwin->w_cursor.col) = c; | |
540 } | |
541 | |
542 /* | |
543 * Skip to next part of an option argument: Skip space and comma. | |
544 */ | |
545 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
546 skip_to_option_part(char_u *p) |
7 | 547 { |
548 if (*p == ',') | |
549 ++p; | |
550 while (*p == ' ') | |
551 ++p; | |
552 return p; | |
553 } | |
554 | |
555 /* | |
556 * check_status: called when the status bars for the buffer 'buf' | |
557 * need to be updated | |
558 */ | |
559 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
560 check_status(buf_T *buf) |
7 | 561 { |
562 win_T *wp; | |
563 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
564 FOR_ALL_WINDOWS(wp) |
7 | 565 if (wp->w_buffer == buf && wp->w_status_height) |
566 { | |
567 wp->w_redr_status = TRUE; | |
568 if (must_redraw < VALID) | |
569 must_redraw = VALID; | |
570 } | |
571 } | |
572 | |
573 /* | |
574 * Ask for a reply from the user, a 'y' or a 'n'. | |
575 * No other characters are accepted, the message is repeated until a valid | |
576 * reply is entered or CTRL-C is hit. | |
577 * If direct is TRUE, don't use vgetc() but ui_inchar(), don't get characters | |
578 * from any buffers but directly from the user. | |
579 * | |
580 * return the 'y' or 'n' | |
581 */ | |
582 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
583 ask_yesno(char_u *str, int direct) |
7 | 584 { |
585 int r = ' '; | |
586 int save_State = State; | |
587 | |
588 if (exiting) /* put terminal in raw mode for this question */ | |
589 settmode(TMODE_RAW); | |
590 ++no_wait_return; | |
591 #ifdef USE_ON_FLY_SCROLL | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
592 dont_scroll = TRUE; // disallow scrolling here |
7 | 593 #endif |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
594 State = CONFIRM; // mouse behaves like with :confirm |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
595 setmouse(); // disables mouse for xterm |
7 | 596 ++no_mapping; |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
597 ++allow_keys; // no mapping here, but recognize keys |
7 | 598 |
599 while (r != 'y' && r != 'n') | |
600 { | |
601 /* same highlighting as for wait_return */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15420
diff
changeset
|
602 smsg_attr(HL_ATTR(HLF_R), "%s (y/n)?", str); |
7 | 603 if (direct) |
604 r = get_keystroke(); | |
605 else | |
1474 | 606 r = plain_vgetc(); |
7 | 607 if (r == Ctrl_C || r == ESC) |
608 r = 'n'; | |
609 msg_putchar(r); /* show what you typed */ | |
610 out_flush(); | |
611 } | |
612 --no_wait_return; | |
613 State = save_State; | |
614 setmouse(); | |
615 --no_mapping; | |
616 --allow_keys; | |
617 | |
618 return r; | |
619 } | |
620 | |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
621 #if defined(FEAT_EVAL) || defined(PROTO) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
622 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
623 /* |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
624 * "mode()" function |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
625 */ |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
626 void |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
627 f_mode(typval_T *argvars, typval_T *rettv) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
628 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
629 char_u buf[4]; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
630 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
631 vim_memset(buf, 0, sizeof(buf)); |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
632 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
633 if (time_for_testing == 93784) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
634 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
635 /* Testing the two-character code. */ |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
636 buf[0] = 'x'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
637 buf[1] = '!'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
638 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
639 #ifdef FEAT_TERMINAL |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
640 else if (term_use_loop()) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
641 buf[0] = 't'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
642 #endif |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
643 else if (VIsual_active) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
644 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
645 if (VIsual_select) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
646 buf[0] = VIsual_mode + 's' - 'v'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
647 else |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
648 buf[0] = VIsual_mode; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
649 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
650 else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
651 || State == CONFIRM) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
652 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
653 buf[0] = 'r'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
654 if (State == ASKMORE) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
655 buf[1] = 'm'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
656 else if (State == CONFIRM) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
657 buf[1] = '?'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
658 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
659 else if (State == EXTERNCMD) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
660 buf[0] = '!'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
661 else if (State & INSERT) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
662 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
663 if (State & VREPLACE_FLAG) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
664 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
665 buf[0] = 'R'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
666 buf[1] = 'v'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
667 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
668 else |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
669 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
670 if (State & REPLACE_FLAG) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
671 buf[0] = 'R'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
672 else |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
673 buf[0] = 'i'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
674 if (ins_compl_active()) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
675 buf[1] = 'c'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
676 else if (ctrl_x_mode_not_defined_yet()) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
677 buf[1] = 'x'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
678 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
679 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
680 else if ((State & CMDLINE) || exmode_active) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
681 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
682 buf[0] = 'c'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
683 if (exmode_active == EXMODE_VIM) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
684 buf[1] = 'v'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
685 else if (exmode_active == EXMODE_NORMAL) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
686 buf[1] = 'e'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
687 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
688 else |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
689 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
690 buf[0] = 'n'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
691 if (finish_op) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
692 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
693 buf[1] = 'o'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
694 // to be able to detect force-linewise/blockwise/characterwise operations |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
695 buf[2] = motion_force; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
696 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
697 else if (restart_edit == 'I' || restart_edit == 'R' |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
698 || restart_edit == 'V') |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
699 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
700 buf[1] = 'i'; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
701 buf[2] = restart_edit; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
702 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
703 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
704 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
705 /* Clear out the minor mode when the argument is not a non-zero number or |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
706 * non-empty string. */ |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
707 if (!non_zero_arg(&argvars[0])) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
708 buf[1] = NUL; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
709 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
710 rettv->vval.v_string = vim_strsave(buf); |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
711 rettv->v_type = VAR_STRING; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
712 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
713 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
714 static void |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
715 may_add_state_char(garray_T *gap, char_u *include, int c) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
716 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
717 if (include == NULL || vim_strchr(include, c) != NULL) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
718 ga_append(gap, c); |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
719 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
720 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
721 /* |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
722 * "state()" function |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
723 */ |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
724 void |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
725 f_state(typval_T *argvars, typval_T *rettv) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
726 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
727 garray_T ga; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
728 char_u *include = NULL; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
729 int i; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
730 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
731 ga_init2(&ga, 1, 20); |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
732 if (argvars[0].v_type != VAR_UNKNOWN) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
733 include = tv_get_string(&argvars[0]); |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
734 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
735 if (!(stuff_empty() && typebuf.tb_len == 0 && scriptin[curscript] == NULL)) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
736 may_add_state_char(&ga, include, 'm'); |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
737 if (op_pending()) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
738 may_add_state_char(&ga, include, 'o'); |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
739 if (autocmd_busy) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
740 may_add_state_char(&ga, include, 'x'); |
18143
2416e1a887ca
patch 8.1.2066: no tests for state()
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
741 if (ins_compl_active()) |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
742 may_add_state_char(&ga, include, 'a'); |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
743 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
744 # ifdef FEAT_JOB_CHANNEL |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
745 if (channel_in_blocking_wait()) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
746 may_add_state_char(&ga, include, 'w'); |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
747 # endif |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
748 if (!get_was_safe_state()) |
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
749 may_add_state_char(&ga, include, 'S'); |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
750 for (i = 0; i < get_callback_depth() && i < 3; ++i) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
751 may_add_state_char(&ga, include, 'c'); |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
752 if (msg_scrolled > 0) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
753 may_add_state_char(&ga, include, 's'); |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
754 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
755 rettv->v_type = VAR_STRING; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
756 rettv->vval.v_string = ga.ga_data; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
757 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
758 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
759 #endif // FEAT_EVAL |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
760 |
7 | 761 /* |
762 * Get a key stroke directly from the user. | |
763 * Ignores mouse clicks and scrollbar events, except a click for the left | |
764 * button (used at the more prompt). | |
765 * Doesn't use vgetc(), because it syncs undo and eats mapped characters. | |
766 * Disadvantage: typeahead is ignored. | |
767 * Translates the interrupt character for unix to ESC. | |
768 */ | |
769 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
770 get_keystroke(void) |
7 | 771 { |
3328 | 772 char_u *buf = NULL; |
773 int buflen = 150; | |
774 int maxlen; | |
7 | 775 int len = 0; |
776 int n; | |
777 int save_mapped_ctrl_c = mapped_ctrl_c; | |
964 | 778 int waited = 0; |
7 | 779 |
780 mapped_ctrl_c = FALSE; /* mappings are not used here */ | |
781 for (;;) | |
782 { | |
783 cursor_on(); | |
784 out_flush(); | |
785 | |
3328 | 786 /* Leave some room for check_termcode() to insert a key code into (max |
787 * 5 chars plus NUL). And fix_input_buffer() can triple the number of | |
788 * bytes. */ | |
789 maxlen = (buflen - 6 - len) / 3; | |
790 if (buf == NULL) | |
791 buf = alloc(buflen); | |
792 else if (maxlen < 10) | |
793 { | |
6596 | 794 char_u *t_buf = buf; |
795 | |
3596 | 796 /* Need some more space. This might happen when receiving a long |
3328 | 797 * escape sequence. */ |
798 buflen += 100; | |
799 buf = vim_realloc(buf, buflen); | |
6596 | 800 if (buf == NULL) |
801 vim_free(t_buf); | |
3328 | 802 maxlen = (buflen - 6 - len) / 3; |
803 } | |
804 if (buf == NULL) | |
805 { | |
806 do_outofmem_msg((long_u)buflen); | |
807 return ESC; /* panic! */ | |
808 } | |
809 | |
7 | 810 /* First time: blocking wait. Second time: wait up to 100ms for a |
3328 | 811 * terminal code to complete. */ |
812 n = ui_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0); | |
7 | 813 if (n > 0) |
814 { | |
815 /* Replace zero and CSI by a special key code. */ | |
9896
7b39615c0db1
commit https://github.com/vim/vim/commit/6bff02eb530aa29aafa2cb5627399837be7a5dd5
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
816 n = fix_input_buffer(buf + len, n); |
7 | 817 len += n; |
964 | 818 waited = 0; |
819 } | |
820 else if (len > 0) | |
821 ++waited; /* keep track of the waiting time */ | |
822 | |
823 /* Incomplete termcode and not timed out yet: get more characters */ | |
3328 | 824 if ((n = check_termcode(1, buf, buflen, &len)) < 0 |
964 | 825 && (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm))) |
7 | 826 continue; |
964 | 827 |
2672 | 828 if (n == KEYLEN_REMOVED) /* key code removed */ |
2721 | 829 { |
2723 | 830 if (must_redraw != 0 && !need_wait_return && (State & CMDLINE) == 0) |
2721 | 831 { |
832 /* Redrawing was postponed, do it now. */ | |
833 update_screen(0); | |
834 setcursor(); /* put cursor back where it belongs */ | |
835 } | |
2672 | 836 continue; |
2721 | 837 } |
2672 | 838 if (n > 0) /* found a termcode: adjust length */ |
7 | 839 len = n; |
2672 | 840 if (len == 0) /* nothing typed yet */ |
7 | 841 continue; |
842 | |
843 /* Handle modifier and/or special key code. */ | |
844 n = buf[0]; | |
845 if (n == K_SPECIAL) | |
846 { | |
847 n = TO_SPECIAL(buf[1], buf[2]); | |
848 if (buf[1] == KS_MODIFIER | |
849 || n == K_IGNORE | |
4221 | 850 || (is_mouse_key(n) && n != K_LEFTMOUSE) |
851 #ifdef FEAT_GUI | |
7 | 852 || n == K_VER_SCROLLBAR |
853 || n == K_HOR_SCROLLBAR | |
854 #endif | |
855 ) | |
856 { | |
857 if (buf[1] == KS_MODIFIER) | |
858 mod_mask = buf[2]; | |
859 len -= 3; | |
860 if (len > 0) | |
861 mch_memmove(buf, buf + 3, (size_t)len); | |
862 continue; | |
863 } | |
828 | 864 break; |
7 | 865 } |
866 if (has_mbyte) | |
867 { | |
868 if (MB_BYTE2LEN(n) > len) | |
869 continue; /* more bytes to get */ | |
3328 | 870 buf[len >= buflen ? buflen - 1 : len] = NUL; |
7 | 871 n = (*mb_ptr2char)(buf); |
872 } | |
873 #ifdef UNIX | |
874 if (n == intr_char) | |
875 n = ESC; | |
876 #endif | |
877 break; | |
878 } | |
3328 | 879 vim_free(buf); |
7 | 880 |
881 mapped_ctrl_c = save_mapped_ctrl_c; | |
882 return n; | |
883 } | |
884 | |
885 /* | |
374 | 886 * Get a number from the user. |
887 * When "mouse_used" is not NULL allow using the mouse. | |
7 | 888 */ |
889 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
890 get_number( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
891 int colon, /* allow colon to abort */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
892 int *mouse_used) |
7 | 893 { |
894 int n = 0; | |
895 int c; | |
810 | 896 int typed = 0; |
7 | 897 |
374 | 898 if (mouse_used != NULL) |
899 *mouse_used = FALSE; | |
900 | |
7 | 901 /* When not printing messages, the user won't know what to type, return a |
902 * zero (as if CR was hit). */ | |
903 if (msg_silent != 0) | |
904 return 0; | |
905 | |
906 #ifdef USE_ON_FLY_SCROLL | |
907 dont_scroll = TRUE; /* disallow scrolling here */ | |
908 #endif | |
909 ++no_mapping; | |
910 ++allow_keys; /* no mapping here, but recognize keys */ | |
911 for (;;) | |
912 { | |
913 windgoto(msg_row, msg_col); | |
914 c = safe_vgetc(); | |
915 if (VIM_ISDIGIT(c)) | |
916 { | |
917 n = n * 10 + c - '0'; | |
918 msg_putchar(c); | |
810 | 919 ++typed; |
7 | 920 } |
921 else if (c == K_DEL || c == K_KDEL || c == K_BS || c == Ctrl_H) | |
922 { | |
810 | 923 if (typed > 0) |
924 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
925 msg_puts("\b \b"); |
810 | 926 --typed; |
927 } | |
7 | 928 n /= 10; |
929 } | |
374 | 930 else if (mouse_used != NULL && c == K_LEFTMOUSE) |
931 { | |
932 *mouse_used = TRUE; | |
933 n = mouse_row + 1; | |
934 break; | |
935 } | |
7 | 936 else if (n == 0 && c == ':' && colon) |
937 { | |
938 stuffcharReadbuff(':'); | |
939 if (!exmode_active) | |
940 cmdline_row = msg_row; | |
941 skip_redraw = TRUE; /* skip redraw once */ | |
942 do_redraw = FALSE; | |
943 break; | |
944 } | |
945 else if (c == CAR || c == NL || c == Ctrl_C || c == ESC) | |
946 break; | |
947 } | |
948 --no_mapping; | |
949 --allow_keys; | |
950 return n; | |
951 } | |
952 | |
323 | 953 /* |
954 * Ask the user to enter a number. | |
374 | 955 * When "mouse_used" is not NULL allow using the mouse and in that case return |
956 * the line number. | |
323 | 957 */ |
958 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
959 prompt_for_number(int *mouse_used) |
323 | 960 { |
961 int i; | |
344 | 962 int save_cmdline_row; |
963 int save_State; | |
323 | 964 |
965 /* When using ":silent" assume that <CR> was entered. */ | |
375 | 966 if (mouse_used != NULL) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
967 msg_puts(_("Type number and <Enter> or click with mouse (empty cancels): ")); |
375 | 968 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
969 msg_puts(_("Type number and <Enter> (empty cancels): ")); |
344 | 970 |
14629
100a44722322
patch 8.1.0328: inputlist() doesn't work with a timer
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
971 // Set the state such that text can be selected/copied/pasted and we still |
100a44722322
patch 8.1.0328: inputlist() doesn't work with a timer
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
972 // get mouse events. redraw_after_callback() will not redraw if cmdline_row |
100a44722322
patch 8.1.0328: inputlist() doesn't work with a timer
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
973 // is zero. |
344 | 974 save_cmdline_row = cmdline_row; |
957 | 975 cmdline_row = 0; |
344 | 976 save_State = State; |
14629
100a44722322
patch 8.1.0328: inputlist() doesn't work with a timer
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
977 State = CMDLINE; |
100a44722322
patch 8.1.0328: inputlist() doesn't work with a timer
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
978 // May show different mouse shape. |
13768
bcef80912112
patch 8.0.1756: GUI: after prompting for a number the mouse shape is wrong
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
979 setmouse(); |
bcef80912112
patch 8.0.1756: GUI: after prompting for a number the mouse shape is wrong
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
980 |
374 | 981 i = get_number(TRUE, mouse_used); |
982 if (KeyTyped) | |
983 { | |
17018
b1263192461f
patch 8.1.1509: cmdline_row can become negative, causing a crash
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
984 // don't call wait_return() now |
b1263192461f
patch 8.1.1509: cmdline_row can become negative, causing a crash
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
985 if (msg_row > 0) |
b1263192461f
patch 8.1.1509: cmdline_row can become negative, causing a crash
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
986 cmdline_row = msg_row - 1; |
323 | 987 need_wait_return = FALSE; |
18528
6ad15a9b7c89
patch 8.1.2258: may get hit-enter prompt after entering a number
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
988 msg_didany = FALSE; |
6ad15a9b7c89
patch 8.1.2258: may get hit-enter prompt after entering a number
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
989 msg_didout = FALSE; |
323 | 990 } |
344 | 991 else |
992 cmdline_row = save_cmdline_row; | |
993 State = save_State; | |
14629
100a44722322
patch 8.1.0328: inputlist() doesn't work with a timer
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
994 // May need to restore mouse shape. |
13768
bcef80912112
patch 8.0.1756: GUI: after prompting for a number the mouse shape is wrong
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
995 setmouse(); |
344 | 996 |
323 | 997 return i; |
998 } | |
999 | |
7 | 1000 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1001 msgmore(long n) |
7 | 1002 { |
1003 long pn; | |
1004 | |
1005 if (global_busy /* no messages now, wait until global is finished */ | |
1006 || !messaging()) /* 'lazyredraw' set, don't do messages now */ | |
1007 return; | |
1008 | |
135 | 1009 /* We don't want to overwrite another important message, but do overwrite |
1010 * a previous "more lines" or "fewer lines" message, so that "5dd" and | |
1011 * then "put" reports the last action. */ | |
1012 if (keep_msg != NULL && !keep_msg_more) | |
1013 return; | |
1014 | |
7 | 1015 if (n > 0) |
1016 pn = n; | |
1017 else | |
1018 pn = -n; | |
1019 | |
1020 if (pn > p_report) | |
1021 { | |
14585
c8f07e8b273e
patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
1022 if (n > 0) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
1023 vim_snprintf(msg_buf, MSG_BUF_LEN, |
14585
c8f07e8b273e
patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
1024 NGETTEXT("%ld more line", "%ld more lines", pn), pn); |
7 | 1025 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
1026 vim_snprintf(msg_buf, MSG_BUF_LEN, |
14585
c8f07e8b273e
patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
1027 NGETTEXT("%ld line less", "%ld fewer lines", pn), pn); |
7 | 1028 if (got_int) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
1029 vim_strcat((char_u *)msg_buf, (char_u *)_(" (Interrupted)"), |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
1030 MSG_BUF_LEN); |
7 | 1031 if (msg(msg_buf)) |
1032 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
1033 set_keep_msg((char_u *)msg_buf, 0); |
135 | 1034 keep_msg_more = TRUE; |
7 | 1035 } |
1036 } | |
1037 } | |
1038 | |
1039 /* | |
1040 * flush map and typeahead buffers and give a warning for an error | |
1041 */ | |
1042 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1043 beep_flush(void) |
7 | 1044 { |
1045 if (emsg_silent == 0) | |
1046 { | |
14909
c97b4b537572
patch 8.1.0466: autocmd test fails
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1047 flush_buffers(FLUSH_MINIMAL); |
6949 | 1048 vim_beep(BO_ERROR); |
1049 } | |
1050 } | |
1051 | |
1052 /* | |
1053 * Give a warning for an error. | |
7 | 1054 */ |
1055 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1056 vim_beep( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1057 unsigned val) /* one of the BO_ values, e.g., BO_OPER */ |
7 | 1058 { |
13272
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1059 #ifdef FEAT_EVAL |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1060 called_vim_beep = TRUE; |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1061 #endif |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1062 |
7 | 1063 if (emsg_silent == 0) |
1064 { | |
6949 | 1065 if (!((bo_flags & val) || (bo_flags & BO_ALL))) |
1066 { | |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1067 #ifdef ELAPSED_FUNC |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1068 static int did_init = FALSE; |
15525
3ef31ce9d9f9
patch 8.1.0770: inconsistent use of ELAPSED_FUNC
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1069 static elapsed_T start_tv; |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1070 |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1071 /* Only beep once per half a second, otherwise a sequence of beeps |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1072 * would freeze Vim. */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1073 if (!did_init || ELAPSED_FUNC(start_tv) > 500) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1074 { |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1075 did_init = TRUE; |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1076 ELAPSED_INIT(start_tv); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1077 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1078 if (p_vb |
7 | 1079 #ifdef FEAT_GUI |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1080 /* While the GUI is starting up the termcap is set for |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1081 * the GUI but the output still goes to a terminal. */ |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1082 && !(gui.in_use && gui.starting) |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1083 #endif |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1084 ) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1085 { |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1086 out_str_cf(T_VB); |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1087 #ifdef FEAT_VTP |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1088 /* No restore color information, refresh the screen. */ |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1089 if (has_vtp_working() != 0 |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1090 # ifdef FEAT_TERMGUICOLORS |
13823
d0d8125ba692
patch 8.0.1783: cannot use 256 colors in a MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13772
diff
changeset
|
1091 && (p_tgc || (!p_tgc && t_colors >= 256)) |
13314
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1092 # endif |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1093 ) |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1094 { |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1095 redraw_later(CLEAR); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1096 update_screen(0); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1097 redrawcmd(); |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1098 } |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1099 #endif |
65c3e8259124
patch 8.0.1531: cannot use 24 bit colors in MS-Windows console
Christian Brabandt <cb@256bit.org>
parents:
13272
diff
changeset
|
1100 } |
11601
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1101 else |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1102 out_char(BELL); |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1103 #ifdef ELAPSED_FUNC |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1104 } |
0a5d405e2520
patch 8.0.0683: visual bell flashes too quickly
Christian Brabandt <cb@256bit.org>
parents:
11384
diff
changeset
|
1105 #endif |
7 | 1106 } |
169 | 1107 |
13272
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1108 /* When 'debug' contains "beep" produce a message. If we are sourcing |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1109 * a script or executing a function give the user a hint where the beep |
abaebba89fd4
patch 8.0.1510: cannot test if a command causes a beep
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1110 * comes from. */ |
169 | 1111 if (vim_strchr(p_debug, 'e') != NULL) |
1112 { | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
1113 msg_source(HL_ATTR(HLF_W)); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
1114 msg_attr(_("Beep!"), HL_ATTR(HLF_W)); |
169 | 1115 } |
7 | 1116 } |
1117 } | |
1118 | |
1119 /* | |
1120 * To get the "real" home directory: | |
1121 * - get value of $HOME | |
1122 * For Unix: | |
1123 * - go to that directory | |
1124 * - do mch_dirname() to get the real name of that directory. | |
1125 * This also works with mounts and links. | |
1126 * Don't do this for MS-DOS, it will change the "current dir" for a drive. | |
15046
c1be7c8bb602
patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents:
14909
diff
changeset
|
1127 * For Windows: |
c1be7c8bb602
patch 8.1.0534: MS-Windows installer uses different $HOME than Vim
Bram Moolenaar <Bram@vim.org>
parents:
14909
diff
changeset
|
1128 * This code is duplicated in init_homedir() in dosinst.c. Keep in sync! |
7 | 1129 */ |
1130 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1131 init_homedir(void) |
7 | 1132 { |
1133 char_u *var; | |
1134 | |
170 | 1135 /* In case we are called a second time (when 'encoding' changes). */ |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13188
diff
changeset
|
1136 VIM_CLEAR(homedir); |
170 | 1137 |
7 | 1138 #ifdef VMS |
1139 var = mch_getenv((char_u *)"SYS$LOGIN"); | |
1140 #else | |
1141 var = mch_getenv((char_u *)"HOME"); | |
1142 #endif | |
1143 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15814
diff
changeset
|
1144 #ifdef MSWIN |
7 | 1145 /* |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1146 * Typically, $HOME is not defined on Windows, unless the user has |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1147 * specifically defined it for Vim's sake. However, on Windows NT |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1148 * platforms, $HOMEDRIVE and $HOMEPATH are automatically defined for |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1149 * each user. Try constructing $HOME from these. |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1150 */ |
12269
d2373927d76d
patch 8.0.1014: old compiler doesn't know uint32_t
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
1151 if (var == NULL || *var == NUL) |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1152 { |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1153 char_u *homedrive, *homepath; |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1154 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1155 homedrive = mch_getenv((char_u *)"HOMEDRIVE"); |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1156 homepath = mch_getenv((char_u *)"HOMEPATH"); |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1157 if (homepath == NULL || *homepath == NUL) |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1158 homepath = (char_u *)"\\"; |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1159 if (homedrive != NULL |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1160 && STRLEN(homedrive) + STRLEN(homepath) < MAXPATHL) |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1161 { |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1162 sprintf((char *)NameBuff, "%s%s", homedrive, homepath); |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1163 if (NameBuff[0] != NUL) |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1164 var = NameBuff; |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1165 } |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1166 } |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1167 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1168 if (var == NULL) |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1169 var = mch_getenv((char_u *)"USERPROFILE"); |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1170 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1171 /* |
7 | 1172 * Weird but true: $HOME may contain an indirect reference to another |
1173 * variable, esp. "%USERPROFILE%". Happens when $USERPROFILE isn't set | |
1174 * when $HOME is being set. | |
1175 */ | |
1176 if (var != NULL && *var == '%') | |
1177 { | |
1178 char_u *p; | |
1179 char_u *exp; | |
1180 | |
1181 p = vim_strchr(var + 1, '%'); | |
1182 if (p != NULL) | |
1183 { | |
419 | 1184 vim_strncpy(NameBuff, var + 1, p - (var + 1)); |
7 | 1185 exp = mch_getenv(NameBuff); |
1186 if (exp != NULL && *exp != NUL | |
1187 && STRLEN(exp) + STRLEN(p) < MAXPATHL) | |
1188 { | |
274 | 1189 vim_snprintf((char *)NameBuff, MAXPATHL, "%s%s", exp, p + 1); |
7 | 1190 var = NameBuff; |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1191 } |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1192 } |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1193 } |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1194 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1195 if (var != NULL && *var == NUL) /* empty is same as not set */ |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1196 var = NULL; |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1197 |
170 | 1198 if (enc_utf8 && var != NULL) |
1199 { | |
1200 int len; | |
2786 | 1201 char_u *pp = NULL; |
170 | 1202 |
1203 /* Convert from active codepage to UTF-8. Other conversions are | |
1204 * not done, because they would fail for non-ASCII characters. */ | |
835 | 1205 acp_to_enc(var, (int)STRLEN(var), &pp, &len); |
170 | 1206 if (pp != NULL) |
1207 { | |
1208 homedir = pp; | |
1209 return; | |
1210 } | |
1211 } | |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1212 |
7 | 1213 /* |
1214 * Default home dir is C:/ | |
1215 * Best assumption we can make in such a situation. | |
1216 */ | |
1217 if (var == NULL) | |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7829
diff
changeset
|
1218 var = (char_u *)"C:/"; |
7 | 1219 #endif |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
12238
diff
changeset
|
1220 |
7 | 1221 if (var != NULL) |
1222 { | |
1223 #ifdef UNIX | |
1224 /* | |
1225 * Change to the directory and get the actual path. This resolves | |
1226 * links. Don't do it when we can't return. | |
1227 */ | |
1228 if (mch_dirname(NameBuff, MAXPATHL) == OK | |
1229 && mch_chdir((char *)NameBuff) == 0) | |
1230 { | |
1231 if (!mch_chdir((char *)var) && mch_dirname(IObuff, IOSIZE) == OK) | |
1232 var = IObuff; | |
1233 if (mch_chdir((char *)NameBuff) != 0) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15420
diff
changeset
|
1234 emsg(_(e_prev_dir)); |
7 | 1235 } |
1236 #endif | |
1237 homedir = vim_strsave(var); | |
1238 } | |
1239 } | |
1240 | |
359 | 1241 #if defined(EXITFREE) || defined(PROTO) |
1242 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1243 free_homedir(void) |
359 | 1244 { |
1245 vim_free(homedir); | |
1246 } | |
3744 | 1247 |
1248 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1249 free_users(void) |
3744 | 1250 { |
1251 ga_clear_strings(&ga_users); | |
1252 } | |
359 | 1253 #endif |
1254 | |
7 | 1255 /* |
1408 | 1256 * Call expand_env() and store the result in an allocated string. |
1257 * This is not very memory efficient, this expects the result to be freed | |
1258 * again soon. | |
1259 */ | |
1260 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1261 expand_env_save(char_u *src) |
1408 | 1262 { |
1263 return expand_env_save_opt(src, FALSE); | |
1264 } | |
1265 | |
1266 /* | |
1267 * Idem, but when "one" is TRUE handle the string as one file name, only | |
1268 * expand "~" at the start. | |
1269 */ | |
1270 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1271 expand_env_save_opt(char_u *src, int one) |
1408 | 1272 { |
1273 char_u *p; | |
1274 | |
1275 p = alloc(MAXPATHL); | |
1276 if (p != NULL) | |
1277 expand_env_esc(src, p, MAXPATHL, FALSE, one, NULL); | |
1278 return p; | |
1279 } | |
1280 | |
1281 /* | |
7 | 1282 * Expand environment variable with path name. |
1283 * "~/" is also expanded, using $HOME. For Unix "~user/" is expanded. | |
1408 | 1284 * Skips over "\ ", "\~" and "\$" (not for Win32 though). |
7 | 1285 * If anything fails no expansion is done and dst equals src. |
1286 */ | |
1287 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1288 expand_env( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1289 char_u *src, /* input string e.g. "$HOME/vim.hlp" */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1290 char_u *dst, /* where to put the result */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1291 int dstlen) /* maximum length of the result */ |
7 | 1292 { |
1408 | 1293 expand_env_esc(src, dst, dstlen, FALSE, FALSE, NULL); |
7 | 1294 } |
1295 | |
1296 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1297 expand_env_esc( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1298 char_u *srcp, /* input string e.g. "$HOME/vim.hlp" */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1299 char_u *dst, /* where to put the result */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1300 int dstlen, /* maximum length of the result */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1301 int esc, /* escape spaces in expanded variables */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1302 int one, /* "srcp" is one file name */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1303 char_u *startstr) /* start again after this (can be NULL) */ |
374 | 1304 { |
1305 char_u *src; | |
7 | 1306 char_u *tail; |
1307 int c; | |
1308 char_u *var; | |
1309 int copy_char; | |
1310 int mustfree; /* var was allocated, need to free it later */ | |
1311 int at_start = TRUE; /* at start of a name */ | |
374 | 1312 int startstr_len = 0; |
1313 | |
1314 if (startstr != NULL) | |
835 | 1315 startstr_len = (int)STRLEN(startstr); |
374 | 1316 |
1317 src = skipwhite(srcp); | |
7 | 1318 --dstlen; /* leave one char space for "\," */ |
1319 while (*src && dstlen > 0) | |
1320 { | |
7038
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1321 #ifdef FEAT_EVAL |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1322 /* Skip over `=expr`. */ |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1323 if (src[0] == '`' && src[1] == '=') |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1324 { |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1325 size_t len; |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1326 |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1327 var = src; |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1328 src += 2; |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1329 (void)skip_expr(&src); |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1330 if (*src == '`') |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1331 ++src; |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1332 len = src - var; |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1333 if (len > (size_t)dstlen) |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1334 len = dstlen; |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1335 vim_strncpy(dst, var, len); |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1336 dst += len; |
7066
094c8ccdc279
commit https://github.com/vim/vim/commit/5df1ed2de3fa9dcace996b9a0a4c9b3cea79cf1e
Christian Brabandt <cb@256bit.org>
parents:
7038
diff
changeset
|
1337 dstlen -= (int)len; |
7038
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1338 continue; |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1339 } |
76042a56ab85
commit https://github.com/vim/vim/commit/be83b73ddb2ee8297037166d243f72e3423a3ce3
Christian Brabandt <cb@256bit.org>
parents:
7036
diff
changeset
|
1340 #endif |
7 | 1341 copy_char = TRUE; |
22 | 1342 if ((*src == '$' |
1343 #ifdef VMS | |
1344 && at_start | |
1345 #endif | |
1346 ) | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
1347 #if defined(MSWIN) |
7 | 1348 || *src == '%' |
1349 #endif | |
1350 || (*src == '~' && at_start)) | |
1351 { | |
1352 mustfree = FALSE; | |
1353 | |
1354 /* | |
1355 * The variable name is copied into dst temporarily, because it may | |
1356 * be a string in read-only memory and a NUL needs to be appended. | |
1357 */ | |
1358 if (*src != '~') /* environment var */ | |
1359 { | |
1360 tail = src + 1; | |
1361 var = dst; | |
1362 c = dstlen - 1; | |
1363 | |
1364 #ifdef UNIX | |
1365 /* Unix has ${var-name} type environment vars */ | |
1366 if (*tail == '{' && !vim_isIDc('{')) | |
1367 { | |
1368 tail++; /* ignore '{' */ | |
1369 while (c-- > 0 && *tail && *tail != '}') | |
1370 *var++ = *tail++; | |
1371 } | |
1372 else | |
1373 #endif | |
1374 { | |
1375 while (c-- > 0 && *tail != NUL && ((vim_isIDc(*tail)) | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
1376 #if defined(MSWIN) |
7 | 1377 || (*src == '%' && *tail != '%') |
1378 #endif | |
1379 )) | |
1380 *var++ = *tail++; | |
1381 } | |
1382 | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
1383 #if defined(MSWIN) || defined(UNIX) |
7 | 1384 # ifdef UNIX |
1385 if (src[1] == '{' && *tail != '}') | |
1386 # else | |
1387 if (*src == '%' && *tail != '%') | |
1388 # endif | |
1389 var = NULL; | |
1390 else | |
1391 { | |
1392 # ifdef UNIX | |
1393 if (src[1] == '{') | |
1394 # else | |
1395 if (*src == '%') | |
1396 #endif | |
1397 ++tail; | |
1398 #endif | |
1399 *var = NUL; | |
1400 var = vim_getenv(dst, &mustfree); | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8163
diff
changeset
|
1401 #if defined(MSWIN) || defined(UNIX) |
7 | 1402 } |
1403 #endif | |
1404 } | |
1405 /* home directory */ | |
1406 else if ( src[1] == NUL | |
1407 || vim_ispathsep(src[1]) | |
1408 || vim_strchr((char_u *)" ,\t\n", src[1]) != NULL) | |
1409 { | |
1410 var = homedir; | |
1411 tail = src + 1; | |
1412 } | |
1413 else /* user directory */ | |
1414 { | |
1415 #if defined(UNIX) || (defined(VMS) && defined(USER_HOME)) | |
1416 /* | |
1417 * Copy ~user to dst[], so we can put a NUL after it. | |
1418 */ | |
1419 tail = src; | |
1420 var = dst; | |
1421 c = dstlen - 1; | |
1422 while ( c-- > 0 | |
1423 && *tail | |
1424 && vim_isfilec(*tail) | |
1425 && !vim_ispathsep(*tail)) | |
1426 *var++ = *tail++; | |
1427 *var = NUL; | |
1428 # ifdef UNIX | |
1429 /* | |
1430 * If the system supports getpwnam(), use it. | |
1431 * Otherwise, or if getpwnam() fails, the shell is used to | |
1432 * expand ~user. This is slower and may fail if the shell | |
1433 * does not support ~user (old versions of /bin/sh). | |
1434 */ | |
1435 # if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H) | |
1436 { | |
626 | 1437 /* Note: memory allocated by getpwnam() is never freed. |
1438 * Calling endpwent() apparently doesn't help. */ | |
10932
141fe140976c
patch 8.0.0355: using uninitialized memory when 'isfname' is empty
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
1439 struct passwd *pw = (*dst == NUL) |
141fe140976c
patch 8.0.0355: using uninitialized memory when 'isfname' is empty
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
1440 ? NULL : getpwnam((char *)dst + 1); |
141fe140976c
patch 8.0.0355: using uninitialized memory when 'isfname' is empty
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
1441 |
141fe140976c
patch 8.0.0355: using uninitialized memory when 'isfname' is empty
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
1442 var = (pw == NULL) ? NULL : (char_u *)pw->pw_dir; |
7 | 1443 } |
1444 if (var == NULL) | |
1445 # endif | |
1446 { | |
1447 expand_T xpc; | |
1448 | |
1449 ExpandInit(&xpc); | |
1450 xpc.xp_context = EXPAND_FILES; | |
1451 var = ExpandOne(&xpc, dst, NULL, | |
1452 WILD_ADD_SLASH|WILD_SILENT, WILD_EXPAND_FREE); | |
1453 mustfree = TRUE; | |
1454 } | |
1455 | |
1456 # else /* !UNIX, thus VMS */ | |
1457 /* | |
1458 * USER_HOME is a comma-separated list of | |
1459 * directories to search for the user account in. | |
1460 */ | |
1461 { | |
1462 char_u test[MAXPATHL], paths[MAXPATHL]; | |
1463 char_u *path, *next_path, *ptr; | |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9225
diff
changeset
|
1464 stat_T st; |
7 | 1465 |
1466 STRCPY(paths, USER_HOME); | |
1467 next_path = paths; | |
1468 while (*next_path) | |
1469 { | |
1470 for (path = next_path; *next_path && *next_path != ','; | |
1471 next_path++); | |
1472 if (*next_path) | |
1473 *next_path++ = NUL; | |
1474 STRCPY(test, path); | |
1475 STRCAT(test, "/"); | |
1476 STRCAT(test, dst + 1); | |
1477 if (mch_stat(test, &st) == 0) | |
1478 { | |
1479 var = alloc(STRLEN(test) + 1); | |
1480 STRCPY(var, test); | |
1481 mustfree = TRUE; | |
1482 break; | |
1483 } | |
1484 } | |
1485 } | |
1486 # endif /* UNIX */ | |
1487 #else | |
1488 /* cannot expand user's home directory, so don't try */ | |
1489 var = NULL; | |
1490 tail = (char_u *)""; /* for gcc */ | |
1491 #endif /* UNIX || VMS */ | |
1492 } | |
1493 | |
1494 #ifdef BACKSLASH_IN_FILENAME | |
1495 /* If 'shellslash' is set change backslashes to forward slashes. | |
1496 * Can't use slash_adjust(), p_ssl may be set temporarily. */ | |
1497 if (p_ssl && var != NULL && vim_strchr(var, '\\') != NULL) | |
1498 { | |
1499 char_u *p = vim_strsave(var); | |
1500 | |
1501 if (p != NULL) | |
1502 { | |
1503 if (mustfree) | |
1504 vim_free(var); | |
1505 var = p; | |
1506 mustfree = TRUE; | |
1507 forward_slash(var); | |
1508 } | |
1509 } | |
1510 #endif | |
1511 | |
1512 /* If "var" contains white space, escape it with a backslash. | |
1513 * Required for ":e ~/tt" when $HOME includes a space. */ | |
1514 if (esc && var != NULL && vim_strpbrk(var, (char_u *)" \t") != NULL) | |
1515 { | |
1516 char_u *p = vim_strsave_escaped(var, (char_u *)" \t"); | |
1517 | |
1518 if (p != NULL) | |
1519 { | |
1520 if (mustfree) | |
1521 vim_free(var); | |
1522 var = p; | |
1523 mustfree = TRUE; | |
1524 } | |
1525 } | |
1526 | |
1527 if (var != NULL && *var != NUL | |
1528 && (STRLEN(var) + STRLEN(tail) + 1 < (unsigned)dstlen)) | |
1529 { | |
1530 STRCPY(dst, var); | |
1531 dstlen -= (int)STRLEN(var); | |
835 | 1532 c = (int)STRLEN(var); |
7 | 1533 /* if var[] ends in a path separator and tail[] starts |
1534 * with it, skip a character */ | |
39 | 1535 if (*var != NUL && after_pathsep(dst, dst + c) |
7 | 1536 #if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA) |
1537 && dst[-1] != ':' | |
1538 #endif | |
1539 && vim_ispathsep(*tail)) | |
1540 ++tail; | |
39 | 1541 dst += c; |
7 | 1542 src = tail; |
1543 copy_char = FALSE; | |
1544 } | |
1545 if (mustfree) | |
1546 vim_free(var); | |
1547 } | |
1548 | |
1549 if (copy_char) /* copy at least one char */ | |
1550 { | |
1551 /* | |
1224 | 1552 * Recognize the start of a new name, for '~'. |
1408 | 1553 * Don't do this when "one" is TRUE, to avoid expanding "~" in |
1554 * ":edit foo ~ foo". | |
7 | 1555 */ |
1556 at_start = FALSE; | |
1557 if (src[0] == '\\' && src[1] != NUL) | |
1558 { | |
1559 *dst++ = *src++; | |
1560 --dstlen; | |
1561 } | |
1408 | 1562 else if ((src[0] == ' ' || src[0] == ',') && !one) |
7 | 1563 at_start = TRUE; |
12005
0496ea4c5c2e
patch 8.0.0883: invalid memory access with nonsensical script
Christian Brabandt <cb@256bit.org>
parents:
11989
diff
changeset
|
1564 if (dstlen > 0) |
0496ea4c5c2e
patch 8.0.0883: invalid memory access with nonsensical script
Christian Brabandt <cb@256bit.org>
parents:
11989
diff
changeset
|
1565 { |
0496ea4c5c2e
patch 8.0.0883: invalid memory access with nonsensical script
Christian Brabandt <cb@256bit.org>
parents:
11989
diff
changeset
|
1566 *dst++ = *src++; |
0496ea4c5c2e
patch 8.0.0883: invalid memory access with nonsensical script
Christian Brabandt <cb@256bit.org>
parents:
11989
diff
changeset
|
1567 --dstlen; |
0496ea4c5c2e
patch 8.0.0883: invalid memory access with nonsensical script
Christian Brabandt <cb@256bit.org>
parents:
11989
diff
changeset
|
1568 |
0496ea4c5c2e
patch 8.0.0883: invalid memory access with nonsensical script
Christian Brabandt <cb@256bit.org>
parents:
11989
diff
changeset
|
1569 if (startstr != NULL && src - startstr_len >= srcp |
0496ea4c5c2e
patch 8.0.0883: invalid memory access with nonsensical script
Christian Brabandt <cb@256bit.org>
parents:
11989
diff
changeset
|
1570 && STRNCMP(src - startstr_len, startstr, |
0496ea4c5c2e
patch 8.0.0883: invalid memory access with nonsensical script
Christian Brabandt <cb@256bit.org>
parents:
11989
diff
changeset
|
1571 startstr_len) == 0) |
0496ea4c5c2e
patch 8.0.0883: invalid memory access with nonsensical script
Christian Brabandt <cb@256bit.org>
parents:
11989
diff
changeset
|
1572 at_start = TRUE; |
0496ea4c5c2e
patch 8.0.0883: invalid memory access with nonsensical script
Christian Brabandt <cb@256bit.org>
parents:
11989
diff
changeset
|
1573 } |
0496ea4c5c2e
patch 8.0.0883: invalid memory access with nonsensical script
Christian Brabandt <cb@256bit.org>
parents:
11989
diff
changeset
|
1574 } |
0496ea4c5c2e
patch 8.0.0883: invalid memory access with nonsensical script
Christian Brabandt <cb@256bit.org>
parents:
11989
diff
changeset
|
1575 |
7 | 1576 } |
1577 *dst = NUL; | |
1578 } | |
1579 | |
1580 /* | |
17978
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1581 * If the string between "p" and "pend" ends in "name/", return "pend" minus |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1582 * the length of "name/". Otherwise return "pend". |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1583 */ |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1584 static char_u * |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1585 remove_tail(char_u *p, char_u *pend, char_u *name) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1586 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1587 int len = (int)STRLEN(name) + 1; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1588 char_u *newend = pend - len; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1589 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1590 if (newend >= p |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1591 && fnamencmp(newend, name, len - 1) == 0 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1592 && (newend == p || after_pathsep(p, newend))) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1593 return newend; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1594 return pend; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1595 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1596 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1597 /* |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1598 * Check if the directory "vimdir/<version>" or "vimdir/runtime" exists. |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1599 * Return NULL if not, return its name in allocated memory otherwise. |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1600 */ |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1601 static char_u * |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1602 vim_version_dir(char_u *vimdir) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1603 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1604 char_u *p; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1605 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1606 if (vimdir == NULL || *vimdir == NUL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1607 return NULL; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1608 p = concat_fnames(vimdir, (char_u *)VIM_VERSION_NODOT, TRUE); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1609 if (p != NULL && mch_isdir(p)) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1610 return p; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1611 vim_free(p); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1612 p = concat_fnames(vimdir, (char_u *)RUNTIME_DIRNAME, TRUE); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1613 if (p != NULL && mch_isdir(p)) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1614 return p; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1615 vim_free(p); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1616 return NULL; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1617 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1618 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
1619 /* |
7 | 1620 * Vim's version of getenv(). |
1621 * Special handling of $HOME, $VIM and $VIMRUNTIME. | |
196 | 1622 * Also does ACP to 'enc' conversion for Win32. |
2786 | 1623 * "mustfree" is set to TRUE when returned is allocated, it must be |
1624 * initialized to FALSE by the caller. | |
7 | 1625 */ |
1626 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1627 vim_getenv(char_u *name, int *mustfree) |
7 | 1628 { |
16172
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1629 char_u *p = NULL; |
7 | 1630 char_u *pend; |
1631 int vimruntime; | |
16172
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1632 #ifdef MSWIN |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1633 WCHAR *wn, *wp; |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1634 |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1635 // use "C:/" when $HOME is not set |
7 | 1636 if (STRCMP(name, "HOME") == 0) |
1637 return homedir; | |
16172
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1638 |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1639 // Use Wide function |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1640 wn = enc_to_utf16(name, NULL); |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1641 if (wn == NULL) |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1642 return NULL; |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1643 |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1644 wp = _wgetenv(wn); |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1645 vim_free(wn); |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1646 |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1647 if (wp != NULL && *wp == NUL) // empty is the same as not set |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1648 wp = NULL; |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1649 |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1650 if (wp != NULL) |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1651 { |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1652 p = utf16_to_enc(wp, NULL); |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1653 if (p == NULL) |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1654 return NULL; |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1655 |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1656 *mustfree = TRUE; |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1657 return p; |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1658 } |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1659 #else |
7 | 1660 p = mch_getenv(name); |
16172
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1661 if (p != NULL && *p == NUL) // empty is the same as not set |
7 | 1662 p = NULL; |
1663 | |
1664 if (p != NULL) | |
1665 return p; | |
16172
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1666 #endif |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1667 |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1668 // handling $VIMRUNTIME and $VIM is below, bail out if it's another name. |
7 | 1669 vimruntime = (STRCMP(name, "VIMRUNTIME") == 0); |
1670 if (!vimruntime && STRCMP(name, "VIM") != 0) | |
1671 return NULL; | |
1672 | |
1673 /* | |
1674 * When expanding $VIMRUNTIME fails, try using $VIM/vim<version> or $VIM. | |
1675 * Don't do this when default_vimruntime_dir is non-empty. | |
1676 */ | |
1677 if (vimruntime | |
1678 #ifdef HAVE_PATHDEF | |
1679 && *default_vimruntime_dir == NUL | |
1680 #endif | |
1681 ) | |
1682 { | |
16172
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1683 #ifdef MSWIN |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1684 // Use Wide function |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1685 wp = _wgetenv(L"VIM"); |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1686 if (wp != NULL && *wp == NUL) // empty is the same as not set |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1687 wp = NULL; |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1688 if (wp != NULL) |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1689 { |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1690 char_u *q = utf16_to_enc(wp, NULL); |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1691 if (q != NULL) |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1692 { |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1693 p = vim_version_dir(q); |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1694 *mustfree = TRUE; |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1695 if (p == NULL) |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1696 p = q; |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1697 } |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1698 } |
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1699 #else |
7 | 1700 p = mch_getenv((char_u *)"VIM"); |
16172
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1701 if (p != NULL && *p == NUL) // empty is the same as not set |
7 | 1702 p = NULL; |
1703 if (p != NULL) | |
1704 { | |
1705 p = vim_version_dir(p); | |
1706 if (p != NULL) | |
1707 *mustfree = TRUE; | |
1708 else | |
1709 p = mch_getenv((char_u *)"VIM"); | |
1710 } | |
16172
6b0836727cf3
patch 8.1.1091: MS-Windows: cannot use multi-byte chars in environment var
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1711 #endif |
7 | 1712 } |
1713 | |
1714 /* | |
1715 * When expanding $VIM or $VIMRUNTIME fails, try using: | |
1716 * - the directory name from 'helpfile' (unless it contains '$') | |
1717 * - the executable name from argv[0] | |
1718 */ | |
1719 if (p == NULL) | |
1720 { | |
1721 if (p_hf != NULL && vim_strchr(p_hf, '$') == NULL) | |
1722 p = p_hf; | |
1723 #ifdef USE_EXE_NAME | |
1724 /* | |
1725 * Use the name of the executable, obtained from argv[0]. | |
1726 */ | |
1727 else | |
1728 p = exe_name; | |
1729 #endif | |
1730 if (p != NULL) | |
1731 { | |
1732 /* remove the file name */ | |
1733 pend = gettail(p); | |
1734 | |
1735 /* remove "doc/" from 'helpfile', if present */ | |
1736 if (p == p_hf) | |
1737 pend = remove_tail(p, pend, (char_u *)"doc"); | |
1738 | |
1739 #ifdef USE_EXE_NAME | |
1740 # ifdef MACOS_X | |
768 | 1741 /* remove "MacOS" from exe_name and add "Resources/vim" */ |
7 | 1742 if (p == exe_name) |
1743 { | |
1744 char_u *pend1; | |
768 | 1745 char_u *pnew; |
1746 | |
1747 pend1 = remove_tail(p, pend, (char_u *)"MacOS"); | |
1748 if (pend1 != pend) | |
1749 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
1750 pnew = alloc(pend1 - p + 15); |
768 | 1751 if (pnew != NULL) |
1752 { | |
1753 STRNCPY(pnew, p, (pend1 - p)); | |
1754 STRCPY(pnew + (pend1 - p), "Resources/vim"); | |
1755 p = pnew; | |
1756 pend = p + STRLEN(p); | |
1757 } | |
1758 } | |
7 | 1759 } |
1760 # endif | |
1761 /* remove "src/" from exe_name, if present */ | |
1762 if (p == exe_name) | |
1763 pend = remove_tail(p, pend, (char_u *)"src"); | |
1764 #endif | |
1765 | |
1766 /* for $VIM, remove "runtime/" or "vim54/", if present */ | |
1767 if (!vimruntime) | |
1768 { | |
1769 pend = remove_tail(p, pend, (char_u *)RUNTIME_DIRNAME); | |
1770 pend = remove_tail(p, pend, (char_u *)VIM_VERSION_NODOT); | |
1771 } | |
1772 | |
1773 /* remove trailing path separator */ | |
39 | 1774 if (pend > p && after_pathsep(p, pend)) |
7 | 1775 --pend; |
1776 | |
768 | 1777 #ifdef MACOS_X |
1778 if (p == exe_name || p == p_hf) | |
1779 #endif | |
1780 /* check that the result is a directory name */ | |
1781 p = vim_strnsave(p, (int)(pend - p)); | |
7 | 1782 |
1783 if (p != NULL && !mch_isdir(p)) | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13188
diff
changeset
|
1784 VIM_CLEAR(p); |
7 | 1785 else |
1786 { | |
1787 #ifdef USE_EXE_NAME | |
1788 /* may add "/vim54" or "/runtime" if it exists */ | |
1789 if (vimruntime && (pend = vim_version_dir(p)) != NULL) | |
1790 { | |
1791 vim_free(p); | |
1792 p = pend; | |
1793 } | |
1794 #endif | |
1795 *mustfree = TRUE; | |
1796 } | |
1797 } | |
1798 } | |
1799 | |
1800 #ifdef HAVE_PATHDEF | |
1801 /* When there is a pathdef.c file we can use default_vim_dir and | |
1802 * default_vimruntime_dir */ | |
1803 if (p == NULL) | |
1804 { | |
1805 /* Only use default_vimruntime_dir when it is not empty */ | |
1806 if (vimruntime && *default_vimruntime_dir != NUL) | |
1807 { | |
1808 p = default_vimruntime_dir; | |
1809 *mustfree = FALSE; | |
1810 } | |
1811 else if (*default_vim_dir != NUL) | |
1812 { | |
1813 if (vimruntime && (p = vim_version_dir(default_vim_dir)) != NULL) | |
1814 *mustfree = TRUE; | |
1815 else | |
1816 { | |
1817 p = default_vim_dir; | |
1818 *mustfree = FALSE; | |
1819 } | |
1820 } | |
1821 } | |
1822 #endif | |
1823 | |
1824 /* | |
1825 * Set the environment variable, so that the new value can be found fast | |
1826 * next time, and others can also use it (e.g. Perl). | |
1827 */ | |
1828 if (p != NULL) | |
1829 { | |
1830 if (vimruntime) | |
1831 { | |
1832 vim_setenv((char_u *)"VIMRUNTIME", p); | |
1833 didset_vimruntime = TRUE; | |
1834 } | |
1835 else | |
1836 { | |
1837 vim_setenv((char_u *)"VIM", p); | |
1838 didset_vim = TRUE; | |
1839 } | |
1840 } | |
1841 return p; | |
1842 } | |
1843 | |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1844 #if defined(FEAT_EVAL) || defined(PROTO) |
13923
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
1845 void |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
1846 vim_unsetenv(char_u *var) |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
1847 { |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
1848 #ifdef HAVE_UNSETENV |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
1849 unsetenv((char *)var); |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
1850 #else |
13942
a039c93f5ff7
patch 8.0.1841: HP-UX does not have setenv()
Christian Brabandt <cb@256bit.org>
parents:
13923
diff
changeset
|
1851 vim_setenv(var, (char_u *)""); |
13923
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
1852 #endif |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
1853 } |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1854 #endif |
13923
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
1855 |
e4d5726e1678
patch 8.0.1832: cannot use :unlet for an environment variable
Christian Brabandt <cb@256bit.org>
parents:
13823
diff
changeset
|
1856 |
7 | 1857 /* |
1858 * Our portable version of setenv. | |
1859 */ | |
1860 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1861 vim_setenv(char_u *name, char_u *val) |
7 | 1862 { |
1863 #ifdef HAVE_SETENV | |
1864 mch_setenv((char *)name, (char *)val, 1); | |
1865 #else | |
1866 char_u *envbuf; | |
1867 | |
1868 /* | |
1869 * Putenv does not copy the string, it has to remain | |
1870 * valid. The allocated memory will never be freed. | |
1871 */ | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
1872 envbuf = alloc(STRLEN(name) + STRLEN(val) + 2); |
7 | 1873 if (envbuf != NULL) |
1874 { | |
1875 sprintf((char *)envbuf, "%s=%s", name, val); | |
1876 putenv((char *)envbuf); | |
1877 } | |
1878 #endif | |
3382 | 1879 #ifdef FEAT_GETTEXT |
1880 /* | |
1881 * When setting $VIMRUNTIME adjust the directory to find message | |
1882 * translations to $VIMRUNTIME/lang. | |
1883 */ | |
1884 if (*val != NUL && STRICMP(name, "VIMRUNTIME") == 0) | |
1885 { | |
1886 char_u *buf = concat_str(val, (char_u *)"/lang"); | |
1887 | |
1888 if (buf != NULL) | |
1889 { | |
1890 bindtextdomain(VIMPACKAGE, (char *)buf); | |
1891 vim_free(buf); | |
1892 } | |
1893 } | |
1894 #endif | |
7 | 1895 } |
1896 | |
1897 /* | |
1898 * Function given to ExpandGeneric() to obtain an environment variable name. | |
1899 */ | |
1900 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1901 get_env_name( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1902 expand_T *xp UNUSED, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1903 int idx) |
7 | 1904 { |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1905 # if defined(AMIGA) |
7 | 1906 /* |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1907 * No environ[] on the Amiga. |
7 | 1908 */ |
1909 return NULL; | |
1910 # else | |
1911 # ifndef __WIN32__ | |
1912 /* Borland C++ 5.2 has this in a header file. */ | |
1913 extern char **environ; | |
1914 # endif | |
17 | 1915 # define ENVNAMELEN 100 |
1916 static char_u name[ENVNAMELEN]; | |
7 | 1917 char_u *str; |
1918 int n; | |
1919 | |
1920 str = (char_u *)environ[idx]; | |
1921 if (str == NULL) | |
1922 return NULL; | |
1923 | |
17 | 1924 for (n = 0; n < ENVNAMELEN - 1; ++n) |
7 | 1925 { |
1926 if (str[n] == '=' || str[n] == NUL) | |
1927 break; | |
1928 name[n] = str[n]; | |
1929 } | |
1930 name[n] = NUL; | |
1931 return name; | |
1932 # endif | |
1933 } | |
3744 | 1934 |
1935 /* | |
14698
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1936 * Add a user name to the list of users in ga_users. |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1937 * Do nothing if user name is NULL or empty. |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1938 */ |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1939 static void |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1940 add_user(char_u *user, int need_copy) |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1941 { |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1942 char_u *user_copy = (user != NULL && need_copy) |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1943 ? vim_strsave(user) : user; |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1944 |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1945 if (user_copy == NULL || *user_copy == NUL || ga_grow(&ga_users, 1) == FAIL) |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1946 { |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1947 if (need_copy) |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1948 vim_free(user); |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1949 return; |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1950 } |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1951 ((char_u **)(ga_users.ga_data))[ga_users.ga_len++] = user_copy; |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1952 } |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1953 |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1954 /* |
3744 | 1955 * Find all user names for user completion. |
1956 * Done only once and then cached. | |
1957 */ | |
1958 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1959 init_users(void) |
4938
bcb84438bb5b
updated for version 7.3.1214
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
1960 { |
3744 | 1961 static int lazy_init_done = FALSE; |
1962 | |
1963 if (lazy_init_done) | |
1964 return; | |
1965 | |
1966 lazy_init_done = TRUE; | |
1967 ga_init2(&ga_users, sizeof(char_u *), 20); | |
1968 | |
1969 # if defined(HAVE_GETPWENT) && defined(HAVE_PWD_H) | |
1970 { | |
1971 struct passwd* pw; | |
1972 | |
1973 setpwent(); | |
1974 while ((pw = getpwent()) != NULL) | |
14698
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1975 add_user((char_u *)pw->pw_name, TRUE); |
3744 | 1976 endpwent(); |
1977 } | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15814
diff
changeset
|
1978 # elif defined(MSWIN) |
14133
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
1979 { |
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
1980 DWORD nusers = 0, ntotal = 0, i; |
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
1981 PUSER_INFO_0 uinfo; |
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
1982 |
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
1983 if (NetUserEnum(NULL, 0, 0, (LPBYTE *) &uinfo, MAX_PREFERRED_LENGTH, |
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
1984 &nusers, &ntotal, NULL) == NERR_Success) |
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
1985 { |
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
1986 for (i = 0; i < nusers; i++) |
14698
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1987 add_user(utf16_to_enc(uinfo[i].usri0_name, NULL), FALSE); |
14133
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
1988 |
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
1989 NetApiBufferFree(uinfo); |
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
1990 } |
352c2832d17f
patch 8.1.0084: user name completion does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13942
diff
changeset
|
1991 } |
3744 | 1992 # endif |
14698
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1993 # if defined(HAVE_GETPWNAM) |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1994 { |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1995 char_u *user_env = mch_getenv((char_u *)"USER"); |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1996 |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1997 // The $USER environment variable may be a valid remote user name (NIS, |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1998 // LDAP) not already listed by getpwent(), as getpwent() only lists |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
1999 // local user names. If $USER is not already listed, check whether it |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2000 // is a valid remote user name using getpwnam() and if it is, add it to |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2001 // the list of user names. |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2002 |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2003 if (user_env != NULL && *user_env != NUL) |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2004 { |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2005 int i; |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2006 |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2007 for (i = 0; i < ga_users.ga_len; i++) |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2008 { |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2009 char_u *local_user = ((char_u **)ga_users.ga_data)[i]; |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2010 |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2011 if (STRCMP(local_user, user_env) == 0) |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2012 break; |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2013 } |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2014 |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2015 if (i == ga_users.ga_len) |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2016 { |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2017 struct passwd *pw = getpwnam((char *)user_env); |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2018 |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2019 if (pw != NULL) |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2020 add_user((char_u *)pw->pw_name, TRUE); |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2021 } |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2022 } |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2023 } |
d2cfca5b178e
patch 8.1.0361: remote user not used for completion
Christian Brabandt <cb@256bit.org>
parents:
14629
diff
changeset
|
2024 # endif |
3744 | 2025 } |
2026 | |
2027 /* | |
2028 * Function given to ExpandGeneric() to obtain an user names. | |
2029 */ | |
2030 char_u* | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2031 get_users(expand_T *xp UNUSED, int idx) |
3744 | 2032 { |
2033 init_users(); | |
2034 if (idx < ga_users.ga_len) | |
2035 return ((char_u **)ga_users.ga_data)[idx]; | |
2036 return NULL; | |
2037 } | |
2038 | |
2039 /* | |
2040 * Check whether name matches a user name. Return: | |
2041 * 0 if name does not match any user name. | |
2042 * 1 if name partially matches the beginning of a user name. | |
2043 * 2 is name fully matches a user name. | |
2044 */ | |
14286
95030c543411
patch 8.1.0159: completion for user names does not work for a prefix.
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
2045 int |
95030c543411
patch 8.1.0159: completion for user names does not work for a prefix.
Christian Brabandt <cb@256bit.org>
parents:
14175
diff
changeset
|
2046 match_user(char_u *name) |
3744 | 2047 { |
2048 int i; | |
2049 int n = (int)STRLEN(name); | |
2050 int result = 0; | |
2051 | |
2052 init_users(); | |
2053 for (i = 0; i < ga_users.ga_len; i++) | |
2054 { | |
2055 if (STRCMP(((char_u **)ga_users.ga_data)[i], name) == 0) | |
2056 return 2; /* full match */ | |
2057 if (STRNCMP(((char_u **)ga_users.ga_data)[i], name, n) == 0) | |
2058 result = 1; /* partial match */ | |
2059 } | |
2060 return result; | |
2061 } | |
7 | 2062 |
2063 /* | |
115 | 2064 * Concatenate two strings and return the result in allocated memory. |
2065 * Returns NULL when out of memory. | |
2066 */ | |
2067 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2068 concat_str(char_u *str1, char_u *str2) |
115 | 2069 { |
2070 char_u *dest; | |
2071 size_t l = STRLEN(str1); | |
2072 | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
2073 dest = alloc(l + STRLEN(str2) + 1L); |
115 | 2074 if (dest != NULL) |
2075 { | |
2076 STRCPY(dest, str1); | |
2077 STRCPY(dest + l, str2); | |
2078 } | |
2079 return dest; | |
2080 } | |
2081 | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2082 static void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2083 prepare_to_exit(void) |
7 | 2084 { |
39 | 2085 #if defined(SIGHUP) && defined(SIG_IGN) |
2086 /* Ignore SIGHUP, because a dropped connection causes a read error, which | |
2087 * makes Vim exit and then handling SIGHUP causes various reentrance | |
2088 * problems. */ | |
36 | 2089 signal(SIGHUP, SIG_IGN); |
2090 #endif | |
2091 | |
7 | 2092 #ifdef FEAT_GUI |
2093 if (gui.in_use) | |
2094 { | |
2095 gui.dying = TRUE; | |
2096 out_trash(); /* trash any pending output */ | |
2097 } | |
2098 else | |
2099 #endif | |
2100 { | |
2101 windgoto((int)Rows - 1, 0); | |
2102 | |
2103 /* | |
2104 * Switch terminal mode back now, so messages end up on the "normal" | |
2105 * screen (if there are two screens). | |
2106 */ | |
2107 settmode(TMODE_COOK); | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10180
diff
changeset
|
2108 stoptermcap(); |
7 | 2109 out_flush(); |
2110 } | |
2111 } | |
2112 | |
2113 /* | |
2114 * Preserve files and exit. | |
2115 * When called IObuff must contain a message. | |
5338 | 2116 * NOTE: This may be called from deathtrap() in a signal handler, avoid unsafe |
2117 * functions, such as allocating memory. | |
7 | 2118 */ |
2119 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2120 preserve_exit(void) |
7 | 2121 { |
2122 buf_T *buf; | |
2123 | |
2124 prepare_to_exit(); | |
2125 | |
625 | 2126 /* Setting this will prevent free() calls. That avoids calling free() |
2127 * recursively when free() was invoked with a bad pointer. */ | |
2128 really_exiting = TRUE; | |
2129 | |
7 | 2130 out_str(IObuff); |
2131 screen_start(); /* don't know where cursor is now */ | |
2132 out_flush(); | |
2133 | |
2134 ml_close_notmod(); /* close all not-modified buffers */ | |
2135 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
2136 FOR_ALL_BUFFERS(buf) |
7 | 2137 { |
2138 if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL) | |
2139 { | |
5338 | 2140 OUT_STR("Vim: preserving files...\n"); |
7 | 2141 screen_start(); /* don't know where cursor is now */ |
2142 out_flush(); | |
2143 ml_sync_all(FALSE, FALSE); /* preserve all swap files */ | |
2144 break; | |
2145 } | |
2146 } | |
2147 | |
2148 ml_close_all(FALSE); /* close all memfiles, without deleting */ | |
2149 | |
5338 | 2150 OUT_STR("Vim: Finished.\n"); |
7 | 2151 |
2152 getout(1); | |
2153 } | |
2154 | |
2155 /* | |
2156 * Check for CTRL-C pressed, but only once in a while. | |
2157 * Should be used instead of ui_breakcheck() for functions that check for | |
2158 * each line in the file. Calling ui_breakcheck() each time takes too much | |
2159 * time, because it can be a system call. | |
2160 */ | |
2161 | |
2162 #ifndef BREAKCHECK_SKIP | |
17452
f12745505a23
patch 8.1.1724: too much overhead checking for CTRL-C while processing text
Bram Moolenaar <Bram@vim.org>
parents:
17018
diff
changeset
|
2163 # define BREAKCHECK_SKIP 1000 |
7 | 2164 #endif |
2165 | |
2166 static int breakcheck_count = 0; | |
2167 | |
2168 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2169 line_breakcheck(void) |
7 | 2170 { |
2171 if (++breakcheck_count >= BREAKCHECK_SKIP) | |
2172 { | |
2173 breakcheck_count = 0; | |
2174 ui_breakcheck(); | |
2175 } | |
2176 } | |
2177 | |
2178 /* | |
2179 * Like line_breakcheck() but check 10 times less often. | |
2180 */ | |
2181 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2182 fast_breakcheck(void) |
7 | 2183 { |
2184 if (++breakcheck_count >= BREAKCHECK_SKIP * 10) | |
2185 { | |
2186 breakcheck_count = 0; | |
2187 ui_breakcheck(); | |
2188 } | |
2189 } | |
2190 | |
17781
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17452
diff
changeset
|
2191 #if defined(VIM_BACKTICK) || defined(FEAT_EVAL) \ |
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17452
diff
changeset
|
2192 || (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ |
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17452
diff
changeset
|
2193 || defined(PROTO) |
7 | 2194 |
2195 #ifndef SEEK_SET | |
2196 # define SEEK_SET 0 | |
2197 #endif | |
2198 #ifndef SEEK_END | |
2199 # define SEEK_END 2 | |
2200 #endif | |
2201 | |
2202 /* | |
2203 * Get the stdout of an external command. | |
5808 | 2204 * If "ret_len" is NULL replace NUL characters with NL. When "ret_len" is not |
2205 * NULL store the length there. | |
7 | 2206 * Returns an allocated string, or NULL for error. |
2207 */ | |
2208 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2209 get_cmd_output( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2210 char_u *cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2211 char_u *infile, /* optional input file name */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2212 int flags, /* can be SHELL_SILENT */ |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2213 int *ret_len) |
7 | 2214 { |
2215 char_u *tempname; | |
2216 char_u *command; | |
2217 char_u *buffer = NULL; | |
2218 int len; | |
2219 int i = 0; | |
2220 FILE *fd; | |
2221 | |
2222 if (check_restricted() || check_secure()) | |
2223 return NULL; | |
2224 | |
2225 /* get a name for the temp file */ | |
6721 | 2226 if ((tempname = vim_tempname('o', FALSE)) == NULL) |
7 | 2227 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15420
diff
changeset
|
2228 emsg(_(e_notmp)); |
7 | 2229 return NULL; |
2230 } | |
2231 | |
2232 /* Add the redirection stuff */ | |
24 | 2233 command = make_filter_cmd(cmd, infile, tempname); |
7 | 2234 if (command == NULL) |
2235 goto done; | |
2236 | |
2237 /* | |
2238 * Call the shell to execute the command (errors are ignored). | |
2239 * Don't check timestamps here. | |
2240 */ | |
2241 ++no_check_timestamps; | |
2242 call_shell(command, SHELL_DOOUT | SHELL_EXPAND | flags); | |
2243 --no_check_timestamps; | |
2244 | |
2245 vim_free(command); | |
2246 | |
2247 /* | |
2248 * read the names from the file into memory | |
2249 */ | |
2250 # ifdef VMS | |
1224 | 2251 /* created temporary file is not always readable as binary */ |
7 | 2252 fd = mch_fopen((char *)tempname, "r"); |
2253 # else | |
2254 fd = mch_fopen((char *)tempname, READBIN); | |
2255 # endif | |
2256 | |
2257 if (fd == NULL) | |
2258 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15420
diff
changeset
|
2259 semsg(_(e_notopen), tempname); |
7 | 2260 goto done; |
2261 } | |
2262 | |
2263 fseek(fd, 0L, SEEK_END); | |
2264 len = ftell(fd); /* get size of temp file */ | |
2265 fseek(fd, 0L, SEEK_SET); | |
2266 | |
2267 buffer = alloc(len + 1); | |
2268 if (buffer != NULL) | |
2269 i = (int)fread((char *)buffer, (size_t)1, (size_t)len, fd); | |
2270 fclose(fd); | |
2271 mch_remove(tempname); | |
2272 if (buffer == NULL) | |
2273 goto done; | |
2274 #ifdef VMS | |
2275 len = i; /* VMS doesn't give us what we asked for... */ | |
2276 #endif | |
2277 if (i != len) | |
2278 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15420
diff
changeset
|
2279 semsg(_(e_notread), tempname); |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13188
diff
changeset
|
2280 VIM_CLEAR(buffer); |
7 | 2281 } |
5808 | 2282 else if (ret_len == NULL) |
5271
25f67b62afd8
updated for version 7.4b.012
Bram Moolenaar <bram@vim.org>
parents:
5104
diff
changeset
|
2283 { |
25f67b62afd8
updated for version 7.4b.012
Bram Moolenaar <bram@vim.org>
parents:
5104
diff
changeset
|
2284 /* Change NUL into SOH, otherwise the string is truncated. */ |
25f67b62afd8
updated for version 7.4b.012
Bram Moolenaar <bram@vim.org>
parents:
5104
diff
changeset
|
2285 for (i = 0; i < len; ++i) |
5275
3ddec3d25bd1
updated for version 7.4b.014
Bram Moolenaar <bram@vim.org>
parents:
5271
diff
changeset
|
2286 if (buffer[i] == NUL) |
3ddec3d25bd1
updated for version 7.4b.014
Bram Moolenaar <bram@vim.org>
parents:
5271
diff
changeset
|
2287 buffer[i] = 1; |
5271
25f67b62afd8
updated for version 7.4b.012
Bram Moolenaar <bram@vim.org>
parents:
5104
diff
changeset
|
2288 |
2429
7ce8b24450dc
Improvements for ":find" completion. (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2409
diff
changeset
|
2289 buffer[len] = NUL; /* make sure the buffer is terminated */ |
5271
25f67b62afd8
updated for version 7.4b.012
Bram Moolenaar <bram@vim.org>
parents:
5104
diff
changeset
|
2290 } |
5808 | 2291 else |
2292 *ret_len = len; | |
7 | 2293 |
2294 done: | |
2295 vim_free(tempname); | |
2296 return buffer; | |
2297 } | |
17978
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2298 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2299 # if defined(FEAT_EVAL) || defined(PROTO) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2300 |
18051
d1e77015f60b
patch 8.1.2021: some global functions can be local to the file
Bram Moolenaar <Bram@vim.org>
parents:
17978
diff
changeset
|
2301 static void |
17978
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2302 get_cmd_output_as_rettv( |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2303 typval_T *argvars, |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2304 typval_T *rettv, |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2305 int retlist) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2306 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2307 char_u *res = NULL; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2308 char_u *p; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2309 char_u *infile = NULL; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2310 int err = FALSE; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2311 FILE *fd; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2312 list_T *list = NULL; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2313 int flags = SHELL_SILENT; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2314 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2315 rettv->v_type = VAR_STRING; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2316 rettv->vval.v_string = NULL; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2317 if (check_restricted() || check_secure()) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2318 goto errret; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2319 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2320 if (argvars[1].v_type != VAR_UNKNOWN) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2321 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2322 /* |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2323 * Write the text to a temp file, to be used for input of the shell |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2324 * command. |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2325 */ |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2326 if ((infile = vim_tempname('i', TRUE)) == NULL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2327 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2328 emsg(_(e_notmp)); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2329 goto errret; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2330 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2331 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2332 fd = mch_fopen((char *)infile, WRITEBIN); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2333 if (fd == NULL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2334 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2335 semsg(_(e_notopen), infile); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2336 goto errret; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2337 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2338 if (argvars[1].v_type == VAR_NUMBER) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2339 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2340 linenr_T lnum; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2341 buf_T *buf; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2342 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2343 buf = buflist_findnr(argvars[1].vval.v_number); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2344 if (buf == NULL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2345 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2346 semsg(_(e_nobufnr), argvars[1].vval.v_number); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2347 fclose(fd); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2348 goto errret; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2349 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2350 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2351 for (lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2352 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2353 for (p = ml_get_buf(buf, lnum, FALSE); *p != NUL; ++p) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2354 if (putc(*p == '\n' ? NUL : *p, fd) == EOF) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2355 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2356 err = TRUE; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2357 break; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2358 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2359 if (putc(NL, fd) == EOF) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2360 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2361 err = TRUE; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2362 break; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2363 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2364 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2365 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2366 else if (argvars[1].v_type == VAR_LIST) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2367 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2368 if (write_list(fd, argvars[1].vval.v_list, TRUE) == FAIL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2369 err = TRUE; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2370 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2371 else |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2372 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2373 size_t len; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2374 char_u buf[NUMBUFLEN]; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2375 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2376 p = tv_get_string_buf_chk(&argvars[1], buf); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2377 if (p == NULL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2378 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2379 fclose(fd); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2380 goto errret; /* type error; errmsg already given */ |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2381 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2382 len = STRLEN(p); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2383 if (len > 0 && fwrite(p, len, 1, fd) != 1) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2384 err = TRUE; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2385 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2386 if (fclose(fd) != 0) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2387 err = TRUE; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2388 if (err) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2389 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2390 emsg(_("E677: Error writing temp file")); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2391 goto errret; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2392 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2393 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2394 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2395 /* Omit SHELL_COOKED when invoked with ":silent". Avoids that the shell |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2396 * echoes typeahead, that messes up the display. */ |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2397 if (!msg_silent) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2398 flags += SHELL_COOKED; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2399 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2400 if (retlist) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2401 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2402 int len; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2403 listitem_T *li; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2404 char_u *s = NULL; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2405 char_u *start; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2406 char_u *end; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2407 int i; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2408 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2409 res = get_cmd_output(tv_get_string(&argvars[0]), infile, flags, &len); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2410 if (res == NULL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2411 goto errret; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2412 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2413 list = list_alloc(); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2414 if (list == NULL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2415 goto errret; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2416 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2417 for (i = 0; i < len; ++i) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2418 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2419 start = res + i; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2420 while (i < len && res[i] != NL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2421 ++i; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2422 end = res + i; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2423 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2424 s = alloc(end - start + 1); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2425 if (s == NULL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2426 goto errret; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2427 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2428 for (p = s; start < end; ++p, ++start) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2429 *p = *start == NUL ? NL : *start; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2430 *p = NUL; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2431 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2432 li = listitem_alloc(); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2433 if (li == NULL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2434 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2435 vim_free(s); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2436 goto errret; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2437 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2438 li->li_tv.v_type = VAR_STRING; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2439 li->li_tv.v_lock = 0; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2440 li->li_tv.vval.v_string = s; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2441 list_append(list, li); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2442 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2443 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2444 rettv_list_set(rettv, list); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2445 list = NULL; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2446 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2447 else |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2448 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2449 res = get_cmd_output(tv_get_string(&argvars[0]), infile, flags, NULL); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2450 #ifdef USE_CRNL |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2451 /* translate <CR><NL> into <NL> */ |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2452 if (res != NULL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2453 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2454 char_u *s, *d; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2455 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2456 d = res; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2457 for (s = res; *s; ++s) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2458 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2459 if (s[0] == CAR && s[1] == NL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2460 ++s; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2461 *d++ = *s; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2462 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2463 *d = NUL; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2464 } |
7 | 2465 #endif |
17978
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2466 rettv->vval.v_string = res; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2467 res = NULL; |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2468 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2469 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2470 errret: |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2471 if (infile != NULL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2472 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2473 mch_remove(infile); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2474 vim_free(infile); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2475 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2476 if (res != NULL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2477 vim_free(res); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2478 if (list != NULL) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2479 list_free(list); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2480 } |
7 | 2481 |
2482 /* | |
17978
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2483 * "system()" function |
7 | 2484 */ |
2485 void | |
17978
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2486 f_system(typval_T *argvars, typval_T *rettv) |
7 | 2487 { |
17978
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2488 get_cmd_output_as_rettv(argvars, rettv, FALSE); |
7 | 2489 } |
2490 | |
2491 /* | |
17978
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2492 * "systemlist()" function |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2493 */ |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2494 void |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2495 f_systemlist(typval_T *argvars, typval_T *rettv) |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2496 { |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2497 get_cmd_output_as_rettv(argvars, rettv, TRUE); |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2498 } |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2499 # endif // FEAT_EVAL |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2500 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2501 #endif |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2502 |
8f4cc259ed7a
patch 8.1.1985: code for dealing with paths is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
2503 /* |
2302
488be8cbe19c
Make CTRL-L in command line mode respect 'ignorecase' and 'smartcase'. (Martin
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
2504 * Return TRUE when need to go to Insert mode because of 'insertmode'. |
7 | 2505 * Don't do this when still processing a command or a mapping. |
2506 * Don't do this when inside a ":normal" command. | |
2507 */ | |
2508 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2509 goto_im(void) |
7 | 2510 { |
2511 return (p_im && stuff_empty() && typebuf_typed()); | |
2512 } | |
5867 | 2513 |
2514 /* | |
5911 | 2515 * Returns the isolated name of the shell in allocated memory: |
5867 | 2516 * - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f". |
2517 * - Remove any argument. E.g., "csh -f" -> "csh". | |
2518 * But don't allow a space in the path, so that this works: | |
2519 * "/usr/bin/csh --rcfile ~/.cshrc" | |
2520 * But don't do that for Windows, it's common to have a space in the path. | |
2521 */ | |
2522 char_u * | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2523 get_isolated_shell_name(void) |
5867 | 2524 { |
2525 char_u *p; | |
2526 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15814
diff
changeset
|
2527 #ifdef MSWIN |
5867 | 2528 p = gettail(p_sh); |
2529 p = vim_strnsave(p, (int)(skiptowhite(p) - p)); | |
2530 #else | |
2531 p = skiptowhite(p_sh); | |
2532 if (*p == NUL) | |
2533 { | |
2534 /* No white space, use the tail. */ | |
2535 p = vim_strsave(gettail(p_sh)); | |
2536 } | |
2537 else | |
2538 { | |
2539 char_u *p1, *p2; | |
2540 | |
2541 /* Find the last path separator before the space. */ | |
2542 p1 = p_sh; | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
2543 for (p2 = p_sh; p2 < p; MB_PTR_ADV(p2)) |
5867 | 2544 if (vim_ispathsep(*p2)) |
2545 p1 = p2 + 1; | |
2546 p = vim_strnsave(p1, (int)(p - p1)); | |
2547 } | |
2548 #endif | |
2549 return p; | |
2550 } | |
15814
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2551 |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2552 /* |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2553 * Check if the "://" of a URL is at the pointer, return URL_SLASH. |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2554 * Also check for ":\\", which MS Internet Explorer accepts, return |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2555 * URL_BACKSLASH. |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2556 */ |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2557 int |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2558 path_is_url(char_u *p) |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2559 { |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2560 if (STRNCMP(p, "://", (size_t)3) == 0) |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2561 return URL_SLASH; |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2562 else if (STRNCMP(p, ":\\\\", (size_t)3) == 0) |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2563 return URL_BACKSLASH; |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2564 return 0; |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2565 } |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2566 |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2567 /* |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2568 * Check if "fname" starts with "name://". Return URL_SLASH if it does. |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2569 * Return URL_BACKSLASH for "name:\\". |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2570 * Return zero otherwise. |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2571 */ |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2572 int |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2573 path_with_url(char_u *fname) |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2574 { |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2575 char_u *p; |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2576 |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2577 for (p = fname; isalpha(*p); ++p) |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2578 ; |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2579 return path_is_url(p); |
99ebf78686a9
patch 8.1.0914: code related to findfile() is spread out
Bram Moolenaar <Bram@vim.org>
parents:
15699
diff
changeset
|
2580 } |
18463
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2581 |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2582 /* |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2583 * Put timestamp "tt" in "buf[buflen]" in a nice format. |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2584 */ |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2585 void |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2586 add_time(char_u *buf, size_t buflen, time_t tt) |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2587 { |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2588 #ifdef HAVE_STRFTIME |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2589 struct tm tmval; |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2590 struct tm *curtime; |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2591 |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2592 if (vim_time() - tt >= 100) |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2593 { |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2594 curtime = vim_localtime(&tt, &tmval); |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2595 if (vim_time() - tt < (60L * 60L * 12L)) |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2596 /* within 12 hours */ |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2597 (void)strftime((char *)buf, buflen, "%H:%M:%S", curtime); |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2598 else |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2599 /* longer ago */ |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2600 (void)strftime((char *)buf, buflen, "%Y/%m/%d %H:%M:%S", curtime); |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2601 } |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2602 else |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2603 #endif |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2604 { |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2605 long seconds = (long)(vim_time() - tt); |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2606 |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2607 vim_snprintf((char *)buf, buflen, |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2608 NGETTEXT("%ld second ago", "%ld seconds ago", seconds), |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2609 seconds); |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2610 } |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2611 } |