annotate src/os_amiga.c @ 30337:dac4fe437840 v9.0.0504

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