Mercurial > vim
annotate src/os_vms.c @ 32189:1a46b76ea2cb
Added tag v9.0.1425 for changeset 70d078793ad28e82a8f4d3a9ec7560f9abc03aa4
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 23 Mar 2023 17:00:07 +0100 |
parents | 50555279168b |
children |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * VMS port by Henk Elbers | |
5 * VMS deport by Zoltan Arpadffy | |
6 * | |
7 * Do ":help uganda" in Vim to read copying and usage conditions. | |
8 * Do ":help credits" in Vim to see a list of people who contributed. | |
9 * See README.txt for an overview of the Vim source code. | |
10 */ | |
11 | |
12 #include "vim.h" | |
13 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
14 // define _generic_64 for use in time functions |
6359 | 15 #if !defined(VAX) && !defined(PROTO) |
5541 | 16 # include <gen64def.h> |
17 #else | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
18 // based on Alpha's gen64def.h; the file is absent on VAX |
5541 | 19 typedef struct _generic_64 { |
20 # pragma __nomember_alignment | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
21 __union { // You can treat me as... |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
22 // long long is not available on VAXen |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
23 // unsigned __int64 gen64$q_quadword; ...a single 64-bit value, or |
5541 | 24 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
25 unsigned int gen64$l_longword [2]; // ...two 32-bit values, or |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
26 unsigned short int gen64$w_word [4]; // ...four 16-bit values |
5541 | 27 } gen64$r_quad_overlay; |
28 } GENERIC_64; | |
29 #endif | |
30 | |
7 | 31 typedef struct |
32 { | |
33 char class; | |
34 char type; | |
35 short width; | |
36 union | |
37 { | |
38 struct | |
39 { | |
40 char _basic[3]; | |
41 char length; | |
42 } y; | |
43 int basic; | |
44 } x; | |
45 int extended; | |
46 } TT_MODE; | |
47 | |
48 typedef struct | |
49 { | |
50 short buflen; | |
51 short itemcode; | |
52 char *bufadrs; | |
53 int *retlen; | |
54 } ITEM; | |
55 | |
56 typedef struct | |
57 { | |
58 ITEM equ; | |
59 int nul; | |
60 } ITMLST1; | |
61 | |
62 typedef struct | |
63 { | |
64 ITEM index; | |
65 ITEM string; | |
66 int nul; | |
67 } ITMLST2; | |
68 | |
69 static TT_MODE orgmode; | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
70 static short iochan; // TTY I/O channel |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
71 static short iosb[4]; // IO status block |
7 | 72 |
73 static int vms_match_num = 0; | |
74 static int vms_match_free = 0; | |
75 static char_u **vms_fmatch = NULL; | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
76 static char *Fspec_Rms; // rms file spec, passed implicitly between routines |
7 | 77 |
78 | |
79 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
6695
diff
changeset
|
80 static TT_MODE get_tty(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
6695
diff
changeset
|
81 static void set_tty(int row, int col); |
7 | 82 |
83 #define EXPL_ALLOC_INC 64 | |
84 | |
85 #define EQN(S1,S2,LN) (strncmp(S1,S2,LN) == 0) | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13353
diff
changeset
|
86 #define SKIP_FOLLOWING_SLASHES(Str) do { while (Str[1] == '/') ++Str; } while (0) |
7 | 87 |
88 | |
89 /* | |
90 * vul_desc vult een descriptor met een string en de lengte | |
91 * hier van. | |
92 */ | |
93 static void | |
94 vul_desc(DESC *des, char *str) | |
95 { | |
96 des->dsc$b_dtype = DSC$K_DTYPE_T; | |
97 des->dsc$b_class = DSC$K_CLASS_S; | |
98 des->dsc$a_pointer = str; | |
99 des->dsc$w_length = str ? strlen(str) : 0; | |
100 } | |
101 | |
102 /* | |
103 * vul_item vult een item met een aantal waarden | |
104 */ | |
105 static void | |
106 vul_item(ITEM *itm, short len, short cod, char *adr, int *ret) | |
107 { | |
108 itm->buflen = len; | |
109 itm->itemcode = cod; | |
110 itm->bufadrs = adr; | |
111 itm->retlen = ret; | |
112 } | |
113 | |
114 void | |
20439
d4b2a8675b78
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'
Bram Moolenaar <Bram@vim.org>
parents:
18810
diff
changeset
|
115 mch_settmode(tmode_T tmode) |
7 | 116 { |
117 int status; | |
118 | |
119 if ( tmode == TMODE_RAW ) | |
120 set_tty(0, 0); | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
121 else |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
122 { |
7 | 123 switch (orgmode.width) |
124 { | |
125 case 132: OUT_STR_NF((char_u *)"\033[?3h\033>"); break; | |
126 case 80: OUT_STR_NF((char_u *)"\033[?3l\033>"); break; | |
127 default: break; | |
128 } | |
129 out_flush(); | |
130 status = sys$qiow(0, iochan, IO$_SETMODE, iosb, 0, 0, | |
131 &orgmode, sizeof(TT_MODE), 0,0,0,0); | |
132 if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL) | |
133 return; | |
134 (void)sys$dassgn(iochan); | |
135 iochan = 0; | |
136 } | |
137 } | |
138 | |
139 static void | |
140 set_tty(int row, int col) | |
141 { | |
142 int status; | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
143 TT_MODE newmode; // New TTY mode bits |
7 | 144 static short first_time = TRUE; |
145 | |
146 if (first_time) | |
147 { | |
148 orgmode = get_tty(); | |
149 first_time = FALSE; | |
150 } | |
151 newmode = get_tty(); | |
152 if (col) | |
153 newmode.width = col; | |
154 if (row) | |
155 newmode.x.y.length = row; | |
156 newmode.x.basic |= (TT$M_NOECHO | TT$M_HOSTSYNC); | |
157 newmode.x.basic &= ~TT$M_TTSYNC; | |
158 newmode.extended |= TT2$M_PASTHRU; | |
159 status = sys$qiow(0, iochan, IO$_SETMODE, iosb, 0, 0, | |
160 &newmode, sizeof(newmode), 0, 0, 0, 0); | |
161 if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL) | |
162 return; | |
163 } | |
164 | |
165 static TT_MODE | |
166 get_tty(void) | |
167 { | |
168 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
169 static $DESCRIPTOR(odsc,"SYS$OUTPUT"); // output descriptor |
7 | 170 |
171 int status; | |
172 TT_MODE tt_mode; | |
173 | |
174 if (!iochan) | |
175 status = sys$assign(&odsc,&iochan,0,0); | |
176 | |
177 status = sys$qiow(0, iochan, IO$_SENSEMODE, iosb, 0, 0, | |
178 &tt_mode, sizeof(tt_mode), 0, 0, 0, 0); | |
179 if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) | |
180 { | |
181 tt_mode.width = 0; | |
182 tt_mode.type = 0; | |
183 tt_mode.class = 0; | |
184 tt_mode.x.basic = 0; | |
185 tt_mode.x.y.length = 0; | |
186 tt_mode.extended = 0; | |
187 } | |
188 return(tt_mode); | |
189 } | |
190 | |
191 /* | |
192 * Get the current window size in Rows and Columns. | |
193 */ | |
194 int | |
195 mch_get_shellsize(void) | |
196 { | |
197 TT_MODE tmode; | |
198 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
199 tmode = get_tty(); // get size from VMS |
7 | 200 Columns = tmode.width; |
201 Rows = tmode.x.y.length; | |
202 return OK; | |
203 } | |
204 | |
205 /* | |
206 * Try to set the window size to Rows and new_Columns. | |
207 */ | |
208 void | |
209 mch_set_shellsize(void) | |
210 { | |
211 set_tty(Rows, Columns); | |
212 switch (Columns) | |
213 { | |
214 case 132: OUT_STR_NF((char_u *)"\033[?3h\033>"); break; | |
215 case 80: OUT_STR_NF((char_u *)"\033[?3l\033>"); break; | |
216 default: break; | |
217 } | |
218 out_flush(); | |
219 screen_start(); | |
220 } | |
221 | |
222 char_u * | |
223 mch_getenv(char_u *lognam) | |
224 { | |
225 DESC d_file_dev, d_lognam ; | |
226 static char buffer[LNM$C_NAMLENGTH+1]; | |
227 char_u *cp = NULL; | |
228 unsigned long attrib; | |
229 int lengte = 0, dum = 0, idx = 0; | |
230 ITMLST2 itmlst; | |
231 char *sbuf = NULL; | |
232 | |
233 vul_desc(&d_lognam, (char *)lognam); | |
234 vul_desc(&d_file_dev, "LNM$FILE_DEV"); | |
235 attrib = LNM$M_CASE_BLIND; | |
236 vul_item(&itmlst.index, sizeof(int), LNM$_INDEX, (char *)&idx, &dum); | |
237 vul_item(&itmlst.string, LNM$C_NAMLENGTH, LNM$_STRING, buffer, &lengte); | |
238 itmlst.nul = 0; | |
239 if (sys$trnlnm(&attrib, &d_file_dev, &d_lognam, NULL,&itmlst) == SS$_NORMAL) | |
240 { | |
241 buffer[lengte] = '\0'; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
242 if (cp = alloc(lengte + 1)) |
7 | 243 strcpy((char *)cp, buffer); |
244 return(cp); | |
245 } | |
246 else if ((sbuf = getenv((char *)lognam))) | |
247 { | |
248 lengte = strlen(sbuf) + 1; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
249 cp = alloc(lengte); |
7 | 250 if (cp) |
251 strcpy((char *)cp, sbuf); | |
252 return cp; | |
253 } | |
254 else | |
255 return(NULL); | |
256 } | |
257 | |
258 /* | |
259 * mch_setenv VMS version of setenv() | |
260 */ | |
261 int | |
262 mch_setenv(char *var, char *value, int x) | |
263 { | |
264 int res, dum; | |
265 long attrib = 0L; | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
266 char acmode = PSL$C_SUPER; // needs SYSNAM privilege |
7 | 267 DESC tabnam, lognam; |
268 ITMLST1 itmlst; | |
269 | |
270 vul_desc(&tabnam, "LNM$JOB"); | |
271 vul_desc(&lognam, var); | |
272 vul_item(&itmlst.equ, value ? strlen(value) : 0, value ? LNM$_STRING : 0, | |
273 value, &dum); | |
274 itmlst.nul = 0; | |
275 res = sys$crelnm(&attrib, &tabnam, &lognam, &acmode, &itmlst); | |
276 return((res == 1) ? 0 : -1); | |
277 } | |
278 | |
279 int | |
280 vms_sys(char *cmd, char *out, char *inp) | |
281 { | |
282 DESC cdsc, odsc, idsc; | |
283 long status; | |
284 | |
285 if (cmd) | |
286 vul_desc(&cdsc, cmd); | |
287 if (out) | |
288 vul_desc(&odsc, out); | |
289 if (inp) | |
290 vul_desc(&idsc, inp); | |
291 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
292 lib$spawn(cmd ? &cdsc : NULL, // command string |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
293 inp ? &idsc : NULL, // input file |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
294 out ? &odsc : NULL, // output file |
7 | 295 0, 0, 0, &status, 0, 0, 0, 0, 0, 0); |
296 return status; | |
297 } | |
298 | |
299 /* | |
5704 | 300 * Convert string to lowercase - most often filename |
301 */ | |
302 char * | |
303 vms_tolower( char *name ) | |
304 { | |
305 int i,nlen = strlen(name); | |
306 for (i = 0; i < nlen; i++) | |
307 name[i] = TOLOWER_ASC(name[i]); | |
308 return name; | |
309 } | |
310 | |
311 /* | |
7 | 312 * Convert VMS system() or lib$spawn() return code to Unix-like exit value. |
313 */ | |
314 int | |
315 vms_sys_status(int status) | |
316 { | |
317 if (status != SS$_NORMAL && (status & STS$M_SUCCESS) == 0) | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
318 return status; // Command failed. |
7 | 319 return 0; |
320 } | |
321 | |
322 /* | |
323 * vms_read() | |
324 * function for low level char input | |
325 * | |
326 * Returns: input length | |
327 */ | |
328 int | |
329 vms_read(char *inbuf, size_t nbytes) | |
330 { | |
775 | 331 int status, function, len; |
332 TT_MODE tt_mode; | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
333 ITEM itmlst[2]; // terminates on everything |
7 | 334 static long trm_mask[8] = {-1, -1, -1, -1, -1, -1, -1, -1}; |
335 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
336 // whatever happened earlier we need an iochan here |
7 | 337 if (!iochan) |
775 | 338 tt_mode = get_tty(); |
7 | 339 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
340 // important: clean the inbuf |
7 | 341 memset(inbuf, 0, nbytes); |
342 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
343 // set up the itemlist for the first read |
694 | 344 vul_item(&itmlst[0], 0, TRM$_MODIFIERS, |
775 | 345 (char *)( TRM$M_TM_NOECHO | TRM$M_TM_NOEDIT | |
346 TRM$M_TM_NOFILTR | TRM$M_TM_TRMNOECHO | | |
347 TRM$M_TM_NORECALL) , 0); | |
694 | 348 vul_item(&itmlst[1], sizeof(trm_mask), TRM$_TERM, (char *)&trm_mask, 0); |
349 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
350 // wait forever for a char |
694 | 351 function = (IO$_READLBLK | IO$M_EXTEND); |
352 status = sys$qiow(0, iochan, function, &iosb, 0, 0, | |
775 | 353 inbuf, nbytes-1, 0, 0, &itmlst, sizeof(itmlst)); |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
354 len = strlen(inbuf); // how many chars we got? |
694 | 355 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
356 // read immediately the rest in the IO queue |
694 | 357 function = (IO$_READLBLK | IO$M_TIMED | IO$M_ESCAPE | IO$M_NOECHO | IO$M_NOFILTR); |
358 status = sys$qiow(0, iochan, function, &iosb, 0, 0, | |
775 | 359 inbuf+len, nbytes-1-len, 0, 0, 0, 0); |
694 | 360 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
361 len = strlen(inbuf); // return the total length |
694 | 362 |
7 | 363 return len; |
364 } | |
365 | |
366 /* | |
367 * vms_wproc() is called for each matching filename by decc$to_vms(). | |
368 * We want to save each match for later retrieval. | |
369 * | |
370 * Returns: 1 - continue finding matches | |
1197 | 371 * 0 - stop trying to find any further matches |
7 | 372 */ |
373 static int | |
374 vms_wproc(char *name, int val) | |
375 { | |
376 int i; | |
377 static int vms_match_alloced = 0; | |
378 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
379 if (val == DECC$K_FOREIGN ) // foreign non VMS files are not counting |
7 | 380 return 1; |
381 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
382 // accept all DECC$K_FILE and DECC$K_DIRECTORY |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
383 if (vms_match_num == 0) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
384 { |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
385 // first time through, setup some things |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
386 if (NULL == vms_fmatch) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
387 { |
18761
e3785af3ba0f
patch 8.1.2370: build problems on VMS
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
388 vms_fmatch = ALLOC_MULT(char_u *, EXPL_ALLOC_INC); |
7 | 389 if (!vms_fmatch) |
390 return 0; | |
391 vms_match_alloced = EXPL_ALLOC_INC; | |
392 vms_match_free = EXPL_ALLOC_INC; | |
393 } | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
394 else |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
395 { |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
396 // re-use existing space |
7 | 397 vms_match_free = vms_match_alloced; |
398 } | |
399 } | |
400 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
401 // make matches look uniform |
7 | 402 vms_remove_version(name); |
5704 | 403 name=vms_tolower(name); |
7 | 404 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
405 // if name already exists, don't add it |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
406 for (i = 0; i<vms_match_num; i++) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
407 { |
7 | 408 if (0 == STRCMP((char_u *)name,vms_fmatch[i])) |
409 return 1; | |
410 } | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
411 if (--vms_match_free == 0) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
412 { |
18765
1130f8309f67
patch 8.1.2372: VMS: failing realloc leaks memory
Bram Moolenaar <Bram@vim.org>
parents:
18761
diff
changeset
|
413 char_u **old_vms_fmatch = vms_fmatch; |
1130f8309f67
patch 8.1.2372: VMS: failing realloc leaks memory
Bram Moolenaar <Bram@vim.org>
parents:
18761
diff
changeset
|
414 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
415 // add more space to store matches |
7 | 416 vms_match_alloced += EXPL_ALLOC_INC; |
18765
1130f8309f67
patch 8.1.2372: VMS: failing realloc leaks memory
Bram Moolenaar <Bram@vim.org>
parents:
18761
diff
changeset
|
417 vms_fmatch = vim_realloc(old_vms_fmatch, |
7 | 418 sizeof(char **) * vms_match_alloced); |
419 if (!vms_fmatch) | |
18765
1130f8309f67
patch 8.1.2372: VMS: failing realloc leaks memory
Bram Moolenaar <Bram@vim.org>
parents:
18761
diff
changeset
|
420 { |
1130f8309f67
patch 8.1.2372: VMS: failing realloc leaks memory
Bram Moolenaar <Bram@vim.org>
parents:
18761
diff
changeset
|
421 vim_free(old_vms_fmatch); |
7 | 422 return 0; |
18765
1130f8309f67
patch 8.1.2372: VMS: failing realloc leaks memory
Bram Moolenaar <Bram@vim.org>
parents:
18761
diff
changeset
|
423 } |
7 | 424 vms_match_free = EXPL_ALLOC_INC; |
425 } | |
426 vms_fmatch[vms_match_num] = vim_strsave((char_u *)name); | |
427 | |
428 ++vms_match_num; | |
429 return 1; | |
430 } | |
431 | |
432 /* | |
433 * mch_expand_wildcards this code does wild-card pattern | |
434 * matching NOT using the shell | |
435 * | |
1698 | 436 * return OK for success, FAIL for error (you may lose some |
7 | 437 * memory) and put an error message in *file. |
438 * | |
439 * num_pat number of input patterns | |
440 * pat array of pointers to input patterns | |
441 * num_file pointer to number of matched file names | |
442 * file pointer to array of pointers to matched file names | |
443 * | |
444 */ | |
445 int | |
446 mch_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file, int flags) | |
447 { | |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
1738
diff
changeset
|
448 int i, cnt = 0; |
7 | 449 char_u buf[MAXPATHL]; |
5704 | 450 char *result; |
7 | 451 int dir; |
452 int files_alloced, files_free; | |
453 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
454 *num_file = 0; // default: no files found |
7 | 455 files_alloced = EXPL_ALLOC_INC; |
456 files_free = EXPL_ALLOC_INC; | |
18761
e3785af3ba0f
patch 8.1.2370: build problems on VMS
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
457 *file = ALLOC_MULT(char_u *, files_alloced); |
7 | 458 if (*file == NULL) |
459 { | |
460 *num_file = 0; | |
461 return FAIL; | |
462 } | |
463 for (i = 0; i < num_pat; i++) | |
464 { | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
465 // expand environment var or home dir |
7 | 466 if (vim_strchr(pat[i],'$') || vim_strchr(pat[i],'~')) |
467 expand_env(pat[i],buf,MAXPATHL); | |
468 else | |
469 STRCPY(buf,pat[i]); | |
470 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
471 vms_match_num = 0; // reset collection counter |
5704 | 472 result = decc$translate_vms(vms_fixfilename(buf)); |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
473 if ( (int) result == 0 || (int) result == -1 ) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
474 { |
5704 | 475 cnt = 0; |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
476 } |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
477 else |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
478 { |
5704 | 479 cnt = decc$to_vms(result, vms_wproc, 1 /*allow wild*/ , (flags & EW_DIR ? 0:1 ) /*allow directory*/) ; |
480 } | |
7 | 481 if (cnt > 0) |
482 cnt = vms_match_num; | |
483 | |
484 if (cnt < 1) | |
485 continue; | |
486 | |
487 for (i = 0; i < cnt; i++) | |
488 { | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
489 // files should exist if expanding interactively |
7 | 490 if (!(flags & EW_NOTFOUND) && mch_getperm(vms_fmatch[i]) < 0) |
491 continue; | |
715 | 492 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
493 // do not include directories |
7 | 494 dir = (mch_isdir(vms_fmatch[i])); |
495 if (( dir && !(flags & EW_DIR)) || (!dir && !(flags & EW_FILE))) | |
496 continue; | |
715 | 497 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
498 // Skip files that are not executable if we check for that. |
6695 | 499 if (!dir && (flags & EW_EXEC) |
500 && !mch_can_exe(vms_fmatch[i], NULL, !(flags & EW_SHELLCMD))) | |
715 | 501 continue; |
502 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
503 // allocate memory for pointers |
7 | 504 if (--files_free < 1) |
505 { | |
18765
1130f8309f67
patch 8.1.2372: VMS: failing realloc leaks memory
Bram Moolenaar <Bram@vim.org>
parents:
18761
diff
changeset
|
506 char_u **old_file = *file; |
1130f8309f67
patch 8.1.2372: VMS: failing realloc leaks memory
Bram Moolenaar <Bram@vim.org>
parents:
18761
diff
changeset
|
507 |
7 | 508 files_alloced += EXPL_ALLOC_INC; |
18765
1130f8309f67
patch 8.1.2372: VMS: failing realloc leaks memory
Bram Moolenaar <Bram@vim.org>
parents:
18761
diff
changeset
|
509 *file = vim_realloc(old_file, sizeof(char_u **) * files_alloced); |
7 | 510 if (*file == NULL) |
511 { | |
18765
1130f8309f67
patch 8.1.2372: VMS: failing realloc leaks memory
Bram Moolenaar <Bram@vim.org>
parents:
18761
diff
changeset
|
512 vim_free(old_file); |
7 | 513 *file = (char_u **)""; |
514 *num_file = 0; | |
515 return(FAIL); | |
516 } | |
517 files_free = EXPL_ALLOC_INC; | |
518 } | |
519 | |
520 (*file)[*num_file++] = vms_fmatch[i]; | |
521 } | |
522 } | |
523 return OK; | |
524 } | |
525 | |
526 int | |
527 mch_expandpath(garray_T *gap, char_u *path, int flags) | |
528 { | |
529 int i,cnt = 0; | |
5704 | 530 char *result; |
7 | 531 |
5704 | 532 vms_match_num = 0; |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
533 // the result from the decc$translate_vms needs to be handled |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
534 // otherwise it might create ACCVIO error in decc$to_vms |
5704 | 535 result = decc$translate_vms(vms_fixfilename(path)); |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
536 if ( (int) result == 0 || (int) result == -1 ) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
537 { |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
538 cnt = 0; |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
539 } |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
540 else |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
541 { |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
542 cnt = decc$to_vms(result, vms_wproc, 1 /*allow_wild*/, (flags & EW_DIR ? 0:1 ) /*allow directory*/); |
5704 | 543 } |
7 | 544 if (cnt > 0) |
545 cnt = vms_match_num; | |
546 for (i = 0; i < cnt; i++) | |
547 { | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
548 if (mch_getperm(vms_fmatch[i]) >= 0) // add existing file |
7 | 549 addfile(gap, vms_fmatch[i], flags); |
550 } | |
551 return cnt; | |
552 } | |
553 | |
554 /* | |
555 * attempt to translate a mixed unix-vms file specification to pure vms | |
556 */ | |
557 static void | |
558 vms_unix_mixed_filespec(char *in, char *out) | |
559 { | |
560 char *lastcolon; | |
561 char *end_of_dir; | |
562 char ch; | |
563 int len; | |
5704 | 564 char *out_str=out; |
7 | 565 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
566 // copy vms filename portion up to last colon |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
567 // (node and/or disk) |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
568 lastcolon = strrchr(in, ':'); // find last colon |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
569 if (lastcolon != NULL) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
570 { |
7 | 571 len = lastcolon - in + 1; |
572 strncpy(out, in, len); | |
573 out += len; | |
574 in += len; | |
575 } | |
576 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
577 end_of_dir = NULL; // default: no directory |
7 | 578 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
579 // start of directory portion |
7 | 580 ch = *in; |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
581 if ((ch == '[') || (ch == '/') || (ch == '<')) // start of directory(s) ? |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
582 { |
7 | 583 ch = '['; |
584 SKIP_FOLLOWING_SLASHES(in); | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
585 } |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
586 else if (EQN(in, "../", 3)) // Unix parent directory? |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
587 { |
7 | 588 *out++ = '['; |
589 *out++ = '-'; | |
590 end_of_dir = out; | |
591 ch = '.'; | |
592 in += 2; | |
593 SKIP_FOLLOWING_SLASHES(in); | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
594 } |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
595 else |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
596 { // not a special character |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
597 while (EQN(in, "./", 2)) // Ignore Unix "current dir" |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
598 { |
7 | 599 in += 2; |
600 SKIP_FOLLOWING_SLASHES(in); | |
601 } | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
602 if (strchr(in, '/') == NULL) // any more Unix directories ? |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
603 { |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
604 strcpy(out, in); // No - get rest of the spec |
7 | 605 return; |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
606 } |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
607 else |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
608 { |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
609 *out++ = '['; // Yes, denote a Vms subdirectory |
7 | 610 ch = '.'; |
611 --in; | |
612 } | |
613 } | |
614 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
615 // if we get here, there is a directory part of the filename |
7 | 616 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
617 // initialize output file spec |
7 | 618 *out++ = ch; |
619 ++in; | |
620 | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
621 while (*in != '\0') |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
622 { |
7 | 623 ch = *in; |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
624 if ((ch == ']') || (ch == '/') || (ch == '>') ) // end of (sub)directory ? |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
625 { |
7 | 626 end_of_dir = out; |
627 ch = '.'; | |
628 SKIP_FOLLOWING_SLASHES(in); | |
629 } | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
630 else if (EQN(in, "../", 3)) // Unix parent directory? |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
631 { |
7 | 632 *out++ = '-'; |
633 end_of_dir = out; | |
634 ch = '.'; | |
635 in += 2; | |
636 SKIP_FOLLOWING_SLASHES(in); | |
637 } | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
638 else |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
639 { |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
640 while (EQN(in, "./", 2)) // Ignore Unix "current dir" |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
641 { |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
642 end_of_dir = out; |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
643 in += 2; |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
644 SKIP_FOLLOWING_SLASHES(in); |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
645 ch = *in; |
7 | 646 } |
647 } | |
648 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
649 // Place next character into output file spec |
7 | 650 *out++ = ch; |
651 ++in; | |
652 } | |
653 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
654 *out = '\0'; // Terminate output file spec |
7 | 655 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
656 if (end_of_dir != NULL) // Terminate directory portion |
7 | 657 *end_of_dir = ']'; |
658 } | |
659 | |
660 /* | |
661 * for decc$to_vms in vms_fixfilename | |
662 */ | |
663 static int | |
664 vms_fspec_proc(char *fil, int val) | |
665 { | |
666 strcpy(Fspec_Rms,fil); | |
667 return(1); | |
668 } | |
669 | |
670 /* | |
671 * change unix and mixed filenames to VMS | |
672 */ | |
673 void * | |
674 vms_fixfilename(void *instring) | |
675 { | |
676 static char *buf = NULL; | |
677 static size_t buflen = 0; | |
678 size_t len; | |
679 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
680 // get a big-enough buffer |
7 | 681 len = strlen(instring) + 1; |
682 if (len > buflen) | |
683 { | |
684 buflen = len + 128; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
685 buf = vim_realloc(buf, buflen * sizeof(char)); |
7 | 686 } |
687 | |
688 #ifdef DEBUG | |
689 char *tmpbuf = NULL; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
690 tmpbuf = ALLOC_MULT(char, buflen); |
7 | 691 strcpy(tmpbuf, instring); |
692 #endif | |
693 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
694 Fspec_Rms = buf; // for decc$to_vms |
7 | 695 |
1121 | 696 if (strchr(instring,'/') == NULL) |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
697 // It is already a VMS file spec |
7 | 698 strcpy(buf, instring); |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
699 else if (strchr(instring,'"') == NULL) // password in the path? |
1121 | 700 { |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
701 // Seems it is a regular file, let guess that it is pure Unix fspec |
28844
c0403cd5ca06
patch 8.2.4945: inconsistent use of white space
Bram Moolenaar <Bram@vim.org>
parents:
23503
diff
changeset
|
702 if ( (strchr(instring,'[') == NULL) && (strchr(instring,'<') == NULL) && |
23503
49d866e9b439
patch 8.2.2294: VMS: a few remaining problems
Bram Moolenaar <Bram@vim.org>
parents:
20439
diff
changeset
|
703 (strchr(instring,']') == NULL) && (strchr(instring,'>') == NULL) && |
49d866e9b439
patch 8.2.2294: VMS: a few remaining problems
Bram Moolenaar <Bram@vim.org>
parents:
20439
diff
changeset
|
704 (strchr(instring,':') == NULL) ) |
49d866e9b439
patch 8.2.2294: VMS: a few remaining problems
Bram Moolenaar <Bram@vim.org>
parents:
20439
diff
changeset
|
705 { |
49d866e9b439
patch 8.2.2294: VMS: a few remaining problems
Bram Moolenaar <Bram@vim.org>
parents:
20439
diff
changeset
|
706 // It must be a truly unix fspec |
49d866e9b439
patch 8.2.2294: VMS: a few remaining problems
Bram Moolenaar <Bram@vim.org>
parents:
20439
diff
changeset
|
707 decc$to_vms(instring, vms_fspec_proc, 0, 0); |
49d866e9b439
patch 8.2.2294: VMS: a few remaining problems
Bram Moolenaar <Bram@vim.org>
parents:
20439
diff
changeset
|
708 } |
49d866e9b439
patch 8.2.2294: VMS: a few remaining problems
Bram Moolenaar <Bram@vim.org>
parents:
20439
diff
changeset
|
709 else |
49d866e9b439
patch 8.2.2294: VMS: a few remaining problems
Bram Moolenaar <Bram@vim.org>
parents:
20439
diff
changeset
|
710 { |
49d866e9b439
patch 8.2.2294: VMS: a few remaining problems
Bram Moolenaar <Bram@vim.org>
parents:
20439
diff
changeset
|
711 // It is a mixed fspec |
7 | 712 vms_unix_mixed_filespec(instring, buf); |
23503
49d866e9b439
patch 8.2.2294: VMS: a few remaining problems
Bram Moolenaar <Bram@vim.org>
parents:
20439
diff
changeset
|
713 } |
7 | 714 } |
715 else | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
716 // we have a password in the path |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
717 // decc$ functions can not handle |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
718 // this is our only hope to resolv |
7 | 719 vms_unix_mixed_filespec(instring, buf); |
720 | |
721 return buf; | |
722 } | |
1121 | 723 |
7 | 724 /* |
725 * Remove version number from file name | |
726 * we need it in some special cases as: | |
727 * creating swap file name and writing new file | |
728 */ | |
729 void | |
730 vms_remove_version(void * fname) | |
731 { | |
732 char_u *cp; | |
733 char_u *fp; | |
734 | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
735 if ((cp = vim_strchr( fname, ';')) != NULL) // remove version |
7 | 736 *cp = '\0'; |
737 else if ((cp = vim_strrchr( fname, '.')) != NULL ) | |
738 { | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
739 if ((fp = vim_strrchr( fname, ']')) != NULL ) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
740 {;} |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
741 else if ((fp = vim_strrchr( fname, '>')) != NULL ) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
742 {;} |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
743 else |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
744 fp = fname; |
7 | 745 |
746 while ( *fp != '\0' && fp < cp ) | |
747 if ( *fp++ == '.' ) | |
748 *cp = '\0'; | |
749 } | |
750 return ; | |
751 } | |
5541 | 752 |
753 struct typeahead_st { | |
754 unsigned short numchars; | |
755 unsigned char firstchar; | |
756 unsigned char reserved0; | |
757 unsigned long reserved1; | |
758 } typeahead; | |
759 | |
760 /* | |
761 * Wait "msec" msec until a character is available from file descriptor "fd". | |
762 * "msec" == 0 will check for characters once. | |
763 * "msec" == -1 will block until a character is available. | |
764 */ | |
765 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
766 RealWaitForChar( |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
767 int fd UNUSED, // always read from iochan |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
768 long msec, |
10328
299f1669c20e
commit https://github.com/vim/vim/commit/de5e2c219b99895445fb75ae3541ee69282a5846
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
769 int *check_for_gpm UNUSED, |
299f1669c20e
commit https://github.com/vim/vim/commit/de5e2c219b99895445fb75ae3541ee69282a5846
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
770 int *interrupted) |
5541 | 771 { |
772 int status; | |
773 struct _generic_64 time_curr; | |
774 struct _generic_64 time_diff; | |
775 struct _generic_64 time_out; | |
776 unsigned int convert_operation = LIB$K_DELTA_SECONDS_F; | |
5704 | 777 float sec =(float) msec/1000; |
5541 | 778 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
779 // make sure the iochan is set |
5541 | 780 if (!iochan) |
781 get_tty(); | |
782 | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
783 if (sec > 0) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
784 { |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
785 // time-out specified; convert it to absolute time |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
786 // sec>0 requirement of lib$cvtf_to_internal_time() |
5541 | 787 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
788 // get current time (number of 100ns ticks since the VMS Epoch) |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
789 status = sys$gettim(&time_curr); |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
790 if (status != SS$_NORMAL) |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
791 return 0; // error |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
792 // construct the delta time |
5704 | 793 #if __G_FLOAT==0 |
794 # ifndef VAX | |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
795 // IEEE is default on IA64, but can be used on Alpha too - but not on VAX |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
796 status = lib$cvts_to_internal_time( |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
797 &convert_operation, &sec, &time_diff); |
5704 | 798 # endif |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
799 #else // default on Alpha and VAX |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
800 status = lib$cvtf_to_internal_time( |
5704 | 801 &convert_operation, &sec, &time_diff); |
802 #endif | |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
803 if (status != LIB$_NORMAL) |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
804 return 0; // error |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
805 // add them up |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
806 status = lib$add_times( |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
807 &time_curr, |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
808 &time_diff, |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
809 &time_out); |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
810 if (status != LIB$_NORMAL) |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
811 return 0; // error |
5541 | 812 } |
813 | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
814 while (TRUE) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
815 { |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
816 // select() |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
817 status = sys$qiow(0, iochan, IO$_SENSEMODE | IO$M_TYPEAHDCNT, iosb, |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
818 0, 0, &typeahead, 8, 0, 0, 0, 0); |
5541 | 819 if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
820 return 0; // error |
5541 | 821 |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
822 if (typeahead.numchars) |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
823 return 1; // ready to read |
5541 | 824 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
825 // there's nothing to read; what now? |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
826 if (msec == 0) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
827 { |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
828 // immediate time-out; return impatiently |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
829 return 0; |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
830 } |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
831 else if (msec < 0) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
832 { |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
833 // no time-out; wait on indefinitely |
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
834 return 1; // fakeout to force a wait in vms_read() |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
835 } |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
836 else |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
28844
diff
changeset
|
837 { |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
838 // time-out needs to be checked |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
839 status = sys$gettim(&time_curr); |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
840 if (status != SS$_NORMAL) |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
841 return 0; // error |
5541 | 842 |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
843 status = lib$sub_times( |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
844 &time_out, |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
845 &time_curr, |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
846 &time_diff); |
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
847 if (status != LIB$_NORMAL) |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
848 return 0; // error, incl. time_diff < 0 (i.e. time-out) |
5541 | 849 |
18810
44b855153d8e
patch 8.1.2393: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18765
diff
changeset
|
850 // otherwise wait some more |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
851 } |
5541 | 852 } |
853 } |