annotate src/os_amiga.c @ 16593:2181d6152fd1

Added tag v8.1.1299 for changeset 80bb4ce2a281bb9431a471343daeb272c07d3ddf
author Bram Moolenaar <Bram@vim.org>
date Wed, 08 May 2019 20:30:05 +0200
parents 639b8318472c
children ef00b6bc186b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 10025
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * os_amiga.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 * Amiga system-dependent routines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 #ifdef Window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 # undef Window /* Amiga has its own Window definition */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 #undef TRUE /* will be redefined by exec/types.h */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 #undef FALSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24
3927
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
25 /* cproto fails on missing include files, skip them */
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
26 #ifndef PROTO
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
27
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 #ifndef LATTICE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 # include <exec/types.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 # include <exec/exec.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 # include <libraries/dos.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 # include <intuition/intuition.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
35 /* XXX These are included from os_amiga.h
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
36 #include <proto/exec.h>
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
37 #include <proto/dos.h>
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
38 #include <proto/intuition.h>
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
39 */
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
40
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 #include <exec/memory.h>
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
42 #include <libraries/dosextens.h>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 #include <dos/dostags.h> /* for 2.0 functions */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 #include <dos/dosasl.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
47 /* From version 4 of AmigaOS, several system structures must be allocated
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
48 * and freed using system functions. "struct AnchorPath" is one.
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
49 */
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
50 #ifdef __amigaos4__
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
51 # include <dos/anchorpath.h>
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
52 # define free_fib(x) FreeDosObject(DOS_FIB, x)
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
53 #else
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
54 # define free_fib(x) vim_free(fib)
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
55 #endif
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
56
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 #if defined(LATTICE) && !defined(SASC) && defined(FEAT_ARP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 # include <libraries/arp_pragmas.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
3927
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
61 #endif /* PROTO */
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
62
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 * At this point TRUE and FALSE are defined as 1L and 0L, but we want 1 and 0.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 #undef TRUE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 #define TRUE (1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 #undef FALSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 #define FALSE (0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
71 #ifdef __amigaos4__
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
72 # define dos_packet(a, b, c) DoPkt(a, b, c, 0, 0, 0, 0)
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
73 #elif !defined(AZTEC_C) && !defined(__AROS__)
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 6695
diff changeset
74 static long dos_packet(struct MsgPort *, long, long);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 #endif
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 6695
diff changeset
76 static int lock2name(BPTR lock, char_u *buf, long len);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 6695
diff changeset
77 static void out_num(long n);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 6695
diff changeset
78 static struct FileInfoBlock *get_fib(char_u *);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 6695
diff changeset
79 static int sortcmp(const void *a, const void *b);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 static BPTR raw_in = (BPTR)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 static BPTR raw_out = (BPTR)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 static int close_win = FALSE; /* set if Vim opened the window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
85 #ifndef __amigaos4__ /* Use autoopen for AmigaOS4 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 struct IntuitionBase *IntuitionBase = NULL;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
87 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 struct ArpBase *ArpBase = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 static struct Window *wb_window;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 static char_u *oldwindowtitle = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 int dos2 = FALSE; /* Amiga DOS 2.0x or higher */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 int size_set = FALSE; /* set to TRUE if window size was set */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
101 win_resize_on(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 OUT_STR_NF("\033[12{");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
107 win_resize_off(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 OUT_STR_NF("\033[12}");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
113 mch_write(char_u *p, int len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 Write(raw_out, (char *)p, (long)len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 /*
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3927
diff changeset
119 * mch_inchar(): low level input function.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 * Get a characters from the keyboard.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 * If time == 0 do not wait for characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 * If time == n wait a short time for characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 * If time == -1 wait forever for characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 * Return number of characters read.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
128 mch_inchar(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
129 char_u *buf,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
130 int maxlen,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
131 long time, /* milli seconds */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
132 int tb_change_cnt)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 long utime;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 if (time >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 if (time == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 utime = 100L; /* time = 0 causes problems in DOS 1.2 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 utime = time * 1000L; /* convert from milli to micro secs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 if (WaitForChar(raw_in, utime) == 0) /* no character available */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 else /* time == -1 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 * If there is no character available within 2 seconds (default)
208
f922db5a1fb3 updated for version 7.0060
vimboss
parents: 39
diff changeset
150 * write the autoscript file to disk. Or cause the CursorHold event
f922db5a1fb3 updated for version 7.0060
vimboss
parents: 39
diff changeset
151 * to be triggered.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 */
208
f922db5a1fb3 updated for version 7.0060
vimboss
parents: 39
diff changeset
153 if (WaitForChar(raw_in, p_ut * 1000L) == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 {
610
cd3689efd90a updated for version 7.0173
vimboss
parents: 419
diff changeset
155 if (trigger_cursorhold() && maxlen >= 3)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 {
208
f922db5a1fb3 updated for version 7.0060
vimboss
parents: 39
diff changeset
157 buf[0] = K_SPECIAL;
f922db5a1fb3 updated for version 7.0060
vimboss
parents: 39
diff changeset
158 buf[1] = KS_EXTRA;
f922db5a1fb3 updated for version 7.0060
vimboss
parents: 39
diff changeset
159 buf[2] = (int)KE_CURSORHOLD;
f922db5a1fb3 updated for version 7.0060
vimboss
parents: 39
diff changeset
160 return 3;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 }
371
4b9fef49d7ff updated for version 7.0095
vimboss
parents: 208
diff changeset
162 before_blocking();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 for (;;) /* repeat until we got a character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 len = Read(raw_in, (char *)buf, (long)maxlen / input_conv.vc_factor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 if (len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 /* Convert from 'termencoding' to 'encoding'. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 if (input_conv.vc_type != CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 len = convert_input(buf, len, maxlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 return len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 * return non-zero if a character is available
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
183 mch_char_avail(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 return (WaitForChar(raw_in, 100L) != 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 /*
3634
286ba0251c0a updated for version 7.3.577
Bram Moolenaar <bram@vim.org>
parents: 3143
diff changeset
189 * Return amount of memory still available in Kbyte.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 long_u
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
192 mch_avail_mem(int special)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 {
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
194 #ifdef __amigaos4__
3634
286ba0251c0a updated for version 7.3.577
Bram Moolenaar <bram@vim.org>
parents: 3143
diff changeset
195 return (long_u)AvailMem(MEMF_ANY) >> 10;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
196 #else
3634
286ba0251c0a updated for version 7.3.577
Bram Moolenaar <bram@vim.org>
parents: 3143
diff changeset
197 return (long_u)(AvailMem(special ? (long)MEMF_CHIP : (long)MEMF_ANY)) >> 10;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
198 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
201 /*
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
202 * Waits a specified amount of time, or until input arrives if
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
203 * ignoreinput is FALSE.
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
204 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
206 mch_delay(long msec, int ignoreinput)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 {
1228
5eb1ac6f92ad updated for version 7.1b
vimboss
parents: 1030
diff changeset
208 #ifndef LATTICE /* SAS declares void Delay(ULONG) */
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 6695
diff changeset
209 void Delay(long);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 if (msec > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 if (ignoreinput)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 Delay(msec / 20L); /* Delay works with 20 msec intervals */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 WaitForChar(raw_in, msec * 1000L);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 * We have no job control, fake it by starting a new shell.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
225 mch_suspend(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 suspend_shell();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 #ifndef DOS_LIBRARY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 # define DOS_LIBRARY ((UBYTE *)"dos.library")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
235 mch_init(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 static char intlibname[] = "intuition.library";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 #ifdef AZTEC_C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 Enable_Abort = 0; /* disallow vim to be aborted */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 Columns = 80;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 Rows = 24;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 * Set input and output channels, unless we have opened our own window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 if (raw_in == (BPTR)NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 raw_in = Input();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 raw_out = Output();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 * If Input() is not interactive, then Output() will be (because of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 * check in mch_check_win()). Used for "Vim -".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 * Also check the other way around, for "Vim -h | more".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 if (!IsInteractive(raw_in))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 raw_in = raw_out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 else if (!IsInteractive(raw_out))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 raw_out = raw_in;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 wb_window = NULL;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
266 #ifndef __amigaos4__
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 if ((IntuitionBase = (struct IntuitionBase *)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 OpenLibrary((UBYTE *)intlibname, 0L)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 mch_errmsg(_("cannot open "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 mch_errmsg(intlibname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 mch_errmsg("!?\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 mch_exit(3);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 }
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
275 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277
3927
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
278 #ifndef PROTO
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
279 # include <workbench/startup.h>
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
280 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 * Check_win checks whether we have an interactive window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 * If not, a new window is opened with the newcli command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 * If we would open a window ourselves, the :sh and :! commands would not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 * work properly (Why? probably because we are then running in a background
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 * CLI). This also is the best way to assure proper working in a next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 * Workbench release.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 * For the -f option (foreground mode) we open our own window and disable :sh.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 * Otherwise the calling program would never know when editing is finished.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 #define BUF2SIZE 320 /* length of buffer for argument with complete path */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
296 mch_check_win(int argc, char **argv)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 BPTR nilfh, fh;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
300 char_u buf1[24];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 char_u buf2[BUF2SIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 static char_u *(constrings[3]) = {(char_u *)"con:0/0/662/210/",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 (char_u *)"con:0/0/640/200/",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 (char_u *)"con:0/0/320/200/"};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 static char_u *winerr = (char_u *)N_("VIM: Can't open window!\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 struct WBArg *argp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 int ac;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 char *av;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 char_u *device = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 int exitval = 4;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
311 #ifndef __amigaos4__
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 struct Library *DosBase;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
313 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 int usewin = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 * check if we are running under DOS 2.0x or higher
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 */
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
319 #ifndef __amigaos4__
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 DosBase = OpenLibrary(DOS_LIBRARY, 37L);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 if (DosBase != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 /* if (((struct Library *)DOSBase)->lib_Version >= 37) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 CloseLibrary(DosBase);
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
325 # ifdef FEAT_ARP
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 dos2 = TRUE;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
327 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 else /* without arp functions we NEED 2.0 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 {
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
331 # ifndef FEAT_ARP
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 mch_errmsg(_("Need Amigados version 2.04 or later\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 exit(3);
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
334 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 /* need arp functions for dos 1.x */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 if (!(ArpBase = (struct ArpBase *) OpenLibrary((UBYTE *)ArpName, ArpVersion)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 fprintf(stderr, _("Need %s version %ld\n"), ArpName, ArpVersion);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 exit(3);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 }
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
341 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 }
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
343 #endif /* __amigaos4__ */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 * scan argv[] for the "-f" and "-d" arguments
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 for (i = 1; i < argc; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 if (argv[i][0] == '-')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 switch (argv[i][1])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 case 'f':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 usewin = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 case 'd':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 if (i < argc - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 /* require using "-dev", "-d" means diff mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 && argv[i][2] == 'e' && argv[i][3] == 'v'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 device = (char_u *)argv[i + 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 * If we were not started from workbench, do not have a "-d" or "-dev"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 * argument and we have been started with an interactive window, use that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 * window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 if (argc != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 && device == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 && (IsInteractive(Input()) || IsInteractive(Output())))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 * When given the "-f" argument, we open our own window. We can't use the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 * newcli trick below, because the calling program (mail, rn, etc.) would not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 * know when we are finished.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 if (usewin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 * Try to open a window. First try the specified device.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 * Then try a 24 line 80 column window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 * If that fails, try two smaller ones.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 for (i = -1; i < 3; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 if (i >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 device = constrings[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 if (device != NULL && (raw_in = Open((UBYTE *)device,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 (long)MODE_NEWFILE)) != (BPTR)NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 if (raw_in == (BPTR)NULL) /* all three failed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 mch_errmsg(_(winerr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 goto exit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 raw_out = raw_in;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 close_win = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 if ((nilfh = Open((UBYTE *)"NIL:", (long)MODE_NEWFILE)) == (BPTR)NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 mch_errmsg(_("Cannot open NIL:\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 goto exit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 * Make a unique name for the temp file (which we will not delete!).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 * Use a pointer on the stack (nobody else will be using it).
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
418 * Under AmigaOS4, this assumption might change in the future, so
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
419 * we use a pointer to the current task instead. This should be a
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
420 * shared structure and thus globally unique.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 */
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
422 #ifdef __amigaos4__
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
423 sprintf((char *)buf1, "t:nc%p", FindTask(0));
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
424 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 sprintf((char *)buf1, "t:nc%ld", (long)buf1);
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
426 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 if ((fh = Open((UBYTE *)buf1, (long)MODE_NEWFILE)) == (BPTR)NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 mch_errmsg(_("Cannot create "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 mch_errmsg((char *)buf1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 mch_errmsg("\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 goto exit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 * Write the command into the file, put quotes around the arguments that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 * have a space in them.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 if (argc == 0) /* run from workbench */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 ac = ((struct WBStartup *)argv)->sm_NumArgs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 ac = argc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 for (i = 0; i < ac; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 if (argc == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 *buf2 = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 argp = &(((struct WBStartup *)argv)->sm_ArgList[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 if (argp->wa_Lock)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 (void)lock2name(argp->wa_Lock, buf2, (long)(BUF2SIZE - 1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 if (dos2) /* use 2.0 function */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 AddPart((UBYTE *)buf2, (UBYTE *)argp->wa_Name, (long)(BUF2SIZE - 1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 else /* use arp function */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 TackOn((char *)buf2, argp->wa_Name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 av = (char *)buf2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 av = argv[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 /* skip '-d' or "-dev" option */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 if (av[0] == '-' && av[1] == 'd'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 && av[2] == 'e' && av[3] == 'v'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 ++i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 if (vim_strchr((char_u *)av, ' '))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 Write(fh, "\"", 1L);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 Write(fh, av, (long)strlen(av));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 if (vim_strchr((char_u *)av, ' '))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 Write(fh, "\"", 1L);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 Write(fh, " ", 1L);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 Write(fh, "\nendcli\n", 8L);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 Close(fh);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 * Try to open a new cli in a window. If "-d" or "-dev" argument was given try
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 * to open the specified device. Then try a 24 line 80 column window. If that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 * fails, try two smaller ones.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 for (i = -1; i < 3; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 if (i >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 device = constrings[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 else if (device == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 sprintf((char *)buf2, "newcli <nil: >nil: %s from %s", (char *)device, (char *)buf1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 if (dos2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 if (!SystemTags((UBYTE *)buf2, SYS_UserShell, TRUE, TAG_DONE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 if (Execute((UBYTE *)buf2, nilfh, nilfh))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 if (i == 3) /* all three failed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 DeleteFile((UBYTE *)buf1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 mch_errmsg(_(winerr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 goto exit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 exitval = 0; /* The Execute succeeded: exit this program */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 exit:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 if (ArpBase)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 CloseLibrary((struct Library *) ArpBase);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 exit(exitval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 /* NOTREACHED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 * Return TRUE if the input comes from a terminal, FALSE otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 * We fake there is a window, because we can always open one!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
533 mch_input_isatty(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 * fname_case(): Set the case of the file name, if it already exists.
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
540 * This will cause the file name to remain exactly the same
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
541 * if the file system ignores, but preserves case.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 /*ARGSUSED*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
545 fname_case(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
546 char_u *name,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
547 int len) /* buffer size, ignored here */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 struct FileInfoBlock *fib;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 size_t flen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 fib = get_fib(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 if (fib != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 flen = STRLEN(name);
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
556 /* TODO: Check if this fix applies to AmigaOS < 4 too.*/
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
557 #ifdef __amigaos4__
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
558 if (fib->fib_DirEntryType == ST_ROOT)
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
559 strcat(fib->fib_FileName, ":");
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
560 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 if (flen == strlen(fib->fib_FileName)) /* safety check */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 mch_memmove(name, fib->fib_FileName, flen);
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
563 free_fib(fib);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 * Get the FileInfoBlock for file "fname"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 * The returned structure has to be free()d.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 * Returns NULL on error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 static struct FileInfoBlock *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
573 get_fib(char_u *fname)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 BPTR flock;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 struct FileInfoBlock *fib;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 if (fname == NULL) /* safety check */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 return NULL;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
580 #ifdef __amigaos4__
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
581 fib = AllocDosObject(DOS_FIB,0);
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
582 #else
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
583 fib = (struct FileInfoBlock *)alloc(sizeof(struct FileInfoBlock));
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
584 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 if (fib != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 flock = Lock((UBYTE *)fname, (long)ACCESS_READ);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 if (flock == (BPTR)NULL || !Examine(flock, fib))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 {
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
590 free_fib(fib); /* in case of an error the memory is freed here */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 fib = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 if (flock)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 UnLock(flock);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 return fib;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 #ifdef FEAT_TITLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 * set the title of our window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 * icon name is not set
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
605 mch_settitle(char_u *title, char_u *icon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 if (wb_window != NULL && title != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 SetWindowTitles(wb_window, (UBYTE *)title, (UBYTE *)-1L);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 * Restore the window/icon title.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 * which is one of:
14479
3375a8cbb442 patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents: 13380
diff changeset
614 * SAVE_RESTORE_TITLE Just restore title
3375a8cbb442 patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents: 13380
diff changeset
615 * SAVE_RESTORE_ICON Just restore icon (which we don't have)
3375a8cbb442 patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents: 13380
diff changeset
616 * SAVE_RESTORE_BOTH Restore title and icon (which we don't have)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
619 mch_restore_title(int which)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 {
14479
3375a8cbb442 patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents: 13380
diff changeset
621 if (which & SAVE_RESTORE_TITLE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 mch_settitle(oldwindowtitle, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
626 mch_can_restore_title(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 return (wb_window != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
632 mch_can_restore_icon(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 * Insert user name in s[len].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
642 mch_get_user_name(char_u *s, int len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 {
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
644 /* TODO: Implement this. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 *s = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 * Insert host name is s[len].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
653 mch_get_host_name(char_u *s, int len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 {
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
655 #if defined(__amigaos4__) && defined(__CLIB2__)
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
656 gethostname(s, len);
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
657 #else
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 371
diff changeset
658 vim_strncpy(s, "Amiga", len - 1);
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
659 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 * return process ID
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 long
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
666 mch_get_pid(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 {
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
668 #ifdef __amigaos4__
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
669 /* This is as close to a pid as we can come. We could use CLI numbers also,
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
670 * but then we would have two different types of process identifiers.
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
671 */
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
672 return((long)FindTask(0));
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
673 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 return (long)0;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
675 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 * Get name of current directory into buffer 'buf' of length 'len' bytes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 * Return OK for success, FAIL for failure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
683 mch_dirname(char_u *buf, int len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 return mch_FullName((char_u *)"", buf, len, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 * get absolute file name into buffer 'buf' of length 'len' bytes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 * return FAIL for failure, OK otherwise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
694 mch_FullName(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
695 char_u *fname,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
696 char_u *buf,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
697 int len,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
698 int force)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 BPTR l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 int retval = FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 /* Lock the file. If it exists, we can get the exact name. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 if ((l = Lock((UBYTE *)fname, (long)ACCESS_READ)) != (BPTR)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 retval = lock2name(l, buf, (long)len - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 UnLock(l);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 else if (force || !mch_isFullName(fname)) /* not a full path yet */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 * If the file cannot be locked (doesn't exist), try to lock the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 * current directory and concatenate the file name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 if ((l = Lock((UBYTE *)"", (long)ACCESS_READ)) != (BPTR)NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 retval = lock2name(l, buf, (long)len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 UnLock(l);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 if (retval == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 i = STRLEN(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 /* Concatenate the fname to the directory. Don't add a slash
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 * if fname is empty, but do change "" to "/". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 if (i == 0 || *fname != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 if (i < len - 1 && (i == 0 || buf[i - 1] != ':'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 buf[i++] = '/';
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 371
diff changeset
729 vim_strncpy(buf + i, fname, len - i - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 if (*buf == 0 || *buf == ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 retval = FAIL; /* something failed; use the file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 * Return TRUE if "fname" does not depend on the current directory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
743 mch_isFullName(char_u *fname)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 return (vim_strchr(fname, ':') != NULL && *fname != ':');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 * Get the full file name from a lock. Use 2.0 function if possible, because
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 * the arp function has more restrictions on the path length.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 * return FAIL for failure, OK otherwise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
755 lock2name(BPTR lock, char_u *buf, long len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 if (dos2) /* use 2.0 function */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 return ((int)NameFromLock(lock, (UBYTE *)buf, len) ? OK : FAIL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 else /* use arp function */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 return ((int)PathName(lock, (char *)buf, (long)(len/32)) ? OK : FAIL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 * get file permissions for 'name'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 * Returns -1 when it doesn't exist.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 long
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
772 mch_getperm(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 struct FileInfoBlock *fib;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 long retval = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 fib = get_fib(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 if (fib != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 retval = fib->fib_Protection;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
781 free_fib(fib);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 * set file permission for 'name' to 'perm'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 * return FAIL for failure, OK otherwise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
792 mch_setperm(char_u *name, long perm)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 perm &= ~FIBF_ARCHIVE; /* reset archived bit */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 return (SetProtection((UBYTE *)name, (long)perm) ? OK : FAIL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 * Set hidden flag for "name".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
802 mch_hide(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 /* can't hide a file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 * return FALSE if "name" is not a directory
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 * return TRUE if "name" is a directory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 * return FALSE for error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
813 mch_isdir(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 struct FileInfoBlock *fib;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 int retval = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 fib = get_fib(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 if (fib != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 {
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
821 #ifdef __amigaos4__
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
822 retval = (FIB_IS_DRAWER(fib)) ? TRUE : FALSE;
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
823 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 retval = ((fib->fib_DirEntryType >= 0) ? TRUE : FALSE);
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
825 #endif
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
826 free_fib(fib);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 * Create directory "name".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 */
982
b00d5f429a4b updated for version 7.0-108
vimboss
parents: 716
diff changeset
834 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
835 mch_mkdir(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 BPTR lock;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 lock = CreateDir(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 if (lock != NULL)
982
b00d5f429a4b updated for version 7.0-108
vimboss
parents: 716
diff changeset
841 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 UnLock(lock);
982
b00d5f429a4b updated for version 7.0-108
vimboss
parents: 716
diff changeset
843 return 0;
b00d5f429a4b updated for version 7.0-108
vimboss
parents: 716
diff changeset
844 }
b00d5f429a4b updated for version 7.0-108
vimboss
parents: 716
diff changeset
845 return -1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 * Return 1 if "name" can be executed, 0 if not.
6695
6529590f6c43 updated for version 7.4.672
Bram Moolenaar <bram@vim.org>
parents: 5782
diff changeset
850 * If "use_path" is FALSE only check if "name" is executable.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 * Return -1 if unknown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
854 mch_can_exe(char_u *name, char_u **path, int use_path)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 * Check what "name" is:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 * NODE_NORMAL: file or directory (or doesn't exist)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 * NODE_WRITABLE: writable device, socket, fifo, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 * NODE_OTHER: non-writable things
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
867 mch_nodetype(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 return NODE_NORMAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
874 mch_early_init(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 * Careful: mch_exit() may be called before mch_init()!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
882 mch_exit(int r)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 {
10835
c9da7f9137af patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Christian Brabandt <cb@256bit.org>
parents: 10240
diff changeset
884 exiting = TRUE;
c9da7f9137af patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Christian Brabandt <cb@256bit.org>
parents: 10240
diff changeset
885
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 if (raw_in) /* put terminal in 'normal' mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 settmode(TMODE_COOK);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 stoptermcap();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 out_char('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 if (raw_out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 if (term_console)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 win_resize_off(); /* window resize events de-activated */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 if (size_set)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 OUT_STR("\233t\233u"); /* reset window size (CSI t CSI u) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 #ifdef FEAT_TITLE
14479
3375a8cbb442 patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents: 13380
diff changeset
904 mch_restore_title(SAVE_RESTORE_BOTH); /* restore window title */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 ml_close_all(TRUE); /* remove all memfiles */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 if (ArpBase)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 CloseLibrary((struct Library *) ArpBase);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 if (close_win)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 Close(raw_in);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 if (r)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 printf(_("Vim exiting with %d\n"), r); /* somehow this makes :cq work!? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 exit(r);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 * This is a routine for setting a given stream to raw or cooked mode on the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 * Amiga . This is useful when you are using Lattice C to produce programs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 * that want to read single characters with the "getch()" or "fgetc" call.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 * Written : 18-Jun-87 By Chuck McManis.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 #define MP(xx) ((struct MsgPort *)((struct FileHandle *) (BADDR(xx)))->fh_Type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 * Function mch_settmode() - Convert the specified file pointer to 'raw' or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 * 'cooked' mode. This only works on TTY's.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 * Raw: keeps DOS from translating keys for you, also (BIG WIN) it means
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 * getch() will return immediately rather than wait for a return. You
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 * lose editing features though.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 *
15034
6e4e0d43b20b patch 8.1.0528: various typos in comments
Bram Moolenaar <Bram@vim.org>
parents: 14479
diff changeset
938 * Cooked: This function returns the designate file pointer to its normal,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 * wait for a <CR> mode. This is exactly like raw() except that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 * it sends a 0 to the console to make it back into a CON: from a RAW:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
943 mch_settmode(int tmode)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 {
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
945 #if defined(__AROS__) || defined(__amigaos4__)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 if (!SetMode(raw_in, tmode == TMODE_RAW ? 1 : 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 if (dos_packet(MP(raw_in), (long)ACTION_SCREEN_MODE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 tmode == TMODE_RAW ? -1L : 0L) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 mch_errmsg(_("cannot change console mode ?!\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 * set screen mode, always fails.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
958 mch_screenmode(char_u *arg)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
960 emsg(_(e_screenmode));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 * Code for this routine came from the following :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 * ConPackets.c - C. Scheppner, A. Finkel, P. Lindsay CBM
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 * DOS packet example
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 * Requires 1.2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 * Found on Fish Disk 56.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 * Heavely modified by mool.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975
3927
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
976 #ifndef PROTO
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
977 # include <devices/conunit.h>
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
978 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 * try to get the real window size
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 * return FAIL for failure, OK otherwise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
985 mch_get_shellsize(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 struct ConUnit *conUnit;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
988 #ifndef __amigaos4__
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 char id_a[sizeof(struct InfoData) + 3];
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
990 #endif
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
991 struct InfoData *id=0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 if (!term_console) /* not an amiga window */
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
994 goto out;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 /* insure longword alignment */
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
997 #ifdef __amigaos4__
3143
314d9368069e updated for version 7.3.342
Bram Moolenaar <bram@vim.org>
parents: 1624
diff changeset
998 if (!(id = AllocDosObject(DOS_INFODATA, 0)))
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
999 goto out;
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1000 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 id = (struct InfoData *)(((long)id_a + 3L) & ~3L);
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1002 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 * Should make console aware of real window size, not the one we set.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 * Unfortunately, under DOS 2.0x this redraws the window and it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 * is rarely needed, so we skip it now, unless we changed the size.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 if (size_set)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 OUT_STR("\233t\233u"); /* CSI t CSI u */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 #ifdef __AROS__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 if (!Info(raw_out, id)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 || (wb_window = (struct Window *) id->id_VolumeNode) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 if (dos_packet(MP(raw_out), (long)ACTION_DISK_INFO, ((ULONG) id) >> 2) == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 || (wb_window = (struct Window *)id->id_VolumeNode) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 /* it's not an amiga window, maybe aux device */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 /* terminal type should be set */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 term_console = FALSE;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1024 goto out;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 if (oldwindowtitle == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 oldwindowtitle = (char_u *)wb_window->Title;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 if (id->id_InUse == (BPTR)NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 mch_errmsg(_("mch_get_shellsize: not a console??\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 conUnit = (struct ConUnit *) ((struct IOStdReq *) id->id_InUse)->io_Unit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 /* get window size */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 Rows = conUnit->cu_YMax + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 Columns = conUnit->cu_XMax + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 if (Rows < 0 || Rows > 200) /* cannot be an amiga window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 Columns = 80;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 Rows = 24;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 term_console = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 return OK;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1047 out:
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1048 #ifdef __amigaos4__
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1049 FreeDosObject(DOS_INFODATA, id); /* Safe to pass NULL */
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1050 #endif
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1051
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1052 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 * Try to set the real window size to Rows and Columns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1059 mch_set_shellsize(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 if (term_console)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 size_set = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 out_char(CSI);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 out_num((long)Rows);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 out_char('t');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 out_char(CSI);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 out_num((long)Columns);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 out_char('u');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 * Rows and/or Columns has changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1078 mch_new_shellsize(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 /* Nothing to do. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 * out_num - output a (big) number fast
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1087 out_num(long n)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 OUT_STR_NF(tltoa((unsigned long)n));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1092 #if !defined(AZTEC_C) && !defined(__AROS__) && !defined(__amigaos4__)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 * Sendpacket.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 * An invaluable addition to your Amiga.lib file. This code sends a packet to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 * the given message port. This makes working around DOS lots easier.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 * Note, I didn't write this, those wonderful folks at CBM did. I do suggest
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 * however that you may wish to add it to Amiga.Lib, to do so, compile it and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 * say 'oml lib:amiga.lib -r sendpacket.o'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103
3927
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
1104 #ifndef PROTO
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 /* #include <proto/exec.h> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 /* #include <proto/dos.h> */
3927
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
1107 # include <exec/memory.h>
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3634
diff changeset
1108 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 * Function - dos_packet written by Phil Lindsay, Carolyn Scheppner, and Andy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 * Finkel. This function will send a packet of the given type to the Message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 * Port supplied.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 static long
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1117 dos_packet(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1118 struct MsgPort *pid, /* process identifier ... (handlers message port) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 long action, /* packet type ... (what you want handler to do) */
10025
068f397d0da4 commit https://github.com/vim/vim/commit/d90b6c02e2900576fb37d95b5e4f4a32b2d7383f
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
1120 long arg) /* single argument */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 struct MsgPort *replyport;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 struct StandardPacket *packet;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 long res1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 if (dos2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 return DoPkt(pid, action, arg, 0L, 0L, 0L, 0L); /* use 2.0 function */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 replyport = (struct MsgPort *) CreatePort(NULL, 0); /* use arp function */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 if (!replyport)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 return (0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 /* Allocate space for a packet, make it public and clear it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 packet = (struct StandardPacket *)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 AllocMem((long) sizeof(struct StandardPacket), MEMF_PUBLIC | MEMF_CLEAR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 if (!packet) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 DeletePort(replyport);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 return (0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 packet->sp_Msg.mn_Node.ln_Name = (char *) &(packet->sp_Pkt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 packet->sp_Pkt.dp_Link = &(packet->sp_Msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 packet->sp_Pkt.dp_Port = replyport;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 packet->sp_Pkt.dp_Type = action;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 packet->sp_Pkt.dp_Arg1 = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 PutMsg(pid, (struct Message *)packet); /* send packet */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 WaitPort(replyport);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 GetMsg(replyport);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 res1 = packet->sp_Pkt.dp_Res1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 FreeMem(packet, (long) sizeof(struct StandardPacket));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 DeletePort(replyport);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 return (res1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 #endif /* !defined(AZTEC_C) && !defined(__AROS__) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 * Call shell.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 * Return error number for failure, 0 otherwise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1169 mch_call_shell(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1170 char_u *cmd,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1171 int options) /* SHELL_*, see vim.h */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 BPTR mydir;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 int tmode = cur_tmode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 #ifdef AZTEC_C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 int use_execute;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 char_u *shellcmd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 char_u *shellarg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 int retval = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 if (close_win)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 /* if Vim opened a window: Executing a shell may cause crashes */
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
1186 emsg(_("E360: Cannot execute shell with -f option"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 if (term_console)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 win_resize_off(); /* window resize events de-activated */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 if (options & SHELL_COOKED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 settmode(TMODE_COOK); /* set to normal mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 mydir = Lock((UBYTE *)"", (long)ACCESS_READ); /* remember current dir */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 #if !defined(AZTEC_C) /* not tested very much */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 if (cmd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 if (dos2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204 x = SystemTags(p_sh, SYS_UserShell, TRUE, TAG_DONE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 x = Execute(p_sh, raw_in, raw_out);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 if (dos2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 x = SystemTags((char *)cmd, SYS_UserShell, TRUE, TAG_DONE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 x = Execute((char *)cmd, 0L, raw_out);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 if ((dos2 && x < 0) || (!dos2 && !x))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 if (x < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
1227 msg_puts(_("Cannot execute "));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 if (cmd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
1230 msg_puts(_("shell "));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 msg_outtrans(p_sh);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 msg_outtrans(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 msg_putchar('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 retval = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 else if (!dos2 || x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 else if (x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 if ((x = IoErr()) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 if (!(options & SHELL_SILENT))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 msg_putchar('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 msg_outnum((long)x);
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
1250 msg_puts(_(" returned\n"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 retval = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 #else /* else part is for AZTEC_C */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 if (p_st >= 4 || (p_st >= 2 && !(options & SHELL_FILTER)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 use_execute = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 use_execute = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 if (!use_execute)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 * separate shell name from argument
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 shellcmd = vim_strsave(p_sh);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 if (shellcmd == NULL) /* out of memory, use Execute */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 use_execute = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 shellarg = skiptowhite(shellcmd); /* find start of arguments */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 if (*shellarg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 *shellarg++ = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 shellarg = skipwhite(shellarg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 if (cmd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 if (use_execute)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 if (dos2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 x = SystemTags((UBYTE *)p_sh, SYS_UserShell, TRUE, TAG_DONE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 x = !Execute((UBYTE *)p_sh, raw_in, raw_out);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 x = fexecl((char *)shellcmd, (char *)shellcmd, (char *)shellarg, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 else if (use_execute)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 if (dos2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 x = SystemTags((UBYTE *)cmd, SYS_UserShell, TRUE, TAG_DONE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 x = !Execute((UBYTE *)cmd, 0L, raw_out);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 else if (p_st & 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 x = fexecl((char *)shellcmd, (char *)shellcmd, (char *)shellarg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 (char *)cmd, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 x = fexecl((char *)shellcmd, (char *)shellcmd, (char *)shellarg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 (char *)p_shcf, (char *)cmd, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 if ((dos2 && x < 0) || (!dos2 && x))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 if (x < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
1317 msg_puts(_("Cannot execute "));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 if (use_execute)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 if (cmd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 msg_outtrans(p_sh);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 msg_outtrans(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
1327 msg_puts(_("shell "));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328 msg_outtrans(shellcmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 msg_putchar('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 retval = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 if (use_execute)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 # ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 if (!dos2 || x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 if (x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 x = IoErr();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 x = wait();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 if (x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 if (!(options & SHELL_SILENT) && !emsg_silent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 msg_putchar('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 msg_outnum((long)x);
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
1352 msg_puts(_(" returned\n"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 retval = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 vim_free(shellcmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 #endif /* AZTEC_C */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 if ((mydir = CurrentDir(mydir)) != 0) /* make sure we stay in the same directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 UnLock(mydir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 if (tmode == TMODE_RAW)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 settmode(TMODE_RAW); /* set to raw mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 #ifdef FEAT_TITLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 resettitle();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 if (term_console)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 win_resize_on(); /* window resize events activated */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 * check for an "interrupt signal"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 * We only react to a CTRL-C, but also clear the other break signals to avoid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 * trouble with lattice-c programs.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 void
10240
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1378 mch_breakcheck(int force)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 if (SetSignal(0L, (long)(SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D|SIGBREAKF_CTRL_E|SIGBREAKF_CTRL_F)) & SIGBREAKF_CTRL_C)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 got_int = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383
15034
6e4e0d43b20b patch 8.1.0528: various typos in comments
Bram Moolenaar <Bram@vim.org>
parents: 14479
diff changeset
1384 /* this routine causes manx to use this Chk_Abort() rather than its own */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 /* otherwise it resets our ^C when doing any I/O (even when Enable_Abort */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 /* is zero). Since we want to check for our own ^C's */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 #ifdef _DCC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 #define Chk_Abort chkabort
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 #ifdef LATTICE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 void __regargs __chkabort(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 void __regargs __chkabort(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 {}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 long
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400 Chk_Abort(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 return(0L);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 * mch_expandpath() - this code does wild-card pattern matching using the arp
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 * routines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 * "pat" has backslashes before chars that are not to be expanded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 * Returns the number of matches found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 * This is based on WildDemo2.c (found in arp1.1 distribution).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 * That code's copyright follows:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415 * Copyright (c) 1987, Scott Ballantyne
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 * Use and abuse as you please.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1419 #ifdef __amigaos4__
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1420 # define ANCHOR_BUF_SIZE 1024
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1421 #else
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1422 # define ANCHOR_BUF_SIZE (512)
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1423 # define ANCHOR_SIZE (sizeof(struct AnchorPath) + ANCHOR_BUF_SIZE)
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1424 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1427 mch_expandpath(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1428 garray_T *gap,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1429 char_u *pat,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1430 int flags) /* EW_* flags */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 struct AnchorPath *Anchor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433 LONG Result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434 char_u *starbuf, *sp, *dp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 int start_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 int matches;
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1437 #ifdef __amigaos4__
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1438 struct TagItem AnchorTags[] = {
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1439 {ADO_Strlen, ANCHOR_BUF_SIZE},
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1440 {ADO_Flags, APF_DODOT|APF_DOWILD|APF_MultiAssigns},
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1441 {TAG_DONE, 0L}
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1442 };
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1443 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 start_len = gap->ga_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 /* Get our AnchorBase */
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1448 #ifdef __amigaos4__
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1449 Anchor = AllocDosObject(DOS_ANCHORPATH, AnchorTags);
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1450 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 Anchor = (struct AnchorPath *)alloc_clear((unsigned)ANCHOR_SIZE);
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1452 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453 if (Anchor == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1456 #ifndef __amigaos4__
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457 Anchor->ap_Strlen = ANCHOR_BUF_SIZE; /* ap_Length not supported anymore */
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1458 # ifdef APF_DODOT
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 Anchor->ap_Flags = APF_DODOT | APF_DOWILD; /* allow '.' for current dir */
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1460 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 Anchor->ap_Flags = APF_DoDot | APF_DoWild; /* allow '.' for current dir */
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1462 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466 if (dos2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 /* hack to replace '*' by '#?' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 starbuf = alloc((unsigned)(2 * STRLEN(pat) + 1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471 if (starbuf == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 goto Return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473 for (sp = pat, dp = starbuf; *sp; ++sp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 if (*sp == '*')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 *dp++ = '#';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 *dp++ = '?';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 *dp++ = *sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 *dp = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 Result = MatchFirst((UBYTE *)starbuf, Anchor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 vim_free(starbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 Result = FindFirst((char *)pat, Anchor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 * Loop to get all matches.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 while (Result == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496 {
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1497 #ifdef __amigaos4__
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1498 addfile(gap, (char_u *)Anchor->ap_Buffer, flags);
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1499 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 addfile(gap, (char_u *)Anchor->ap_Buf, flags);
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1501 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 if (dos2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 Result = MatchNext(Anchor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 Result = FindNext(Anchor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 matches = gap->ga_len - start_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 if (Result == ERROR_BUFFER_OVERFLOW)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
1514 emsg(_("ANCHOR_BUF_SIZE too small."));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515 else if (matches == 0 && Result != ERROR_OBJECT_NOT_FOUND
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 && Result != ERROR_DEVICE_NOT_MOUNTED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 && Result != ERROR_NO_MORE_ENTRIES)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
1518 emsg(_("I/O ERROR"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 * Sort the files for this pattern.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 if (matches)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524 qsort((void *)(((char_u **)gap->ga_data) + start_len),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 (size_t)matches, sizeof(char_u *), sortcmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 /* Free the wildcard stuff */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 if (dos2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 MatchEnd(Anchor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 FreeAnchorChain(Anchor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 Return:
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1538 #ifdef __amigaos4__
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1539 FreeDosObject(DOS_ANCHORPATH, Anchor);
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1540 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 vim_free(Anchor);
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 982
diff changeset
1542 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544 return matches;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1548 sortcmp(const void *a, const void *b)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1549 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 char *s = *(char **)a;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 char *t = *(char **)b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 7
diff changeset
1553 return pathcmp(s, t, -1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557 * Return TRUE if "p" has wildcards that can be expanded by mch_expandpath().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1558 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1559 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1560 mch_has_exp_wildcard(char_u *p)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1561 {
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10835
diff changeset
1562 for ( ; *p; MB_PTR_ADV(p))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1563 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1564 if (*p == '\\' && p[1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 else if (vim_strchr((char_u *)"*?[(#", *p) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1567 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1571
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1572 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1573 mch_has_wildcard(char_u *p)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1574 {
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10835
diff changeset
1575 for ( ; *p; MB_PTR_ADV(p))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577 if (*p == '\\' && p[1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1579 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1580 if (vim_strchr((char_u *)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1581 # ifdef VIM_BACKTICK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1582 "*?[(#$`"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1583 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1584 "*?[(#$"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1585 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1586 , *p) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1587 || (*p == '~' && p[1] != NUL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1588 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1589 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1590 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1591 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1592
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1593 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1594 * With AmigaDOS 2.0 support for reading local environment variables
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1595 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1596 * Two buffers are allocated:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1597 * - A big one to do the expansion into. It is freed before returning.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1598 * - A small one to hold the return value. It is kept until the next call.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1599 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1600 char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1601 mch_getenv(char_u *var)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1602 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1603 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1604 UBYTE *buf; /* buffer to expand in */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1605 char_u *retval; /* return value */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1606 static char_u *alloced = NULL; /* allocated memory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1607
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1608 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1609 if (!dos2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1610 retval = (char_u *)getenv((char *)var);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1611 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1612 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1613 {
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
1614 VIM_CLEAR(alloced);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1615 retval = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1616
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1617 buf = alloc(IOSIZE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1618 if (buf == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1619 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1620
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1621 len = GetVar((UBYTE *)var, buf, (long)(IOSIZE - 1), (long)0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1622 if (len >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1623 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1624 retval = vim_strsave((char_u *)buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1625 alloced = retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1626 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1627
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1628 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1629 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1630
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1631 /* if $VIM is not defined, use "vim:" instead */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1632 if (retval == NULL && STRCMP(var, "VIM") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1633 retval = (char_u *)"vim:";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1634
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1635 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1636 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1637
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1638 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1639 * Amiga version of setenv() with AmigaDOS 2.0 support.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1640 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1641 /* ARGSUSED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1642 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1643 mch_setenv(char *var, char *value, int x)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1644 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1645 #ifdef FEAT_ARP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1646 if (!dos2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1647 return setenv(var, value);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1648 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1649
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1650 if (SetVar((UBYTE *)var, (UBYTE *)value, (LONG)-1, (ULONG)GVF_LOCAL_ONLY))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1651 return 0; /* success */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1652 return -1; /* failure */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1653 }