Mercurial > vim
annotate src/channel.c @ 20083:0da696bd7352 v8.2.0597
patch 8.2.0597: test_eval is old style
Commit: https://github.com/vim/vim/commit/90455cfa87f84f16179c19241b034abbfa8b3c9a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 18 21:56:38 2020 +0200
patch 8.2.0597: test_eval is old style
Problem: Test_eval is old style.
Solution: Change some tests to a new style test.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 18 Apr 2020 22:00:04 +0200 |
parents | 128963cd954f |
children | 456c3b98d4c8 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 * |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 * |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 */ |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 /* |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 * Implements communication through a socket or any file handle. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 */ |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
13 #ifdef WIN32 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
14 // Must include winsock2.h before windows.h since it conflicts with winsock.h |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
15 // (included in windows.h). |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
16 # include <winsock2.h> |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
17 # include <ws2tcpip.h> |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
18 #endif |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
19 |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 #include "vim.h" |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8491
diff
changeset
|
22 #if defined(FEAT_JOB_CHANNEL) || defined(PROTO) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
24 // TRUE when netbeans is running with a GUI. |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
25 #ifdef FEAT_GUI |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
26 # define CH_HAS_GUI (gui.in_use || gui.starting) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
27 #endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
28 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
29 // Note: when making changes here also adjust configure.ac. |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
30 #ifdef MSWIN |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
31 // WinSock API is separated from C API, thus we can't use read(), write(), |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
32 // errno... |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
33 # define SOCK_ERRNO errno = WSAGetLastError() |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
34 # undef ECONNREFUSED |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
35 # define ECONNREFUSED WSAECONNREFUSED |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
36 # undef EWOULDBLOCK |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
37 # define EWOULDBLOCK WSAEWOULDBLOCK |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
38 # undef EINPROGRESS |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
39 # define EINPROGRESS WSAEINPROGRESS |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
40 # ifdef EINTR |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
41 # undef EINTR |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
42 # endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
43 # define EINTR WSAEINTR |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
44 # define sock_write(sd, buf, len) send((SOCKET)sd, buf, len, 0) |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
45 # define sock_read(sd, buf, len) recv((SOCKET)sd, buf, len, 0) |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
46 # define sock_close(sd) closesocket((SOCKET)sd) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
47 #else |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
48 # include <netdb.h> |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
49 # include <netinet/in.h> |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
50 # include <arpa/inet.h> |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
51 # include <sys/socket.h> |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
52 # ifdef HAVE_LIBGEN_H |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
53 # include <libgen.h> |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
54 # endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
55 # define SOCK_ERRNO |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
56 # define sock_write(sd, buf, len) write(sd, buf, len) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
57 # define sock_read(sd, buf, len) read(sd, buf, len) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
58 # define sock_close(sd) close(sd) |
8072
38887bf423ba
commit https://github.com/vim/vim/commit/0943a09db84b036ec550d7f2e5b832f621b400ca
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
59 # define fd_read(fd, buf, len) read(fd, buf, len) |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
60 # define fd_write(sd, buf, len) write(sd, buf, len) |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
61 # define fd_close(sd) close(sd) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
62 #endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
63 |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
64 static void channel_read(channel_T *channel, ch_part_T part, char *func); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
65 static ch_mode_T channel_get_mode(channel_T *channel, ch_part_T part); |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
66 static int channel_get_timeout(channel_T *channel, ch_part_T part); |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
67 static ch_part_T channel_part_send(channel_T *channel); |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
68 static ch_part_T channel_part_read(channel_T *channel); |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
69 static void free_job_options(jobopt_T *opt); |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
70 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
71 #define FOR_ALL_CHANNELS(ch) \ |
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
72 for ((ch) = first_channel; (ch) != NULL; (ch) = (ch)->ch_next) |
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
73 |
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
74 #define FOR_ALL_JOBS(job) \ |
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
75 for ((job) = first_job; (job) != NULL; (job) = (job)->jv_next) |
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
76 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
77 // Whether a redraw is needed for appending a line to a buffer. |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
78 static int channel_need_redraw = FALSE; |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
79 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
80 // Whether we are inside channel_parse_messages() or another situation where it |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
81 // is safe to invoke callbacks. |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
82 static int safe_to_invoke_callback = 0; |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
83 |
9089
6bc0a492e8ba
commit https://github.com/vim/vim/commit/de7eb0a47b557eb4656c6b63d421c7e7bae1ef30
Christian Brabandt <cb@256bit.org>
parents:
9087
diff
changeset
|
84 static char *part_names[] = {"sock", "out", "err", "in"}; |
6bc0a492e8ba
commit https://github.com/vim/vim/commit/de7eb0a47b557eb4656c6b63d421c7e7bae1ef30
Christian Brabandt <cb@256bit.org>
parents:
9087
diff
changeset
|
85 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
86 #ifdef MSWIN |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
87 static int |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
8074
diff
changeset
|
88 fd_read(sock_T fd, char *buf, size_t len) |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
89 { |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
90 HANDLE h = (HANDLE)fd; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
91 DWORD nread; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
92 |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
93 if (!ReadFile(h, buf, (DWORD)len, &nread, NULL)) |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
94 return -1; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
95 return (int)nread; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
96 } |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
97 |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
98 static int |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
8074
diff
changeset
|
99 fd_write(sock_T fd, char *buf, size_t len) |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
100 { |
15621
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
101 size_t todo = len; |
15539
ba876ced4f1f
patch 8.1.0777: Win32: using pipes for channel does not work well
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
102 HANDLE h = (HANDLE)fd; |
15621
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
103 DWORD nwrite, size, done = 0; |
15539
ba876ced4f1f
patch 8.1.0777: Win32: using pipes for channel does not work well
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
104 OVERLAPPED ov; |
ba876ced4f1f
patch 8.1.0777: Win32: using pipes for channel does not work well
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
105 |
15621
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
106 while (todo > 0) |
15539
ba876ced4f1f
patch 8.1.0777: Win32: using pipes for channel does not work well
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
107 { |
15621
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
108 if (todo > MAX_NAMED_PIPE_SIZE) |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
109 size = MAX_NAMED_PIPE_SIZE; |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
110 else |
15661
b6f11ff3b6d1
patch 8.1.0838: compiler warning for type conversion
Bram Moolenaar <Bram@vim.org>
parents:
15632
diff
changeset
|
111 size = (DWORD)todo; |
15764
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15746
diff
changeset
|
112 // If the pipe overflows while the job does not read the data, |
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15746
diff
changeset
|
113 // WriteFile() will block forever. This abandons the write. |
15621
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
114 memset(&ov, 0, sizeof(ov)); |
15764
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15746
diff
changeset
|
115 nwrite = 0; |
15621
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
116 if (!WriteFile(h, buf + done, size, &nwrite, &ov)) |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
117 { |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
118 DWORD err = GetLastError(); |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
119 |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
120 if (err != ERROR_IO_PENDING) |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
121 return -1; |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
122 if (!GetOverlappedResult(h, &ov, &nwrite, FALSE)) |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
123 return -1; |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
124 FlushFileBuffers(h); |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
125 } |
15764
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15746
diff
changeset
|
126 else if (nwrite == 0) |
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15746
diff
changeset
|
127 // WriteFile() returns TRUE but did not write anything. This causes |
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15746
diff
changeset
|
128 // a hang, so bail out. |
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15746
diff
changeset
|
129 break; |
15621
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
130 todo -= nwrite; |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
131 done += nwrite; |
15539
ba876ced4f1f
patch 8.1.0777: Win32: using pipes for channel does not work well
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
132 } |
15621
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15577
diff
changeset
|
133 return (int)done; |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
134 } |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
135 |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
136 static void |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
137 fd_close(sock_T fd) |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
138 { |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
139 HANDLE h = (HANDLE)fd; |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
140 |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
141 CloseHandle(h); |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
142 } |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
143 #endif |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
144 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
145 // Log file opened with ch_logfile(). |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
146 static FILE *log_fd = NULL; |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
147 #ifdef FEAT_RELTIME |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
148 static proftime_T log_start; |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
149 #endif |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
150 |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
151 void |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
152 ch_logfile(char_u *fname, char_u *opt) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
153 { |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
154 FILE *file = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
155 |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
156 if (log_fd != NULL) |
18191
0f8a34c996eb
patch 8.1.2090: not clear why channel log file ends
Bram Moolenaar <Bram@vim.org>
parents:
18170
diff
changeset
|
157 { |
0f8a34c996eb
patch 8.1.2090: not clear why channel log file ends
Bram Moolenaar <Bram@vim.org>
parents:
18170
diff
changeset
|
158 if (*fname != NUL) |
0f8a34c996eb
patch 8.1.2090: not clear why channel log file ends
Bram Moolenaar <Bram@vim.org>
parents:
18170
diff
changeset
|
159 ch_log(NULL, "closing, opening %s", fname); |
0f8a34c996eb
patch 8.1.2090: not clear why channel log file ends
Bram Moolenaar <Bram@vim.org>
parents:
18170
diff
changeset
|
160 else |
0f8a34c996eb
patch 8.1.2090: not clear why channel log file ends
Bram Moolenaar <Bram@vim.org>
parents:
18170
diff
changeset
|
161 ch_log(NULL, "closing"); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
162 fclose(log_fd); |
18191
0f8a34c996eb
patch 8.1.2090: not clear why channel log file ends
Bram Moolenaar <Bram@vim.org>
parents:
18170
diff
changeset
|
163 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
164 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
165 if (*fname != NUL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
166 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
167 file = fopen((char *)fname, *opt == 'w' ? "w" : "a"); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
168 if (file == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
169 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
170 semsg(_(e_notopen), fname); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
171 return; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
172 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
173 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
174 log_fd = file; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
175 |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
176 if (log_fd != NULL) |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
177 { |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
178 fprintf(log_fd, "==== start log session ====\n"); |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
179 #ifdef FEAT_RELTIME |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
180 profile_start(&log_start); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
181 #endif |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
182 } |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
183 } |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
184 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
185 int |
9282
9f97a6290c63
commit https://github.com/vim/vim/commit/cf089463492fab53b2a5d81517829d22f882f82e
Christian Brabandt <cb@256bit.org>
parents:
9246
diff
changeset
|
186 ch_log_active(void) |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
187 { |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
188 return log_fd != NULL; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
189 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
190 |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
191 static void |
14499
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
192 ch_log_lead(const char *what, channel_T *ch, ch_part_T part) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
193 { |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
194 if (log_fd != NULL) |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
195 { |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
196 #ifdef FEAT_RELTIME |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
197 proftime_T log_now; |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
198 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
199 profile_start(&log_now); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
200 profile_sub(&log_now, &log_start); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
201 fprintf(log_fd, "%s ", profile_msg(&log_now)); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
202 #endif |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
203 if (ch != NULL) |
14499
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
204 { |
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
205 if (part < PART_COUNT) |
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
206 fprintf(log_fd, "%son %d(%s): ", |
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
207 what, ch->ch_id, part_names[part]); |
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
208 else |
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
209 fprintf(log_fd, "%son %d: ", what, ch->ch_id); |
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
210 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
211 else |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
212 fprintf(log_fd, "%s: ", what); |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
213 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
214 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
215 |
15908
379247470597
patch 8.1.0960: when using ConPTY garbage collection has undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
216 #ifndef PROTO // prototype is in proto.h |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
217 void |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
218 ch_log(channel_T *ch, const char *fmt, ...) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
219 { |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
220 if (log_fd != NULL) |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
221 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
222 va_list ap; |
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
223 |
14499
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
224 ch_log_lead("", ch, PART_COUNT); |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
225 va_start(ap, fmt); |
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
226 vfprintf(log_fd, fmt, ap); |
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
227 va_end(ap); |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
228 fputc('\n', log_fd); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
229 fflush(log_fd); |
18160
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
230 did_repeated_msg = 0; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
231 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
232 } |
13608
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
233 #endif |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
234 |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
235 static void |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
236 ch_error(channel_T *ch, const char *fmt, ...) |
13618
ea4f2a8040b4
patch 8.0.1681: the format attribute fails with MinGW
Christian Brabandt <cb@256bit.org>
parents:
13608
diff
changeset
|
237 #ifdef USE_PRINTF_FORMAT_ATTRIBUTE |
ea4f2a8040b4
patch 8.0.1681: the format attribute fails with MinGW
Christian Brabandt <cb@256bit.org>
parents:
13608
diff
changeset
|
238 __attribute__((format(printf, 2, 3))) |
13608
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
239 #endif |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
240 ; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
241 |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
242 static void |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
243 ch_error(channel_T *ch, const char *fmt, ...) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
244 { |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
245 if (log_fd != NULL) |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
246 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
247 va_list ap; |
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
248 |
14499
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
249 ch_log_lead("ERR ", ch, PART_COUNT); |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
250 va_start(ap, fmt); |
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
251 vfprintf(log_fd, fmt, ap); |
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
252 va_end(ap); |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
253 fputc('\n', log_fd); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
254 fflush(log_fd); |
18160
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
255 did_repeated_msg = 0; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
256 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
257 } |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
258 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
259 #ifdef MSWIN |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
260 # undef PERROR |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
261 # define PERROR(msg) (void)semsg("%s: %s", msg, strerror_win32(errno)) |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
262 |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
263 static char * |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
264 strerror_win32(int eno) |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
265 { |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
266 static LPVOID msgbuf = NULL; |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
267 char_u *ptr; |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
268 |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
269 if (msgbuf) |
9355
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
270 { |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
271 LocalFree(msgbuf); |
9355
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
272 msgbuf = NULL; |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
273 } |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
274 FormatMessage( |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
275 FORMAT_MESSAGE_ALLOCATE_BUFFER | |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
276 FORMAT_MESSAGE_FROM_SYSTEM | |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
277 FORMAT_MESSAGE_IGNORE_INSERTS, |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
278 NULL, |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
279 eno, |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
280 MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
281 (LPTSTR) &msgbuf, |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
282 0, |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
283 NULL); |
9355
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
284 if (msgbuf != NULL) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
285 // chomp \r or \n |
9355
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
286 for (ptr = (char_u *)msgbuf; *ptr; ptr++) |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
287 switch (*ptr) |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
288 { |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
289 case '\r': |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
290 STRMOVE(ptr, ptr + 1); |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
291 ptr--; |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
292 break; |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
293 case '\n': |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
294 if (*(ptr + 1) == '\0') |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
295 *ptr = '\0'; |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
296 else |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
297 *ptr = ' '; |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
298 break; |
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
299 } |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
300 return msgbuf; |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
301 } |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
302 #endif |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
303 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
304 /* |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
305 * The list of all allocated channels. |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
306 */ |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
307 static channel_T *first_channel = NULL; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
308 static int next_ch_id = 0; |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
309 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
310 /* |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
311 * Allocate a new channel. The refcount is set to 1. |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
312 * The channel isn't actually used until it is opened. |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
313 * Returns NULL if out of memory. |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
314 */ |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
315 channel_T * |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
316 add_channel(void) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
317 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
318 ch_part_T part; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
319 channel_T *channel = ALLOC_CLEAR_ONE(channel_T); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
320 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
321 if (channel == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
322 return NULL; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
323 |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
324 channel->ch_id = next_ch_id++; |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
325 ch_log(channel, "Created channel"); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
326 |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
327 for (part = PART_SOCK; part < PART_COUNT; ++part) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
328 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
329 channel->ch_part[part].ch_fd = INVALID_FD; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
330 #ifdef FEAT_GUI_X11 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
331 channel->ch_part[part].ch_inputHandler = (XtInputId)NULL; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
332 #endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
333 #ifdef FEAT_GUI_GTK |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
334 channel->ch_part[part].ch_inputHandler = 0; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
335 #endif |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
336 channel->ch_part[part].ch_timeout = 2000; |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
337 } |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
338 |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
339 if (first_channel != NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
340 { |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
341 first_channel->ch_prev = channel; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
342 channel->ch_next = first_channel; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
343 } |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
344 first_channel = channel; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
345 |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
346 channel->ch_refcount = 1; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
347 return channel; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
348 } |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
349 |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
350 int |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
351 has_any_channel(void) |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
352 { |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
353 return first_channel != NULL; |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
354 } |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
355 |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
356 /* |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
357 * Called when the refcount of a channel is zero. |
8259
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
358 * Return TRUE if "channel" has a callback and the associated job wasn't |
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
359 * killed. |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
360 */ |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
361 static int |
8259
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
362 channel_still_useful(channel_T *channel) |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
363 { |
8332
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
364 int has_sock_msg; |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
365 int has_out_msg; |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
366 int has_err_msg; |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
367 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
368 // If the job was killed the channel is not expected to work anymore. |
8259
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
369 if (channel->ch_job_killed && channel->ch_job == NULL) |
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
370 return FALSE; |
8332
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
371 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
372 // If there is a close callback it may still need to be invoked. |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
373 if (channel->ch_close_cb.cb_name != NULL) |
8332
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
374 return TRUE; |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
375 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
376 // If reading from or a buffer it's still useful. |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
377 if (channel->ch_part[PART_IN].ch_bufref.br_buf != NULL) |
9081
b2b915c1d311
commit https://github.com/vim/vim/commit/5d96e3ae534ade8ed09a5de9ff8fd7519537ec28
Christian Brabandt <cb@256bit.org>
parents:
9079
diff
changeset
|
378 return TRUE; |
b2b915c1d311
commit https://github.com/vim/vim/commit/5d96e3ae534ade8ed09a5de9ff8fd7519537ec28
Christian Brabandt <cb@256bit.org>
parents:
9079
diff
changeset
|
379 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
380 // If there is no callback then nobody can get readahead. If the fd is |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
381 // closed and there is no readahead then the callback won't be called. |
8332
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
382 has_sock_msg = channel->ch_part[PART_SOCK].ch_fd != INVALID_FD |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
383 || channel->ch_part[PART_SOCK].ch_head.rq_next != NULL |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
384 || channel->ch_part[PART_SOCK].ch_json_head.jq_next != NULL; |
8332
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
385 has_out_msg = channel->ch_part[PART_OUT].ch_fd != INVALID_FD |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
386 || channel->ch_part[PART_OUT].ch_head.rq_next != NULL |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
387 || channel->ch_part[PART_OUT].ch_json_head.jq_next != NULL; |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
388 has_err_msg = channel->ch_part[PART_ERR].ch_fd != INVALID_FD |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
389 || channel->ch_part[PART_ERR].ch_head.rq_next != NULL |
07713b8243ac
commit https://github.com/vim/vim/commit/fdd6ce4a2f922afac7bd719a00228dbd8539b9c4
Christian Brabandt <cb@256bit.org>
parents:
8330
diff
changeset
|
390 || channel->ch_part[PART_ERR].ch_json_head.jq_next != NULL; |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
391 return (channel->ch_callback.cb_name != NULL && (has_sock_msg |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8491
diff
changeset
|
392 || has_out_msg || has_err_msg)) |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
393 || ((channel->ch_part[PART_OUT].ch_callback.cb_name != NULL |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
394 || channel->ch_part[PART_OUT].ch_bufref.br_buf != NULL) |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
395 && has_out_msg) |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
396 || ((channel->ch_part[PART_ERR].ch_callback.cb_name != NULL |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
397 || channel->ch_part[PART_ERR].ch_bufref.br_buf != NULL) |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
398 && has_err_msg); |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
399 } |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
400 |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
401 /* |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
402 * Return TRUE if "channel" is closeable (i.e. all readable fds are closed). |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
403 */ |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
404 static int |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
405 channel_can_close(channel_T *channel) |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
406 { |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
407 return channel->ch_to_be_closed == 0; |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
408 } |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
409 |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
410 /* |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
411 * Close a channel and free all its resources. |
19772
472dc753e985
patch 8.2.0442: channel contents might be used after being freed
Bram Moolenaar <Bram@vim.org>
parents:
19758
diff
changeset
|
412 * The "channel" pointer remains valid. |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
413 */ |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
414 static void |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
415 channel_free_contents(channel_T *channel) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
416 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
417 channel_close(channel, TRUE); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
418 channel_clear(channel); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
419 ch_log(channel, "Freeing channel"); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
420 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
421 |
19772
472dc753e985
patch 8.2.0442: channel contents might be used after being freed
Bram Moolenaar <Bram@vim.org>
parents:
19758
diff
changeset
|
422 /* |
472dc753e985
patch 8.2.0442: channel contents might be used after being freed
Bram Moolenaar <Bram@vim.org>
parents:
19758
diff
changeset
|
423 * Unlink "channel" from the list of channels and free it. |
472dc753e985
patch 8.2.0442: channel contents might be used after being freed
Bram Moolenaar <Bram@vim.org>
parents:
19758
diff
changeset
|
424 */ |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
425 static void |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
426 channel_free_channel(channel_T *channel) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
427 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
428 if (channel->ch_next != NULL) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
429 channel->ch_next->ch_prev = channel->ch_prev; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
430 if (channel->ch_prev == NULL) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
431 first_channel = channel->ch_next; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
432 else |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
433 channel->ch_prev->ch_next = channel->ch_next; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
434 vim_free(channel); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
435 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
436 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
437 static void |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
438 channel_free(channel_T *channel) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
439 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
440 if (!in_free_unref_items) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
441 { |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
442 if (safe_to_invoke_callback == 0) |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
443 channel->ch_to_be_freed = TRUE; |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
444 else |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
445 { |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
446 channel_free_contents(channel); |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
447 channel_free_channel(channel); |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
448 } |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
449 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
450 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
451 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
452 /* |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
453 * Close a channel and free all its resources if there is no further action |
8259
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
454 * possible, there is no callback to be invoked or the associated job was |
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
455 * killed. |
8318
190d8084cb3a
commit https://github.com/vim/vim/commit/707659490d35e8d66e8bbdcfd93b12dc1387d86c
Christian Brabandt <cb@256bit.org>
parents:
8310
diff
changeset
|
456 * Return TRUE if the channel was freed. |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
457 */ |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
458 static int |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
459 channel_may_free(channel_T *channel) |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
460 { |
8259
99a70c3b902f
commit https://github.com/vim/vim/commit/46c85439c966d7ed39fb3d711d4d6c61ac964647
Christian Brabandt <cb@256bit.org>
parents:
8257
diff
changeset
|
461 if (!channel_still_useful(channel)) |
8318
190d8084cb3a
commit https://github.com/vim/vim/commit/707659490d35e8d66e8bbdcfd93b12dc1387d86c
Christian Brabandt <cb@256bit.org>
parents:
8310
diff
changeset
|
462 { |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
463 channel_free(channel); |
8318
190d8084cb3a
commit https://github.com/vim/vim/commit/707659490d35e8d66e8bbdcfd93b12dc1387d86c
Christian Brabandt <cb@256bit.org>
parents:
8310
diff
changeset
|
464 return TRUE; |
190d8084cb3a
commit https://github.com/vim/vim/commit/707659490d35e8d66e8bbdcfd93b12dc1387d86c
Christian Brabandt <cb@256bit.org>
parents:
8310
diff
changeset
|
465 } |
190d8084cb3a
commit https://github.com/vim/vim/commit/707659490d35e8d66e8bbdcfd93b12dc1387d86c
Christian Brabandt <cb@256bit.org>
parents:
8310
diff
changeset
|
466 return FALSE; |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
467 } |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
468 |
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
469 /* |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
470 * Decrement the reference count on "channel" and maybe free it when it goes |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
471 * down to zero. Don't free it if there is a pending action. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
472 * Returns TRUE when the channel is no longer referenced. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
473 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
474 int |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
475 channel_unref(channel_T *channel) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
476 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
477 if (channel != NULL && --channel->ch_refcount <= 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
478 return channel_may_free(channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
479 return FALSE; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
480 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
481 |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
482 int |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
483 free_unused_channels_contents(int copyID, int mask) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
484 { |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
485 int did_free = FALSE; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
486 channel_T *ch; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
487 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
488 // This is invoked from the garbage collector, which only runs at a safe |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
489 // point. |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
490 ++safe_to_invoke_callback; |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
491 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
492 FOR_ALL_CHANNELS(ch) |
9011
72a597e9e36d
commit https://github.com/vim/vim/commit/674127e1801fd02ff07dddf0dc3bf0d8cce68997
Christian Brabandt <cb@256bit.org>
parents:
9007
diff
changeset
|
493 if (!channel_still_useful(ch) |
72a597e9e36d
commit https://github.com/vim/vim/commit/674127e1801fd02ff07dddf0dc3bf0d8cce68997
Christian Brabandt <cb@256bit.org>
parents:
9007
diff
changeset
|
494 && (ch->ch_copyID & mask) != (copyID & mask)) |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
495 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
496 // Free the channel and ordinary items it contains, but don't |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
497 // recurse into Lists, Dictionaries etc. |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
498 channel_free_contents(ch); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
499 did_free = TRUE; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
500 } |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
501 |
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
502 --safe_to_invoke_callback; |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
503 return did_free; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
504 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
505 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
506 void |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
507 free_unused_channels(int copyID, int mask) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
508 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
509 channel_T *ch; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
510 channel_T *ch_next; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
511 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
512 for (ch = first_channel; ch != NULL; ch = ch_next) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
513 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
514 ch_next = ch->ch_next; |
9011
72a597e9e36d
commit https://github.com/vim/vim/commit/674127e1801fd02ff07dddf0dc3bf0d8cce68997
Christian Brabandt <cb@256bit.org>
parents:
9007
diff
changeset
|
515 if (!channel_still_useful(ch) |
72a597e9e36d
commit https://github.com/vim/vim/commit/674127e1801fd02ff07dddf0dc3bf0d8cce68997
Christian Brabandt <cb@256bit.org>
parents:
9007
diff
changeset
|
516 && (ch->ch_copyID & mask) != (copyID & mask)) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
517 // Free the channel struct itself. |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
518 channel_free_channel(ch); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
519 } |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
520 } |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
521 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
522 #if defined(FEAT_GUI) || defined(PROTO) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
523 |
17974
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
524 # if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
525 /* |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
526 * Lookup the channel from the socket. Set "partp" to the fd index. |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
527 * Returns NULL when the socket isn't found. |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
528 */ |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
529 static channel_T * |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
530 channel_fd2channel(sock_T fd, ch_part_T *partp) |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
531 { |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
532 channel_T *channel; |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
533 ch_part_T part; |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
534 |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
535 if (fd != INVALID_FD) |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
536 FOR_ALL_CHANNELS(channel) |
17974
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
537 { |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
538 for (part = PART_SOCK; part < PART_IN; ++part) |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
539 if (channel->ch_part[part].ch_fd == fd) |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
540 { |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
541 *partp = part; |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
542 return channel; |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
543 } |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
544 } |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
545 return NULL; |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
546 } |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
547 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
548 static void |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
549 channel_read_fd(int fd) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
550 { |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
551 channel_T *channel; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
552 ch_part_T part; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
553 |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
554 channel = channel_fd2channel(fd, &part); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
555 if (channel == NULL) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
556 ch_error(NULL, "Channel for fd %d not found", fd); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
557 else |
9123
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
558 channel_read(channel, part, "channel_read_fd"); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
559 } |
17974
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
560 # endif |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
561 |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
562 /* |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
563 * Read a command from netbeans. |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
564 */ |
17974
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
565 # ifdef FEAT_GUI_X11 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
566 static void |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
567 messageFromServerX11(XtPointer clientData, |
9123
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
568 int *unused1 UNUSED, |
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
569 XtInputId *unused2 UNUSED) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
570 { |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
571 channel_read_fd((int)(long)clientData); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
572 } |
17974
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
573 # endif |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
574 |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
575 # ifdef FEAT_GUI_GTK |
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
576 # if GTK_CHECK_VERSION(3,0,0) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
577 static gboolean |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
578 messageFromServerGtk3(GIOChannel *unused1 UNUSED, |
9123
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
579 GIOCondition unused2 UNUSED, |
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
580 gpointer clientData) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
581 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
582 channel_read_fd(GPOINTER_TO_INT(clientData)); |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
583 return TRUE; // Return FALSE instead in case the event source is to |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
584 // be removed after this function returns. |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
585 } |
17974
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
586 # else |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
587 static void |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
588 messageFromServerGtk2(gpointer clientData, |
9123
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
589 gint unused1 UNUSED, |
b430d4f2aa79
commit https://github.com/vim/vim/commit/f8df45d84f1d17dced23e185d4835fc23406d73d
Christian Brabandt <cb@256bit.org>
parents:
9089
diff
changeset
|
590 GdkInputCondition unused2 UNUSED) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
591 { |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
592 channel_read_fd((int)(long)clientData); |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
593 } |
17974
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
594 # endif |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
595 # endif |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
596 |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
597 static void |
18139
59bc3cd42cf5
patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
598 channel_gui_register_one(channel_T *channel, ch_part_T part UNUSED) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
599 { |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
600 if (!CH_HAS_GUI) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
601 return; |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
602 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
603 // gets stuck in handling events for a not connected channel |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
604 if (channel->ch_keep_open) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
605 return; |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
606 |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
607 # ifdef FEAT_GUI_X11 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
608 // Tell notifier we are interested in being called when there is input on |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
609 // the editor connection socket. |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
610 if (channel->ch_part[part].ch_inputHandler == (XtInputId)NULL) |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
611 { |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
612 ch_log(channel, "Registering part %s with fd %d", |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
613 part_names[part], channel->ch_part[part].ch_fd); |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
614 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
615 channel->ch_part[part].ch_inputHandler = XtAppAddInput( |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
616 (XtAppContext)app_context, |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
617 channel->ch_part[part].ch_fd, |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
618 (XtPointer)(XtInputReadMask + XtInputExceptMask), |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
619 messageFromServerX11, |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
620 (XtPointer)(long)channel->ch_part[part].ch_fd); |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
621 } |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
622 # else |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
623 # ifdef FEAT_GUI_GTK |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
624 // Tell gdk we are interested in being called when there is input on the |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
625 // editor connection socket. |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
626 if (channel->ch_part[part].ch_inputHandler == 0) |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
627 { |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
628 ch_log(channel, "Registering part %s with fd %d", |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
629 part_names[part], channel->ch_part[part].ch_fd); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
630 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
631 GIOChannel *chnnl = g_io_channel_unix_new( |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
632 (gint)channel->ch_part[part].ch_fd); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
633 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
634 channel->ch_part[part].ch_inputHandler = g_io_add_watch( |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
635 chnnl, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
636 G_IO_IN|G_IO_HUP|G_IO_ERR|G_IO_PRI, |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
637 messageFromServerGtk3, |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
638 GINT_TO_POINTER(channel->ch_part[part].ch_fd)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
639 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
640 g_io_channel_unref(chnnl); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
641 # else |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
642 channel->ch_part[part].ch_inputHandler = gdk_input_add( |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
643 (gint)channel->ch_part[part].ch_fd, |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
644 (GdkInputCondition) |
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
645 ((int)GDK_INPUT_READ + (int)GDK_INPUT_EXCEPTION), |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
646 messageFromServerGtk2, |
8155
6ee6fb27dcea
commit https://github.com/vim/vim/commit/fffd5560c6c8840be3233ef1c8da3c9e5dd424ea
Christian Brabandt <cb@256bit.org>
parents:
8151
diff
changeset
|
647 (gpointer)(long)channel->ch_part[part].ch_fd); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
648 # endif |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
649 } |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
650 # endif |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
651 # endif |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
652 } |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
653 |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
654 static void |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
655 channel_gui_register(channel_T *channel) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
656 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
657 if (channel->CH_SOCK_FD != INVALID_FD) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
658 channel_gui_register_one(channel, PART_SOCK); |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
659 if (channel->CH_OUT_FD != INVALID_FD |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
660 && channel->CH_OUT_FD != channel->CH_SOCK_FD) |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
661 channel_gui_register_one(channel, PART_OUT); |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
662 if (channel->CH_ERR_FD != INVALID_FD |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
663 && channel->CH_ERR_FD != channel->CH_SOCK_FD |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
664 && channel->CH_ERR_FD != channel->CH_OUT_FD) |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
665 channel_gui_register_one(channel, PART_ERR); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
666 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
667 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
668 /* |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
669 * Register any of our file descriptors with the GUI event handling system. |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
670 * Called when the GUI has started. |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
671 */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
672 void |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
673 channel_gui_register_all(void) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
674 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
675 channel_T *channel; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
676 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
677 FOR_ALL_CHANNELS(channel) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
678 channel_gui_register(channel); |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
679 } |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
680 |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
681 static void |
18139
59bc3cd42cf5
patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
682 channel_gui_unregister_one(channel_T *channel UNUSED, ch_part_T part UNUSED) |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
683 { |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
684 # ifdef FEAT_GUI_X11 |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
685 if (channel->ch_part[part].ch_inputHandler != (XtInputId)NULL) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
686 { |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
687 ch_log(channel, "Unregistering part %s", part_names[part]); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
688 XtRemoveInput(channel->ch_part[part].ch_inputHandler); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
689 channel->ch_part[part].ch_inputHandler = (XtInputId)NULL; |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
690 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
691 # else |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
692 # ifdef FEAT_GUI_GTK |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
693 if (channel->ch_part[part].ch_inputHandler != 0) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
694 { |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
695 ch_log(channel, "Unregistering part %s", part_names[part]); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
696 # if GTK_CHECK_VERSION(3,0,0) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
697 g_source_remove(channel->ch_part[part].ch_inputHandler); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
698 # else |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
699 gdk_input_remove(channel->ch_part[part].ch_inputHandler); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
700 # endif |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
701 channel->ch_part[part].ch_inputHandler = 0; |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
702 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
703 # endif |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
704 # endif |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
705 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
706 |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
707 static void |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
708 channel_gui_unregister(channel_T *channel) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
709 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
710 ch_part_T part; |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
711 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
712 for (part = PART_SOCK; part < PART_IN; ++part) |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
713 channel_gui_unregister_one(channel, part); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
714 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
715 |
17974
9fb236d0f386
patch 8.1.1983: compiler nags for uninitialized variable and unused function
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
716 #endif // FEAT_GUI |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
717 |
8096
882ba5080c5c
commit https://github.com/vim/vim/commit/e74e8e7d758e9312165a931f176185f07a64231a
Christian Brabandt <cb@256bit.org>
parents:
8094
diff
changeset
|
718 static char *e_cannot_connect = N_("E902: Cannot connect to port"); |
882ba5080c5c
commit https://github.com/vim/vim/commit/e74e8e7d758e9312165a931f176185f07a64231a
Christian Brabandt <cb@256bit.org>
parents:
8094
diff
changeset
|
719 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
720 /* |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
721 * For Unix we need to call connect() again after connect() failed. |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
722 * On Win32 one time is sufficient. |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
723 */ |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
724 static int |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
725 channel_connect( |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
726 channel_T *channel, |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
727 const struct sockaddr *server_addr, |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
728 int server_addrlen, |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
729 int *waittime) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
730 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
731 int sd = -1; |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
732 #ifdef MSWIN |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
733 u_long val = 1; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
734 #endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
735 |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
736 while (TRUE) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
737 { |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
738 long elapsed_msec = 0; |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
739 int waitnow; |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
740 int ret; |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
741 |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
742 if (sd >= 0) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
743 sock_close(sd); |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
744 sd = socket(server_addr->sa_family, SOCK_STREAM, 0); |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
745 if (sd == -1) |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
746 { |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
747 ch_error(channel, "in socket() in channel_connect()."); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
748 PERROR(_("E898: socket() in channel_connect()")); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
749 return -1; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
750 } |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
751 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
752 if (*waittime >= 0) |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
753 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
754 // Make connect() non-blocking. |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
755 if ( |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
756 #ifdef MSWIN |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
757 ioctlsocket(sd, FIONBIO, &val) < 0 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
758 #else |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
759 fcntl(sd, F_SETFL, O_NONBLOCK) < 0 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
760 #endif |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
761 ) |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
762 { |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
763 SOCK_ERRNO; |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
764 ch_error(channel, |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
765 "channel_connect: Connect failed with errno %d", errno); |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
766 sock_close(sd); |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
767 return -1; |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
768 } |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
769 } |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
770 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
771 // Try connecting to the server. |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
772 ch_log(channel, "Connecting..."); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
773 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
774 ret = connect(sd, server_addr, server_addrlen); |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
775 if (ret == 0) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
776 // The connection could be established. |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
777 break; |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
778 |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
779 SOCK_ERRNO; |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
780 if (*waittime < 0 || (errno != EWOULDBLOCK |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
781 && errno != ECONNREFUSED |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
782 #ifdef EINPROGRESS |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
783 && errno != EINPROGRESS |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
784 #endif |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
785 )) |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
786 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
787 ch_error(channel, |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
788 "channel_connect: Connect failed with errno %d", errno); |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
789 PERROR(_(e_cannot_connect)); |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
790 sock_close(sd); |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
791 return -1; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
792 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
793 else if (errno == ECONNREFUSED) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
794 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
795 ch_error(channel, "channel_connect: Connection refused"); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
796 sock_close(sd); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
797 return -1; |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
798 } |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
799 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
800 // Limit the waittime to 50 msec. If it doesn't work within this |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
801 // time we close the socket and try creating it again. |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
802 waitnow = *waittime > 50 ? 50 : *waittime; |
8481
8924d7adbc22
commit https://github.com/vim/vim/commit/40e8cb292c36f5057628e570591e8917ac1ca121
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
803 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
804 // If connect() didn't finish then try using select() to wait for the |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
805 // connection to be made. For Win32 always use select() to wait. |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
806 { |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
807 struct timeval tv; |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
808 fd_set rfds; |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
809 fd_set wfds; |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
810 #ifndef MSWIN |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
811 int so_error = 0; |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
812 socklen_t so_error_len = sizeof(so_error); |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
813 struct timeval start_tv; |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
814 struct timeval end_tv; |
8334
ad4b00bf2984
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Christian Brabandt <cb@256bit.org>
parents:
8332
diff
changeset
|
815 #endif |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
816 FD_ZERO(&rfds); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
817 FD_SET(sd, &rfds); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
818 FD_ZERO(&wfds); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
819 FD_SET(sd, &wfds); |
8096
882ba5080c5c
commit https://github.com/vim/vim/commit/e74e8e7d758e9312165a931f176185f07a64231a
Christian Brabandt <cb@256bit.org>
parents:
8094
diff
changeset
|
820 |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
821 tv.tv_sec = waitnow / 1000; |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
822 tv.tv_usec = (waitnow % 1000) * 1000; |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
823 #ifndef MSWIN |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
824 gettimeofday(&start_tv, NULL); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
825 #endif |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
826 ch_log(channel, |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
827 "Waiting for connection (waiting %d msec)...", waitnow); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
828 |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
829 ret = select((int)sd + 1, &rfds, &wfds, NULL, &tv); |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
830 if (ret < 0) |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
831 { |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
832 SOCK_ERRNO; |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
833 ch_error(channel, |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
834 "channel_connect: Connect failed with errno %d", errno); |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
835 PERROR(_(e_cannot_connect)); |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
836 sock_close(sd); |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
837 return -1; |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
838 } |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
839 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
840 #ifdef MSWIN |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
841 // On Win32: select() is expected to work and wait for up to |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
842 // "waitnow" msec for the socket to be open. |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
843 if (FD_ISSET(sd, &wfds)) |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
844 break; |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
845 elapsed_msec = waitnow; |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
846 if (*waittime > 1 && elapsed_msec < *waittime) |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
847 { |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
848 *waittime -= elapsed_msec; |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
849 continue; |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
850 } |
8334
ad4b00bf2984
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Christian Brabandt <cb@256bit.org>
parents:
8332
diff
changeset
|
851 #else |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
852 // On Linux-like systems: See socket(7) for the behavior |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
853 // After putting the socket in non-blocking mode, connect() will |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
854 // return EINPROGRESS, select() will not wait (as if writing is |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
855 // possible), need to use getsockopt() to check if the socket is |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
856 // actually able to connect. |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
857 // We detect a failure to connect when either read and write fds |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
858 // are set. Use getsockopt() to find out what kind of failure. |
8354
b151c3f9be72
commit https://github.com/vim/vim/commit/42bc6dde46f1b52476cc84ee89277f981b4116c4
Christian Brabandt <cb@256bit.org>
parents:
8348
diff
changeset
|
859 if (FD_ISSET(sd, &rfds) || FD_ISSET(sd, &wfds)) |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
860 { |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
861 ret = getsockopt(sd, |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
862 SOL_SOCKET, SO_ERROR, &so_error, &so_error_len); |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
863 if (ret < 0 || (so_error != 0 |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
864 && so_error != EWOULDBLOCK |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
865 && so_error != ECONNREFUSED |
8334
ad4b00bf2984
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Christian Brabandt <cb@256bit.org>
parents:
8332
diff
changeset
|
866 # ifdef EINPROGRESS |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
867 && so_error != EINPROGRESS |
8334
ad4b00bf2984
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Christian Brabandt <cb@256bit.org>
parents:
8332
diff
changeset
|
868 # endif |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
869 )) |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
870 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
871 ch_error(channel, |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
872 "channel_connect: Connect failed with errno %d", |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
873 so_error); |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
874 PERROR(_(e_cannot_connect)); |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
875 sock_close(sd); |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
876 return -1; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
877 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
878 else if (errno == ECONNREFUSED) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
879 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
880 ch_error(channel, "channel_connect: Connection refused"); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
881 sock_close(sd); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
882 return -1; |
8330
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
883 } |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
884 } |
ec940c11f749
commit https://github.com/vim/vim/commit/d42119fff228434fe57e88d501c744de0a9fb1b1
Christian Brabandt <cb@256bit.org>
parents:
8320
diff
changeset
|
885 |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
886 if (FD_ISSET(sd, &wfds) && so_error == 0) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
887 // Did not detect an error, connection is established. |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
888 break; |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
889 |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
890 gettimeofday(&end_tv, NULL); |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
891 elapsed_msec = (end_tv.tv_sec - start_tv.tv_sec) * 1000 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
892 + (end_tv.tv_usec - start_tv.tv_usec) / 1000; |
8334
ad4b00bf2984
commit https://github.com/vim/vim/commit/e081e21f760bffc24ca98d5f9bbdb5f02e6aea79
Christian Brabandt <cb@256bit.org>
parents:
8332
diff
changeset
|
893 #endif |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
894 } |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
895 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
896 #ifndef MSWIN |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
897 if (*waittime > 1 && elapsed_msec < *waittime) |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
898 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
899 // The port isn't ready but we also didn't get an error. |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
900 // This happens when the server didn't open the socket |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
901 // yet. Select() may return early, wait until the remaining |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
902 // "waitnow" and try again. |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
903 waitnow -= elapsed_msec; |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
904 *waittime -= elapsed_msec; |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
905 if (waitnow > 0) |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
906 { |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
907 mch_delay((long)waitnow, TRUE); |
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
908 ui_breakcheck(); |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
909 *waittime -= waitnow; |
8473
ade1797aa6f4
commit https://github.com/vim/vim/commit/562ca7142845273bca656aa5aeeda90f001062e0
Christian Brabandt <cb@256bit.org>
parents:
8467
diff
changeset
|
910 } |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
911 if (!got_int) |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
912 { |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
913 if (*waittime <= 0) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
914 // give it one more try |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
915 *waittime = 1; |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
916 continue; |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
917 } |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
918 // we were interrupted, behave as if timed out |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
919 } |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
920 #endif |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
921 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
922 // We timed out. |
8467
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
923 ch_error(channel, "Connection timed out"); |
86a327403fb0
commit https://github.com/vim/vim/commit/045a284a83c2a85113de233d5233eae34724a4b6
Christian Brabandt <cb@256bit.org>
parents:
8463
diff
changeset
|
924 sock_close(sd); |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
925 return -1; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
926 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
927 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
928 if (*waittime >= 0) |
7982
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7967
diff
changeset
|
929 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
930 #ifdef MSWIN |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
931 val = 0; |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
932 ioctlsocket(sd, FIONBIO, &val); |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
933 #else |
7961
a7e58c6e4e9a
commit https://github.com/vim/vim/commit/fbc4b4db3a9690906a96e16724350a6241cf32a5
Christian Brabandt <cb@256bit.org>
parents:
7945
diff
changeset
|
934 (void)fcntl(sd, F_SETFL, 0); |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
935 #endif |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
936 } |
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
937 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
938 return sd; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
939 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
940 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
941 /* |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
942 * Open a socket channel to "hostname":"port". |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
943 * "waittime" is the time in msec to wait for the connection. |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
944 * When negative wait forever. |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
945 * Returns the channel for success. |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
946 * Returns NULL for failure. |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
947 */ |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
948 channel_T * |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
949 channel_open( |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
950 const char *hostname, |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
951 int port, |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
952 int waittime, |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
953 void (*nb_close_cb)(void)) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
954 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
955 int sd = -1; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
956 channel_T *channel = NULL; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
957 #ifdef FEAT_IPV6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
958 struct addrinfo hints; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
959 struct addrinfo *res = NULL; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
960 struct addrinfo *addr = NULL; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
961 #else |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
962 struct sockaddr_in server; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
963 struct hostent *host = NULL; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
964 #endif |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
965 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
966 #ifdef MSWIN |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
967 channel_init_winsock(); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
968 #endif |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
969 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
970 channel = add_channel(); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
971 if (channel == NULL) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
972 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
973 ch_error(NULL, "Cannot allocate channel."); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
974 return NULL; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
975 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
976 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
977 // Get the server internet address and put into addr structure fill in the |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
978 // socket address structure and connect to server. |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
979 #ifdef FEAT_IPV6 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
20003
diff
changeset
|
980 CLEAR_FIELD(hints); |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
981 hints.ai_family = AF_UNSPEC; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
982 hints.ai_socktype = SOCK_STREAM; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
983 # ifdef AI_ADDRCONFIG |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
984 hints.ai_flags = AI_ADDRCONFIG; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
985 # endif |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
986 // Set port number manually in order to prevent name resolution services |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
987 // from being invoked in the environment where AI_NUMERICSERV is not |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
988 // defined. |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
989 if (getaddrinfo(hostname, NULL, &hints, &res) != 0) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
990 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
991 ch_error(channel, "in getaddrinfo() in channel_open()"); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
992 PERROR(_("E901: getaddrinfo() in channel_open()")); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
993 channel_free(channel); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
994 return NULL; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
995 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
996 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
997 for (addr = res; addr != NULL; addr = addr->ai_next) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
998 { |
20077
128963cd954f
patch 8.2.0594: MS-Windows: cannot build with WINVER set to 0x0501
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
999 const char *dst = hostname; |
128963cd954f
patch 8.2.0594: MS-Windows: cannot build with WINVER set to 0x0501
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1000 const void *src = NULL; |
128963cd954f
patch 8.2.0594: MS-Windows: cannot build with WINVER set to 0x0501
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1001 # ifdef HAVE_INET_NTOP |
128963cd954f
patch 8.2.0594: MS-Windows: cannot build with WINVER set to 0x0501
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1002 char buf[NUMBUFLEN]; |
128963cd954f
patch 8.2.0594: MS-Windows: cannot build with WINVER set to 0x0501
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1003 # endif |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1004 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1005 if (addr->ai_family == AF_INET6) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1006 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1007 struct sockaddr_in6 *sai = (struct sockaddr_in6 *)addr->ai_addr; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1008 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1009 sai->sin6_port = htons(port); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1010 src = &sai->sin6_addr; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1011 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1012 else if (addr->ai_family == AF_INET) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1013 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1014 struct sockaddr_in *sai = (struct sockaddr_in *)addr->ai_addr; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1015 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1016 sai->sin_port = htons(port); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1017 src = &sai->sin_addr; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1018 } |
20077
128963cd954f
patch 8.2.0594: MS-Windows: cannot build with WINVER set to 0x0501
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1019 # ifdef HAVE_INET_NTOP |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1020 if (src != NULL) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1021 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1022 dst = inet_ntop(addr->ai_family, src, buf, sizeof(buf)); |
20077
128963cd954f
patch 8.2.0594: MS-Windows: cannot build with WINVER set to 0x0501
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1023 if (dst == NULL) |
128963cd954f
patch 8.2.0594: MS-Windows: cannot build with WINVER set to 0x0501
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1024 dst = hostname; |
128963cd954f
patch 8.2.0594: MS-Windows: cannot build with WINVER set to 0x0501
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1025 else if (STRCMP(hostname, dst) != 0) |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1026 ch_log(channel, "Resolved %s to %s", hostname, dst); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1027 } |
20077
128963cd954f
patch 8.2.0594: MS-Windows: cannot build with WINVER set to 0x0501
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1028 # endif |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1029 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1030 ch_log(channel, "Trying to connect to %s port %d", dst, port); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1031 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1032 // On Mac and Solaris a zero timeout almost never works. At least wait |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1033 // one millisecond. Let's do it for all systems, because we don't know |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1034 // why this is needed. |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1035 if (waittime == 0) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1036 waittime = 1; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1037 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1038 sd = channel_connect(channel, addr->ai_addr, addr->ai_addrlen, |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1039 &waittime); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1040 if (sd >= 0) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1041 break; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1042 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1043 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1044 freeaddrinfo(res); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1045 #else |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
20003
diff
changeset
|
1046 CLEAR_FIELD(server); |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1047 server.sin_family = AF_INET; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1048 server.sin_port = htons(port); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1049 if ((host = gethostbyname(hostname)) == NULL) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1050 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1051 ch_error(channel, "in gethostbyname() in channel_open()"); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1052 PERROR(_("E901: gethostbyname() in channel_open()")); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1053 channel_free(channel); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1054 return NULL; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1055 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1056 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1057 char *p; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1058 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1059 // When using host->h_addr_list[0] directly ubsan warns for it to not |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1060 // be aligned. First copy the pointer to avoid that. |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1061 memcpy(&p, &host->h_addr_list[0], sizeof(p)); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1062 memcpy((char *)&server.sin_addr, p, host->h_length); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1063 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1064 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1065 ch_log(channel, "Trying to connect to %s port %d", hostname, port); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1066 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1067 // On Mac and Solaris a zero timeout almost never works. At least wait one |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1068 // millisecond. Let's do it for all systems, because we don't know why |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1069 // this is needed. |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1070 if (waittime == 0) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1071 waittime = 1; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1072 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1073 sd = channel_connect(channel, (struct sockaddr *)&server, sizeof(server), |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1074 &waittime); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1075 #endif |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1076 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1077 if (sd < 0) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1078 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1079 channel_free(channel); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1080 return NULL; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1081 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1082 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1083 ch_log(channel, "Connection made"); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1084 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1085 channel->CH_SOCK_FD = (sock_T)sd; |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
1086 channel->ch_nb_close_cb = nb_close_cb; |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
1087 channel->ch_hostname = (char *)vim_strsave((char_u *)hostname); |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1088 channel->ch_port = port; |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1089 channel->ch_to_be_closed |= (1U << PART_SOCK); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
1090 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
1091 #ifdef FEAT_GUI |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1092 channel_gui_register_one(channel, PART_SOCK); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
1093 #endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
1094 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1095 return channel; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
1096 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
1097 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1098 /* |
17170
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1099 * Copy callback from "src" to "dest", incrementing the refcounts. |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1100 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1101 static void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1102 copy_callback(callback_T *dest, callback_T *src) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1103 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1104 dest->cb_partial = src->cb_partial; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1105 if (dest->cb_partial != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1106 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1107 dest->cb_name = src->cb_name; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1108 dest->cb_free_name = FALSE; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1109 ++dest->cb_partial->pt_refcount; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1110 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1111 else |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1112 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1113 dest->cb_name = vim_strsave(src->cb_name); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1114 dest->cb_free_name = TRUE; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1115 func_ref(src->cb_name); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1116 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1117 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1118 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1119 static void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1120 free_set_callback(callback_T *cbp, callback_T *callback) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1121 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1122 free_callback(cbp); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1123 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1124 if (callback->cb_name != NULL && *callback->cb_name != NUL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1125 copy_callback(cbp, callback); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1126 else |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1127 cbp->cb_name = NULL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1128 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1129 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1130 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1131 * Prepare buffer "buf" for writing channel output to. |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1132 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1133 static void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1134 prepare_buffer(buf_T *buf) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1135 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1136 buf_T *save_curbuf = curbuf; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1137 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1138 buf_copy_options(buf, BCO_ENTER); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1139 curbuf = buf; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1140 #ifdef FEAT_QUICKFIX |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1141 set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1142 set_option_value((char_u *)"bh", 0L, (char_u *)"hide", OPT_LOCAL); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1143 #endif |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1144 if (curbuf->b_ml.ml_mfp == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1145 ml_open(curbuf); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1146 curbuf = save_curbuf; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1147 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1148 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1149 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1150 * Find a buffer matching "name" or create a new one. |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1151 * Returns NULL if there is something very wrong (error already reported). |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1152 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1153 static buf_T * |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
17974
diff
changeset
|
1154 channel_find_buffer(char_u *name, int err, int msg) |
17170
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1155 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1156 buf_T *buf = NULL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1157 buf_T *save_curbuf = curbuf; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1158 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1159 if (name != NULL && *name != NUL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1160 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1161 buf = buflist_findname(name); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1162 if (buf == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1163 buf = buflist_findname_exp(name); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1164 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1165 if (buf == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1166 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1167 buf = buflist_new(name == NULL || *name == NUL ? NULL : name, |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1168 NULL, (linenr_T)0, BLN_LISTED | BLN_NEW); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1169 if (buf == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1170 return NULL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1171 prepare_buffer(buf); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1172 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1173 curbuf = buf; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1174 if (msg) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1175 ml_replace(1, (char_u *)(err ? "Reading from channel error..." |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1176 : "Reading from channel output..."), TRUE); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1177 changed_bytes(1, 0); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1178 curbuf = save_curbuf; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1179 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1180 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1181 return buf; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1182 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1183 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1184 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1185 * Set various properties from an "opt" argument. |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1186 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1187 static void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1188 channel_set_options(channel_T *channel, jobopt_T *opt) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1189 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1190 ch_part_T part; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1191 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1192 if (opt->jo_set & JO_MODE) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1193 for (part = PART_SOCK; part < PART_COUNT; ++part) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1194 channel->ch_part[part].ch_mode = opt->jo_mode; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1195 if (opt->jo_set & JO_IN_MODE) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1196 channel->ch_part[PART_IN].ch_mode = opt->jo_in_mode; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1197 if (opt->jo_set & JO_OUT_MODE) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1198 channel->ch_part[PART_OUT].ch_mode = opt->jo_out_mode; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1199 if (opt->jo_set & JO_ERR_MODE) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1200 channel->ch_part[PART_ERR].ch_mode = opt->jo_err_mode; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1201 channel->ch_nonblock = opt->jo_noblock; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1202 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1203 if (opt->jo_set & JO_TIMEOUT) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1204 for (part = PART_SOCK; part < PART_COUNT; ++part) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1205 channel->ch_part[part].ch_timeout = opt->jo_timeout; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1206 if (opt->jo_set & JO_OUT_TIMEOUT) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1207 channel->ch_part[PART_OUT].ch_timeout = opt->jo_out_timeout; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1208 if (opt->jo_set & JO_ERR_TIMEOUT) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1209 channel->ch_part[PART_ERR].ch_timeout = opt->jo_err_timeout; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1210 if (opt->jo_set & JO_BLOCK_WRITE) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1211 channel->ch_part[PART_IN].ch_block_write = 1; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1212 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1213 if (opt->jo_set & JO_CALLBACK) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1214 free_set_callback(&channel->ch_callback, &opt->jo_callback); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1215 if (opt->jo_set & JO_OUT_CALLBACK) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1216 free_set_callback(&channel->ch_part[PART_OUT].ch_callback, |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1217 &opt->jo_out_cb); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1218 if (opt->jo_set & JO_ERR_CALLBACK) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1219 free_set_callback(&channel->ch_part[PART_ERR].ch_callback, |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1220 &opt->jo_err_cb); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1221 if (opt->jo_set & JO_CLOSE_CALLBACK) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1222 free_set_callback(&channel->ch_close_cb, &opt->jo_close_cb); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1223 channel->ch_drop_never = opt->jo_drop_never; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1224 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1225 if ((opt->jo_set & JO_OUT_IO) && opt->jo_io[PART_OUT] == JIO_BUFFER) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1226 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1227 buf_T *buf; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1228 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1229 // writing output to a buffer. Default mode is NL. |
17170
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1230 if (!(opt->jo_set & JO_OUT_MODE)) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1231 channel->ch_part[PART_OUT].ch_mode = MODE_NL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1232 if (opt->jo_set & JO_OUT_BUF) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1233 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1234 buf = buflist_findnr(opt->jo_io_buf[PART_OUT]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1235 if (buf == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1236 semsg(_(e_nobufnr), (long)opt->jo_io_buf[PART_OUT]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1237 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1238 else |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1239 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1240 int msg = TRUE; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1241 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1242 if (opt->jo_set2 & JO2_OUT_MSG) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1243 msg = opt->jo_message[PART_OUT]; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
17974
diff
changeset
|
1244 buf = channel_find_buffer(opt->jo_io_name[PART_OUT], FALSE, msg); |
17170
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1245 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1246 if (buf != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1247 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1248 if (opt->jo_set & JO_OUT_MODIFIABLE) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1249 channel->ch_part[PART_OUT].ch_nomodifiable = |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1250 !opt->jo_modifiable[PART_OUT]; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1251 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1252 if (!buf->b_p_ma && !channel->ch_part[PART_OUT].ch_nomodifiable) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1253 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1254 emsg(_(e_modifiable)); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1255 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1256 else |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1257 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1258 ch_log(channel, "writing out to buffer '%s'", |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1259 (char *)buf->b_ffname); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1260 set_bufref(&channel->ch_part[PART_OUT].ch_bufref, buf); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1261 // if the buffer was deleted or unloaded resurrect it |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1262 if (buf->b_ml.ml_mfp == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1263 prepare_buffer(buf); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1264 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1265 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1266 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1267 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1268 if ((opt->jo_set & JO_ERR_IO) && (opt->jo_io[PART_ERR] == JIO_BUFFER |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1269 || (opt->jo_io[PART_ERR] == JIO_OUT && (opt->jo_set & JO_OUT_IO) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1270 && opt->jo_io[PART_OUT] == JIO_BUFFER))) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1271 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1272 buf_T *buf; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1273 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1274 // writing err to a buffer. Default mode is NL. |
17170
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1275 if (!(opt->jo_set & JO_ERR_MODE)) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1276 channel->ch_part[PART_ERR].ch_mode = MODE_NL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1277 if (opt->jo_io[PART_ERR] == JIO_OUT) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1278 buf = channel->ch_part[PART_OUT].ch_bufref.br_buf; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1279 else if (opt->jo_set & JO_ERR_BUF) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1280 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1281 buf = buflist_findnr(opt->jo_io_buf[PART_ERR]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1282 if (buf == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1283 semsg(_(e_nobufnr), (long)opt->jo_io_buf[PART_ERR]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1284 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1285 else |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1286 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1287 int msg = TRUE; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1288 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1289 if (opt->jo_set2 & JO2_ERR_MSG) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1290 msg = opt->jo_message[PART_ERR]; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
17974
diff
changeset
|
1291 buf = channel_find_buffer(opt->jo_io_name[PART_ERR], TRUE, msg); |
17170
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1292 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1293 if (buf != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1294 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1295 if (opt->jo_set & JO_ERR_MODIFIABLE) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1296 channel->ch_part[PART_ERR].ch_nomodifiable = |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1297 !opt->jo_modifiable[PART_ERR]; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1298 if (!buf->b_p_ma && !channel->ch_part[PART_ERR].ch_nomodifiable) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1299 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1300 emsg(_(e_modifiable)); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1301 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1302 else |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1303 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1304 ch_log(channel, "writing err to buffer '%s'", |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1305 (char *)buf->b_ffname); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1306 set_bufref(&channel->ch_part[PART_ERR].ch_bufref, buf); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1307 // if the buffer was deleted or unloaded resurrect it |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1308 if (buf->b_ml.ml_mfp == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1309 prepare_buffer(buf); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1310 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1311 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1312 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1313 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1314 channel->ch_part[PART_OUT].ch_io = opt->jo_io[PART_OUT]; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1315 channel->ch_part[PART_ERR].ch_io = opt->jo_io[PART_ERR]; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1316 channel->ch_part[PART_IN].ch_io = opt->jo_io[PART_IN]; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1317 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1318 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
1319 /* |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1320 * Implements ch_open(). |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1321 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
1322 static channel_T * |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1323 channel_open_func(typval_T *argvars) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1324 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1325 char_u *address; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1326 char_u *p; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1327 char *rest; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1328 int port; |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1329 int is_ipv6 = FALSE; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1330 jobopt_T opt; |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1331 channel_T *channel = NULL; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1332 |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
1333 address = tv_get_string(&argvars[0]); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1334 if (argvars[1].v_type != VAR_UNKNOWN |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1335 && (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1336 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
1337 emsg(_(e_invarg)); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1338 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1339 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1340 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1341 // parse address |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1342 if (*address == '[') |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1343 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1344 // ipv6 address |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1345 is_ipv6 = TRUE; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1346 p = vim_strchr(address + 1, ']'); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1347 if (p == NULL || *++p != ':') |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1348 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1349 semsg(_(e_invarg2), address); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1350 return NULL; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1351 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1352 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1353 else |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1354 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1355 p = vim_strchr(address, ':'); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1356 if (p == NULL) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1357 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1358 semsg(_(e_invarg2), address); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1359 return NULL; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1360 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1361 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1362 port = strtol((char *)(p + 1), &rest, 10); |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1363 if (*address == NUL || port <= 0 || port >= 65536 || *rest != NUL) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1364 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
1365 semsg(_(e_invarg2), address); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1366 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1367 } |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1368 if (is_ipv6) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1369 { |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1370 // strip '[' and ']' |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1371 ++address; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1372 *(p - 1) = NUL; |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1373 } |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1374 else |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
1375 *p = NUL; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1376 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1377 // parse options |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1378 clear_job_options(&opt); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1379 opt.jo_mode = MODE_JSON; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1380 opt.jo_timeout = 2000; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1381 if (get_job_options(&argvars[1], &opt, |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
1382 JO_MODE_ALL + JO_CB_ALL + JO_WAITTIME + JO_TIMEOUT_ALL, 0) == FAIL) |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1383 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1384 if (opt.jo_timeout < 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1385 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
1386 emsg(_(e_invarg)); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1387 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1388 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1389 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1390 channel = channel_open((char *)address, port, opt.jo_waittime, NULL); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1391 if (channel != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1392 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1393 opt.jo_set = JO_ALL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1394 channel_set_options(channel, &opt); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1395 } |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1396 theend: |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1397 free_job_options(&opt); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1398 return channel; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1399 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
1400 |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1401 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1402 ch_close_part(channel_T *channel, ch_part_T part) |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1403 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1404 sock_T *fd = &channel->ch_part[part].ch_fd; |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1405 |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1406 if (*fd != INVALID_FD) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1407 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1408 if (part == PART_SOCK) |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1409 sock_close(*fd); |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1410 else |
11723
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
1411 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1412 // When using a pty the same FD is set on multiple parts, only |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1413 // close it when the last reference is closed. |
11933
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1414 if ((part == PART_IN || channel->CH_IN_FD != *fd) |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1415 && (part == PART_OUT || channel->CH_OUT_FD != *fd) |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1416 && (part == PART_ERR || channel->CH_ERR_FD != *fd)) |
12389
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
1417 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
1418 #ifdef MSWIN |
12389
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
1419 if (channel->ch_named_pipe) |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
1420 DisconnectNamedPipe((HANDLE)fd); |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
1421 #endif |
11723
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
1422 fd_close(*fd); |
12389
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
1423 } |
11723
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
1424 } |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1425 *fd = INVALID_FD; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1426 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1427 // channel is closed, may want to end the job if it was the last |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1428 channel->ch_to_be_closed &= ~(1U << part); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1429 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1430 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1431 |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1432 void |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
1433 channel_set_pipes(channel_T *channel, sock_T in, sock_T out, sock_T err) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1434 { |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1435 if (in != INVALID_FD) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1436 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1437 ch_close_part(channel, PART_IN); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1438 channel->CH_IN_FD = in; |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1439 # if defined(UNIX) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1440 // Do not end the job when all output channels are closed, wait until |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1441 // the job ended. |
15632
d4a6d575e910
patch 8.1.0824: SunOS/Solaris has a problem with ttys
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1442 if (mch_isatty(in)) |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1443 channel->ch_to_be_closed |= (1U << PART_IN); |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1444 # endif |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1445 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1446 if (out != INVALID_FD) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1447 { |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1448 # if defined(FEAT_GUI) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1449 channel_gui_unregister_one(channel, PART_OUT); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1450 # endif |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1451 ch_close_part(channel, PART_OUT); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1452 channel->CH_OUT_FD = out; |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1453 channel->ch_to_be_closed |= (1U << PART_OUT); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1454 # if defined(FEAT_GUI) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1455 channel_gui_register_one(channel, PART_OUT); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1456 # endif |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1457 } |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1458 if (err != INVALID_FD) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1459 { |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1460 # if defined(FEAT_GUI) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1461 channel_gui_unregister_one(channel, PART_ERR); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1462 # endif |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1463 ch_close_part(channel, PART_ERR); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1464 channel->CH_ERR_FD = err; |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
1465 channel->ch_to_be_closed |= (1U << PART_ERR); |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1466 # if defined(FEAT_GUI) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1467 channel_gui_register_one(channel, PART_ERR); |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1468 # endif |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8481
diff
changeset
|
1469 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
1470 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
1471 |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
1472 /* |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1473 * Sets the job the channel is associated with and associated options. |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
1474 * This does not keep a refcount, when the job is freed ch_job is cleared. |
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
1475 */ |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
1476 void |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1477 channel_set_job(channel_T *channel, job_T *job, jobopt_T *options) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
1478 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1479 channel->ch_job = job; |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1480 |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1481 channel_set_options(channel, options); |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1482 |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1483 if (job->jv_in_buf != NULL) |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1484 { |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1485 chanpart_T *in_part = &channel->ch_part[PART_IN]; |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1486 |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1487 set_bufref(&in_part->ch_bufref, job->jv_in_buf); |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1488 ch_log(channel, "reading from buffer '%s'", |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1489 (char *)in_part->ch_bufref.br_buf->b_ffname); |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1490 if (options->jo_set & JO_IN_TOP) |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1491 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1492 if (options->jo_in_top == 0 && !(options->jo_set & JO_IN_BOT)) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1493 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1494 // Special mode: send last-but-one line when appending a line |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1495 // to the buffer. |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1496 in_part->ch_bufref.br_buf->b_write_to_channel = TRUE; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1497 in_part->ch_buf_append = TRUE; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1498 in_part->ch_buf_top = |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1499 in_part->ch_bufref.br_buf->b_ml.ml_line_count + 1; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1500 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1501 else |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1502 in_part->ch_buf_top = options->jo_in_top; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1503 } |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1504 else |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1505 in_part->ch_buf_top = 1; |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1506 if (options->jo_set & JO_IN_BOT) |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1507 in_part->ch_buf_bot = options->jo_in_bot; |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1508 else |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1509 in_part->ch_buf_bot = in_part->ch_bufref.br_buf->b_ml.ml_line_count; |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1510 } |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1511 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1512 |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1513 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1514 * Set the callback for "channel"/"part" for the response with "id". |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
1515 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
1516 static void |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1517 channel_set_req_callback( |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
1518 channel_T *channel, |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1519 ch_part_T part, |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1520 callback_T *callback, |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
1521 int id) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
1522 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1523 cbq_T *head = &channel->ch_part[part].ch_cb_head; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
1524 cbq_T *item = ALLOC_ONE(cbq_T); |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
1525 |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
1526 if (item != NULL) |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
1527 { |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1528 copy_callback(&item->cq_callback, callback); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1529 item->cq_seq_nr = id; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1530 item->cq_prev = head->cq_prev; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1531 head->cq_prev = item; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1532 item->cq_next = NULL; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1533 if (item->cq_prev == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1534 head->cq_next = item; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1535 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1536 item->cq_prev->cq_next = item; |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
1537 } |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1538 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1539 |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1540 static void |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1541 write_buf_line(buf_T *buf, linenr_T lnum, channel_T *channel) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1542 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1543 char_u *line = ml_get_buf(buf, lnum, FALSE); |
8453
fed4e19bd884
commit https://github.com/vim/vim/commit/367aabdbf76f7df00fd18e39d9378d1360a526ab
Christian Brabandt <cb@256bit.org>
parents:
8428
diff
changeset
|
1544 int len = (int)STRLEN(line); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1545 char_u *p; |
9434
8f904a323b3f
commit https://github.com/vim/vim/commit/bf2cc5f36d5ffd5de445e6970602000c7869b65a
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1546 int i; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1547 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1548 // Need to make a copy to be able to append a NL. |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1549 if ((p = alloc(len + 2)) == NULL) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1550 return; |
9367
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9355
diff
changeset
|
1551 memcpy((char *)p, (char *)line, len); |
9434
8f904a323b3f
commit https://github.com/vim/vim/commit/bf2cc5f36d5ffd5de445e6970602000c7869b65a
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1552 |
12311
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1553 if (channel->ch_write_text_mode) |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1554 p[len] = CAR; |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1555 else |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1556 { |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1557 for (i = 0; i < len; ++i) |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1558 if (p[i] == NL) |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1559 p[i] = NUL; |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1560 |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1561 p[len] = NL; |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
1562 } |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1563 p[len + 1] = NUL; |
10363
471b87c3b67d
commit https://github.com/vim/vim/commit/79cbdcb1eeead00bad6fc64ab4a53e5860d5a663
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
1564 channel_send(channel, PART_IN, p, len + 1, "write_buf_line"); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1565 vim_free(p); |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1566 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1567 |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1568 /* |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1569 * Return TRUE if "channel" can be written to. |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1570 * Returns FALSE if the input is closed or the write would block. |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1571 */ |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1572 static int |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1573 can_write_buf_line(channel_T *channel) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1574 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1575 chanpart_T *in_part = &channel->ch_part[PART_IN]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1576 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1577 if (in_part->ch_fd == INVALID_FD) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1578 return FALSE; // pipe was closed |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1579 |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1580 // for testing: block every other attempt to write |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1581 if (in_part->ch_block_write == 1) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1582 in_part->ch_block_write = -1; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1583 else if (in_part->ch_block_write == -1) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1584 in_part->ch_block_write = 1; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1585 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1586 // TODO: Win32 implementation, probably using WaitForMultipleObjects() |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
1587 #ifndef MSWIN |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1588 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1589 # if defined(HAVE_SELECT) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1590 struct timeval tval; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1591 fd_set wfds; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1592 int ret; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1593 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1594 FD_ZERO(&wfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1595 FD_SET((int)in_part->ch_fd, &wfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1596 tval.tv_sec = 0; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1597 tval.tv_usec = 0; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1598 for (;;) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1599 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1600 ret = select((int)in_part->ch_fd + 1, NULL, &wfds, NULL, &tval); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1601 # ifdef EINTR |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1602 SOCK_ERRNO; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1603 if (ret == -1 && errno == EINTR) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1604 continue; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1605 # endif |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1606 if (ret <= 0 || in_part->ch_block_write == 1) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1607 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1608 if (ret > 0) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1609 ch_log(channel, "FAKED Input not ready for writing"); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1610 else |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1611 ch_log(channel, "Input not ready for writing"); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1612 return FALSE; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1613 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1614 break; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1615 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1616 # else |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1617 struct pollfd fds; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1618 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1619 fds.fd = in_part->ch_fd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1620 fds.events = POLLOUT; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1621 if (poll(&fds, 1, 0) <= 0) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1622 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1623 ch_log(channel, "Input not ready for writing"); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1624 return FALSE; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1625 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1626 if (in_part->ch_block_write == 1) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1627 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1628 ch_log(channel, "FAKED Input not ready for writing"); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1629 return FALSE; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1630 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1631 # endif |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1632 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1633 #endif |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1634 return TRUE; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1635 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1636 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1637 /* |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1638 * Write any buffer lines to the input channel. |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1639 */ |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1640 static void |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1641 channel_write_in(channel_T *channel) |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1642 { |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1643 chanpart_T *in_part = &channel->ch_part[PART_IN]; |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1644 linenr_T lnum; |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1645 buf_T *buf = in_part->ch_bufref.br_buf; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1646 int written = 0; |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1647 |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1648 if (buf == NULL || in_part->ch_buf_append) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1649 return; // no buffer or using appending |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1650 if (!bufref_valid(&in_part->ch_bufref) || buf->b_ml.ml_mfp == NULL) |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1651 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1652 // buffer was wiped out or unloaded |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11416
diff
changeset
|
1653 ch_log(channel, "input buffer has been wiped out"); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1654 in_part->ch_bufref.br_buf = NULL; |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1655 return; |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1656 } |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1657 |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1658 for (lnum = in_part->ch_buf_top; lnum <= in_part->ch_buf_bot |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1659 && lnum <= buf->b_ml.ml_line_count; ++lnum) |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1660 { |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1661 if (!can_write_buf_line(channel)) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1662 break; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1663 write_buf_line(buf, lnum, channel); |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1664 ++written; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1665 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1666 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1667 if (written == 1) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1668 ch_log(channel, "written line %d to channel", (int)lnum - 1); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1669 else if (written > 1) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1670 ch_log(channel, "written %d lines to channel", written); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1671 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1672 in_part->ch_buf_top = lnum; |
10052
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1673 if (lnum > buf->b_ml.ml_line_count || lnum > in_part->ch_buf_bot) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1674 { |
12313
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
1675 #if defined(FEAT_TERMINAL) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1676 // Send CTRL-D or "eof_chars" to close stdin on MS-Windows. |
12309
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
1677 if (channel->ch_job != NULL) |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
1678 term_send_eof(channel); |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
1679 #endif |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
1680 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1681 // Writing is done, no longer need the buffer. |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1682 in_part->ch_bufref.br_buf = NULL; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1683 ch_log(channel, "Finished writing all lines to channel"); |
10052
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1684 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1685 // Close the pipe/socket, so that the other side gets EOF. |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1686 ch_close_part(channel, PART_IN); |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1687 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1688 else |
13608
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
1689 ch_log(channel, "Still %ld more lines to write", |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
1690 (long)(buf->b_ml.ml_line_count - lnum + 1)); |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1691 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1692 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1693 /* |
9355
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
1694 * Handle buffer "buf" being freed, remove it from any channels. |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1695 */ |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1696 void |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1697 channel_buffer_free(buf_T *buf) |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1698 { |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1699 channel_T *channel; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1700 ch_part_T part; |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1701 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
1702 FOR_ALL_CHANNELS(channel) |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1703 for (part = PART_SOCK; part < PART_COUNT; ++part) |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1704 { |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1705 chanpart_T *ch_part = &channel->ch_part[part]; |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1706 |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1707 if (ch_part->ch_bufref.br_buf == buf) |
9089
6bc0a492e8ba
commit https://github.com/vim/vim/commit/de7eb0a47b557eb4656c6b63d421c7e7bae1ef30
Christian Brabandt <cb@256bit.org>
parents:
9087
diff
changeset
|
1708 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1709 ch_log(channel, "%s buffer has been wiped out", |
9089
6bc0a492e8ba
commit https://github.com/vim/vim/commit/de7eb0a47b557eb4656c6b63d421c7e7bae1ef30
Christian Brabandt <cb@256bit.org>
parents:
9087
diff
changeset
|
1710 part_names[part]); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1711 ch_part->ch_bufref.br_buf = NULL; |
9089
6bc0a492e8ba
commit https://github.com/vim/vim/commit/de7eb0a47b557eb4656c6b63d421c7e7bae1ef30
Christian Brabandt <cb@256bit.org>
parents:
9087
diff
changeset
|
1712 } |
9087
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1713 } |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1714 } |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1715 |
d4606ae170aa
commit https://github.com/vim/vim/commit/e0f76d00979c972329f6c371463a20da61ccad65
Christian Brabandt <cb@256bit.org>
parents:
9085
diff
changeset
|
1716 /* |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1717 * Write any lines waiting to be written to "channel". |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1718 */ |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1719 static void |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1720 channel_write_input(channel_T *channel) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1721 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1722 chanpart_T *in_part = &channel->ch_part[PART_IN]; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1723 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1724 if (in_part->ch_writeque.wq_next != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1725 channel_send(channel, PART_IN, (char_u *)"", 0, "channel_write_input"); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1726 else if (in_part->ch_bufref.br_buf != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1727 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1728 if (in_part->ch_buf_append) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1729 channel_write_new_lines(in_part->ch_bufref.br_buf); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1730 else |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1731 channel_write_in(channel); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1732 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1733 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1734 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1735 /* |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1736 * Write any lines waiting to be written to a channel. |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1737 */ |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1738 void |
9282
9f97a6290c63
commit https://github.com/vim/vim/commit/cf089463492fab53b2a5d81517829d22f882f82e
Christian Brabandt <cb@256bit.org>
parents:
9246
diff
changeset
|
1739 channel_write_any_lines(void) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1740 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1741 channel_T *channel; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1742 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
1743 FOR_ALL_CHANNELS(channel) |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1744 channel_write_input(channel); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1745 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1746 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1747 /* |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1748 * Write appended lines above the last one in "buf" to the channel. |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1749 */ |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1750 void |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1751 channel_write_new_lines(buf_T *buf) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1752 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1753 channel_T *channel; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1754 int found_one = FALSE; |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1755 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1756 // There could be more than one channel for the buffer, loop over all of |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1757 // them. |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
1758 FOR_ALL_CHANNELS(channel) |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1759 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1760 chanpart_T *in_part = &channel->ch_part[PART_IN]; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1761 linenr_T lnum; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1762 int written = 0; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1763 |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
1764 if (in_part->ch_bufref.br_buf == buf && in_part->ch_buf_append) |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1765 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1766 if (in_part->ch_fd == INVALID_FD) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1767 continue; // pipe was closed |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1768 found_one = TRUE; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1769 for (lnum = in_part->ch_buf_bot; lnum < buf->b_ml.ml_line_count; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1770 ++lnum) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1771 { |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1772 if (!can_write_buf_line(channel)) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1773 break; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1774 write_buf_line(buf, lnum, channel); |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1775 ++written; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1776 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1777 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1778 if (written == 1) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1779 ch_log(channel, "written line %d to channel", (int)lnum - 1); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1780 else if (written > 1) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
1781 ch_log(channel, "written %d lines to channel", written); |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
1782 if (lnum < buf->b_ml.ml_line_count) |
13608
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
1783 ch_log(channel, "Still %ld more lines to write", |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
1784 (long)(buf->b_ml.ml_line_count - lnum)); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1785 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1786 in_part->ch_buf_bot = lnum; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1787 } |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1788 } |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1789 if (!found_one) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
1790 buf->b_write_to_channel = FALSE; |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1791 } |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1792 |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
1793 /* |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1794 * Invoke the "callback" on channel "channel". |
8928
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1795 * This does not redraw but sets channel_need_redraw; |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1796 */ |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1797 static void |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1798 invoke_callback(channel_T *channel, callback_T *callback, typval_T *argv) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1799 { |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1800 typval_T rettv; |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1801 |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
1802 if (safe_to_invoke_callback == 0) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
1803 iemsg("INTERNAL: Invoking callback when it is not safe"); |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
1804 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1805 argv[0].v_type = VAR_CHANNEL; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1806 argv[0].vval.v_channel = channel; |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
1807 |
17606
ff097edaae89
patch 8.1.1800: function call functions have too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1808 call_callback(callback, -1, &rettv, 2, argv); |
8174
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8172
diff
changeset
|
1809 clear_tv(&rettv); |
8928
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1810 channel_need_redraw = TRUE; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
1811 } |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
1812 |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
1813 /* |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1814 * Return the first node from "channel"/"part" without removing it. |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1815 * Returns NULL if there is nothing. |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1816 */ |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1817 readq_T * |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1818 channel_peek(channel_T *channel, ch_part_T part) |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1819 { |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1820 readq_T *head = &channel->ch_part[part].ch_head; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1821 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1822 return head->rq_next; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1823 } |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1824 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1825 /* |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1826 * Return a pointer to the first NL in "node". |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1827 * Skips over NUL characters. |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1828 * Returns NULL if there is no NL. |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1829 */ |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1830 char_u * |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1831 channel_first_nl(readq_T *node) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1832 { |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1833 char_u *buffer = node->rq_buffer; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1834 long_u i; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1835 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1836 for (i = 0; i < node->rq_buflen; ++i) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1837 if (buffer[i] == NL) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1838 return buffer + i; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1839 return NULL; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1840 } |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1841 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1842 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1843 * Return the first buffer from channel "channel"/"part" and remove it. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1844 * The caller must free it. |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1845 * Returns NULL if there is nothing. |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1846 */ |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1847 char_u * |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1848 channel_get(channel_T *channel, ch_part_T part, int *outlen) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1849 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1850 readq_T *head = &channel->ch_part[part].ch_head; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1851 readq_T *node = head->rq_next; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1852 char_u *p; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1853 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1854 if (node == NULL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1855 return NULL; |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1856 if (outlen != NULL) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1857 *outlen += node->rq_buflen; |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1858 // dispose of the node but keep the buffer |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1859 p = node->rq_buffer; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1860 head->rq_next = node->rq_next; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1861 if (node->rq_next == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1862 head->rq_prev = NULL; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1863 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1864 node->rq_next->rq_prev = NULL; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1865 vim_free(node); |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1866 return p; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1867 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1868 |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1869 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1870 * Returns the whole buffer contents concatenated for "channel"/"part". |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1871 * Replaces NUL bytes with NL. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1872 */ |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1873 static char_u * |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1874 channel_get_all(channel_T *channel, ch_part_T part, int *outlen) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1875 { |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1876 readq_T *head = &channel->ch_part[part].ch_head; |
16054
78faa25f9698
patch 8.1.1032: warnings from clang static analyzer
Bram Moolenaar <Bram@vim.org>
parents:
15975
diff
changeset
|
1877 readq_T *node; |
9367
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9355
diff
changeset
|
1878 long_u len = 0; |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1879 char_u *res; |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1880 char_u *p; |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1881 |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1882 // Concatenate everything into one buffer. |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1883 for (node = head->rq_next; node != NULL; node = node->rq_next) |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1884 len += node->rq_buflen; |
16768
695d9ef00b03
patch 8.1.1386: unessesary type casts for lalloc()
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1885 res = alloc(len + 1); |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1886 if (res == NULL) |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1887 return NULL; |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1888 p = res; |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1889 for (node = head->rq_next; node != NULL; node = node->rq_next) |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1890 { |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1891 mch_memmove(p, node->rq_buffer, node->rq_buflen); |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1892 p += node->rq_buflen; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1893 } |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1894 *p = NUL; |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1895 |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1896 // Free all buffers |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1897 do |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1898 { |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1899 p = channel_get(channel, part, NULL); |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1900 vim_free(p); |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1901 } while (p != NULL); |
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1902 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1903 if (outlen != NULL) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1904 { |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1905 // Returning the length, keep NUL characters. |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1906 *outlen += len; |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1907 return res; |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1908 } |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1909 |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1910 // Turn all NUL into NL, so that the result can be used as a string. |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1911 p = res; |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1912 while (p < res + len) |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1913 { |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1914 if (*p == NUL) |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1915 *p = NL; |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
1916 #ifdef MSWIN |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1917 else if (*p == 0x1b) |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1918 { |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1919 // crush the escape sequence OSC 0/1/2: ESC ]0; |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1920 if (p + 3 < res + len |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1921 && p[1] == ']' |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1922 && (p[2] == '0' || p[2] == '1' || p[2] == '2') |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1923 && p[3] == ';') |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1924 { |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1925 // '\a' becomes a NL |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1926 while (p < res + (len - 1) && *p != '\a') |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1927 ++p; |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1928 // BEL is zero width characters, suppress display mistake |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1929 // ConPTY (after 10.0.18317) requires advance checking |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1930 if (p[-1] == NUL) |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1931 p[-1] = 0x07; |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1932 } |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1933 } |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1934 #endif |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
1935 ++p; |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1936 } |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1937 |
8759
cc2ef7367643
commit https://github.com/vim/vim/commit/ee1f7b3cb71684aaa9bf457e2caf9d02187e6b7c
Christian Brabandt <cb@256bit.org>
parents:
8757
diff
changeset
|
1938 return res; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1939 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1940 |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1941 /* |
9282
9f97a6290c63
commit https://github.com/vim/vim/commit/cf089463492fab53b2a5d81517829d22f882f82e
Christian Brabandt <cb@256bit.org>
parents:
9246
diff
changeset
|
1942 * Consume "len" bytes from the head of "node". |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1943 * Caller must check these bytes are available. |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1944 */ |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1945 void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1946 channel_consume(channel_T *channel, ch_part_T part, int len) |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1947 { |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1948 readq_T *head = &channel->ch_part[part].ch_head; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1949 readq_T *node = head->rq_next; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1950 char_u *buf = node->rq_buffer; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1951 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1952 mch_memmove(buf, buf + len, node->rq_buflen - len); |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1953 node->rq_buflen -= len; |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
1954 node->rq_buffer[node->rq_buflen] = NUL; |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1955 } |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1956 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1957 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1958 * Collapses the first and second buffer for "channel"/"part". |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1959 * Returns FAIL if that is not possible. |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1960 * When "want_nl" is TRUE collapse more buffers until a NL is found. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1961 */ |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1962 int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
1963 channel_collapse(channel_T *channel, ch_part_T part, int want_nl) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1964 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
1965 readq_T *head = &channel->ch_part[part].ch_head; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1966 readq_T *node = head->rq_next; |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1967 readq_T *last_node; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1968 readq_T *n; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1969 char_u *newbuf; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1970 char_u *p; |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1971 long_u len; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1972 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1973 if (node == NULL || node->rq_next == NULL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1974 return FAIL; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
1975 |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1976 last_node = node->rq_next; |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
1977 len = node->rq_buflen + last_node->rq_buflen; |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1978 if (want_nl) |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1979 while (last_node->rq_next != NULL |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1980 && channel_first_nl(last_node) == NULL) |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1981 { |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1982 last_node = last_node->rq_next; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1983 len += last_node->rq_buflen; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1984 } |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1985 |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
1986 p = newbuf = alloc(len + 1); |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1987 if (newbuf == NULL) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
1988 return FAIL; // out of memory |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1989 mch_memmove(p, node->rq_buffer, node->rq_buflen); |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1990 p += node->rq_buflen; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
1991 vim_free(node->rq_buffer); |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1992 node->rq_buffer = newbuf; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1993 for (n = node; n != last_node; ) |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1994 { |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1995 n = n->rq_next; |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1996 mch_memmove(p, n->rq_buffer, n->rq_buflen); |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1997 p += n->rq_buflen; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1998 vim_free(n->rq_buffer); |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
1999 } |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
2000 *p = NUL; |
9238
7d13d180a6ae
commit https://github.com/vim/vim/commit/bbe8d91e695184771d7e45315258fab8eb3e6b07
Christian Brabandt <cb@256bit.org>
parents:
9215
diff
changeset
|
2001 node->rq_buflen = (long_u)(p - newbuf); |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2002 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2003 // dispose of the collapsed nodes and their buffers |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2004 for (n = node->rq_next; n != last_node; ) |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2005 { |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2006 n = n->rq_next; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2007 vim_free(n->rq_prev); |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2008 } |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2009 node->rq_next = last_node->rq_next; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2010 if (last_node->rq_next == NULL) |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2011 head->rq_prev = node; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2012 else |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2013 last_node->rq_next->rq_prev = node; |
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2014 vim_free(last_node); |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2015 return OK; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2016 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2017 |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2018 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2019 * Store "buf[len]" on "channel"/"part". |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2020 * When "prepend" is TRUE put in front, otherwise append at the end. |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2021 * Returns OK or FAIL. |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2022 */ |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2023 static int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2024 channel_save(channel_T *channel, ch_part_T part, char_u *buf, int len, |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2025 int prepend, char *lead) |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2026 { |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2027 readq_T *node; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2028 readq_T *head = &channel->ch_part[part].ch_head; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2029 char_u *p; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2030 int i; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2031 |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
2032 node = ALLOC_ONE(readq_T); |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2033 if (node == NULL) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2034 return FAIL; // out of memory |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2035 // A NUL is added at the end, because netbeans code expects that. |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2036 // Otherwise a NUL may appear inside the text. |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2037 node->rq_buffer = alloc(len + 1); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2038 if (node->rq_buffer == NULL) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2039 { |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2040 vim_free(node); |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2041 return FAIL; // out of memory |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2042 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2043 |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2044 if (channel->ch_part[part].ch_mode == MODE_NL) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2045 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2046 // Drop any CR before a NL. |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2047 p = node->rq_buffer; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2048 for (i = 0; i < len; ++i) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2049 if (buf[i] != CAR || i + 1 >= len || buf[i + 1] != NL) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2050 *p++ = buf[i]; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2051 *p = NUL; |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2052 node->rq_buflen = (long_u)(p - node->rq_buffer); |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2053 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2054 else |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2055 { |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2056 mch_memmove(node->rq_buffer, buf, len); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2057 node->rq_buffer[len] = NUL; |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2058 node->rq_buflen = (long_u)len; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2059 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2060 |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2061 if (prepend) |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2062 { |
16378
3d6b282e2d6e
patch 8.1.1194: typos and small problems in source files
Bram Moolenaar <Bram@vim.org>
parents:
16306
diff
changeset
|
2063 // prepend node to the head of the queue |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2064 node->rq_next = head->rq_next; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2065 node->rq_prev = NULL; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2066 if (head->rq_next == NULL) |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2067 head->rq_prev = node; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2068 else |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2069 head->rq_next->rq_prev = node; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2070 head->rq_next = node; |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2071 } |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2072 else |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2073 { |
16378
3d6b282e2d6e
patch 8.1.1194: typos and small problems in source files
Bram Moolenaar <Bram@vim.org>
parents:
16306
diff
changeset
|
2074 // append node to the tail of the queue |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2075 node->rq_next = NULL; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2076 node->rq_prev = head->rq_prev; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2077 if (head->rq_prev == NULL) |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2078 head->rq_next = node; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2079 else |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2080 head->rq_prev->rq_next = node; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2081 head->rq_prev = node; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2082 } |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2083 |
12443
579faede5d9c
patch 8.0.1101: channel write fails if writing to log fails
Christian Brabandt <cb@256bit.org>
parents:
12407
diff
changeset
|
2084 if (ch_log_active() && lead != NULL) |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2085 { |
14499
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
2086 ch_log_lead(lead, channel, part); |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2087 fprintf(log_fd, "'"); |
14730
193471015e1a
patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions
Christian Brabandt <cb@256bit.org>
parents:
14675
diff
changeset
|
2088 vim_ignored = (int)fwrite(buf, len, 1, log_fd); |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2089 fprintf(log_fd, "'\n"); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2090 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2091 return OK; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2092 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2093 |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2094 /* |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2095 * Try to fill the buffer of "reader". |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2096 * Returns FALSE when nothing was added. |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2097 */ |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2098 static int |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2099 channel_fill(js_read_T *reader) |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2100 { |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2101 channel_T *channel = (channel_T *)reader->js_cookie; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2102 ch_part_T part = reader->js_cookie_arg; |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
2103 char_u *next = channel_get(channel, part, NULL); |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2104 int keeplen; |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2105 int addlen; |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2106 char_u *p; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2107 |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2108 if (next == NULL) |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2109 return FALSE; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2110 |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2111 keeplen = reader->js_end - reader->js_buf; |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2112 if (keeplen > 0) |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2113 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2114 // Prepend unused text. |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2115 addlen = (int)STRLEN(next); |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2116 p = alloc(keeplen + addlen + 1); |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2117 if (p == NULL) |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2118 { |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2119 vim_free(next); |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2120 return FALSE; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2121 } |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2122 mch_memmove(p, reader->js_buf, keeplen); |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2123 mch_memmove(p + keeplen, next, addlen + 1); |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2124 vim_free(next); |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2125 next = p; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2126 } |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2127 |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2128 vim_free(reader->js_buf); |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2129 reader->js_buf = next; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2130 return TRUE; |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2131 } |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2132 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2133 /* |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2134 * Use the read buffer of "channel"/"part" and parse a JSON message that is |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2135 * complete. The messages are added to the queue. |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2136 * Return TRUE if there is more to read. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2137 */ |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2138 static int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2139 channel_parse_json(channel_T *channel, ch_part_T part) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2140 { |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2141 js_read_T reader; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2142 typval_T listtv; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2143 jsonq_T *item; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2144 chanpart_T *chanpart = &channel->ch_part[part]; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2145 jsonq_T *head = &chanpart->ch_json_head; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2146 int status; |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2147 int ret; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2148 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2149 if (channel_peek(channel, part) == NULL) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2150 return FALSE; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2151 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
2152 reader.js_buf = channel_get(channel, part, NULL); |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2153 reader.js_used = 0; |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2154 reader.js_fill = channel_fill; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2155 reader.js_cookie = channel; |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2156 reader.js_cookie_arg = part; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2157 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2158 // When a message is incomplete we wait for a short while for more to |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2159 // arrive. After the delay drop the input, otherwise a truncated string |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2160 // or list will make us hang. |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2161 // Do not generate error messages, they will be written in a channel log. |
10553
f83b6a0b6148
patch 8.0.0166: JSON with a duplicate key gives an internal error
Christian Brabandt <cb@256bit.org>
parents:
10540
diff
changeset
|
2162 ++emsg_silent; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2163 status = json_decode(&reader, &listtv, |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2164 chanpart->ch_mode == MODE_JS ? JSON_JS : 0); |
10553
f83b6a0b6148
patch 8.0.0166: JSON with a duplicate key gives an internal error
Christian Brabandt <cb@256bit.org>
parents:
10540
diff
changeset
|
2165 --emsg_silent; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2166 if (status == OK) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2167 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2168 // Only accept the response when it is a list with at least two |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2169 // items. |
7937
2e905dfc6999
commit https://github.com/vim/vim/commit/6076fe1986255d32b7a078a28bf9e7bea19d6f30
Christian Brabandt <cb@256bit.org>
parents:
7935
diff
changeset
|
2170 if (listtv.v_type != VAR_LIST || listtv.vval.v_list->lv_len < 2) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2171 { |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2172 if (listtv.v_type != VAR_LIST) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2173 ch_error(channel, "Did not receive a list, discarding"); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2174 else |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2175 ch_error(channel, "Expected list with two items, got %d", |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2176 listtv.vval.v_list->lv_len); |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2177 clear_tv(&listtv); |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2178 } |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2179 else |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2180 { |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
2181 item = ALLOC_ONE(jsonq_T); |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2182 if (item == NULL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2183 clear_tv(&listtv); |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2184 else |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2185 { |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2186 item->jq_no_callback = FALSE; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2187 item->jq_value = alloc_tv(); |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2188 if (item->jq_value == NULL) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2189 { |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2190 vim_free(item); |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2191 clear_tv(&listtv); |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2192 } |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2193 else |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2194 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2195 *item->jq_value = listtv; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2196 item->jq_prev = head->jq_prev; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2197 head->jq_prev = item; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2198 item->jq_next = NULL; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2199 if (item->jq_prev == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2200 head->jq_next = item; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2201 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2202 item->jq_prev->jq_next = item; |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2203 } |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2204 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2205 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2206 } |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2207 |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2208 if (status == OK) |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2209 chanpart->ch_wait_len = 0; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2210 else if (status == MAYBE) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2211 { |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2212 size_t buflen = STRLEN(reader.js_buf); |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2213 |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2214 if (chanpart->ch_wait_len < buflen) |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2215 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2216 // First time encountering incomplete message or after receiving |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2217 // more (but still incomplete): set a deadline of 100 msec. |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2218 ch_log(channel, |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2219 "Incomplete message (%d bytes) - wait 100 msec for more", |
10996
2f041b367cd9
patch 8.0.0387: compiler warnings
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
2220 (int)buflen); |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2221 reader.js_used = 0; |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2222 chanpart->ch_wait_len = buflen; |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2223 #ifdef MSWIN |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2224 chanpart->ch_deadline = GetTickCount() + 100L; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2225 #else |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2226 gettimeofday(&chanpart->ch_deadline, NULL); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2227 chanpart->ch_deadline.tv_usec += 100 * 1000; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2228 if (chanpart->ch_deadline.tv_usec > 1000 * 1000) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2229 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2230 chanpart->ch_deadline.tv_usec -= 1000 * 1000; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2231 ++chanpart->ch_deadline.tv_sec; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2232 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2233 #endif |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2234 } |
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2235 else |
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2236 { |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2237 int timeout; |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2238 #ifdef MSWIN |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2239 timeout = GetTickCount() > chanpart->ch_deadline; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2240 #else |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2241 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2242 struct timeval now_tv; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2243 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2244 gettimeofday(&now_tv, NULL); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2245 timeout = now_tv.tv_sec > chanpart->ch_deadline.tv_sec |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2246 || (now_tv.tv_sec == chanpart->ch_deadline.tv_sec |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2247 && now_tv.tv_usec > chanpart->ch_deadline.tv_usec); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2248 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2249 #endif |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2250 if (timeout) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2251 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2252 status = FAIL; |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2253 chanpart->ch_wait_len = 0; |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2254 ch_log(channel, "timed out"); |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2255 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2256 else |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2257 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2258 reader.js_used = 0; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2259 ch_log(channel, "still waiting on incomplete message"); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2260 } |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2261 } |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2262 } |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2263 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2264 if (status == FAIL) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2265 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2266 ch_error(channel, "Decoding failed - discarding input"); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2267 ret = FALSE; |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
2268 chanpart->ch_wait_len = 0; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2269 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2270 else if (reader.js_buf[reader.js_used] != NUL) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2271 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2272 // Put the unread part back into the channel. |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2273 channel_save(channel, part, reader.js_buf + reader.js_used, |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2274 (int)(reader.js_end - reader.js_buf) - reader.js_used, |
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
2275 TRUE, NULL); |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2276 ret = status == MAYBE ? FALSE: TRUE; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2277 } |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2278 else |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2279 ret = FALSE; |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2280 |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2281 vim_free(reader.js_buf); |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2282 return ret; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2283 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2284 |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2285 /* |
8074
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
2286 * Remove "node" from the queue that it is in. Does not free it. |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2287 */ |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2288 static void |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2289 remove_cb_node(cbq_T *head, cbq_T *node) |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2290 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2291 if (node->cq_prev == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2292 head->cq_next = node->cq_next; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2293 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2294 node->cq_prev->cq_next = node->cq_next; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2295 if (node->cq_next == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2296 head->cq_prev = node->cq_prev; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2297 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2298 node->cq_next->cq_prev = node->cq_prev; |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2299 } |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2300 |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2301 /* |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2302 * Remove "node" from the queue that it is in and free it. |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2303 * Caller should have freed or used node->jq_value. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2304 */ |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2305 static void |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2306 remove_json_node(jsonq_T *head, jsonq_T *node) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2307 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2308 if (node->jq_prev == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2309 head->jq_next = node->jq_next; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2310 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2311 node->jq_prev->jq_next = node->jq_next; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2312 if (node->jq_next == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2313 head->jq_prev = node->jq_prev; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2314 else |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2315 node->jq_next->jq_prev = node->jq_prev; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2316 vim_free(node); |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2317 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2318 |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2319 /* |
17024
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2320 * Add "id" to the list of JSON message IDs we are waiting on. |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2321 */ |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2322 static void |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2323 channel_add_block_id(chanpart_T *chanpart, int id) |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2324 { |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2325 garray_T *gap = &chanpart->ch_block_ids; |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2326 |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2327 if (gap->ga_growsize == 0) |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2328 ga_init2(gap, (int)sizeof(int), 10); |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2329 if (ga_grow(gap, 1) == OK) |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2330 { |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2331 ((int *)gap->ga_data)[gap->ga_len] = id; |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2332 ++gap->ga_len; |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2333 } |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2334 } |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2335 |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2336 /* |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2337 * Remove "id" from the list of JSON message IDs we are waiting on. |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2338 */ |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2339 static void |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2340 channel_remove_block_id(chanpart_T *chanpart, int id) |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2341 { |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2342 garray_T *gap = &chanpart->ch_block_ids; |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2343 int i; |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2344 |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2345 for (i = 0; i < gap->ga_len; ++i) |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2346 if (((int *)gap->ga_data)[i] == id) |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2347 { |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2348 --gap->ga_len; |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2349 if (i < gap->ga_len) |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2350 { |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2351 int *p = ((int *)gap->ga_data) + i; |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2352 |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2353 mch_memmove(p, p + 1, (gap->ga_len - i) * sizeof(int)); |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2354 } |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2355 return; |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2356 } |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2357 siemsg("INTERNAL: channel_remove_block_id: cannot find id %d", id); |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2358 } |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2359 |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2360 /* |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2361 * Return TRUE if "id" is in the list of JSON message IDs we are waiting on. |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2362 */ |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2363 static int |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2364 channel_has_block_id(chanpart_T *chanpart, int id) |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2365 { |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2366 garray_T *gap = &chanpart->ch_block_ids; |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2367 int i; |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2368 |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2369 for (i = 0; i < gap->ga_len; ++i) |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2370 if (((int *)gap->ga_data)[i] == id) |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2371 return TRUE; |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2372 return FALSE; |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2373 } |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2374 |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2375 /* |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2376 * Get a message from the JSON queue for channel "channel". |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2377 * When "id" is positive it must match the first number in the list. |
17024
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2378 * When "id" is zero or negative jut get the first message. But not one |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2379 * in the ch_block_ids list. |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2380 * When "without_callback" is TRUE also get messages that were pushed back. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2381 * Return OK when found and return the value in "rettv". |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2382 * Return FAIL otherwise. |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2383 */ |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2384 static int |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2385 channel_get_json( |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2386 channel_T *channel, |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2387 ch_part_T part, |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2388 int id, |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2389 int without_callback, |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2390 typval_T **rettv) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2391 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2392 jsonq_T *head = &channel->ch_part[part].ch_json_head; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2393 jsonq_T *item = head->jq_next; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2394 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2395 while (item != NULL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2396 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2397 list_T *l = item->jq_value->vval.v_list; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19168
diff
changeset
|
2398 typval_T *tv; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19168
diff
changeset
|
2399 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19168
diff
changeset
|
2400 range_list_materialize(l); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19168
diff
changeset
|
2401 tv = &l->lv_first->li_tv; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2402 |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2403 if ((without_callback || !item->jq_no_callback) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2404 && ((id > 0 && tv->v_type == VAR_NUMBER && tv->vval.v_number == id) |
7997
c1c9ab17e197
commit https://github.com/vim/vim/commit/e56bf15c163a921ce9e1c09c0d5b3a03efc63324
Christian Brabandt <cb@256bit.org>
parents:
7988
diff
changeset
|
2405 || (id <= 0 && (tv->v_type != VAR_NUMBER |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2406 || tv->vval.v_number == 0 |
17024
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2407 || !channel_has_block_id( |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
2408 &channel->ch_part[part], tv->vval.v_number))))) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2409 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2410 *rettv = item->jq_value; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
2411 if (tv->v_type == VAR_NUMBER) |
13608
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
2412 ch_log(channel, "Getting JSON message %ld", |
2a2b668cf24c
patch 8.0.1676: no compiler warning for wrong printf format
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
2413 (long)tv->vval.v_number); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2414 remove_json_node(head, item); |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2415 return OK; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2416 } |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2417 item = item->jq_next; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2418 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2419 return FAIL; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2420 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2421 |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2422 /* |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2423 * Put back "rettv" into the JSON queue, there was no callback for it. |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2424 * Takes over the values in "rettv". |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2425 */ |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2426 static void |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2427 channel_push_json(channel_T *channel, ch_part_T part, typval_T *rettv) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2428 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2429 jsonq_T *head = &channel->ch_part[part].ch_json_head; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2430 jsonq_T *item = head->jq_next; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2431 jsonq_T *newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2432 |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2433 if (head->jq_prev != NULL && head->jq_prev->jq_no_callback) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2434 // last item was pushed back, append to the end |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2435 item = NULL; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2436 else while (item != NULL && item->jq_no_callback) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2437 // append after the last item that was pushed back |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2438 item = item->jq_next; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2439 |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
2440 newitem = ALLOC_ONE(jsonq_T); |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2441 if (newitem == NULL) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2442 clear_tv(rettv); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2443 else |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2444 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2445 newitem->jq_value = alloc_tv(); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2446 if (newitem->jq_value == NULL) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2447 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2448 vim_free(newitem); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2449 clear_tv(rettv); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2450 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2451 else |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2452 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2453 newitem->jq_no_callback = FALSE; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2454 *newitem->jq_value = *rettv; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2455 if (item == NULL) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2456 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2457 // append to the end |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2458 newitem->jq_prev = head->jq_prev; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2459 head->jq_prev = newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2460 newitem->jq_next = NULL; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2461 if (newitem->jq_prev == NULL) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2462 head->jq_next = newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2463 else |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2464 newitem->jq_prev->jq_next = newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2465 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2466 else |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2467 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2468 // append after "item" |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2469 newitem->jq_prev = item; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2470 newitem->jq_next = item->jq_next; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2471 item->jq_next = newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2472 if (newitem->jq_next == NULL) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2473 head->jq_prev = newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2474 else |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2475 newitem->jq_next->jq_prev = newitem; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2476 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2477 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2478 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2479 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2480 |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2481 #define CH_JSON_MAX_ARGS 4 |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2482 |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2483 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2484 * Execute a command received over "channel"/"part" |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2485 * "argv[0]" is the command string. |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2486 * "argv[1]" etc. have further arguments, type is VAR_UNKNOWN if missing. |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2487 */ |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2488 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2489 channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv) |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2490 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2491 char_u *cmd = argv[0].vval.v_string; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2492 char_u *arg; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2493 int options = channel->ch_part[part].ch_mode == MODE_JS ? JSON_JS : 0; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2494 |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2495 if (argv[1].v_type != VAR_STRING) |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2496 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2497 ch_error(channel, "received command with non-string argument"); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2498 if (p_verbose > 2) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
2499 emsg(_("E903: received command with non-string argument")); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2500 return; |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2501 } |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2502 arg = argv[1].vval.v_string; |
7872
4b9d4600166f
commit https://github.com/vim/vim/commit/14ad611ca435d97e8fd0d9ab03ddc982843298ac
Christian Brabandt <cb@256bit.org>
parents:
7868
diff
changeset
|
2503 if (arg == NULL) |
4b9d4600166f
commit https://github.com/vim/vim/commit/14ad611ca435d97e8fd0d9ab03ddc982843298ac
Christian Brabandt <cb@256bit.org>
parents:
7868
diff
changeset
|
2504 arg = (char_u *)""; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2505 |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2506 if (STRCMP(cmd, "ex") == 0) |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2507 { |
18949
5c405689da3e
patch 8.2.0035: saving and restoring called_emsg is clumsy
Bram Moolenaar <Bram@vim.org>
parents:
18943
diff
changeset
|
2508 int called_emsg_before = called_emsg; |
5c405689da3e
patch 8.2.0035: saving and restoring called_emsg is clumsy
Bram Moolenaar <Bram@vim.org>
parents:
18943
diff
changeset
|
2509 |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2510 ch_log(channel, "Executing ex command '%s'", (char *)arg); |
8746
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8684
diff
changeset
|
2511 ++emsg_silent; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2512 do_cmdline_cmd(arg); |
8746
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8684
diff
changeset
|
2513 --emsg_silent; |
18949
5c405689da3e
patch 8.2.0035: saving and restoring called_emsg is clumsy
Bram Moolenaar <Bram@vim.org>
parents:
18943
diff
changeset
|
2514 if (called_emsg > called_emsg_before) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2515 ch_log(channel, "Ex command error: '%s'", |
8746
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8684
diff
changeset
|
2516 (char *)get_vim_var_str(VV_ERRMSG)); |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2517 } |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2518 else if (STRCMP(cmd, "normal") == 0) |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2519 { |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2520 exarg_T ea; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2521 |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2522 ch_log(channel, "Executing normal command '%s'", (char *)arg); |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
20003
diff
changeset
|
2523 CLEAR_FIELD(ea); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2524 ea.arg = arg; |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2525 ea.addr_count = 0; |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2526 ea.forceit = TRUE; // no mapping |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2527 ex_normal(&ea); |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2528 } |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2529 else if (STRCMP(cmd, "redraw") == 0) |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2530 { |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2531 exarg_T ea; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2532 |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2533 ch_log(channel, "redraw"); |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
20003
diff
changeset
|
2534 CLEAR_FIELD(ea); |
7872
4b9d4600166f
commit https://github.com/vim/vim/commit/14ad611ca435d97e8fd0d9ab03ddc982843298ac
Christian Brabandt <cb@256bit.org>
parents:
7868
diff
changeset
|
2535 ea.forceit = *arg != NUL; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2536 ex_redraw(&ea); |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2537 showruler(FALSE); |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2538 setcursor(); |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
2539 out_flush_cursor(TRUE, FALSE); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2540 } |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2541 else if (STRCMP(cmd, "expr") == 0 || STRCMP(cmd, "call") == 0) |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2542 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2543 int is_call = cmd[0] == 'c'; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2544 int id_idx = is_call ? 3 : 2; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2545 |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2546 if (argv[id_idx].v_type != VAR_UNKNOWN |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2547 && argv[id_idx].v_type != VAR_NUMBER) |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2548 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2549 ch_error(channel, "last argument for expr/call must be a number"); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2550 if (p_verbose > 2) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
2551 emsg(_("E904: last argument for expr/call must be a number")); |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2552 } |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2553 else if (is_call && argv[2].v_type != VAR_LIST) |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2554 { |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2555 ch_error(channel, "third argument for call must be a list"); |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2556 if (p_verbose > 2) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
2557 emsg(_("E904: third argument for call must be a list")); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2558 } |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2559 else |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2560 { |
10112
90b9898d05a6
commit https://github.com/vim/vim/commit/c8fe338d64cc6183c03d4c12b1e036a7745e2932
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
2561 typval_T *tv = NULL; |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2562 typval_T res_tv; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2563 typval_T err_tv; |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2564 char_u *json = NULL; |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2565 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2566 // Don't pollute the display with errors. |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7899
diff
changeset
|
2567 ++emsg_skip; |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2568 if (!is_call) |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2569 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2570 ch_log(channel, "Evaluating expression '%s'", (char *)arg); |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2571 tv = eval_expr(arg, NULL); |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2572 } |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2573 else |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2574 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2575 ch_log(channel, "Calling '%s'", (char *)arg); |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2576 if (func_call(arg, &argv[2], NULL, NULL, &res_tv) == OK) |
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2577 tv = &res_tv; |
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8607
diff
changeset
|
2578 } |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2579 |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2580 if (argv[id_idx].v_type == VAR_NUMBER) |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2581 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2582 int id = argv[id_idx].vval.v_number; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2583 |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2584 if (tv != NULL) |
9969
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
2585 json = json_encode_nr_expr(id, tv, options | JSON_NL); |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2586 if (tv == NULL || (json != NULL && *json == NUL)) |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2587 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2588 // If evaluation failed or the result can't be encoded |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2589 // then return the string "ERROR". |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2590 vim_free(json); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2591 err_tv.v_type = VAR_STRING; |
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2592 err_tv.vval.v_string = (char_u *)"ERROR"; |
10112
90b9898d05a6
commit https://github.com/vim/vim/commit/c8fe338d64cc6183c03d4c12b1e036a7745e2932
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
2593 json = json_encode_nr_expr(id, &err_tv, options | JSON_NL); |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
2594 } |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2595 if (json != NULL) |
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2596 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2597 channel_send(channel, |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2598 part == PART_SOCK ? PART_SOCK : PART_IN, |
9434
8f904a323b3f
commit https://github.com/vim/vim/commit/bf2cc5f36d5ffd5de445e6970602000c7869b65a
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
2599 json, (int)STRLEN(json), (char *)cmd); |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2600 vim_free(json); |
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2601 } |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2602 } |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7961
diff
changeset
|
2603 --emsg_skip; |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2604 if (tv == &res_tv) |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2605 clear_tv(tv); |
10112
90b9898d05a6
commit https://github.com/vim/vim/commit/c8fe338d64cc6183c03d4c12b1e036a7745e2932
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
2606 else |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7899
diff
changeset
|
2607 free_tv(tv); |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2608 } |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2609 } |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2610 else if (p_verbose > 2) |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2611 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2612 ch_error(channel, "Received unknown command: %s", (char *)cmd); |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
2613 semsg(_("E905: received unknown command: %s"), cmd); |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2614 } |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2615 } |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2616 |
8928
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
2617 /* |
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
2618 * Invoke the callback at "cbhead". |
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
2619 * Does not redraw but sets channel_need_redraw. |
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
2620 */ |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2621 static void |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2622 invoke_one_time_callback( |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2623 channel_T *channel, |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2624 cbq_T *cbhead, |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2625 cbq_T *item, |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2626 typval_T *argv) |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2627 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2628 ch_log(channel, "Invoking one-time callback %s", |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2629 (char *)item->cq_callback.cb_name); |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2630 // Remove the item from the list first, if the callback |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2631 // invokes ch_close() the list will be cleared. |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2632 remove_cb_node(cbhead, item); |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2633 invoke_callback(channel, &item->cq_callback, argv); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2634 free_callback(&item->cq_callback); |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2635 vim_free(item); |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2636 } |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2637 |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2638 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2639 append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part) |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2640 { |
11959
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2641 bufref_T save_curbuf = {NULL, 0, 0}; |
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2642 win_T *save_curwin = NULL; |
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2643 tabpage_T *save_curtab = NULL; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2644 linenr_T lnum = buffer->b_ml.ml_line_count; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2645 int save_write_to = buffer->b_write_to_channel; |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2646 chanpart_T *ch_part = &channel->ch_part[part]; |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2647 int save_p_ma = buffer->b_p_ma; |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11416
diff
changeset
|
2648 int empty = (buffer->b_ml.ml_flags & ML_EMPTY) ? 1 : 0; |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2649 |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2650 if (!buffer->b_p_ma && !ch_part->ch_nomodifiable) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2651 { |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2652 if (!ch_part->ch_nomod_error) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2653 { |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2654 ch_error(channel, "Buffer is not modifiable, cannot append"); |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2655 ch_part->ch_nomod_error = TRUE; |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2656 } |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2657 return; |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2658 } |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2659 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2660 // If the buffer is also used as input insert above the last |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2661 // line. Don't write these lines. |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2662 if (save_write_to) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2663 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2664 --lnum; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2665 buffer->b_write_to_channel = FALSE; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2666 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2667 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2668 // Append to the buffer |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2669 ch_log(channel, "appending line %d to buffer", (int)lnum + 1 - empty); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2670 |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2671 buffer->b_p_ma = TRUE; |
11959
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2672 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2673 // Save curbuf/curwin/curtab and make "buffer" the current buffer. |
11959
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2674 switch_to_win_for_buf(buffer, &save_curwin, &save_curtab, &save_curbuf); |
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2675 |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2676 u_sync(TRUE); |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2677 // ignore undo failure, undo is not very useful here |
14730
193471015e1a
patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions
Christian Brabandt <cb@256bit.org>
parents:
14675
diff
changeset
|
2678 vim_ignored = u_save(lnum - empty, lnum + 1); |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2679 |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2680 if (empty) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2681 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2682 // The buffer is empty, replace the first (dummy) line. |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2683 ml_replace(lnum, msg, TRUE); |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2684 lnum = 0; |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2685 } |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2686 else |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
2687 ml_append(lnum, msg, 0, FALSE); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2688 appended_lines_mark(lnum, 1L); |
11959
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2689 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2690 // Restore curbuf/curwin/curtab |
11959
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2691 restore_win_for_buf(save_curwin, save_curtab, &save_curbuf); |
91a26b7a4119
patch 8.0.0860: side effects when channel appends to a buffer
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
2692 |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2693 if (ch_part->ch_nomodifiable) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2694 buffer->b_p_ma = FALSE; |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2695 else |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
2696 buffer->b_p_ma = save_p_ma; |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2697 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2698 if (buffer->b_nwindows > 0) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2699 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2700 win_T *wp; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2701 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2702 FOR_ALL_WINDOWS(wp) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2703 { |
17557
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2704 if (wp->w_buffer == buffer) |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2705 { |
17557
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2706 int move_cursor = save_write_to |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2707 ? wp->w_cursor.lnum == lnum + 1 |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2708 : (wp->w_cursor.lnum == lnum |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2709 && wp->w_cursor.col == 0); |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2710 |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2711 // If the cursor is at or above the new line, move it one line |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2712 // down. If the topline is outdated update it now. |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2713 if (move_cursor || wp->w_topline > buffer->b_ml.ml_line_count) |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2714 { |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2715 if (move_cursor) |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2716 ++wp->w_cursor.lnum; |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2717 save_curwin = curwin; |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2718 curwin = wp; |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2719 curbuf = curwin->w_buffer; |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2720 scroll_cursor_bot(0, FALSE); |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2721 curwin = save_curwin; |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2722 curbuf = curwin->w_buffer; |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
17308
diff
changeset
|
2723 } |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2724 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2725 } |
11416
32aed0993813
patch 8.0.0592: if a job writes to a buffer screen is not updated
Christian Brabandt <cb@256bit.org>
parents:
11408
diff
changeset
|
2726 redraw_buf_and_status_later(buffer, VALID); |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2727 channel_need_redraw = TRUE; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2728 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2729 |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2730 if (save_write_to) |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2731 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2732 channel_T *ch; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2733 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2734 // Find channels reading from this buffer and adjust their |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2735 // next-to-read line number. |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2736 buffer->b_write_to_channel = TRUE; |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
2737 FOR_ALL_CHANNELS(ch) |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2738 { |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2739 chanpart_T *in_part = &ch->ch_part[PART_IN]; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2740 |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9434
diff
changeset
|
2741 if (in_part->ch_bufref.br_buf == buffer) |
8422
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2742 in_part->ch_buf_bot = buffer->b_ml.ml_line_count; |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2743 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2744 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2745 } |
5d2c84be23b5
commit https://github.com/vim/vim/commit/99ef06296f3c37490511c03786a2c8672e015c56
Christian Brabandt <cb@256bit.org>
parents:
8410
diff
changeset
|
2746 |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2747 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2748 drop_messages(channel_T *channel, ch_part_T part) |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2749 { |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2750 char_u *msg; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2751 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
2752 while ((msg = channel_get(channel, part, NULL)) != NULL) |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2753 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2754 ch_log(channel, "Dropping message '%s'", (char *)msg); |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2755 vim_free(msg); |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2756 } |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2757 } |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2758 |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2759 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2760 * Invoke a callback for "channel"/"part" if needed. |
8928
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
2761 * This does not redraw but sets channel_need_redraw when redraw is needed. |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2762 * Return TRUE when a message was handled, there might be another one. |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2763 */ |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2764 static int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
2765 may_invoke_callback(channel_T *channel, ch_part_T part) |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2766 { |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2767 char_u *msg = NULL; |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2768 typval_T *listtv = NULL; |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2769 typval_T argv[CH_JSON_MAX_ARGS]; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2770 int seq_nr = -1; |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2771 chanpart_T *ch_part = &channel->ch_part[part]; |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2772 ch_mode_T ch_mode = ch_part->ch_mode; |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2773 cbq_T *cbhead = &ch_part->ch_cb_head; |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
2774 cbq_T *cbitem; |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2775 callback_T *callback = NULL; |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2776 buf_T *buffer = NULL; |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2777 char_u *p; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2778 |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
2779 if (channel->ch_nb_close_cb != NULL) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2780 // this channel is handled elsewhere (netbeans) |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2781 return FALSE; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2782 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2783 // Use a message-specific callback, part callback or channel callback |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
2784 for (cbitem = cbhead->cq_next; cbitem != NULL; cbitem = cbitem->cq_next) |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
2785 if (cbitem->cq_seq_nr == 0) |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
2786 break; |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2787 if (cbitem != NULL) |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2788 callback = &cbitem->cq_callback; |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2789 else if (ch_part->ch_callback.cb_name != NULL) |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2790 callback = &ch_part->ch_callback; |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2791 else if (channel->ch_callback.cb_name != NULL) |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2792 callback = &channel->ch_callback; |
8291
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8267
diff
changeset
|
2793 |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2794 buffer = ch_part->ch_bufref.br_buf; |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11416
diff
changeset
|
2795 if (buffer != NULL && (!bufref_valid(&ch_part->ch_bufref) |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11416
diff
changeset
|
2796 || buffer->b_ml.ml_mfp == NULL)) |
8291
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8267
diff
changeset
|
2797 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2798 // buffer was wiped out or unloaded |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2799 ch_log(channel, "%s buffer has been wiped out", part_names[part]); |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2800 ch_part->ch_bufref.br_buf = NULL; |
8291
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8267
diff
changeset
|
2801 buffer = NULL; |
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8267
diff
changeset
|
2802 } |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2803 |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2804 if (ch_mode == MODE_JSON || ch_mode == MODE_JS) |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2805 { |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2806 listitem_T *item; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2807 int argc = 0; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2808 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2809 // Get any json message in the queue. |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2810 if (channel_get_json(channel, part, -1, FALSE, &listtv) == FAIL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2811 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2812 // Parse readahead, return when there is still no message. |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2813 channel_parse_json(channel, part); |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2814 if (channel_get_json(channel, part, -1, FALSE, &listtv) == FAIL) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2815 return FALSE; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2816 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2817 |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2818 for (item = listtv->vval.v_list->lv_first; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2819 item != NULL && argc < CH_JSON_MAX_ARGS; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2820 item = item->li_next) |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2821 argv[argc++] = item->li_tv; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2822 while (argc < CH_JSON_MAX_ARGS) |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2823 argv[argc++].v_type = VAR_UNKNOWN; |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2824 |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2825 if (argv[0].v_type == VAR_STRING) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2826 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2827 // ["cmd", arg] or ["cmd", arg, arg] or ["cmd", arg, arg, arg] |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2828 channel_exe_cmd(channel, part, argv); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2829 free_tv(listtv); |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2830 return TRUE; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2831 } |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2832 |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2833 if (argv[0].v_type != VAR_NUMBER) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2834 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2835 ch_error(channel, |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
2836 "Dropping message with invalid sequence number type"); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2837 free_tv(listtv); |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2838 return FALSE; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2839 } |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
2840 seq_nr = argv[0].vval.v_number; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2841 } |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2842 else if (channel_peek(channel, part) == NULL) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2843 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2844 // nothing to read on RAW or NL channel |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2845 return FALSE; |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
2846 } |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2847 else |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2848 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2849 // If there is no callback or buffer drop the message. |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2850 if (callback == NULL && buffer == NULL) |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2851 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2852 // If there is a close callback it may use ch_read() to get the |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2853 // messages. |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2854 if (channel->ch_close_cb.cb_name == NULL && !channel->ch_drop_never) |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
2855 drop_messages(channel, part); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2856 return FALSE; |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2857 } |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2858 |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2859 if (ch_mode == MODE_NL) |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2860 { |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2861 char_u *nl = NULL; |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2862 char_u *buf; |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2863 readq_T *node; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2864 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2865 // See if we have a message ending in NL in the first buffer. If |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2866 // not try to concatenate the first and the second buffer. |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2867 while (TRUE) |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2868 { |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2869 node = channel_peek(channel, part); |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2870 nl = channel_first_nl(node); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2871 if (nl != NULL) |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2872 break; |
9215
d2d44592467d
commit https://github.com/vim/vim/commit/9ed96efb3d47d46e9637da04656efff715102407
Christian Brabandt <cb@256bit.org>
parents:
9189
diff
changeset
|
2873 if (channel_collapse(channel, part, TRUE) == FAIL) |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2874 { |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2875 if (ch_part->ch_fd == INVALID_FD && node->rq_buflen > 0) |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2876 break; |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2877 return FALSE; // incomplete message |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2878 } |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2879 } |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2880 buf = node->rq_buffer; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2881 |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
2882 // Convert NUL to NL, the internal representation. |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
2883 for (p = buf; (nl == NULL || p < nl) |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
2884 && p < buf + node->rq_buflen; ++p) |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
2885 if (*p == NUL) |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
2886 *p = NL; |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
2887 |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2888 if (nl == NULL) |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2889 { |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
2890 // get the whole buffer, drop the NL |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
2891 msg = channel_get(channel, part, NULL); |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
2892 } |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
2893 else if (nl + 1 == buf + node->rq_buflen) |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2894 { |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15908
diff
changeset
|
2895 // get the whole buffer |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
2896 msg = channel_get(channel, part, NULL); |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2897 *nl = NUL; |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2898 } |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2899 else |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2900 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2901 // Copy the message into allocated memory (excluding the NL) |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2902 // and remove it from the buffer (including the NL). |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2903 msg = vim_strnsave(buf, (int)(nl - buf)); |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2904 channel_consume(channel, part, (int)(nl - buf) + 1); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2905 } |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2906 } |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2907 else |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2908 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2909 // For a raw channel we don't know where the message ends, just |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2910 // get everything we have. |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2911 // Convert NUL to NL, the internal representation. |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
2912 msg = channel_get_all(channel, part, NULL); |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
2913 } |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2914 |
8358
49d0e094cb93
commit https://github.com/vim/vim/commit/bf73b91c664488ca57e2b4a8eb9b1f36f6625bc7
Christian Brabandt <cb@256bit.org>
parents:
8356
diff
changeset
|
2915 if (msg == NULL) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2916 return FALSE; // out of memory (and avoids Coverity warning) |
8358
49d0e094cb93
commit https://github.com/vim/vim/commit/bf73b91c664488ca57e2b4a8eb9b1f36f6625bc7
Christian Brabandt <cb@256bit.org>
parents:
8356
diff
changeset
|
2917 |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2918 argv[1].v_type = VAR_STRING; |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2919 argv[1].vval.v_string = msg; |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2920 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2921 |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2922 if (seq_nr > 0) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2923 { |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2924 int done = FALSE; |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2925 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2926 // JSON or JS mode: invoke the one-time callback with the matching nr |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
2927 for (cbitem = cbhead->cq_next; cbitem != NULL; cbitem = cbitem->cq_next) |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2928 if (cbitem->cq_seq_nr == seq_nr) |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2929 { |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2930 invoke_one_time_callback(channel, cbhead, cbitem, argv); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2931 done = TRUE; |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2932 break; |
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7931
diff
changeset
|
2933 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2934 if (!done) |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2935 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2936 if (channel->ch_drop_never) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2937 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2938 // message must be read with ch_read() |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2939 channel_push_json(channel, part, listtv); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2940 listtv = NULL; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2941 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2942 else |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2943 ch_log(channel, "Dropping message %d without callback", |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2944 seq_nr); |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
2945 } |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2946 } |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2947 else if (callback != NULL || buffer != NULL) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2948 { |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2949 if (buffer != NULL) |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2950 { |
8346
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8334
diff
changeset
|
2951 if (msg == NULL) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2952 // JSON or JS mode: re-encode the message. |
8346
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8334
diff
changeset
|
2953 msg = json_encode(listtv, ch_mode); |
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8334
diff
changeset
|
2954 if (msg != NULL) |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
2955 { |
11672
3c6cc2f24645
patch 8.0.0719: build failure without +terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
2956 #ifdef FEAT_TERMINAL |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
2957 if (buffer->b_term != NULL) |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
2958 write_to_term(buffer, msg, channel); |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
2959 else |
11672
3c6cc2f24645
patch 8.0.0719: build failure without +terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
2960 #endif |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
2961 append_to_buffer(buffer, msg, channel, part); |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
2962 } |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2963 } |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2964 |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2965 if (callback != NULL) |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2966 { |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2967 if (cbitem != NULL) |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2968 invoke_one_time_callback(channel, cbhead, cbitem, argv); |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2969 else |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2970 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
2971 // invoke the channel callback |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2972 ch_log(channel, "Invoking channel callback %s", |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2973 (char *)callback->cb_name); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2974 invoke_callback(channel, callback, argv); |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8358
diff
changeset
|
2975 } |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
2976 } |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2977 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
2978 else |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2979 ch_log(channel, "Dropping message %d", seq_nr); |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2980 |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
2981 if (listtv != NULL) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2982 free_tv(listtv); |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
2983 vim_free(msg); |
7885
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2984 |
6e6f829af138
commit https://github.com/vim/vim/commit/df5b27b20ec023274fb0f5347973d5abcde7ddd6
Christian Brabandt <cb@256bit.org>
parents:
7883
diff
changeset
|
2985 return TRUE; |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2986 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2987 |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15539
diff
changeset
|
2988 #if defined(FEAT_NETBEANS_INTG) || defined(PROTO) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
2989 /* |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2990 * Return TRUE when channel "channel" is open for writing to. |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2991 * Also returns FALSE or invalid "channel". |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2992 */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2993 int |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
2994 channel_can_write_to(channel_T *channel) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2995 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
2996 return channel != NULL && (channel->CH_SOCK_FD != INVALID_FD |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8491
diff
changeset
|
2997 || channel->CH_IN_FD != INVALID_FD); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
2998 } |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15539
diff
changeset
|
2999 #endif |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3000 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3001 /* |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3002 * Return TRUE when channel "channel" is open for reading or writing. |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3003 * Also returns FALSE for invalid "channel". |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3004 */ |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3005 int |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3006 channel_is_open(channel_T *channel) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3007 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3008 return channel != NULL && (channel->CH_SOCK_FD != INVALID_FD |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3009 || channel->CH_IN_FD != INVALID_FD |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3010 || channel->CH_OUT_FD != INVALID_FD |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8491
diff
changeset
|
3011 || channel->CH_ERR_FD != INVALID_FD); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3012 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3013 |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3014 /* |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3015 * Return TRUE if "channel" has JSON or other typeahead. |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3016 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
3017 static int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3018 channel_has_readahead(channel_T *channel, ch_part_T part) |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3019 { |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3020 ch_mode_T ch_mode = channel->ch_part[part].ch_mode; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3021 |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3022 if (ch_mode == MODE_JSON || ch_mode == MODE_JS) |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3023 { |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3024 jsonq_T *head = &channel->ch_part[part].ch_json_head; |
17212
fd983b381ec0
patch 8.1.1605: Vim may delay processing messages on a json channel
Bram Moolenaar <Bram@vim.org>
parents:
17170
diff
changeset
|
3025 |
fd983b381ec0
patch 8.1.1605: Vim may delay processing messages on a json channel
Bram Moolenaar <Bram@vim.org>
parents:
17170
diff
changeset
|
3026 if (head->jq_next == NULL) |
fd983b381ec0
patch 8.1.1605: Vim may delay processing messages on a json channel
Bram Moolenaar <Bram@vim.org>
parents:
17170
diff
changeset
|
3027 // Parse json from readahead, there might be a complete message to |
fd983b381ec0
patch 8.1.1605: Vim may delay processing messages on a json channel
Bram Moolenaar <Bram@vim.org>
parents:
17170
diff
changeset
|
3028 // process. |
fd983b381ec0
patch 8.1.1605: Vim may delay processing messages on a json channel
Bram Moolenaar <Bram@vim.org>
parents:
17170
diff
changeset
|
3029 channel_parse_json(channel, part); |
fd983b381ec0
patch 8.1.1605: Vim may delay processing messages on a json channel
Bram Moolenaar <Bram@vim.org>
parents:
17170
diff
changeset
|
3030 |
fd983b381ec0
patch 8.1.1605: Vim may delay processing messages on a json channel
Bram Moolenaar <Bram@vim.org>
parents:
17170
diff
changeset
|
3031 return head->jq_next != NULL; |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3032 } |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3033 return channel_peek(channel, part) != NULL; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3034 } |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3035 |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3036 /* |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3037 * Return a string indicating the status of the channel. |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3038 * If "req_part" is not negative check that part. |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3039 */ |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3040 char * |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3041 channel_status(channel_T *channel, int req_part) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3042 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3043 ch_part_T part; |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3044 int has_readahead = FALSE; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3045 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3046 if (channel == NULL) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3047 return "fail"; |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3048 if (req_part == PART_OUT) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3049 { |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3050 if (channel->CH_OUT_FD != INVALID_FD) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3051 return "open"; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3052 if (channel_has_readahead(channel, PART_OUT)) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3053 has_readahead = TRUE; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3054 } |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3055 else if (req_part == PART_ERR) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3056 { |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3057 if (channel->CH_ERR_FD != INVALID_FD) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3058 return "open"; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3059 if (channel_has_readahead(channel, PART_ERR)) |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3060 has_readahead = TRUE; |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3061 } |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3062 else |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3063 { |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3064 if (channel_is_open(channel)) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3065 return "open"; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3066 for (part = PART_SOCK; part < PART_IN; ++part) |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3067 if (channel_has_readahead(channel, part)) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3068 { |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3069 has_readahead = TRUE; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3070 break; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3071 } |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3072 } |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3073 |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3074 if (has_readahead) |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3075 return "buffered"; |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3076 return "closed"; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3077 } |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3078 |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3079 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3080 channel_part_info(channel_T *channel, dict_T *dict, char *name, ch_part_T part) |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3081 { |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3082 chanpart_T *chanpart = &channel->ch_part[part]; |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3083 char namebuf[20]; // longest is "sock_timeout" |
8678
a4e7f4a62193
commit https://github.com/vim/vim/commit/3f3fbd3fdb73bdfbfeab22a9dfc7a25e38bdf5f6
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
3084 size_t tail; |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3085 char *status; |
8684
6e567914f55a
commit https://github.com/vim/vim/commit/573e445664eef399a72b1bfc975260a639605fef
Christian Brabandt <cb@256bit.org>
parents:
8678
diff
changeset
|
3086 char *s = ""; |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3087 |
8783
23b7f05a7f48
commit https://github.com/vim/vim/commit/925ccfde79bf734bc89269c705cebe2d49fe6444
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
3088 vim_strncpy((char_u *)namebuf, (char_u *)name, 4); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3089 STRCAT(namebuf, "_"); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3090 tail = STRLEN(namebuf); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3091 |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3092 STRCPY(namebuf + tail, "status"); |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3093 if (chanpart->ch_fd != INVALID_FD) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3094 status = "open"; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3095 else if (channel_has_readahead(channel, part)) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3096 status = "buffered"; |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3097 else |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
3098 status = "closed"; |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
3099 dict_add_string(dict, namebuf, (char_u *)status); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3100 |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3101 STRCPY(namebuf + tail, "mode"); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3102 switch (chanpart->ch_mode) |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3103 { |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3104 case MODE_NL: s = "NL"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3105 case MODE_RAW: s = "RAW"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3106 case MODE_JSON: s = "JSON"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3107 case MODE_JS: s = "JS"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3108 } |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
3109 dict_add_string(dict, namebuf, (char_u *)s); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3110 |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3111 STRCPY(namebuf + tail, "io"); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3112 if (part == PART_SOCK) |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3113 s = "socket"; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3114 else switch (chanpart->ch_io) |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3115 { |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3116 case JIO_NULL: s = "null"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3117 case JIO_PIPE: s = "pipe"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3118 case JIO_FILE: s = "file"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3119 case JIO_BUFFER: s = "buffer"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3120 case JIO_OUT: s = "out"; break; |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3121 } |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
3122 dict_add_string(dict, namebuf, (char_u *)s); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3123 |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3124 STRCPY(namebuf + tail, "timeout"); |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
3125 dict_add_number(dict, namebuf, chanpart->ch_timeout); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3126 } |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3127 |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
3128 static void |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3129 channel_info(channel_T *channel, dict_T *dict) |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3130 { |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
3131 dict_add_number(dict, "id", channel->ch_id); |
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
3132 dict_add_string(dict, "status", (char_u *)channel_status(channel, -1)); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3133 |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3134 if (channel->ch_hostname != NULL) |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3135 { |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
3136 dict_add_string(dict, "hostname", (char_u *)channel->ch_hostname); |
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14103
diff
changeset
|
3137 dict_add_number(dict, "port", channel->ch_port); |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3138 channel_part_info(channel, dict, "sock", PART_SOCK); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3139 } |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3140 else |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3141 { |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3142 channel_part_info(channel, dict, "out", PART_OUT); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3143 channel_part_info(channel, dict, "err", PART_ERR); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3144 channel_part_info(channel, dict, "in", PART_IN); |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3145 } |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3146 } |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8667
diff
changeset
|
3147 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3148 /* |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3149 * Close channel "channel". |
8257
c4ffdda8cdfd
commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7
Christian Brabandt <cb@256bit.org>
parents:
8240
diff
changeset
|
3150 * Trigger the close callback if "invoke_close_cb" is TRUE. |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
3151 * Does not clear the buffers. |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3152 */ |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3153 void |
8240
60586ce747c4
commit https://github.com/vim/vim/commit/8b374215ccd35003b95ba1df8f12e03bf8a8adc3
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
3154 channel_close(channel_T *channel, int invoke_close_cb) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3155 { |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
3156 ch_log(channel, "Closing channel"); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3157 |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
3158 #ifdef FEAT_GUI |
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
3159 channel_gui_unregister(channel); |
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
3160 #endif |
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
3161 |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3162 ch_close_part(channel, PART_SOCK); |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3163 ch_close_part(channel, PART_IN); |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3164 ch_close_part(channel, PART_OUT); |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3165 ch_close_part(channel, PART_ERR); |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
3166 |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3167 if (invoke_close_cb) |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
3168 { |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3169 ch_part_T part; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3170 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3171 // Invoke callbacks and flush buffers before the close callback. |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3172 if (channel->ch_close_cb.cb_name != NULL) |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3173 ch_log(channel, |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3174 "Invoking callbacks and flushing buffers before closing"); |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3175 for (part = PART_SOCK; part < PART_IN; ++part) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3176 { |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3177 if (channel->ch_close_cb.cb_name != NULL |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3178 || channel->ch_part[part].ch_bufref.br_buf != NULL) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3179 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3180 // Increment the refcount to avoid the channel being freed |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3181 // halfway. |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3182 ++channel->ch_refcount; |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3183 if (channel->ch_close_cb.cb_name == NULL) |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3184 ch_log(channel, "flushing %s buffers before closing", |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3185 part_names[part]); |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3186 while (may_invoke_callback(channel, part)) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3187 ; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3188 --channel->ch_refcount; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3189 } |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3190 } |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3191 |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3192 if (channel->ch_close_cb.cb_name != NULL) |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3193 { |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3194 typval_T argv[1]; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3195 typval_T rettv; |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3196 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3197 // Increment the refcount to avoid the channel being freed |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3198 // halfway. |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3199 ++channel->ch_refcount; |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3200 ch_log(channel, "Invoking close callback %s", |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3201 (char *)channel->ch_close_cb.cb_name); |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3202 argv[0].v_type = VAR_CHANNEL; |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3203 argv[0].vval.v_channel = channel; |
17606
ff097edaae89
patch 8.1.1800: function call functions have too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
3204 call_callback(&channel->ch_close_cb, -1, &rettv, 1, argv); |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3205 clear_tv(&rettv); |
9064
a86103d4b356
commit https://github.com/vim/vim/commit/cefe4f994853c2d4866e2aa4ea3e3f36ab2fea13
Christian Brabandt <cb@256bit.org>
parents:
9058
diff
changeset
|
3206 channel_need_redraw = TRUE; |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3207 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3208 // the callback is only called once |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3209 free_callback(&channel->ch_close_cb); |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3210 |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3211 if (channel_need_redraw) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3212 { |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3213 channel_need_redraw = FALSE; |
12244
d0b039e2ed56
patch 8.0.1002: unnecessarily updating screen after timer callback
Christian Brabandt <cb@256bit.org>
parents:
12240
diff
changeset
|
3214 redraw_after_callback(TRUE); |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3215 } |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3216 |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3217 if (!channel->ch_drop_never) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3218 // any remaining messages are useless now |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3219 for (part = PART_SOCK; part < PART_IN; ++part) |
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3220 drop_messages(channel, part); |
12818
60e1e4cfb21e
patch 8.0.1286: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
12584
diff
changeset
|
3221 |
60e1e4cfb21e
patch 8.0.1286: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
12584
diff
changeset
|
3222 --channel->ch_refcount; |
11977
701aea3bc68b
patch 8.0.0869: job output is sometimes not displayed in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11969
diff
changeset
|
3223 } |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
3224 } |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
3225 |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8204
diff
changeset
|
3226 channel->ch_nb_close_cb = NULL; |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
3227 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
3228 #ifdef FEAT_TERMINAL |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
3229 term_channel_closed(channel); |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
3230 #endif |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3231 } |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3232 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3233 /* |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
3234 * Close the "in" part channel "channel". |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
3235 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
3236 static void |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
3237 channel_close_in(channel_T *channel) |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
3238 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3239 ch_close_part(channel, PART_IN); |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
3240 } |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
3241 |
12403
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3242 static void |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3243 remove_from_writeque(writeq_T *wq, writeq_T *entry) |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3244 { |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3245 ga_clear(&entry->wq_ga); |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3246 wq->wq_next = entry->wq_next; |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3247 if (wq->wq_next == NULL) |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3248 wq->wq_prev = NULL; |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3249 else |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3250 wq->wq_next->wq_prev = NULL; |
12407
e9dbdc4d8279
patch 8.0.1083: leaking memory in input part of channel
Christian Brabandt <cb@256bit.org>
parents:
12403
diff
changeset
|
3251 vim_free(entry); |
12403
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3252 } |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3253 |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
3254 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3255 * Clear the read buffer on "channel"/"part". |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3256 */ |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3257 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3258 channel_clear_one(channel_T *channel, ch_part_T part) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3259 { |
12403
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3260 chanpart_T *ch_part = &channel->ch_part[part]; |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3261 jsonq_T *json_head = &ch_part->ch_json_head; |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3262 cbq_T *cb_head = &ch_part->ch_cb_head; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3263 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3264 while (channel_peek(channel, part) != NULL) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3265 vim_free(channel_get(channel, part, NULL)); |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3266 |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3267 while (cb_head->cq_next != NULL) |
8074
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
3268 { |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
3269 cbq_T *node = cb_head->cq_next; |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
3270 |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
3271 remove_cb_node(cb_head, node); |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3272 free_callback(&node->cq_callback); |
8074
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
3273 vim_free(node); |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8072
diff
changeset
|
3274 } |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3275 |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3276 while (json_head->jq_next != NULL) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3277 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3278 free_tv(json_head->jq_next->jq_value); |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3279 remove_json_node(json_head, json_head->jq_next); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3280 } |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
3281 |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3282 free_callback(&ch_part->ch_callback); |
17024
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
3283 ga_clear(&ch_part->ch_block_ids); |
12403
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3284 |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3285 while (ch_part->ch_writeque.wq_next != NULL) |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3286 remove_from_writeque(&ch_part->ch_writeque, |
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
3287 ch_part->ch_writeque.wq_next); |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3288 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3289 |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3290 /* |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3291 * Clear all the read buffers on "channel". |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3292 */ |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3293 void |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3294 channel_clear(channel_T *channel) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3295 { |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
3296 ch_log(channel, "Clearing channel"); |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
3297 VIM_CLEAR(channel->ch_hostname); |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3298 channel_clear_one(channel, PART_SOCK); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3299 channel_clear_one(channel, PART_OUT); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3300 channel_clear_one(channel, PART_ERR); |
12407
e9dbdc4d8279
patch 8.0.1083: leaking memory in input part of channel
Christian Brabandt <cb@256bit.org>
parents:
12403
diff
changeset
|
3301 channel_clear_one(channel, PART_IN); |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3302 free_callback(&channel->ch_callback); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3303 free_callback(&channel->ch_close_cb); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3304 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3305 |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3306 #if defined(EXITFREE) || defined(PROTO) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3307 void |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3308 channel_free_all(void) |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3309 { |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3310 channel_T *channel; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3311 |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
3312 ch_log(NULL, "channel_free_all()"); |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
3313 FOR_ALL_CHANNELS(channel) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3314 channel_clear(channel); |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3315 } |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3316 #endif |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3317 |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3318 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3319 // Sent when the netbeans channel is found closed when reading. |
8204
08d251a1c178
commit https://github.com/vim/vim/commit/eed284a16977ab81fa6da8c9562990ba498acd8c
Christian Brabandt <cb@256bit.org>
parents:
8200
diff
changeset
|
3320 #define DETACH_MSG_RAW "DETACH\n" |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3321 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3322 // Buffer size for reading incoming messages. |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3323 #define MAXMSGSIZE 4096 |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3324 |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3325 #if defined(HAVE_SELECT) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3326 /* |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3327 * Add write fds where we are waiting for writing to be possible. |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3328 */ |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3329 static int |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3330 channel_fill_wfds(int maxfd_arg, fd_set *wfds) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3331 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3332 int maxfd = maxfd_arg; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3333 channel_T *ch; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3334 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
3335 FOR_ALL_CHANNELS(ch) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3336 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3337 chanpart_T *in_part = &ch->ch_part[PART_IN]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3338 |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3339 if (in_part->ch_fd != INVALID_FD |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3340 && (in_part->ch_bufref.br_buf != NULL |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3341 || in_part->ch_writeque.wq_next != NULL)) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3342 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3343 FD_SET((int)in_part->ch_fd, wfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3344 if ((int)in_part->ch_fd >= maxfd) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3345 maxfd = (int)in_part->ch_fd + 1; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3346 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3347 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3348 return maxfd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3349 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3350 #else |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3351 /* |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3352 * Add write fds where we are waiting for writing to be possible. |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3353 */ |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3354 static int |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3355 channel_fill_poll_write(int nfd_in, struct pollfd *fds) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3356 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3357 int nfd = nfd_in; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3358 channel_T *ch; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3359 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
3360 FOR_ALL_CHANNELS(ch) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3361 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3362 chanpart_T *in_part = &ch->ch_part[PART_IN]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3363 |
12168
51e5a8602624
patch 8.0.0964: channel write buffer does not work with poll()
Christian Brabandt <cb@256bit.org>
parents:
12158
diff
changeset
|
3364 if (in_part->ch_fd != INVALID_FD |
51e5a8602624
patch 8.0.0964: channel write buffer does not work with poll()
Christian Brabandt <cb@256bit.org>
parents:
12158
diff
changeset
|
3365 && (in_part->ch_bufref.br_buf != NULL |
51e5a8602624
patch 8.0.0964: channel write buffer does not work with poll()
Christian Brabandt <cb@256bit.org>
parents:
12158
diff
changeset
|
3366 || in_part->ch_writeque.wq_next != NULL)) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3367 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3368 in_part->ch_poll_idx = nfd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3369 fds[nfd].fd = in_part->ch_fd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3370 fds[nfd].events = POLLOUT; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3371 ++nfd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3372 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3373 else |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3374 in_part->ch_poll_idx = -1; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3375 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3376 return nfd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3377 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3378 #endif |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3379 |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3380 typedef enum { |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3381 CW_READY, |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3382 CW_NOT_READY, |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3383 CW_ERROR |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3384 } channel_wait_result; |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3385 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3386 /* |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3387 * Check for reading from "fd" with "timeout" msec. |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3388 * Return CW_READY when there is something to read. |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3389 * Return CW_NOT_READY when there is nothing to read. |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3390 * Return CW_ERROR when there is an error. |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3391 */ |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3392 static channel_wait_result |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3393 channel_wait(channel_T *channel, sock_T fd, int timeout) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3394 { |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3395 if (timeout > 0) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3396 ch_log(channel, "Waiting for up to %d msec", timeout); |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3397 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
3398 # ifdef MSWIN |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3399 if (fd != channel->CH_SOCK_FD) |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3400 { |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3401 DWORD nread; |
8757
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3402 int sleep_time; |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3403 DWORD deadline = GetTickCount() + timeout; |
8757
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3404 int delay = 1; |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3405 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3406 // reading from a pipe, not a socket |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3407 while (TRUE) |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3408 { |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3409 int r = PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &nread, NULL); |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3410 |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3411 if (r && nread > 0) |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3412 return CW_READY; |
15577
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3413 |
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3414 if (channel->ch_named_pipe) |
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3415 { |
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3416 DisconnectNamedPipe((HANDLE)fd); |
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3417 ConnectNamedPipe((HANDLE)fd, NULL); |
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3418 } |
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
3419 else if (r == 0) |
15539
ba876ced4f1f
patch 8.1.0777: Win32: using pipes for channel does not work well
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
3420 return CW_ERROR; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3421 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3422 // perhaps write some buffer lines |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3423 channel_write_any_lines(); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3424 |
8757
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3425 sleep_time = deadline - GetTickCount(); |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3426 if (sleep_time <= 0) |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3427 break; |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3428 // Wait for a little while. Very short at first, up to 10 msec |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3429 // after looping a few times. |
8757
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3430 if (sleep_time > delay) |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3431 sleep_time = delay; |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3432 Sleep(sleep_time); |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3433 delay = delay * 2; |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3434 if (delay > 10) |
4fb37555e814
commit https://github.com/vim/vim/commit/84e1d2b21a424f2687b61daaf84f5fc4f1ab0abe
Christian Brabandt <cb@256bit.org>
parents:
8755
diff
changeset
|
3435 delay = 10; |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3436 } |
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3437 } |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3438 else |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3439 #endif |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3440 { |
8222
4f0677020a43
commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
3441 #if defined(HAVE_SELECT) |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3442 struct timeval tval; |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3443 fd_set rfds; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3444 fd_set wfds; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3445 int ret; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3446 int maxfd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3447 |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3448 tval.tv_sec = timeout / 1000; |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3449 tval.tv_usec = (timeout % 1000) * 1000; |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3450 for (;;) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3451 { |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3452 FD_ZERO(&rfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3453 FD_SET((int)fd, &rfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3454 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3455 // Write lines to a pipe when a pipe can be written to. Need to |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3456 // set this every time, some buffers may be done. |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3457 maxfd = (int)fd + 1; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3458 FD_ZERO(&wfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3459 maxfd = channel_fill_wfds(maxfd, &wfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3460 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3461 ret = select(maxfd, &rfds, &wfds, NULL, &tval); |
8222
4f0677020a43
commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
3462 # ifdef EINTR |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3463 SOCK_ERRNO; |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3464 if (ret == -1 && errno == EINTR) |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3465 continue; |
8222
4f0677020a43
commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
3466 # endif |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3467 if (ret > 0) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3468 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3469 if (FD_ISSET(fd, &rfds)) |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3470 return CW_READY; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3471 channel_write_any_lines(); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3472 continue; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3473 } |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3474 break; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3475 } |
8222
4f0677020a43
commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
3476 #else |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3477 for (;;) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3478 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3479 struct pollfd fds[MAX_OPEN_CHANNELS + 1]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3480 int nfd = 1; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3481 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3482 fds[0].fd = fd; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3483 fds[0].events = POLLIN; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3484 nfd = channel_fill_poll_write(nfd, fds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3485 if (poll(fds, nfd, timeout) > 0) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3486 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3487 if (fds[0].revents & POLLIN) |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3488 return CW_READY; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3489 channel_write_any_lines(); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3490 continue; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3491 } |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3492 break; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
3493 } |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3494 #endif |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3495 } |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3496 return CW_NOT_READY; |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3497 } |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3498 |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3499 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3500 ch_close_part_on_error( |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3501 channel_T *channel, ch_part_T part, int is_err, char *func) |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3502 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3503 char msg[] = "%s(): Read %s from ch_part[%d], closing"; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3504 |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3505 if (is_err) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3506 // Do not call emsg(), most likely the other end just exited. |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3507 ch_error(channel, msg, func, "error", part); |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3508 else |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3509 ch_log(channel, msg, func, "EOF", part); |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3510 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3511 // Queue a "DETACH" netbeans message in the command queue in order to |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3512 // terminate the netbeans session later. Do not end the session here |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3513 // directly as we may be running in the context of a call to |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3514 // netbeans_parse_messages(): |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3515 // netbeans_parse_messages |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3516 // -> autocmd triggered while processing the netbeans cmd |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3517 // -> ui_breakcheck |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3518 // -> gui event loop or select loop |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3519 // -> channel_read() |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3520 // Only send "DETACH" for a netbeans channel. |
9050
31bba6f25d84
commit https://github.com/vim/vim/commit/715d285d79a1d97928dd717278e25e6de45d1496
Christian Brabandt <cb@256bit.org>
parents:
9044
diff
changeset
|
3521 if (channel->ch_nb_close_cb != NULL) |
10253
a92c4abb8c1f
commit https://github.com/vim/vim/commit/8ddef48d1eade1911b946fdda8c73c80856e6273
Christian Brabandt <cb@256bit.org>
parents:
10249
diff
changeset
|
3522 channel_save(channel, PART_SOCK, (char_u *)DETACH_MSG_RAW, |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3523 (int)STRLEN(DETACH_MSG_RAW), FALSE, "PUT "); |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3524 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3525 // When reading is not possible close this part of the channel. Don't |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3526 // close the channel yet, there may be something to read on another part. |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3527 // When stdout and stderr use the same FD we get the error only on one of |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3528 // them, also close the other. |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3529 if (part == PART_OUT || part == PART_ERR) |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3530 { |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3531 ch_part_T other = part == PART_OUT ? PART_ERR : PART_OUT; |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3532 |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3533 if (channel->ch_part[part].ch_fd == channel->ch_part[other].ch_fd) |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3534 ch_close_part(channel, other); |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
3535 } |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3536 ch_close_part(channel, part); |
9133
dec3b7b977c0
commit https://github.com/vim/vim/commit/bf981eeb6b4ee63ae8543a7f9865ab700159a79c
Christian Brabandt <cb@256bit.org>
parents:
9131
diff
changeset
|
3537 |
dec3b7b977c0
commit https://github.com/vim/vim/commit/bf981eeb6b4ee63ae8543a7f9865ab700159a79c
Christian Brabandt <cb@256bit.org>
parents:
9131
diff
changeset
|
3538 #ifdef FEAT_GUI |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3539 // Stop listening to GUI events right away. |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3540 channel_gui_unregister_one(channel, part); |
9133
dec3b7b977c0
commit https://github.com/vim/vim/commit/bf981eeb6b4ee63ae8543a7f9865ab700159a79c
Christian Brabandt <cb@256bit.org>
parents:
9131
diff
changeset
|
3541 #endif |
9083
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
3542 } |
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
3543 |
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
3544 static void |
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
3545 channel_close_now(channel_T *channel) |
69bb7b230094
commit https://github.com/vim/vim/commit/cf7ff70ca73218d618e7c00ab785bcf5f9120a94
Christian Brabandt <cb@256bit.org>
parents:
9081
diff
changeset
|
3546 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3547 ch_log(channel, "Closing channel because all readable fds are closed"); |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3548 if (channel->ch_nb_close_cb != NULL) |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3549 (*channel->ch_nb_close_cb)(); |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
3550 channel_close(channel, TRUE); |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3551 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3552 |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3553 /* |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
3554 * Read from channel "channel" for as long as there is something to read. |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3555 * "part" is PART_SOCK, PART_OUT or PART_ERR. |
9143
b9c1a397a8a6
commit https://github.com/vim/vim/commit/655da31a18ef3f888acf10e68b438e2a851f7b14
Christian Brabandt <cb@256bit.org>
parents:
9139
diff
changeset
|
3556 * The data is put in the read queue. No callbacks are invoked here. |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3557 */ |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3558 static void |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3559 channel_read(channel_T *channel, ch_part_T part, char *func) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3560 { |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3561 static char_u *buf = NULL; |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3562 int len = 0; |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3563 int readlen = 0; |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3564 sock_T fd; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3565 int use_socket = FALSE; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3566 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3567 fd = channel->ch_part[part].ch_fd; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3568 if (fd == INVALID_FD) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3569 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3570 ch_error(channel, "channel_read() called while %s part is closed", |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3571 part_names[part]); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3572 return; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3573 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3574 use_socket = fd == channel->CH_SOCK_FD; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3575 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3576 // Allocate a buffer to read into. |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3577 if (buf == NULL) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3578 { |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3579 buf = alloc(MAXMSGSIZE); |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3580 if (buf == NULL) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3581 return; // out of memory! |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3582 } |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3583 |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3584 // Keep on reading for as long as there is something to read. |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3585 // Use select() or poll() to avoid blocking on a message that is exactly |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3586 // MAXMSGSIZE long. |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3587 for (;;) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3588 { |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3589 if (channel_wait(channel, fd, 0) != CW_READY) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3590 break; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3591 if (use_socket) |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
8074
diff
changeset
|
3592 len = sock_read(fd, (char *)buf, MAXMSGSIZE); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3593 else |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
8074
diff
changeset
|
3594 len = fd_read(fd, (char *)buf, MAXMSGSIZE); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3595 if (len <= 0) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3596 break; // error or nothing more to read |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3597 |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3598 // Store the read message in the queue. |
8755
7038ec89d1fd
commit https://github.com/vim/vim/commit/46c00a6565b8f1f4b7b1041d03eaceaf6ffc4aee
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
3599 channel_save(channel, part, buf, len, FALSE, "RECV "); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3600 readlen += len; |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3601 if (len < MAXMSGSIZE) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3602 break; // did read everything that's available |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3603 } |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3604 |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3605 // Reading a disconnection (readlen == 0), or an error. |
8200
ee84450e604e
commit https://github.com/vim/vim/commit/bd73ae1bc63a3b0187ffe7fc8f0caee5a4eb66fa
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
3606 if (readlen <= 0) |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3607 { |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3608 if (!channel->ch_keep_open) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3609 ch_close_part_on_error(channel, part, (len < 0), func); |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3610 } |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3611 #if defined(CH_HAS_GUI) && defined(FEAT_GUI_GTK) |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3612 else if (CH_HAS_GUI && gtk_main_level() > 0) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3613 // signal the main loop that there is something to read |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3614 gtk_main_quit(); |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3615 #endif |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3616 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3617 |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3618 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3619 * Read from RAW or NL "channel"/"part". Blocks until there is something to |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3620 * read or the timeout expires. |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3621 * When "raw" is TRUE don't block waiting on a NL. |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3622 * Does not trigger timers or handle messages. |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3623 * Returns what was read in allocated memory. |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3624 * Returns NULL in case of error or timeout. |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3625 */ |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3626 static char_u * |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3627 channel_read_block( |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3628 channel_T *channel, ch_part_T part, int timeout, int raw, int *outlen) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3629 { |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3630 char_u *buf; |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3631 char_u *msg; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3632 ch_mode_T mode = channel->ch_part[part].ch_mode; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3633 sock_T fd = channel->ch_part[part].ch_fd; |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3634 char_u *nl; |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3635 readq_T *node; |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3636 |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3637 ch_log(channel, "Blocking %s read, timeout: %d msec", |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3638 mode == MODE_RAW ? "RAW" : "NL", timeout); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3639 |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3640 while (TRUE) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3641 { |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3642 node = channel_peek(channel, part); |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3643 if (node != NULL) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3644 { |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3645 if (mode == MODE_RAW || (mode == MODE_NL |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3646 && channel_first_nl(node) != NULL)) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3647 // got a complete message |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3648 break; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3649 if (channel_collapse(channel, part, mode == MODE_NL) == OK) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3650 continue; |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3651 // If not blocking or nothing more is coming then return what we |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3652 // have. |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3653 if (raw || fd == INVALID_FD) |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3654 break; |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3655 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
3656 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3657 // Wait for up to the channel timeout. |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3658 if (fd == INVALID_FD) |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3659 return NULL; |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3660 if (channel_wait(channel, fd, timeout) != CW_READY) |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3661 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3662 ch_log(channel, "Timed out"); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3663 return NULL; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3664 } |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3665 channel_read(channel, part, "channel_read_block"); |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3666 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3667 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3668 // We have a complete message now. |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3669 if (mode == MODE_RAW || outlen != NULL) |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3670 { |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3671 msg = channel_get_all(channel, part, outlen); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3672 } |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3673 else |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3674 { |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3675 char_u *p; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3676 |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3677 buf = node->rq_buffer; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3678 nl = channel_first_nl(node); |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3679 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3680 // Convert NUL to NL, the internal representation. |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3681 for (p = buf; (nl == NULL || p < nl) && p < buf + node->rq_buflen; ++p) |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3682 if (*p == NUL) |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3683 *p = NL; |
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3684 |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3685 if (nl == NULL) |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3686 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3687 // must be a closed channel with missing NL |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3688 msg = channel_get(channel, part, NULL); |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3689 } |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3690 else if (nl + 1 == buf + node->rq_buflen) |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3691 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3692 // get the whole buffer |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3693 msg = channel_get(channel, part, NULL); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3694 *nl = NUL; |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3695 } |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3696 else |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3697 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3698 // Copy the message into allocated memory and remove it from the |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3699 // buffer. |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3700 msg = vim_strnsave(buf, (int)(nl - buf)); |
9246
6ee88fa405b3
commit https://github.com/vim/vim/commit/5f1032d2a55b9417a0a6fa225e35089c98a5a419
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
3701 channel_consume(channel, part, (int)(nl - buf) + 1); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3702 } |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3703 } |
12443
579faede5d9c
patch 8.0.1101: channel write fails if writing to log fails
Christian Brabandt <cb@256bit.org>
parents:
12407
diff
changeset
|
3704 if (ch_log_active()) |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
3705 ch_log(channel, "Returning %d bytes", (int)STRLEN(msg)); |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
3706 return msg; |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3707 } |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3708 |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3709 static int channel_blocking_wait = 0; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3710 |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3711 /* |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3712 * Return TRUE if in a blocking wait that might trigger callbacks. |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3713 */ |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3714 int |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3715 channel_in_blocking_wait(void) |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3716 { |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3717 return channel_blocking_wait > 0; |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3718 } |
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3719 |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3720 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3721 * Read one JSON message with ID "id" from "channel"/"part" and store the |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3722 * result in "rettv". |
8157
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
3723 * When "id" is -1 accept any message; |
7935
3f2e0b62003d
commit https://github.com/vim/vim/commit/4d919d748e4e435edb135aa5ccf6ee7de9212023
Christian Brabandt <cb@256bit.org>
parents:
7933
diff
changeset
|
3724 * Blocks until the message is received or the timeout is reached. |
17024
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
3725 * In corner cases this can be called recursively, that is why ch_block_ids is |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
3726 * a list. |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3727 */ |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
3728 static int |
8157
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
3729 channel_read_json_block( |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
3730 channel_T *channel, |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3731 ch_part_T part, |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3732 int timeout_arg, |
8310
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
3733 int id, |
aec8f8ce8e4c
commit https://github.com/vim/vim/commit/d6051b5eb83687f60bb4a2f3d5cd23fe8b290eb4
Christian Brabandt <cb@256bit.org>
parents:
8297
diff
changeset
|
3734 typval_T **rettv) |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3735 { |
7997
c1c9ab17e197
commit https://github.com/vim/vim/commit/e56bf15c163a921ce9e1c09c0d5b3a03efc63324
Christian Brabandt <cb@256bit.org>
parents:
7988
diff
changeset
|
3736 int more; |
8059
19304db153bc
commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents:
8055
diff
changeset
|
3737 sock_T fd; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3738 int timeout; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3739 chanpart_T *chanpart = &channel->ch_part[part]; |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
3740 int retval = FAIL; |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3741 |
17024
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
3742 ch_log(channel, "Blocking read JSON for id %d", id); |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3743 ++channel_blocking_wait; |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
3744 |
17024
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
3745 if (id >= 0) |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
3746 channel_add_block_id(chanpart, id); |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
3747 |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3748 for (;;) |
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3749 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
3750 more = channel_parse_json(channel, part); |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3751 |
17024
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
3752 // search for message "id" |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
3753 if (channel_get_json(channel, part, id, TRUE, rettv) == OK) |
7997
c1c9ab17e197
commit https://github.com/vim/vim/commit/e56bf15c163a921ce9e1c09c0d5b3a03efc63324
Christian Brabandt <cb@256bit.org>
parents:
7988
diff
changeset
|
3754 { |
17024
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
3755 ch_log(channel, "Received JSON for id %d", id); |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
3756 retval = OK; |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
3757 break; |
7997
c1c9ab17e197
commit https://github.com/vim/vim/commit/e56bf15c163a921ce9e1c09c0d5b3a03efc63324
Christian Brabandt <cb@256bit.org>
parents:
7988
diff
changeset
|
3758 } |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3759 |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3760 if (!more) |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3761 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3762 // Handle any other messages in the queue. If done some more |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3763 // messages may have arrived. |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3764 if (channel_parse_messages()) |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3765 continue; |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3766 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3767 // Wait for up to the timeout. If there was an incomplete message |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3768 // use the deadline for that. |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3769 timeout = timeout_arg; |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
3770 if (chanpart->ch_wait_len > 0) |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3771 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
3772 #ifdef MSWIN |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3773 timeout = chanpart->ch_deadline - GetTickCount() + 1; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3774 #else |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3775 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3776 struct timeval now_tv; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3777 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3778 gettimeofday(&now_tv, NULL); |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3779 timeout = (chanpart->ch_deadline.tv_sec |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3780 - now_tv.tv_sec) * 1000 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3781 + (chanpart->ch_deadline.tv_usec |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3782 - now_tv.tv_usec) / 1000 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3783 + 1; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3784 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3785 #endif |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3786 if (timeout < 0) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3787 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3788 // Something went wrong, channel_parse_json() didn't |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3789 // discard message. Cancel waiting. |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10587
diff
changeset
|
3790 chanpart->ch_wait_len = 0; |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3791 timeout = timeout_arg; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3792 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3793 else if (timeout > timeout_arg) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3794 timeout = timeout_arg; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3795 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3796 fd = chanpart->ch_fd; |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3797 if (fd == INVALID_FD |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3798 || channel_wait(channel, fd, timeout) != CW_READY) |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3799 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3800 if (timeout == timeout_arg) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3801 { |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3802 if (fd != INVALID_FD) |
17024
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
3803 ch_log(channel, "Timed out on id %d", id); |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3804 break; |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3805 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3806 } |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3807 else |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
3808 channel_read(channel, part, "channel_read_json_block"); |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
3809 } |
7868
17e6ff1a74f1
commit https://github.com/vim/vim/commit/19d2f1589850d7db1ce77efec052929246f156e2
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3810 } |
17024
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
3811 if (id >= 0) |
727f8cc87a45
patch 8.1.1512: ch_evalexpr() hangs when used recursively
Bram Moolenaar <Bram@vim.org>
parents:
16912
diff
changeset
|
3812 channel_remove_block_id(chanpart, id); |
18104
e59ff7b5d7a7
patch 8.1.2047: cannot check the current state
Bram Moolenaar <Bram@vim.org>
parents:
18102
diff
changeset
|
3813 --channel_blocking_wait; |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
3814 |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
3815 return retval; |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3816 } |
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
3817 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3818 /* |
17170
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3819 * Get the channel from the argument. |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3820 * Returns NULL if the handle is invalid. |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3821 * When "check_open" is TRUE check that the channel can be used. |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3822 * When "reading" is TRUE "check_open" considers typeahead useful. |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3823 * "part" is used to check typeahead, when PART_COUNT use the default part. |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3824 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3825 static channel_T * |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3826 get_channel_arg(typval_T *tv, int check_open, int reading, ch_part_T part) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3827 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3828 channel_T *channel = NULL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3829 int has_readahead = FALSE; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3830 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3831 if (tv->v_type == VAR_JOB) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3832 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3833 if (tv->vval.v_job != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3834 channel = tv->vval.v_job->jv_channel; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3835 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3836 else if (tv->v_type == VAR_CHANNEL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3837 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3838 channel = tv->vval.v_channel; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3839 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3840 else |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3841 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3842 semsg(_(e_invarg2), tv_get_string(tv)); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3843 return NULL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3844 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3845 if (channel != NULL && reading) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3846 has_readahead = channel_has_readahead(channel, |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3847 part != PART_COUNT ? part : channel_part_read(channel)); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3848 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3849 if (check_open && (channel == NULL || (!channel_is_open(channel) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3850 && !(reading && has_readahead)))) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3851 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3852 emsg(_("E906: not an open channel")); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3853 return NULL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3854 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3855 return channel; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3856 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3857 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
3858 /* |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3859 * Common for ch_read() and ch_readraw(). |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3860 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
3861 static void |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3862 common_channel_read(typval_T *argvars, typval_T *rettv, int raw, int blob) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3863 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3864 channel_T *channel; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3865 ch_part_T part = PART_COUNT; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3866 jobopt_T opt; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3867 int mode; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3868 int timeout; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3869 int id = -1; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3870 typval_T *listtv = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3871 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3872 // return an empty string by default |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3873 rettv->v_type = VAR_STRING; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3874 rettv->vval.v_string = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3875 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3876 clear_job_options(&opt); |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
3877 if (get_job_options(&argvars[1], &opt, JO_TIMEOUT + JO_PART + JO_ID, 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3878 == FAIL) |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
3879 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3880 |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3881 if (opt.jo_set & JO_PART) |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3882 part = opt.jo_part; |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
3883 channel = get_channel_arg(&argvars[0], TRUE, TRUE, part); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3884 if (channel != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3885 { |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3886 if (part == PART_COUNT) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3887 part = channel_part_read(channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3888 mode = channel_get_mode(channel, part); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3889 timeout = channel_get_timeout(channel, part); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3890 if (opt.jo_set & JO_TIMEOUT) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3891 timeout = opt.jo_timeout; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3892 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3893 if (blob) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3894 { |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3895 int outlen = 0; |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3896 char_u *p = channel_read_block(channel, part, |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3897 timeout, TRUE, &outlen); |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3898 if (p != NULL) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3899 { |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3900 blob_T *b = blob_alloc(); |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3901 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3902 if (b != NULL) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3903 { |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3904 b->bv_ga.ga_len = outlen; |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3905 if (ga_grow(&b->bv_ga, outlen) == FAIL) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3906 blob_free(b); |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3907 else |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3908 { |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3909 memcpy(b->bv_ga.ga_data, p, outlen); |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3910 rettv_blob_set(rettv, b); |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3911 } |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3912 } |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3913 vim_free(p); |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3914 } |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3915 } |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3916 else if (raw || mode == MODE_RAW || mode == MODE_NL) |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
3917 rettv->vval.v_string = channel_read_block(channel, part, |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
3918 timeout, raw, NULL); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3919 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3920 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3921 if (opt.jo_set & JO_ID) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3922 id = opt.jo_id; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3923 channel_read_json_block(channel, part, timeout, id, &listtv); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3924 if (listtv != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3925 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3926 *rettv = *listtv; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3927 vim_free(listtv); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3928 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3929 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3930 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3931 rettv->v_type = VAR_SPECIAL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3932 rettv->vval.v_number = VVAL_NONE; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3933 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3934 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3935 } |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
3936 |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
3937 theend: |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
3938 free_job_options(&opt); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3939 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
3940 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
3941 # if defined(MSWIN) || defined(FEAT_GUI) || defined(PROTO) |
8172
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3942 /* |
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3943 * Check the channels for anything that is ready to be read. |
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3944 * The data is put in the read queue. |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3945 * if "only_keep_open" is TRUE only check channels where ch_keep_open is set. |
8172
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3946 */ |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3947 void |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3948 channel_handle_events(int only_keep_open) |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3949 { |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3950 channel_T *channel; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3951 ch_part_T part; |
8172
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3952 sock_T fd; |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3953 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
3954 FOR_ALL_CHANNELS(channel) |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3955 { |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3956 if (only_keep_open && !channel->ch_keep_open) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3957 continue; |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12178
diff
changeset
|
3958 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
3959 // check the socket and pipes |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3960 for (part = PART_SOCK; part < PART_IN; ++part) |
8172
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3961 { |
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3962 fd = channel->ch_part[part].ch_fd; |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3963 if (fd != INVALID_FD) |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3964 { |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3965 int r = channel_wait(channel, fd, 0); |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3966 |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3967 if (r == CW_READY) |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3968 channel_read(channel, part, "channel_handle_events"); |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3969 else if (r == CW_ERROR) |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3970 ch_close_part_on_error(channel, part, TRUE, |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
3971 "channel_handle_events"); |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8928
diff
changeset
|
3972 } |
8172
db5c79d93eee
commit https://github.com/vim/vim/commit/b7522a2f0ca6c970df37241c9e70024465d8596b
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
3973 } |
8122
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3974 } |
39532ee7dd43
commit https://github.com/vim/vim/commit/ed5a78e11c80c7b13b233149fd4273b71fc96262
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
3975 } |
7780
e09af43f98f7
commit https://github.com/vim/vim/commit/85be35f33ea848b50e84d57321a45ebfedfad669
Christian Brabandt <cb@256bit.org>
parents:
7774
diff
changeset
|
3976 # endif |
e09af43f98f7
commit https://github.com/vim/vim/commit/85be35f33ea848b50e84d57321a45ebfedfad669
Christian Brabandt <cb@256bit.org>
parents:
7774
diff
changeset
|
3977 |
12250
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3978 # if defined(FEAT_GUI) || defined(PROTO) |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3979 /* |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3980 * Return TRUE when there is any channel with a keep_open flag. |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3981 */ |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3982 int |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3983 channel_any_keep_open() |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3984 { |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3985 channel_T *channel; |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3986 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
3987 FOR_ALL_CHANNELS(channel) |
12250
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3988 if (channel->ch_keep_open) |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3989 return TRUE; |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3990 return FALSE; |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3991 } |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3992 # endif |
ac8b2f9c1409
patch 8.0.1005: terminal without job updates slowly in GUI
Christian Brabandt <cb@256bit.org>
parents:
12246
diff
changeset
|
3993 |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
3994 /* |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3995 * Set "channel"/"part" to non-blocking. |
12158
b3e39486880a
patch 8.0.0959: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
3996 * Only works for sockets and pipes. |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3997 */ |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3998 void |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
3999 channel_set_nonblock(channel_T *channel, ch_part_T part) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4000 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4001 chanpart_T *ch_part = &channel->ch_part[part]; |
14675
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
14499
diff
changeset
|
4002 int fd = ch_part->ch_fd; |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4003 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4004 if (fd != INVALID_FD) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4005 { |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
4006 #ifdef MSWIN |
12158
b3e39486880a
patch 8.0.0959: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
4007 u_long val = 1; |
b3e39486880a
patch 8.0.0959: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
4008 |
b3e39486880a
patch 8.0.0959: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
4009 ioctlsocket(fd, FIONBIO, &val); |
b3e39486880a
patch 8.0.0959: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
4010 #else |
12178
a1014f647b61
patch 8.0.0969: Coverity warning for unused return value
Christian Brabandt <cb@256bit.org>
parents:
12168
diff
changeset
|
4011 (void)fcntl(fd, F_SETFL, O_NONBLOCK); |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4012 #endif |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4013 ch_part->ch_nonblocking = TRUE; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4014 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4015 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4016 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4017 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4018 * Write "buf" (NUL terminated string) to "channel"/"part". |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4019 * When "fun" is not NULL an error message might be given. |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
4020 * Return FAIL or OK. |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4021 */ |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
4022 int |
10363
471b87c3b67d
commit https://github.com/vim/vim/commit/79cbdcb1eeead00bad6fc64ab4a53e5860d5a663
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
4023 channel_send( |
471b87c3b67d
commit https://github.com/vim/vim/commit/79cbdcb1eeead00bad6fc64ab4a53e5860d5a663
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
4024 channel_T *channel, |
471b87c3b67d
commit https://github.com/vim/vim/commit/79cbdcb1eeead00bad6fc64ab4a53e5860d5a663
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
4025 ch_part_T part, |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4026 char_u *buf_arg, |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4027 int len_arg, |
10363
471b87c3b67d
commit https://github.com/vim/vim/commit/79cbdcb1eeead00bad6fc64ab4a53e5860d5a663
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
4028 char *fun) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4029 { |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4030 int res; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4031 sock_T fd; |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4032 chanpart_T *ch_part = &channel->ch_part[part]; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4033 int did_use_queue = FALSE; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4034 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4035 fd = ch_part->ch_fd; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4036 if (fd == INVALID_FD) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4037 { |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4038 if (!channel->ch_error && fun != NULL) |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4039 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
4040 ch_error(channel, "%s(): write while not connected", fun); |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
4041 semsg(_("E630: %s(): write while not connected"), fun); |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4042 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4043 channel->ch_error = TRUE; |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
4044 return FAIL; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4045 } |
7788
192ae655ac91
commit https://github.com/vim/vim/commit/3b5f929b18492fec291d1ec95a91f54e5912c03b
Christian Brabandt <cb@256bit.org>
parents:
7780
diff
changeset
|
4046 |
14675
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
14499
diff
changeset
|
4047 if (channel->ch_nonblock && !ch_part->ch_nonblocking) |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
14499
diff
changeset
|
4048 channel_set_nonblock(channel, part); |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
14499
diff
changeset
|
4049 |
12443
579faede5d9c
patch 8.0.1101: channel write fails if writing to log fails
Christian Brabandt <cb@256bit.org>
parents:
12407
diff
changeset
|
4050 if (ch_log_active()) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4051 { |
14499
2661d77e440e
patch 8.1.0263: channel log doesn't show part of channel
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
4052 ch_log_lead("SEND ", channel, part); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4053 fprintf(log_fd, "'"); |
14730
193471015e1a
patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions
Christian Brabandt <cb@256bit.org>
parents:
14675
diff
changeset
|
4054 vim_ignored = (int)fwrite(buf_arg, len_arg, 1, log_fd); |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4055 fprintf(log_fd, "'\n"); |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4056 fflush(log_fd); |
18160
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
4057 did_repeated_msg = 0; |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4058 } |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4059 |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4060 for (;;) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4061 { |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4062 writeq_T *wq = &ch_part->ch_writeque; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4063 char_u *buf; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4064 int len; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4065 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4066 if (wq->wq_next != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4067 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4068 // first write what was queued |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4069 buf = wq->wq_next->wq_ga.ga_data; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4070 len = wq->wq_next->wq_ga.ga_len; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4071 did_use_queue = TRUE; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4072 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4073 else |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4074 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4075 if (len_arg == 0) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4076 // nothing to write, called from channel_select_check() |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4077 return OK; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4078 buf = buf_arg; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4079 len = len_arg; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4080 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4081 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4082 if (part == PART_SOCK) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4083 res = sock_write(fd, (char *)buf, len); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4084 else |
15577
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
4085 { |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4086 res = fd_write(fd, (char *)buf, len); |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
4087 #ifdef MSWIN |
15577
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
4088 if (channel->ch_named_pipe && res < 0) |
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
4089 { |
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
4090 DisconnectNamedPipe((HANDLE)fd); |
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
4091 ConnectNamedPipe((HANDLE)fd, NULL); |
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
4092 } |
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
4093 #endif |
f611222a4349
patch 8.1.0796: MS-Windows 7: problem with named pipe on channel
Bram Moolenaar <Bram@vim.org>
parents:
15555
diff
changeset
|
4094 } |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4095 if (res < 0 && (errno == EWOULDBLOCK |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4096 #ifdef EAGAIN |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4097 || errno == EAGAIN |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4098 #endif |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4099 )) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4100 res = 0; // nothing got written |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4101 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4102 if (res >= 0 && ch_part->ch_nonblocking) |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4103 { |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4104 writeq_T *entry = wq->wq_next; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4105 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4106 if (did_use_queue) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4107 ch_log(channel, "Sent %d bytes now", res); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4108 if (res == len) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4109 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4110 // Wrote all the buf[len] bytes. |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4111 if (entry != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4112 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4113 // Remove the entry from the write queue. |
12403
b44bd42a374e
patch 8.0.1081: memory leak for the channel write queue
Christian Brabandt <cb@256bit.org>
parents:
12393
diff
changeset
|
4114 remove_from_writeque(wq, entry); |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4115 continue; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4116 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4117 if (did_use_queue) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4118 ch_log(channel, "Write queue empty"); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4119 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4120 else |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4121 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4122 // Wrote only buf[res] bytes, can't write more now. |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4123 if (entry != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4124 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4125 if (res > 0) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4126 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4127 // Remove the bytes that were written. |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4128 mch_memmove(entry->wq_ga.ga_data, |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4129 (char *)entry->wq_ga.ga_data + res, |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4130 len - res); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4131 entry->wq_ga.ga_len -= res; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4132 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4133 buf = buf_arg; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4134 len = len_arg; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4135 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4136 else |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4137 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4138 buf += res; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4139 len -= res; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4140 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4141 ch_log(channel, "Adding %d bytes to the write queue", len); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4142 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4143 // Append the not written bytes of the argument to the write |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4144 // buffer. Limit entries to 4000 bytes. |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4145 if (wq->wq_prev != NULL |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4146 && wq->wq_prev->wq_ga.ga_len + len < 4000) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4147 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4148 writeq_T *last = wq->wq_prev; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4149 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4150 // append to the last entry |
17308
d04de6c49f59
patch 8.1.1653: ubsan warns for possibly passing NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
17212
diff
changeset
|
4151 if (len > 0 && ga_grow(&last->wq_ga, len) == OK) |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4152 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4153 mch_memmove((char *)last->wq_ga.ga_data |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4154 + last->wq_ga.ga_len, |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4155 buf, len); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4156 last->wq_ga.ga_len += len; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4157 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4158 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4159 else |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4160 { |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
4161 writeq_T *last = ALLOC_ONE(writeq_T); |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4162 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4163 if (last != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4164 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4165 last->wq_prev = wq->wq_prev; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4166 last->wq_next = NULL; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4167 if (wq->wq_prev == NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4168 wq->wq_next = last; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4169 else |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4170 wq->wq_prev->wq_next = last; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4171 wq->wq_prev = last; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4172 ga_init2(&last->wq_ga, 1, 1000); |
17308
d04de6c49f59
patch 8.1.1653: ubsan warns for possibly passing NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
17212
diff
changeset
|
4173 if (len > 0 && ga_grow(&last->wq_ga, len) == OK) |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4174 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4175 mch_memmove(last->wq_ga.ga_data, buf, len); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4176 last->wq_ga.ga_len = len; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4177 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4178 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4179 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4180 } |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4181 } |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4182 else if (res != len) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4183 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4184 if (!channel->ch_error && fun != NULL) |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4185 { |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4186 ch_error(channel, "%s(): write failed", fun); |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
4187 semsg(_("E631: %s(): write failed"), fun); |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4188 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4189 channel->ch_error = TRUE; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4190 return FAIL; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4191 } |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4192 |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4193 channel->ch_error = FALSE; |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4194 return OK; |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4195 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4196 } |
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7743
diff
changeset
|
4197 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4198 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4199 * Common for "ch_sendexpr()" and "ch_sendraw()". |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4200 * Returns the channel if the caller should read the response. |
9355
40c8a8b012b5
commit https://github.com/vim/vim/commit/aad30bbcde2b268e2fffb6fd1443f27ebda9d1ff
Christian Brabandt <cb@256bit.org>
parents:
9282
diff
changeset
|
4201 * Sets "part_read" to the read fd. |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4202 * Otherwise returns NULL. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4203 */ |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4204 static channel_T * |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4205 send_common( |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4206 typval_T *argvars, |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4207 char_u *text, |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4208 int len, |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4209 int id, |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4210 int eval, |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4211 jobopt_T *opt, |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4212 char *fun, |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4213 ch_part_T *part_read) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4214 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4215 channel_T *channel; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4216 ch_part_T part_send; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4217 |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4218 clear_job_options(opt); |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
4219 channel = get_channel_arg(&argvars[0], TRUE, FALSE, 0); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4220 if (channel == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4221 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4222 part_send = channel_part_send(channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4223 *part_read = channel_part_read(channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4224 |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4225 if (get_job_options(&argvars[2], opt, JO_CALLBACK + JO_TIMEOUT, 0) == FAIL) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4226 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4227 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4228 // Set the callback. An empty callback means no callback and not reading |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4229 // the response. With "ch_evalexpr()" and "ch_evalraw()" a callback is not |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4230 // allowed. |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4231 if (opt->jo_callback.cb_name != NULL && *opt->jo_callback.cb_name != NUL) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4232 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4233 if (eval) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4234 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
4235 semsg(_("E917: Cannot use a callback with %s()"), fun); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4236 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4237 } |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4238 channel_set_req_callback(channel, *part_read, &opt->jo_callback, id); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4239 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4240 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4241 if (channel_send(channel, part_send, text, len, fun) == OK |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4242 && opt->jo_callback.cb_name == NULL) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4243 return channel; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4244 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4245 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4246 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4247 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4248 * common for "ch_evalexpr()" and "ch_sendexpr()" |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4249 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
4250 static void |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4251 ch_expr_common(typval_T *argvars, typval_T *rettv, int eval) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4252 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4253 char_u *text; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4254 typval_T *listtv; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4255 channel_T *channel; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4256 int id; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4257 ch_mode_T ch_mode; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4258 ch_part_T part_send; |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4259 ch_part_T part_read; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4260 jobopt_T opt; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4261 int timeout; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4262 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4263 // return an empty string by default |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4264 rettv->v_type = VAR_STRING; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4265 rettv->vval.v_string = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4266 |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
4267 channel = get_channel_arg(&argvars[0], TRUE, FALSE, 0); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4268 if (channel == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4269 return; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4270 part_send = channel_part_send(channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4271 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4272 ch_mode = channel_get_mode(channel, part_send); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4273 if (ch_mode == MODE_RAW || ch_mode == MODE_NL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4274 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
4275 emsg(_("E912: cannot use ch_evalexpr()/ch_sendexpr() with a raw or nl channel")); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4276 return; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4277 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4278 |
8667
8c80c21a1885
commit https://github.com/vim/vim/commit/e9d6a298df6108e2044b1f0da5a2712f0c51c7d9
Christian Brabandt <cb@256bit.org>
parents:
8657
diff
changeset
|
4279 id = ++channel->ch_last_msg_id; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4280 text = json_encode_nr_expr(id, &argvars[1], |
9969
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
4281 (ch_mode == MODE_JS ? JSON_JS : 0) | JSON_NL); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4282 if (text == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4283 return; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4284 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4285 channel = send_common(argvars, text, (int)STRLEN(text), id, eval, &opt, |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4286 eval ? "ch_evalexpr" : "ch_sendexpr", &part_read); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4287 vim_free(text); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4288 if (channel != NULL && eval) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4289 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4290 if (opt.jo_set & JO_TIMEOUT) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4291 timeout = opt.jo_timeout; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4292 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4293 timeout = channel_get_timeout(channel, part_read); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4294 if (channel_read_json_block(channel, part_read, timeout, id, &listtv) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4295 == OK) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4296 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4297 list_T *list = listtv->vval.v_list; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4298 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4299 // Move the item from the list and then change the type to |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4300 // avoid the value being freed. |
19229
d776967d0f0d
patch 8.2.0173: build fails with old compiler
Bram Moolenaar <Bram@vim.org>
parents:
19201
diff
changeset
|
4301 *rettv = list->lv_u.mat.lv_last->li_tv; |
d776967d0f0d
patch 8.2.0173: build fails with old compiler
Bram Moolenaar <Bram@vim.org>
parents:
19201
diff
changeset
|
4302 list->lv_u.mat.lv_last->li_tv.v_type = VAR_NUMBER; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4303 free_tv(listtv); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4304 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4305 } |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4306 free_job_options(&opt); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4307 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4308 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4309 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4310 * common for "ch_evalraw()" and "ch_sendraw()" |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4311 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
4312 static void |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4313 ch_raw_common(typval_T *argvars, typval_T *rettv, int eval) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4314 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4315 char_u buf[NUMBUFLEN]; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4316 char_u *text; |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4317 int len; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4318 channel_T *channel; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4319 ch_part_T part_read; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4320 jobopt_T opt; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4321 int timeout; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4322 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4323 // return an empty string by default |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4324 rettv->v_type = VAR_STRING; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4325 rettv->vval.v_string = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4326 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4327 if (argvars[1].v_type == VAR_BLOB) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4328 { |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4329 text = argvars[1].vval.v_blob->bv_ga.ga_data; |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4330 len = argvars[1].vval.v_blob->bv_ga.ga_len; |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4331 } |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4332 else |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4333 { |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4334 text = tv_get_string_buf(&argvars[1], buf); |
15508
69207f77754a
patch 8.1.0762: compiler warning
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4335 len = (int)STRLEN(text); |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4336 } |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4337 channel = send_common(argvars, text, len, 0, eval, &opt, |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4338 eval ? "ch_evalraw" : "ch_sendraw", &part_read); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4339 if (channel != NULL && eval) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4340 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4341 if (opt.jo_set & JO_TIMEOUT) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4342 timeout = opt.jo_timeout; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4343 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4344 timeout = channel_get_timeout(channel, part_read); |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12818
diff
changeset
|
4345 rettv->vval.v_string = channel_read_block(channel, part_read, |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
4346 timeout, TRUE, NULL); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4347 } |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4348 free_job_options(&opt); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4349 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4350 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4351 #define KEEP_OPEN_TIME 20 // msec |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
4352 |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
4353 #if (defined(UNIX) && !defined(HAVE_SELECT)) || defined(PROTO) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4354 /* |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4355 * Add open channels to the poll struct. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4356 * Return the adjusted struct index. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4357 * The type of "fds" is hidden to avoid problems with the function proto. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4358 */ |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4359 int |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4360 channel_poll_setup(int nfd_in, void *fds_in, int *towait) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4361 { |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4362 int nfd = nfd_in; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4363 channel_T *channel; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4364 struct pollfd *fds = fds_in; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4365 ch_part_T part; |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4366 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
4367 FOR_ALL_CHANNELS(channel) |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4368 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4369 for (part = PART_SOCK; part < PART_IN; ++part) |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4370 { |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4371 chanpart_T *ch_part = &channel->ch_part[part]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4372 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4373 if (ch_part->ch_fd != INVALID_FD) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4374 { |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4375 if (channel->ch_keep_open) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4376 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4377 // For unknown reason poll() returns immediately for a |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4378 // keep-open channel. Instead of adding it to the fds add |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4379 // a short timeout and check, like polling. |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4380 if (*towait < 0 || *towait > KEEP_OPEN_TIME) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4381 *towait = KEEP_OPEN_TIME; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4382 } |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4383 else |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4384 { |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4385 ch_part->ch_poll_idx = nfd; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4386 fds[nfd].fd = ch_part->ch_fd; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4387 fds[nfd].events = POLLIN; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4388 nfd++; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4389 } |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4390 } |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4391 else |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4392 channel->ch_part[part].ch_poll_idx = -1; |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4393 } |
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4394 } |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4395 |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4396 nfd = channel_fill_poll_write(nfd, fds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4397 |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4398 return nfd; |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4399 } |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4400 |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4401 /* |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4402 * The type of "fds" is hidden to avoid problems with the function proto. |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4403 */ |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4404 int |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4405 channel_poll_check(int ret_in, void *fds_in) |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4406 { |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4407 int ret = ret_in; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4408 channel_T *channel; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4409 struct pollfd *fds = fds_in; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4410 ch_part_T part; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4411 int idx; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4412 chanpart_T *in_part; |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4413 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
4414 FOR_ALL_CHANNELS(channel) |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4415 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4416 for (part = PART_SOCK; part < PART_IN; ++part) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4417 { |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4418 idx = channel->ch_part[part].ch_poll_idx; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4419 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4420 if (ret > 0 && idx != -1 && (fds[idx].revents & POLLIN)) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4421 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4422 channel_read(channel, part, "channel_poll_check"); |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4423 --ret; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4424 } |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4425 else if (channel->ch_part[part].ch_fd != INVALID_FD |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4426 && channel->ch_keep_open) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4427 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4428 // polling a keep-open channel |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4429 channel_read(channel, part, "channel_poll_check_keep_open"); |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4430 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4431 } |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4432 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4433 in_part = &channel->ch_part[PART_IN]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4434 idx = in_part->ch_poll_idx; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4435 if (ret > 0 && idx != -1 && (fds[idx].revents & POLLOUT)) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4436 { |
12168
51e5a8602624
patch 8.0.0964: channel write buffer does not work with poll()
Christian Brabandt <cb@256bit.org>
parents:
12158
diff
changeset
|
4437 channel_write_input(channel); |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4438 --ret; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4439 } |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4440 } |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4441 |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4442 return ret; |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4443 } |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4444 #endif // UNIX && !HAVE_SELECT |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
4445 |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
4446 #if (!defined(MSWIN) && defined(HAVE_SELECT)) || defined(PROTO) |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4447 |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4448 /* |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4449 * The "fd_set" type is hidden to avoid problems with the function proto. |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4450 */ |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4451 int |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4452 channel_select_setup( |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4453 int maxfd_in, |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4454 void *rfds_in, |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4455 void *wfds_in, |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4456 struct timeval *tv, |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4457 struct timeval **tvp) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4458 { |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4459 int maxfd = maxfd_in; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4460 channel_T *channel; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4461 fd_set *rfds = rfds_in; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4462 fd_set *wfds = wfds_in; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4463 ch_part_T part; |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4464 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
4465 FOR_ALL_CHANNELS(channel) |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4466 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4467 for (part = PART_SOCK; part < PART_IN; ++part) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4468 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4469 sock_T fd = channel->ch_part[part].ch_fd; |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4470 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4471 if (fd != INVALID_FD) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4472 { |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4473 if (channel->ch_keep_open) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4474 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4475 // For unknown reason select() returns immediately for a |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4476 // keep-open channel. Instead of adding it to the rfds add |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4477 // a short timeout and check, like polling. |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4478 if (*tvp == NULL || tv->tv_sec > 0 |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4479 || tv->tv_usec > KEEP_OPEN_TIME * 1000) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4480 { |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4481 *tvp = tv; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4482 tv->tv_sec = 0; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4483 tv->tv_usec = KEEP_OPEN_TIME * 1000; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4484 } |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4485 } |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4486 else |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4487 { |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4488 FD_SET((int)fd, rfds); |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4489 if (maxfd < (int)fd) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4490 maxfd = (int)fd; |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4491 } |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4492 } |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4493 } |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4494 } |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4495 |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4496 maxfd = channel_fill_wfds(maxfd, wfds); |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4497 |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4498 return maxfd; |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4499 } |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4500 |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4501 /* |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4502 * The "fd_set" type is hidden to avoid problems with the function proto. |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4503 */ |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4504 int |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4505 channel_select_check(int ret_in, void *rfds_in, void *wfds_in) |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4506 { |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4507 int ret = ret_in; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4508 channel_T *channel; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4509 fd_set *rfds = rfds_in; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4510 fd_set *wfds = wfds_in; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4511 ch_part_T part; |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4512 chanpart_T *in_part; |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4513 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
4514 FOR_ALL_CHANNELS(channel) |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4515 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4516 for (part = PART_SOCK; part < PART_IN; ++part) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4517 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4518 sock_T fd = channel->ch_part[part].ch_fd; |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4519 |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4520 if (ret > 0 && fd != INVALID_FD && FD_ISSET(fd, rfds)) |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4521 { |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4522 channel_read(channel, part, "channel_select_check"); |
12393
128cd982c7b8
patch 8.0.1076: term_start() does not take callbacks
Christian Brabandt <cb@256bit.org>
parents:
12389
diff
changeset
|
4523 FD_CLR(fd, rfds); |
8047
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4524 --ret; |
7c74cafac0a1
commit https://github.com/vim/vim/commit/7b3ca76a451b10d238ef946f3231762e0bd988e9
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
4525 } |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4526 else if (fd != INVALID_FD && channel->ch_keep_open) |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4527 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4528 // polling a keep-open channel |
12584
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4529 channel_read(channel, part, "channel_select_check_keep_open"); |
f28067b83dec
patch 8.0.1170: using termdebug results in 100% CPU time
Christian Brabandt <cb@256bit.org>
parents:
12443
diff
changeset
|
4530 } |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4531 } |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4532 |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4533 in_part = &channel->ch_part[PART_IN]; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4534 if (ret > 0 && in_part->ch_fd != INVALID_FD |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4535 && FD_ISSET(in_part->ch_fd, wfds)) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4536 { |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
4537 // Clear the flag first, ch_fd may change in channel_write_input(). |
13569
97720d9a01d4
patch 8.0.1657: crash when reading a channel
Christian Brabandt <cb@256bit.org>
parents:
13470
diff
changeset
|
4538 FD_CLR(in_part->ch_fd, wfds); |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
4539 channel_write_input(channel); |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4540 --ret; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
4541 } |
8049
15253130abd8
commit https://github.com/vim/vim/commit/16eb4f88000cfdba68df6c421fe44e7e029ba53e
Christian Brabandt <cb@256bit.org>
parents:
8047
diff
changeset
|
4542 } |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4543 |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4544 return ret; |
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4545 } |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
4546 #endif // !MSWIN && HAVE_SELECT |
7743
6069f43cea4e
commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4547 |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4548 /* |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
4549 * Execute queued up commands. |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
4550 * Invoked from the main loop when it's safe to execute received commands, |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
4551 * and during a blocking wait for ch_evalexpr(). |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
4552 * Return TRUE when something was done. |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4553 */ |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
4554 int |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4555 channel_parse_messages(void) |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4556 { |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4557 channel_T *channel = first_channel; |
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4558 int ret = FALSE; |
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4559 int r; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4560 ch_part_T part = PART_SOCK; |
19820
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4561 static int recursive = 0; |
10406
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4562 #ifdef ELAPSED_FUNC |
15525
3ef31ce9d9f9
patch 8.1.0770: inconsistent use of ELAPSED_FUNC
Bram Moolenaar <Bram@vim.org>
parents:
15508
diff
changeset
|
4563 elapsed_T start_tv; |
19791
f46d3a9fe27d
patch 8.2.0452: channel_parse_messages() fails when called recursively
Bram Moolenaar <Bram@vim.org>
parents:
19772
diff
changeset
|
4564 #endif |
f46d3a9fe27d
patch 8.2.0452: channel_parse_messages() fails when called recursively
Bram Moolenaar <Bram@vim.org>
parents:
19772
diff
changeset
|
4565 |
f46d3a9fe27d
patch 8.2.0452: channel_parse_messages() fails when called recursively
Bram Moolenaar <Bram@vim.org>
parents:
19772
diff
changeset
|
4566 // The code below may invoke callbacks, which might call us back. |
19820
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4567 // In a recursive call channels will not be closed. |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4568 ++recursive; |
19791
f46d3a9fe27d
patch 8.2.0452: channel_parse_messages() fails when called recursively
Bram Moolenaar <Bram@vim.org>
parents:
19772
diff
changeset
|
4569 ++safe_to_invoke_callback; |
f46d3a9fe27d
patch 8.2.0452: channel_parse_messages() fails when called recursively
Bram Moolenaar <Bram@vim.org>
parents:
19772
diff
changeset
|
4570 |
f46d3a9fe27d
patch 8.2.0452: channel_parse_messages() fails when called recursively
Bram Moolenaar <Bram@vim.org>
parents:
19772
diff
changeset
|
4571 #ifdef ELAPSED_FUNC |
10406
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4572 ELAPSED_INIT(start_tv); |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4573 #endif |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4574 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4575 // Only do this message when another message was given, otherwise we get |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4576 // lots of them. |
18160
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
4577 if ((did_repeated_msg & REPEATED_MSG_LOOKING) == 0) |
8428
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
4578 { |
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
4579 ch_log(NULL, "looking for messages on channels"); |
18160
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
4580 // now we should also give the message for SafeState |
770987511384
patch 8.1.2075: get many log messages when waiting for a typed character
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
4581 did_repeated_msg = REPEATED_MSG_LOOKING; |
8428
4e22d0e7bfb1
commit https://github.com/vim/vim/commit/d0b6502a7ace39d6cd30874110a572371d10beae
Christian Brabandt <cb@256bit.org>
parents:
8422
diff
changeset
|
4582 } |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4583 while (channel != NULL) |
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4584 { |
19820
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4585 if (recursive == 1) |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4586 { |
19820
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4587 if (channel_can_close(channel)) |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4588 { |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4589 channel->ch_to_be_closed = (1U << PART_COUNT); |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4590 channel_close_now(channel); |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4591 // channel may have been freed, start over |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4592 channel = first_channel; |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4593 continue; |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4594 } |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4595 if (channel->ch_to_be_freed || channel->ch_killing) |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4596 { |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4597 channel_free_contents(channel); |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4598 if (channel->ch_job != NULL) |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4599 channel->ch_job->jv_channel = NULL; |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4600 |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4601 // free the channel and then start over |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4602 channel_free_channel(channel); |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4603 channel = first_channel; |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4604 continue; |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4605 } |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4606 if (channel->ch_refcount == 0 && !channel_still_useful(channel)) |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4607 { |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4608 // channel is no longer useful, free it |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4609 channel_free(channel); |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4610 channel = first_channel; |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4611 part = PART_SOCK; |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4612 continue; |
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4613 } |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4614 } |
19820
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4615 |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
4616 if (channel->ch_part[part].ch_fd != INVALID_FD |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4617 || channel_has_readahead(channel, part)) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
4618 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4619 // Increase the refcount, in case the handler causes the channel |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4620 // to be unreferenced or closed. |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4621 ++channel->ch_refcount; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4622 r = may_invoke_callback(channel, part); |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4623 if (r == OK) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4624 ret = TRUE; |
10406
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4625 if (channel_unref(channel) || (r == OK |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4626 #ifdef ELAPSED_FUNC |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4627 // Limit the time we loop here to 100 msec, otherwise |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4628 // Vim becomes unresponsive when the callback takes |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4629 // more than a bit of time. |
10406
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4630 && ELAPSED_FUNC(start_tv) < 100L |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4631 #endif |
42911b233245
commit https://github.com/vim/vim/commit/833eb1d752426689051bf2001083359899536939
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
4632 )) |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4633 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
4634 // channel was freed or something was done, start over |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4635 channel = first_channel; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4636 part = PART_SOCK; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4637 continue; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4638 } |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
4639 } |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4640 if (part < PART_ERR) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4641 ++part; |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4642 else |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4643 { |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4644 channel = channel->ch_next; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4645 part = PART_SOCK; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4646 } |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8049
diff
changeset
|
4647 } |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
4648 |
8928
e6916e1683bb
commit https://github.com/vim/vim/commit/7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
4649 if (channel_need_redraw) |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
4650 { |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
4651 channel_need_redraw = FALSE; |
12244
d0b039e2ed56
patch 8.0.1002: unnecessarily updating screen after timer callback
Christian Brabandt <cb@256bit.org>
parents:
12240
diff
changeset
|
4652 redraw_after_callback(TRUE); |
8267
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
4653 } |
108d30ed34ba
commit https://github.com/vim/vim/commit/187db50d0499aecf4cfd42fb4db0a1bebf61c8cd
Christian Brabandt <cb@256bit.org>
parents:
8261
diff
changeset
|
4654 |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4655 --safe_to_invoke_callback; |
19820
49e38e5472e6
patch 8.2.0466: not parsing messages recursively breaks the govim plugin
Bram Moolenaar <Bram@vim.org>
parents:
19797
diff
changeset
|
4656 --recursive; |
9085
d362e6df1deb
commit https://github.com/vim/vim/commit/fb6ffc732e65dbc459c89247ff78134402f1a18b
Christian Brabandt <cb@256bit.org>
parents:
9083
diff
changeset
|
4657 |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
7885
diff
changeset
|
4658 return ret; |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4659 } |
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
4660 |
7961
a7e58c6e4e9a
commit https://github.com/vim/vim/commit/fbc4b4db3a9690906a96e16724350a6241cf32a5
Christian Brabandt <cb@256bit.org>
parents:
7945
diff
changeset
|
4661 /* |
10418
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4662 * Return TRUE if any channel has readahead. That means we should not block on |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4663 * waiting for input. |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4664 */ |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4665 int |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4666 channel_any_readahead(void) |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4667 { |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4668 channel_T *channel = first_channel; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4669 ch_part_T part = PART_SOCK; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4670 |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4671 while (channel != NULL) |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4672 { |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4673 if (channel_has_readahead(channel, part)) |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4674 return TRUE; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4675 if (part < PART_ERR) |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4676 ++part; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4677 else |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4678 { |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4679 channel = channel->ch_next; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4680 part = PART_SOCK; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4681 } |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4682 } |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4683 return FALSE; |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4684 } |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4685 |
56cb9538386c
commit https://github.com/vim/vim/commit/8a8199e4a1814b10630a770165502abb1121cd1b
Christian Brabandt <cb@256bit.org>
parents:
10406
diff
changeset
|
4686 /* |
7961
a7e58c6e4e9a
commit https://github.com/vim/vim/commit/fbc4b4db3a9690906a96e16724350a6241cf32a5
Christian Brabandt <cb@256bit.org>
parents:
7945
diff
changeset
|
4687 * Mark references to lists used in channels. |
a7e58c6e4e9a
commit https://github.com/vim/vim/commit/fbc4b4db3a9690906a96e16724350a6241cf32a5
Christian Brabandt <cb@256bit.org>
parents:
7945
diff
changeset
|
4688 */ |
7931
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4689 int |
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4690 set_ref_in_channel(int copyID) |
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4691 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
4692 int abort = FALSE; |
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
4693 channel_T *channel; |
9058
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
4694 typval_T tv; |
7931
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4695 |
17151
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17024
diff
changeset
|
4696 for (channel = first_channel; !abort && channel != NULL; |
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17024
diff
changeset
|
4697 channel = channel->ch_next) |
9058
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
4698 if (channel_still_useful(channel)) |
7931
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4699 { |
9058
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
4700 tv.v_type = VAR_CHANNEL; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
4701 tv.vval.v_channel = channel; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
4702 abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); |
7931
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4703 } |
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4704 return abort; |
2679e636e862
commit https://github.com/vim/vim/commit/4b6a6dcbe7bd13170c4884cc17acb1eac2c633d1
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
4705 } |
7986
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4706 |
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4707 /* |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4708 * Return the "part" to write to for "channel". |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4709 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
4710 static ch_part_T |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4711 channel_part_send(channel_T *channel) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4712 { |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4713 if (channel->CH_SOCK_FD == INVALID_FD) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4714 return PART_IN; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4715 return PART_SOCK; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4716 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4717 |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4718 /* |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4719 * Return the default "part" to read from for "channel". |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4720 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
4721 static ch_part_T |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4722 channel_part_read(channel_T *channel) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4723 { |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4724 if (channel->CH_SOCK_FD == INVALID_FD) |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4725 return PART_OUT; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4726 return PART_SOCK; |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4727 } |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4728 |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4729 /* |
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4730 * Return the mode of "channel"/"part" |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
4731 * If "channel" is invalid returns MODE_JSON. |
7986
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4732 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
4733 static ch_mode_T |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4734 channel_get_mode(channel_T *channel, ch_part_T part) |
7986
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4735 { |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8039
diff
changeset
|
4736 if (channel == NULL) |
7986
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4737 return MODE_JSON; |
8151
aa845d10c6fb
commit https://github.com/vim/vim/commit/42d38a2db17e70312d073095257555c27a5f9443
Christian Brabandt <cb@256bit.org>
parents:
8134
diff
changeset
|
4738 return channel->ch_part[part].ch_mode; |
7986
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4739 } |
8e0d4cd8157a
commit https://github.com/vim/vim/commit/ae8eb3ca927f1b0ac2a6643da8699538cdc380f6
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
4740 |
8157
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4741 /* |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4742 * Return the timeout of "channel"/"part" |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4743 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
4744 static int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4745 channel_get_timeout(channel_T *channel, ch_part_T part) |
8157
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4746 { |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4747 return channel->ch_part[part].ch_timeout; |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4748 } |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8155
diff
changeset
|
4749 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4750 static int |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4751 handle_mode(typval_T *item, jobopt_T *opt, ch_mode_T *modep, int jo) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4752 { |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
4753 char_u *val = tv_get_string(item); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4754 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4755 opt->jo_set |= jo; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4756 if (STRCMP(val, "nl") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4757 *modep = MODE_NL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4758 else if (STRCMP(val, "raw") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4759 *modep = MODE_RAW; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4760 else if (STRCMP(val, "js") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4761 *modep = MODE_JS; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4762 else if (STRCMP(val, "json") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4763 *modep = MODE_JSON; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4764 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4765 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
4766 semsg(_(e_invarg2), val); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4767 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4768 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4769 return OK; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4770 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4771 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4772 static int |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4773 handle_io(typval_T *item, ch_part_T part, jobopt_T *opt) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4774 { |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
4775 char_u *val = tv_get_string(item); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4776 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4777 opt->jo_set |= JO_OUT_IO << (part - PART_OUT); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4778 if (STRCMP(val, "null") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4779 opt->jo_io[part] = JIO_NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4780 else if (STRCMP(val, "pipe") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4781 opt->jo_io[part] = JIO_PIPE; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4782 else if (STRCMP(val, "file") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4783 opt->jo_io[part] = JIO_FILE; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4784 else if (STRCMP(val, "buffer") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4785 opt->jo_io[part] = JIO_BUFFER; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4786 else if (STRCMP(val, "out") == 0 && part == PART_ERR) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4787 opt->jo_io[part] = JIO_OUT; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4788 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4789 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
4790 semsg(_(e_invarg2), val); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4791 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4792 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4793 return OK; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4794 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4795 |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4796 /* |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4797 * Clear a jobopt_T before using it. |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4798 */ |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4799 void |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4800 clear_job_options(jobopt_T *opt) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4801 { |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
20003
diff
changeset
|
4802 CLEAR_POINTER(opt); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4803 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4804 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4805 /* |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4806 * Free any members of a jobopt_T. |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4807 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
4808 static void |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4809 free_job_options(jobopt_T *opt) |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4810 { |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4811 if (opt->jo_callback.cb_partial != NULL) |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4812 partial_unref(opt->jo_callback.cb_partial); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4813 else if (opt->jo_callback.cb_name != NULL) |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4814 func_unref(opt->jo_callback.cb_name); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4815 if (opt->jo_out_cb.cb_partial != NULL) |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4816 partial_unref(opt->jo_out_cb.cb_partial); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4817 else if (opt->jo_out_cb.cb_name != NULL) |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4818 func_unref(opt->jo_out_cb.cb_name); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4819 if (opt->jo_err_cb.cb_partial != NULL) |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4820 partial_unref(opt->jo_err_cb.cb_partial); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4821 else if (opt->jo_err_cb.cb_name != NULL) |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4822 func_unref(opt->jo_err_cb.cb_name); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4823 if (opt->jo_close_cb.cb_partial != NULL) |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4824 partial_unref(opt->jo_close_cb.cb_partial); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4825 else if (opt->jo_close_cb.cb_name != NULL) |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4826 func_unref(opt->jo_close_cb.cb_name); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4827 if (opt->jo_exit_cb.cb_partial != NULL) |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4828 partial_unref(opt->jo_exit_cb.cb_partial); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4829 else if (opt->jo_exit_cb.cb_name != NULL) |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4830 func_unref(opt->jo_exit_cb.cb_name); |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4831 if (opt->jo_env != NULL) |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
4832 dict_unref(opt->jo_env); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4833 } |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4834 |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
4835 /* |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4836 * Get the PART_ number from the first character of an option name. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4837 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4838 static int |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4839 part_from_char(int c) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4840 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4841 return c == 'i' ? PART_IN : c == 'o' ? PART_OUT: PART_ERR; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4842 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4843 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4844 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4845 * Get the option entries from the dict in "tv", parse them and put the result |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4846 * in "opt". |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4847 * Only accept JO_ options in "supported" and JO2_ options in "supported2". |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4848 * If an option value is invalid return FAIL. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4849 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4850 int |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
4851 get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4852 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4853 typval_T *item; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4854 char_u *val; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4855 dict_T *dict; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4856 int todo; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4857 hashitem_T *hi; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
4858 ch_part_T part; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4859 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4860 if (tv->v_type == VAR_UNKNOWN) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4861 return OK; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4862 if (tv->v_type != VAR_DICT) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4863 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
4864 emsg(_(e_dictreq)); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4865 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4866 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4867 dict = tv->vval.v_dict; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4868 if (dict == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4869 return OK; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4870 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4871 todo = (int)dict->dv_hashtab.ht_used; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4872 for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4873 if (!HASHITEM_EMPTY(hi)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4874 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4875 item = &dict_lookup(hi)->di_tv; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4876 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4877 if (STRCMP(hi->hi_key, "mode") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4878 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4879 if (!(supported & JO_MODE)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4880 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4881 if (handle_mode(item, opt, &opt->jo_mode, JO_MODE) == FAIL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4882 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4883 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4884 else if (STRCMP(hi->hi_key, "in_mode") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4885 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4886 if (!(supported & JO_IN_MODE)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4887 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4888 if (handle_mode(item, opt, &opt->jo_in_mode, JO_IN_MODE) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4889 == FAIL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4890 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4891 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4892 else if (STRCMP(hi->hi_key, "out_mode") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4893 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4894 if (!(supported & JO_OUT_MODE)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4895 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4896 if (handle_mode(item, opt, &opt->jo_out_mode, JO_OUT_MODE) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4897 == FAIL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4898 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4899 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4900 else if (STRCMP(hi->hi_key, "err_mode") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4901 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4902 if (!(supported & JO_ERR_MODE)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4903 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4904 if (handle_mode(item, opt, &opt->jo_err_mode, JO_ERR_MODE) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4905 == FAIL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4906 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4907 } |
14675
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
14499
diff
changeset
|
4908 else if (STRCMP(hi->hi_key, "noblock") == 0) |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
14499
diff
changeset
|
4909 { |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
14499
diff
changeset
|
4910 if (!(supported & JO_MODE)) |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
14499
diff
changeset
|
4911 break; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
4912 opt->jo_noblock = tv_get_number(item); |
14675
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
14499
diff
changeset
|
4913 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4914 else if (STRCMP(hi->hi_key, "in_io") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4915 || STRCMP(hi->hi_key, "out_io") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4916 || STRCMP(hi->hi_key, "err_io") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4917 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4918 if (!(supported & JO_OUT_IO)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4919 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4920 if (handle_io(item, part_from_char(*hi->hi_key), opt) == FAIL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4921 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4922 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4923 else if (STRCMP(hi->hi_key, "in_name") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4924 || STRCMP(hi->hi_key, "out_name") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4925 || STRCMP(hi->hi_key, "err_name") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4926 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4927 part = part_from_char(*hi->hi_key); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4928 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4929 if (!(supported & JO_OUT_IO)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4930 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4931 opt->jo_set |= JO_OUT_NAME << (part - PART_OUT); |
19245
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
4932 opt->jo_io_name[part] = tv_get_string_buf_chk(item, |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
4933 opt->jo_io_name_buf[part]); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4934 } |
11723
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
4935 else if (STRCMP(hi->hi_key, "pty") == 0) |
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
4936 { |
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
4937 if (!(supported & JO_MODE)) |
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
4938 break; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
4939 opt->jo_pty = tv_get_number(item); |
11723
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
4940 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4941 else if (STRCMP(hi->hi_key, "in_buf") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4942 || STRCMP(hi->hi_key, "out_buf") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4943 || STRCMP(hi->hi_key, "err_buf") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4944 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4945 part = part_from_char(*hi->hi_key); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4946 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4947 if (!(supported & JO_OUT_IO)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4948 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4949 opt->jo_set |= JO_OUT_BUF << (part - PART_OUT); |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
4950 opt->jo_io_buf[part] = tv_get_number(item); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4951 if (opt->jo_io_buf[part] <= 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4952 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
4953 semsg(_(e_invargNval), hi->hi_key, tv_get_string(item)); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4954 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4955 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4956 if (buflist_findnr(opt->jo_io_buf[part]) == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4957 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
4958 semsg(_(e_nobufnr), (long)opt->jo_io_buf[part]); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4959 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4960 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4961 } |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4962 else if (STRCMP(hi->hi_key, "out_modifiable") == 0 |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4963 || STRCMP(hi->hi_key, "err_modifiable") == 0) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4964 { |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4965 part = part_from_char(*hi->hi_key); |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4966 |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4967 if (!(supported & JO_OUT_IO)) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4968 break; |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4969 opt->jo_set |= JO_OUT_MODIFIABLE << (part - PART_OUT); |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
4970 opt->jo_modifiable[part] = tv_get_number(item); |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9143
diff
changeset
|
4971 } |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4972 else if (STRCMP(hi->hi_key, "out_msg") == 0 |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4973 || STRCMP(hi->hi_key, "err_msg") == 0) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4974 { |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4975 part = part_from_char(*hi->hi_key); |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4976 |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4977 if (!(supported & JO_OUT_IO)) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4978 break; |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4979 opt->jo_set2 |= JO2_OUT_MSG << (part - PART_OUT); |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
4980 opt->jo_message[part] = tv_get_number(item); |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10112
diff
changeset
|
4981 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4982 else if (STRCMP(hi->hi_key, "in_top") == 0 |
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
4983 || STRCMP(hi->hi_key, "in_bot") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4984 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4985 linenr_T *lp; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4986 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4987 if (!(supported & JO_OUT_IO)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4988 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4989 if (hi->hi_key[3] == 't') |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4990 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4991 lp = &opt->jo_in_top; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4992 opt->jo_set |= JO_IN_TOP; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4993 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4994 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4995 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4996 lp = &opt->jo_in_bot; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4997 opt->jo_set |= JO_IN_BOT; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
4998 } |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
4999 *lp = tv_get_number(item); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5000 if (*lp < 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5001 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5002 semsg(_(e_invargNval), hi->hi_key, tv_get_string(item)); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5003 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5004 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5005 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5006 else if (STRCMP(hi->hi_key, "channel") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5007 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5008 if (!(supported & JO_OUT_IO)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5009 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5010 opt->jo_set |= JO_CHANNEL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5011 if (item->v_type != VAR_CHANNEL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5012 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5013 semsg(_(e_invargval), "channel"); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5014 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5015 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5016 opt->jo_channel = item->vval.v_channel; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5017 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5018 else if (STRCMP(hi->hi_key, "callback") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5019 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5020 if (!(supported & JO_CALLBACK)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5021 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5022 opt->jo_set |= JO_CALLBACK; |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5023 opt->jo_callback = get_callback(item); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5024 if (opt->jo_callback.cb_name == NULL) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5025 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5026 semsg(_(e_invargval), "callback"); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5027 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5028 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5029 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
5030 else if (STRCMP(hi->hi_key, "out_cb") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5031 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5032 if (!(supported & JO_OUT_CALLBACK)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5033 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5034 opt->jo_set |= JO_OUT_CALLBACK; |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5035 opt->jo_out_cb = get_callback(item); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5036 if (opt->jo_out_cb.cb_name == NULL) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5037 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5038 semsg(_(e_invargval), "out_cb"); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5039 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5040 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5041 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
5042 else if (STRCMP(hi->hi_key, "err_cb") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5043 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5044 if (!(supported & JO_ERR_CALLBACK)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5045 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5046 opt->jo_set |= JO_ERR_CALLBACK; |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5047 opt->jo_err_cb = get_callback(item); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5048 if (opt->jo_err_cb.cb_name == NULL) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5049 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5050 semsg(_(e_invargval), "err_cb"); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5051 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5052 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5053 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
5054 else if (STRCMP(hi->hi_key, "close_cb") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5055 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5056 if (!(supported & JO_CLOSE_CALLBACK)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5057 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5058 opt->jo_set |= JO_CLOSE_CALLBACK; |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5059 opt->jo_close_cb = get_callback(item); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5060 if (opt->jo_close_cb.cb_name == NULL) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5061 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5062 semsg(_(e_invargval), "close_cb"); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5063 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5064 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5065 } |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
5066 else if (STRCMP(hi->hi_key, "drop") == 0) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
5067 { |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
5068 int never = FALSE; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5069 val = tv_get_string(item); |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
5070 |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
5071 if (STRCMP(val, "never") == 0) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
5072 never = TRUE; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
5073 else if (STRCMP(val, "auto") != 0) |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
5074 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5075 semsg(_(e_invargNval), "drop", val); |
10426
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
5076 return FAIL; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
5077 } |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
5078 opt->jo_drop_never = never; |
acfc83aca8ee
commit https://github.com/vim/vim/commit/958dc6923d341390531888058495569d73c356c3
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
5079 } |
9151
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
5080 else if (STRCMP(hi->hi_key, "exit_cb") == 0) |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
5081 { |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
5082 if (!(supported & JO_EXIT_CB)) |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
5083 break; |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
5084 opt->jo_set |= JO_EXIT_CB; |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5085 opt->jo_exit_cb = get_callback(item); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5086 if (opt->jo_exit_cb.cb_name == NULL) |
9151
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
5087 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5088 semsg(_(e_invargval), "exit_cb"); |
9151
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
5089 return FAIL; |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
5090 } |
d0f69d0bea7a
commit https://github.com/vim/vim/commit/ef3abc6442260e9a0314970a532400b05571d3fe
Christian Brabandt <cb@256bit.org>
parents:
9149
diff
changeset
|
5091 } |
11969
5dc3730de58d
patch 8.0.0865: cannot build with channel but without terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11967
diff
changeset
|
5092 #ifdef FEAT_TERMINAL |
11967
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
5093 else if (STRCMP(hi->hi_key, "term_name") == 0) |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
5094 { |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5095 if (!(supported2 & JO2_TERM_NAME)) |
11967
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
5096 break; |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
5097 opt->jo_set2 |= JO2_TERM_NAME; |
19245
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5098 opt->jo_term_name = tv_get_string_buf_chk(item, |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5099 opt->jo_term_name_buf); |
11967
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
5100 if (opt->jo_term_name == NULL) |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
5101 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5102 semsg(_(e_invargval), "term_name"); |
11967
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
5103 return FAIL; |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
5104 } |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11959
diff
changeset
|
5105 } |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
5106 else if (STRCMP(hi->hi_key, "term_finish") == 0) |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
5107 { |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5108 if (!(supported2 & JO2_TERM_FINISH)) |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
5109 break; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5110 val = tv_get_string(item); |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
5111 if (STRCMP(val, "open") != 0 && STRCMP(val, "close") != 0) |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
5112 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5113 semsg(_(e_invargNval), "term_finish", val); |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
5114 return FAIL; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
5115 } |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
5116 opt->jo_set2 |= JO2_TERM_FINISH; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
5117 opt->jo_term_finish = *val; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
11977
diff
changeset
|
5118 } |
12072
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5119 else if (STRCMP(hi->hi_key, "term_opencmd") == 0) |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5120 { |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5121 char_u *p; |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5122 |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5123 if (!(supported2 & JO2_TERM_OPENCMD)) |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5124 break; |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5125 opt->jo_set2 |= JO2_TERM_OPENCMD; |
19245
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5126 p = opt->jo_term_opencmd = tv_get_string_buf_chk(item, |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5127 opt->jo_term_opencmd_buf); |
12072
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5128 if (p != NULL) |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5129 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5130 // Must have %d and no other %. |
12072
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5131 p = vim_strchr(p, '%'); |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5132 if (p != NULL && (p[1] != 'd' |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5133 || vim_strchr(p + 2, '%') != NULL)) |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5134 p = NULL; |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5135 } |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5136 if (p == NULL) |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5137 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5138 semsg(_(e_invargval), "term_opencmd"); |
12072
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5139 return FAIL; |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5140 } |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
5141 } |
12309
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
5142 else if (STRCMP(hi->hi_key, "eof_chars") == 0) |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
5143 { |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
5144 if (!(supported2 & JO2_EOF_CHARS)) |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
5145 break; |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
5146 opt->jo_set2 |= JO2_EOF_CHARS; |
19245
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5147 opt->jo_eof_chars = tv_get_string_buf_chk(item, |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5148 opt->jo_eof_chars_buf); |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5149 if (opt->jo_eof_chars == NULL) |
12309
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
5150 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5151 semsg(_(e_invargval), "eof_chars"); |
12309
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
5152 return FAIL; |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
5153 } |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12250
diff
changeset
|
5154 } |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5155 else if (STRCMP(hi->hi_key, "term_rows") == 0) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5156 { |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5157 if (!(supported2 & JO2_TERM_ROWS)) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5158 break; |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5159 opt->jo_set2 |= JO2_TERM_ROWS; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5160 opt->jo_term_rows = tv_get_number(item); |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5161 } |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5162 else if (STRCMP(hi->hi_key, "term_cols") == 0) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5163 { |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5164 if (!(supported2 & JO2_TERM_COLS)) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5165 break; |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5166 opt->jo_set2 |= JO2_TERM_COLS; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5167 opt->jo_term_cols = tv_get_number(item); |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5168 } |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5169 else if (STRCMP(hi->hi_key, "vertical") == 0) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5170 { |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5171 if (!(supported2 & JO2_VERTICAL)) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5172 break; |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5173 opt->jo_set2 |= JO2_VERTICAL; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5174 opt->jo_vertical = tv_get_number(item); |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5175 } |
12060
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12058
diff
changeset
|
5176 else if (STRCMP(hi->hi_key, "curwin") == 0) |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12058
diff
changeset
|
5177 { |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12058
diff
changeset
|
5178 if (!(supported2 & JO2_CURWIN)) |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12058
diff
changeset
|
5179 break; |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5180 opt->jo_set2 |= JO2_CURWIN; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5181 opt->jo_curwin = tv_get_number(item); |
12060
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12058
diff
changeset
|
5182 } |
16912
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5183 else if (STRCMP(hi->hi_key, "bufnr") == 0) |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5184 { |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5185 int nr; |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5186 |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5187 if (!(supported2 & JO2_CURWIN)) |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5188 break; |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5189 opt->jo_set2 |= JO2_BUFNR; |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5190 nr = tv_get_number(item); |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5191 if (nr <= 0) |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5192 { |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5193 semsg(_(e_invargNval), hi->hi_key, tv_get_string(item)); |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5194 return FAIL; |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5195 } |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5196 opt->jo_bufnr_buf = buflist_findnr(nr); |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5197 if (opt->jo_bufnr_buf == NULL) |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5198 { |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5199 semsg(_(e_nobufnr), (long)nr); |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5200 return FAIL; |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5201 } |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5202 if (opt->jo_bufnr_buf->b_nwindows == 0 |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5203 || opt->jo_bufnr_buf->b_term == NULL) |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5204 { |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5205 semsg(_(e_invarg2), "bufnr"); |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5206 return FAIL; |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5207 } |
a5e3509b33ca
patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Bram Moolenaar <Bram@vim.org>
parents:
16872
diff
changeset
|
5208 } |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
5209 else if (STRCMP(hi->hi_key, "hidden") == 0) |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
5210 { |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
5211 if (!(supported2 & JO2_HIDDEN)) |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
5212 break; |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5213 opt->jo_set2 |= JO2_HIDDEN; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5214 opt->jo_hidden = tv_get_number(item); |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
5215 } |
13435
fa198b71bab2
patch 8.0.1592: terminal windows in a session are not properly restored
Christian Brabandt <cb@256bit.org>
parents:
13284
diff
changeset
|
5216 else if (STRCMP(hi->hi_key, "norestore") == 0) |
fa198b71bab2
patch 8.0.1592: terminal windows in a session are not properly restored
Christian Brabandt <cb@256bit.org>
parents:
13284
diff
changeset
|
5217 { |
fa198b71bab2
patch 8.0.1592: terminal windows in a session are not properly restored
Christian Brabandt <cb@256bit.org>
parents:
13284
diff
changeset
|
5218 if (!(supported2 & JO2_NORESTORE)) |
fa198b71bab2
patch 8.0.1592: terminal windows in a session are not properly restored
Christian Brabandt <cb@256bit.org>
parents:
13284
diff
changeset
|
5219 break; |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5220 opt->jo_set2 |= JO2_NORESTORE; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5221 opt->jo_term_norestore = tv_get_number(item); |
13435
fa198b71bab2
patch 8.0.1592: terminal windows in a session are not properly restored
Christian Brabandt <cb@256bit.org>
parents:
13284
diff
changeset
|
5222 } |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5223 else if (STRCMP(hi->hi_key, "term_kill") == 0) |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5224 { |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5225 if (!(supported2 & JO2_TERM_KILL)) |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5226 break; |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5227 opt->jo_set2 |= JO2_TERM_KILL; |
19245
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5228 opt->jo_term_kill = tv_get_string_buf_chk(item, |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5229 opt->jo_term_kill_buf); |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5230 if (opt->jo_term_kill == NULL) |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5231 { |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5232 semsg(_(e_invargval), "term_kill"); |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5233 return FAIL; |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5234 } |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5235 } |
15746
c017195b121b
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty
Bram Moolenaar <Bram@vim.org>
parents:
15725
diff
changeset
|
5236 else if (STRCMP(hi->hi_key, "tty_type") == 0) |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5237 { |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5238 char_u *p; |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5239 |
15746
c017195b121b
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty
Bram Moolenaar <Bram@vim.org>
parents:
15725
diff
changeset
|
5240 if (!(supported2 & JO2_TTY_TYPE)) |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5241 break; |
15746
c017195b121b
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty
Bram Moolenaar <Bram@vim.org>
parents:
15725
diff
changeset
|
5242 opt->jo_set2 |= JO2_TTY_TYPE; |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5243 p = tv_get_string_chk(item); |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5244 if (p == NULL) |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5245 { |
15746
c017195b121b
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty
Bram Moolenaar <Bram@vim.org>
parents:
15725
diff
changeset
|
5246 semsg(_(e_invargval), "tty_type"); |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5247 return FAIL; |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5248 } |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5249 // Allow empty string, "winpty", "conpty". |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5250 if (!(*p == NUL || STRCMP(p, "winpty") == 0 |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5251 || STRCMP(p, "conpty") == 0)) |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5252 { |
15746
c017195b121b
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty
Bram Moolenaar <Bram@vim.org>
parents:
15725
diff
changeset
|
5253 semsg(_(e_invargval), "tty_type"); |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5254 return FAIL; |
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5255 } |
15746
c017195b121b
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty
Bram Moolenaar <Bram@vim.org>
parents:
15725
diff
changeset
|
5256 opt->jo_tty_type = p[0]; |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5257 } |
13626
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5258 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5259 else if (STRCMP(hi->hi_key, "ansi_colors") == 0) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5260 { |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5261 int n = 0; |
13626
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5262 listitem_T *li; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5263 long_u rgb[16]; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5264 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5265 if (!(supported2 & JO2_ANSI_COLORS)) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5266 break; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5267 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5268 if (item == NULL || item->v_type != VAR_LIST |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5269 || item->vval.v_list == NULL) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5270 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5271 semsg(_(e_invargval), "ansi_colors"); |
13626
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5272 return FAIL; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5273 } |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5274 |
19201
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
5275 range_list_materialize(item->vval.v_list); |
13626
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5276 li = item->vval.v_list->lv_first; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5277 for (; li != NULL && n < 16; li = li->li_next, n++) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5278 { |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5279 char_u *color_name; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5280 guicolor_T guicolor; |
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5281 |
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5282 color_name = tv_get_string_chk(&li->li_tv); |
13626
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5283 if (color_name == NULL) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5284 return FAIL; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5285 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5286 guicolor = GUI_GET_COLOR(color_name); |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5287 if (guicolor == INVALCOLOR) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5288 return FAIL; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5289 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5290 rgb[n] = GUI_MCH_GET_RGB(guicolor); |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5291 } |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5292 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5293 if (n != 16 || li != NULL) |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5294 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5295 semsg(_(e_invargval), "ansi_colors"); |
13626
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5296 return FAIL; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5297 } |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5298 |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5299 opt->jo_set2 |= JO2_ANSI_COLORS; |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5300 memcpy(opt->jo_ansi_colors, rgb, sizeof(rgb)); |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5301 } |
ab89131d30e0
patch 8.0.1685: can't set ANSI colors of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13618
diff
changeset
|
5302 # endif |
19797
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5303 else if (STRCMP(hi->hi_key, "term_highlight") == 0) |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5304 { |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5305 char_u *p; |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5306 |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5307 if (!(supported2 & JO2_TERM_HIGHLIGHT)) |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5308 break; |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5309 opt->jo_set2 |= JO2_TERM_HIGHLIGHT; |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5310 p = tv_get_string_buf_chk(item, opt->jo_term_highlight_buf); |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5311 if (p == NULL || *p == NUL) |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5312 { |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5313 semsg(_(e_invargval), "term_highlight"); |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5314 return FAIL; |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5315 } |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5316 opt->jo_term_highlight = p; |
d73d982499ae
patch 8.2.0455: cannot set the highlight group for a specific terminal
Bram Moolenaar <Bram@vim.org>
parents:
19791
diff
changeset
|
5317 } |
18170
4ac8161e92e0
patch 8.1.2080: the terminal API is limited and can't be disabled
Bram Moolenaar <Bram@vim.org>
parents:
18160
diff
changeset
|
5318 else if (STRCMP(hi->hi_key, "term_api") == 0) |
4ac8161e92e0
patch 8.1.2080: the terminal API is limited and can't be disabled
Bram Moolenaar <Bram@vim.org>
parents:
18160
diff
changeset
|
5319 { |
4ac8161e92e0
patch 8.1.2080: the terminal API is limited and can't be disabled
Bram Moolenaar <Bram@vim.org>
parents:
18160
diff
changeset
|
5320 if (!(supported2 & JO2_TERM_API)) |
4ac8161e92e0
patch 8.1.2080: the terminal API is limited and can't be disabled
Bram Moolenaar <Bram@vim.org>
parents:
18160
diff
changeset
|
5321 break; |
4ac8161e92e0
patch 8.1.2080: the terminal API is limited and can't be disabled
Bram Moolenaar <Bram@vim.org>
parents:
18160
diff
changeset
|
5322 opt->jo_set2 |= JO2_TERM_API; |
4ac8161e92e0
patch 8.1.2080: the terminal API is limited and can't be disabled
Bram Moolenaar <Bram@vim.org>
parents:
18160
diff
changeset
|
5323 opt->jo_term_api = tv_get_string_buf_chk(item, |
19245
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5324 opt->jo_term_api_buf); |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5325 if (opt->jo_term_api == NULL) |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5326 { |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5327 semsg(_(e_invargval), "term_api"); |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5328 return FAIL; |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5329 } |
18170
4ac8161e92e0
patch 8.1.2080: the terminal API is limited and can't be disabled
Bram Moolenaar <Bram@vim.org>
parents:
18160
diff
changeset
|
5330 } |
11969
5dc3730de58d
patch 8.0.0865: cannot build with channel but without terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11967
diff
changeset
|
5331 #endif |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
5332 else if (STRCMP(hi->hi_key, "env") == 0) |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
5333 { |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5334 if (!(supported2 & JO2_ENV)) |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
5335 break; |
13598
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13569
diff
changeset
|
5336 if (item->v_type != VAR_DICT) |
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13569
diff
changeset
|
5337 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5338 semsg(_(e_invargval), "env"); |
13598
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13569
diff
changeset
|
5339 return FAIL; |
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13569
diff
changeset
|
5340 } |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5341 opt->jo_set2 |= JO2_ENV; |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
5342 opt->jo_env = item->vval.v_dict; |
13598
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13569
diff
changeset
|
5343 if (opt->jo_env != NULL) |
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13569
diff
changeset
|
5344 ++opt->jo_env->dv_refcount; |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
5345 } |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
5346 else if (STRCMP(hi->hi_key, "cwd") == 0) |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
5347 { |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
5348 if (!(supported2 & JO2_CWD)) |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
5349 break; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5350 opt->jo_cwd = tv_get_string_buf_chk(item, opt->jo_cwd_buf); |
14948
cb07193c6257
patch 8.1.0485: term_start() does not check if directory is accessible
Bram Moolenaar <Bram@vim.org>
parents:
14730
diff
changeset
|
5351 if (opt->jo_cwd == NULL || !mch_isdir(opt->jo_cwd) |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
5352 #ifndef MSWIN // Win32 directories don't have the concept of "executable" |
14950
6783403ff35e
patch 8.1.0486: can't build in MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
14948
diff
changeset
|
5353 || mch_access((char *)opt->jo_cwd, X_OK) != 0 |
6783403ff35e
patch 8.1.0486: can't build in MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
14948
diff
changeset
|
5354 #endif |
6783403ff35e
patch 8.1.0486: can't build in MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
14948
diff
changeset
|
5355 ) |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
5356 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5357 semsg(_(e_invargval), "cwd"); |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
5358 return FAIL; |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
5359 } |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5360 opt->jo_set2 |= JO2_CWD; |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
12037
diff
changeset
|
5361 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5362 else if (STRCMP(hi->hi_key, "waittime") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5363 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5364 if (!(supported & JO_WAITTIME)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5365 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5366 opt->jo_set |= JO_WAITTIME; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5367 opt->jo_waittime = tv_get_number(item); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5368 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5369 else if (STRCMP(hi->hi_key, "timeout") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5370 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5371 if (!(supported & JO_TIMEOUT)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5372 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5373 opt->jo_set |= JO_TIMEOUT; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5374 opt->jo_timeout = tv_get_number(item); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5375 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
5376 else if (STRCMP(hi->hi_key, "out_timeout") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5377 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5378 if (!(supported & JO_OUT_TIMEOUT)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5379 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5380 opt->jo_set |= JO_OUT_TIMEOUT; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5381 opt->jo_out_timeout = tv_get_number(item); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5382 } |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8538
diff
changeset
|
5383 else if (STRCMP(hi->hi_key, "err_timeout") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5384 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5385 if (!(supported & JO_ERR_TIMEOUT)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5386 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5387 opt->jo_set |= JO_ERR_TIMEOUT; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5388 opt->jo_err_timeout = tv_get_number(item); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5389 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5390 else if (STRCMP(hi->hi_key, "part") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5391 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5392 if (!(supported & JO_PART)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5393 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5394 opt->jo_set |= JO_PART; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5395 val = tv_get_string(item); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5396 if (STRCMP(val, "err") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5397 opt->jo_part = PART_ERR; |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
5398 else if (STRCMP(val, "out") == 0) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
5399 opt->jo_part = PART_OUT; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5400 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5401 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5402 semsg(_(e_invargNval), "part", val); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5403 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5404 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5405 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5406 else if (STRCMP(hi->hi_key, "id") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5407 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5408 if (!(supported & JO_ID)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5409 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5410 opt->jo_set |= JO_ID; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5411 opt->jo_id = tv_get_number(item); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5412 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5413 else if (STRCMP(hi->hi_key, "stoponexit") == 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5414 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5415 if (!(supported & JO_STOPONEXIT)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5416 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5417 opt->jo_set |= JO_STOPONEXIT; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5418 opt->jo_stoponexit = tv_get_string_buf_chk(item, |
19245
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5419 opt->jo_stoponexit_buf); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5420 if (opt->jo_stoponexit == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5421 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5422 semsg(_(e_invargval), "stoponexit"); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5423 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5424 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5425 } |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
5426 else if (STRCMP(hi->hi_key, "block_write") == 0) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
5427 { |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
5428 if (!(supported & JO_BLOCK_WRITE)) |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
5429 break; |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
5430 opt->jo_set |= JO_BLOCK_WRITE; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5431 opt->jo_block_write = tv_get_number(item); |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8759
diff
changeset
|
5432 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5433 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5434 break; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5435 --todo; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5436 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5437 if (todo > 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5438 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
5439 semsg(_(e_invarg2), hi->hi_key); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5440 return FAIL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5441 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5442 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5443 return OK; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5444 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5445 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5446 static job_T *first_job = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5447 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5448 static void |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5449 job_free_contents(job_T *job) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5450 { |
13740
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5451 int i; |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5452 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5453 ch_log(job->jv_channel, "Freeing job"); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5454 if (job->jv_channel != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5455 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5456 // The link from the channel to the job doesn't count as a reference, |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5457 // thus don't decrement the refcount of the job. The reference from |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5458 // the job to the channel does count the reference, decrement it and |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5459 // NULL the reference. We don't set ch_job_killed, unreferencing the |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5460 // job doesn't mean it stops running. |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5461 job->jv_channel->ch_job = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5462 channel_unref(job->jv_channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5463 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5464 mch_clear_job(job); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5465 |
12389
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
5466 vim_free(job->jv_tty_in); |
d0cf7f71b95b
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
5467 vim_free(job->jv_tty_out); |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5468 vim_free(job->jv_stoponexit); |
15711
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15675
diff
changeset
|
5469 #ifdef UNIX |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15675
diff
changeset
|
5470 vim_free(job->jv_termsig); |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15675
diff
changeset
|
5471 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
5472 #ifdef MSWIN |
15746
c017195b121b
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty
Bram Moolenaar <Bram@vim.org>
parents:
15725
diff
changeset
|
5473 vim_free(job->jv_tty_type); |
c017195b121b
patch 8.1.0880: MS-Windows: inconsistent selection of winpty/conpty
Bram Moolenaar <Bram@vim.org>
parents:
15725
diff
changeset
|
5474 #endif |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5475 free_callback(&job->jv_exit_cb); |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5476 if (job->jv_argv != NULL) |
13740
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5477 { |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5478 for (i = 0; job->jv_argv[i] != NULL; i++) |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5479 vim_free(job->jv_argv[i]); |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5480 vim_free(job->jv_argv); |
13740
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
5481 } |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5482 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5483 |
15675
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5484 /* |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5485 * Remove "job" from the list of jobs. |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5486 */ |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5487 static void |
15675
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5488 job_unlink(job_T *job) |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5489 { |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5490 if (job->jv_next != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5491 job->jv_next->jv_prev = job->jv_prev; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5492 if (job->jv_prev == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5493 first_job = job->jv_next; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5494 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5495 job->jv_prev->jv_next = job->jv_next; |
15675
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5496 } |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5497 |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5498 static void |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5499 job_free_job(job_T *job) |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5500 { |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5501 job_unlink(job); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5502 vim_free(job); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5503 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5504 |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5505 static void |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5506 job_free(job_T *job) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5507 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5508 if (!in_free_unref_items) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5509 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5510 job_free_contents(job); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5511 job_free_job(job); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5512 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5513 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5514 |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17606
diff
changeset
|
5515 static job_T *jobs_to_free = NULL; |
15675
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5516 |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5517 /* |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5518 * Put "job" in a list to be freed later, when it's no longer referenced. |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5519 */ |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5520 static void |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5521 job_free_later(job_T *job) |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5522 { |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5523 job_unlink(job); |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5524 job->jv_next = jobs_to_free; |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5525 jobs_to_free = job; |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5526 } |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5527 |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5528 static void |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5529 free_jobs_to_free_later(void) |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5530 { |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5531 job_T *job; |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5532 |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5533 while (jobs_to_free != NULL) |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5534 { |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5535 job = jobs_to_free; |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5536 jobs_to_free = job->jv_next; |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5537 job_free_contents(job); |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5538 vim_free(job); |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5539 } |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5540 } |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5541 |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5542 #if defined(EXITFREE) || defined(PROTO) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5543 void |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5544 job_free_all(void) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5545 { |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5546 while (first_job != NULL) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5547 job_free(first_job); |
15675
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5548 free_jobs_to_free_later(); |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5549 |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5550 # ifdef FEAT_TERMINAL |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5551 free_unused_terminals(); |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5552 # endif |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5553 } |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5554 #endif |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5555 |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5556 /* |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5557 * Return TRUE if we need to check if the process of "job" has ended. |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5558 */ |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5559 static int |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5560 job_need_end_check(job_T *job) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5561 { |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5562 return job->jv_status == JOB_STARTED |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5563 && (job->jv_stoponexit != NULL || job->jv_exit_cb.cb_name != NULL); |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5564 } |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5565 |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5566 /* |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5567 * Return TRUE if the channel of "job" is still useful. |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5568 */ |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5569 static int |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5570 job_channel_still_useful(job_T *job) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5571 { |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5572 return job->jv_channel != NULL && channel_still_useful(job->jv_channel); |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5573 } |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5574 |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5575 /* |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5576 * Return TRUE if the channel of "job" is closeable. |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5577 */ |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5578 static int |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5579 job_channel_can_close(job_T *job) |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5580 { |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5581 return job->jv_channel != NULL && channel_can_close(job->jv_channel); |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5582 } |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5583 |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5584 /* |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5585 * Return TRUE if the job should not be freed yet. Do not free the job when |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5586 * it has not ended yet and there is a "stoponexit" flag, an exit callback |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5587 * or when the associated channel will do something with the job output. |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5588 */ |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5589 static int |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5590 job_still_useful(job_T *job) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5591 { |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5592 return job_need_end_check(job) || job_channel_still_useful(job); |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5593 } |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5594 |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
5595 #if defined(GUI_MAY_FORK) || defined(GUI_MAY_SPAWN) || defined(PROTO) |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5596 /* |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5597 * Return TRUE when there is any running job that we care about. |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5598 */ |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5599 int |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5600 job_any_running() |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5601 { |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5602 job_T *job; |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5603 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
5604 FOR_ALL_JOBS(job) |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5605 if (job_still_useful(job)) |
13915
8314bb913e14
patch 8.0.1828: get no clue why :gui does not fork
Christian Brabandt <cb@256bit.org>
parents:
13913
diff
changeset
|
5606 { |
8314bb913e14
patch 8.0.1828: get no clue why :gui does not fork
Christian Brabandt <cb@256bit.org>
parents:
13913
diff
changeset
|
5607 ch_log(NULL, "GUI not forking because a job is running"); |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5608 return TRUE; |
13915
8314bb913e14
patch 8.0.1828: get no clue why :gui does not fork
Christian Brabandt <cb@256bit.org>
parents:
13913
diff
changeset
|
5609 } |
13847
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5610 return FALSE; |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5611 } |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5612 #endif |
fa0dcdaec6a3
patch 8.0.1795: lose contact with jobs when :gui forks
Christian Brabandt <cb@256bit.org>
parents:
13806
diff
changeset
|
5613 |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5614 #if !defined(USE_ARGV) || defined(PROTO) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5615 /* |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5616 * Escape one argument for an external command. |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5617 * Returns the escaped string in allocated memory. NULL when out of memory. |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5618 */ |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5619 static char_u * |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5620 win32_escape_arg(char_u *arg) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5621 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5622 int slen, dlen; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5623 int escaping = 0; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5624 int i; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5625 char_u *s, *d; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5626 char_u *escaped_arg; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5627 int has_spaces = FALSE; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5628 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5629 // First count the number of extra bytes required. |
12246
337690672bda
patch 8.0.1003: 64 bit compiler warning
Christian Brabandt <cb@256bit.org>
parents:
12244
diff
changeset
|
5630 slen = (int)STRLEN(arg); |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5631 dlen = slen; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5632 for (s = arg; *s != NUL; MB_PTR_ADV(s)) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5633 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5634 if (*s == '"' || *s == '\\') |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5635 ++dlen; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5636 if (*s == ' ' || *s == '\t') |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5637 has_spaces = TRUE; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5638 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5639 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5640 if (has_spaces) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5641 dlen += 2; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5642 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5643 if (dlen == slen) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5644 return vim_strsave(arg); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5645 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5646 // Allocate memory for the result and fill it. |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5647 escaped_arg = alloc(dlen + 1); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5648 if (escaped_arg == NULL) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5649 return NULL; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5650 memset(escaped_arg, 0, dlen+1); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5651 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5652 d = escaped_arg; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5653 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5654 if (has_spaces) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5655 *d++ = '"'; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5656 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5657 for (s = arg; *s != NUL;) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5658 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5659 switch (*s) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5660 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5661 case '"': |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5662 for (i = 0; i < escaping; i++) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5663 *d++ = '\\'; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5664 escaping = 0; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5665 *d++ = '\\'; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5666 *d++ = *s++; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5667 break; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5668 case '\\': |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5669 escaping++; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5670 *d++ = *s++; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5671 break; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5672 default: |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5673 escaping = 0; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5674 MB_COPY_CHAR(s, d); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5675 break; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5676 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5677 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5678 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5679 // add terminating quote and finish with a NUL |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5680 if (has_spaces) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5681 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5682 for (i = 0; i < escaping; i++) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5683 *d++ = '\\'; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5684 *d++ = '"'; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5685 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5686 *d = NUL; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5687 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5688 return escaped_arg; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5689 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5690 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5691 /* |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5692 * Build a command line from a list, taking care of escaping. |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5693 * The result is put in gap->ga_data. |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5694 * Returns FAIL when out of memory. |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5695 */ |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5696 int |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5697 win32_build_cmd(list_T *l, garray_T *gap) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5698 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5699 listitem_T *li; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5700 char_u *s; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5701 |
19201
e7b4fff348dd
patch 8.2.0159: non-materialized range() list causes problems
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
5702 range_list_materialize(l); |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
5703 FOR_ALL_LIST_ITEMS(l, li) |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5704 { |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
5705 s = tv_get_string_chk(&li->li_tv); |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5706 if (s == NULL) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5707 return FAIL; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5708 s = win32_escape_arg(s); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5709 if (s == NULL) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5710 return FAIL; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5711 ga_concat(gap, s); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5712 vim_free(s); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5713 if (li->li_next != NULL) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5714 ga_append(gap, ' '); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5715 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5716 return OK; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5717 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5718 #endif |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
5719 |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5720 /* |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5721 * NOTE: Must call job_cleanup() only once right after the status of "job" |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5722 * changed to JOB_ENDED (i.e. after job_status() returned "dead" first or |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5723 * mch_detect_ended_job() returned non-NULL). |
15675
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5724 * If the job is no longer used it will be removed from the list of jobs, and |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5725 * deleted a bit later. |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5726 */ |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
5727 void |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5728 job_cleanup(job_T *job) |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5729 { |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5730 if (job->jv_status != JOB_ENDED) |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5731 return; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5732 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5733 // Ready to cleanup the job. |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5734 job->jv_status = JOB_FINISHED; |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5735 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5736 // When only channel-in is kept open, close explicitly. |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5737 if (job->jv_channel != NULL) |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5738 ch_close_part(job->jv_channel, PART_IN); |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5739 |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5740 if (job->jv_exit_cb.cb_name != NULL) |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5741 { |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5742 typval_T argv[3]; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5743 typval_T rettv; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5744 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5745 // Invoke the exit callback. Make sure the refcount is > 0. |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5746 ch_log(job->jv_channel, "Invoking exit callback %s", |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5747 job->jv_exit_cb.cb_name); |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5748 ++job->jv_refcount; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5749 argv[0].v_type = VAR_JOB; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5750 argv[0].vval.v_job = job; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5751 argv[1].v_type = VAR_NUMBER; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5752 argv[1].vval.v_number = job->jv_exitval; |
17606
ff097edaae89
patch 8.1.1800: function call functions have too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
5753 call_callback(&job->jv_exit_cb, -1, &rettv, 2, argv); |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5754 clear_tv(&rettv); |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5755 --job->jv_refcount; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5756 channel_need_redraw = TRUE; |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5757 } |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5758 |
15908
379247470597
patch 8.1.0960: when using ConPTY garbage collection has undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5759 if (job->jv_channel != NULL && job->jv_channel->ch_anonymous_pipe) |
379247470597
patch 8.1.0960: when using ConPTY garbage collection has undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
5760 job->jv_channel->ch_killing = TRUE; |
15725
a3e2e7948ee4
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
5761 |
15675
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5762 // Do not free the job in case the close callback of the associated channel |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5763 // isn't invoked yet and may get information by job_info(). |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5764 if (job->jv_refcount == 0 && !job_channel_still_useful(job)) |
15675
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5765 // The job was already unreferenced and the associated channel was |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5766 // detached, now that it ended it can be freed. However, a caller might |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5767 // still use it, thus free it a bit later. |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5768 job_free_later(job); |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5769 } |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5770 |
9058
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5771 /* |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5772 * Mark references in jobs that are still useful. |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5773 */ |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5774 int |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5775 set_ref_in_job(int copyID) |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5776 { |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5777 int abort = FALSE; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5778 job_T *job; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5779 typval_T tv; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5780 |
17151
ebe9aab81898
patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents:
17024
diff
changeset
|
5781 for (job = first_job; !abort && job != NULL; job = job->jv_next) |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5782 if (job_still_useful(job)) |
9058
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5783 { |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5784 tv.v_type = VAR_JOB; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5785 tv.vval.v_job = job; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5786 abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5787 } |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5788 return abort; |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5789 } |
87c2e43a4a12
commit https://github.com/vim/vim/commit/b8d4905592fc26fcd09180d7d6bfefd899f2f6c6
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
5790 |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5791 /* |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5792 * Dereference "job". Note that after this "job" may have been freed. |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5793 */ |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5794 void |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5795 job_unref(job_T *job) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5796 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5797 if (job != NULL && --job->jv_refcount <= 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5798 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5799 // Do not free the job if there is a channel where the close callback |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5800 // may get the job info. |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5801 if (!job_channel_still_useful(job)) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5802 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5803 // Do not free the job when it has not ended yet and there is a |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5804 // "stoponexit" flag or an exit callback. |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5805 if (!job_need_end_check(job)) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5806 { |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5807 job_free(job); |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5808 } |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5809 else if (job->jv_channel != NULL) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5810 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5811 // Do remove the link to the channel, otherwise it hangs |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5812 // around until Vim exits. See job_free() for refcount. |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5813 ch_log(job->jv_channel, "detaching channel from job"); |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5814 job->jv_channel->ch_job = NULL; |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5815 channel_unref(job->jv_channel); |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5816 job->jv_channel = NULL; |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5817 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5818 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5819 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5820 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5821 |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5822 int |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5823 free_unused_jobs_contents(int copyID, int mask) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5824 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5825 int did_free = FALSE; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5826 job_T *job; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5827 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
5828 FOR_ALL_JOBS(job) |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
5829 if ((job->jv_copyID & mask) != (copyID & mask) |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5830 && !job_still_useful(job)) |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5831 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5832 // Free the channel and ordinary items it contains, but don't |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5833 // recurse into Lists, Dictionaries etc. |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5834 job_free_contents(job); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5835 did_free = TRUE; |
9079
2cd83c854073
commit https://github.com/vim/vim/commit/36e0f7da9bc4a6ee8a7b17df503542a339e034c8
Christian Brabandt <cb@256bit.org>
parents:
9064
diff
changeset
|
5836 } |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5837 return did_free; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5838 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5839 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5840 void |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5841 free_unused_jobs(int copyID, int mask) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5842 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5843 job_T *job; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5844 job_T *job_next; |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5845 |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5846 for (job = first_job; job != NULL; job = job_next) |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5847 { |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5848 job_next = job->jv_next; |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
5849 if ((job->jv_copyID & mask) != (copyID & mask) |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5850 && !job_still_useful(job)) |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5851 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5852 // Free the job struct itself. |
8863
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5853 job_free_job(job); |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5854 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5855 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5856 } |
e1b84109506a
commit https://github.com/vim/vim/commit/107e1eef1df3b786ad3ad49fbdb9e058649303b5
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
5857 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5858 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5859 * Allocate a job. Sets the refcount to one and sets options default. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5860 */ |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
5861 job_T * |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5862 job_alloc(void) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5863 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5864 job_T *job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5865 |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
5866 job = ALLOC_CLEAR_ONE(job_T); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5867 if (job != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5868 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5869 job->jv_refcount = 1; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5870 job->jv_stoponexit = vim_strsave((char_u *)"term"); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5871 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5872 if (first_job != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5873 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5874 first_job->jv_prev = job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5875 job->jv_next = first_job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5876 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5877 first_job = job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5878 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5879 return job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5880 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5881 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5882 void |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5883 job_set_options(job_T *job, jobopt_T *opt) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5884 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5885 if (opt->jo_set & JO_STOPONEXIT) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5886 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5887 vim_free(job->jv_stoponexit); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5888 if (opt->jo_stoponexit == NULL || *opt->jo_stoponexit == NUL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5889 job->jv_stoponexit = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5890 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5891 job->jv_stoponexit = vim_strsave(opt->jo_stoponexit); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5892 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5893 if (opt->jo_set & JO_EXIT_CB) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5894 { |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5895 free_callback(&job->jv_exit_cb); |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5896 if (opt->jo_exit_cb.cb_name == NULL || *opt->jo_exit_cb.cb_name == NUL) |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
5897 { |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5898 job->jv_exit_cb.cb_name = NULL; |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5899 job->jv_exit_cb.cb_partial = NULL; |
8538
c337c813c64d
commit https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
Christian Brabandt <cb@256bit.org>
parents:
8508
diff
changeset
|
5900 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5901 else |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5902 copy_callback(&job->jv_exit_cb, &opt->jo_exit_cb); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5903 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5904 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5905 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5906 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5907 * Called when Vim is exiting: kill all jobs that have the "stoponexit" flag. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5908 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5909 void |
9282
9f97a6290c63
commit https://github.com/vim/vim/commit/cf089463492fab53b2a5d81517829d22f882f82e
Christian Brabandt <cb@256bit.org>
parents:
9246
diff
changeset
|
5910 job_stop_on_exit(void) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5911 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5912 job_T *job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5913 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
5914 FOR_ALL_JOBS(job) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5915 if (job->jv_status == JOB_STARTED && job->jv_stoponexit != NULL) |
12037
85f0f557661e
patch 8.0.0899: function name mch_stop_job() is confusing
Christian Brabandt <cb@256bit.org>
parents:
12033
diff
changeset
|
5916 mch_signal_job(job, job->jv_stoponexit); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5917 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5918 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5919 /* |
10309
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10279
diff
changeset
|
5920 * Return TRUE when there is any job that has an exit callback and might exit, |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10279
diff
changeset
|
5921 * which means job_check_ended() should be called more often. |
9189
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5922 */ |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5923 int |
9282
9f97a6290c63
commit https://github.com/vim/vim/commit/cf089463492fab53b2a5d81517829d22f882f82e
Christian Brabandt <cb@256bit.org>
parents:
9246
diff
changeset
|
5924 has_pending_job(void) |
9189
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5925 { |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5926 job_T *job; |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5927 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
5928 FOR_ALL_JOBS(job) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5929 // Only should check if the channel has been closed, if the channel is |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
5930 // open the job won't exit. |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5931 if ((job->jv_status == JOB_STARTED && !job_channel_still_useful(job)) |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5932 || (job->jv_status == JOB_FINISHED |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13750
diff
changeset
|
5933 && job_channel_can_close(job))) |
9189
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5934 return TRUE; |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5935 return FALSE; |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5936 } |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5937 |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5938 #define MAX_CHECK_ENDED 8 |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5939 |
9189
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5940 /* |
9079
2cd83c854073
commit https://github.com/vim/vim/commit/36e0f7da9bc4a6ee8a7b17df503542a339e034c8
Christian Brabandt <cb@256bit.org>
parents:
9064
diff
changeset
|
5941 * Called once in a while: check if any jobs that seem useful have ended. |
15160
ec67c6b8ef12
patch 8.1.0590: when a job ends the closed channels are not handled
Bram Moolenaar <Bram@vim.org>
parents:
14950
diff
changeset
|
5942 * Returns TRUE if a job did end. |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5943 */ |
15160
ec67c6b8ef12
patch 8.1.0590: when a job ends the closed channels are not handled
Bram Moolenaar <Bram@vim.org>
parents:
14950
diff
changeset
|
5944 int |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5945 job_check_ended(void) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5946 { |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5947 int i; |
15160
ec67c6b8ef12
patch 8.1.0590: when a job ends the closed channels are not handled
Bram Moolenaar <Bram@vim.org>
parents:
14950
diff
changeset
|
5948 int did_end = FALSE; |
ec67c6b8ef12
patch 8.1.0590: when a job ends the closed channels are not handled
Bram Moolenaar <Bram@vim.org>
parents:
14950
diff
changeset
|
5949 |
ec67c6b8ef12
patch 8.1.0590: when a job ends the closed channels are not handled
Bram Moolenaar <Bram@vim.org>
parents:
14950
diff
changeset
|
5950 // be quick if there are no jobs to check |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5951 if (first_job == NULL) |
15160
ec67c6b8ef12
patch 8.1.0590: when a job ends the closed channels are not handled
Bram Moolenaar <Bram@vim.org>
parents:
14950
diff
changeset
|
5952 return did_end; |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
5953 |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5954 for (i = 0; i < MAX_CHECK_ENDED; ++i) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5955 { |
15160
ec67c6b8ef12
patch 8.1.0590: when a job ends the closed channels are not handled
Bram Moolenaar <Bram@vim.org>
parents:
14950
diff
changeset
|
5956 // NOTE: mch_detect_ended_job() must only return a job of which the |
ec67c6b8ef12
patch 8.1.0590: when a job ends the closed channels are not handled
Bram Moolenaar <Bram@vim.org>
parents:
14950
diff
changeset
|
5957 // status was just set to JOB_ENDED. |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5958 job_T *job = mch_detect_ended_job(first_job); |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5959 |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5960 if (job == NULL) |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5961 break; |
15160
ec67c6b8ef12
patch 8.1.0590: when a job ends the closed channels are not handled
Bram Moolenaar <Bram@vim.org>
parents:
14950
diff
changeset
|
5962 did_end = TRUE; |
15675
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5963 job_cleanup(job); // may add "job" to jobs_to_free |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5964 } |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
5965 |
15675
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5966 // Actually free jobs that were cleaned up. |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5967 free_jobs_to_free_later(); |
01890a3caefd
patch 8.1.0845: having job_status() free the job causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15661
diff
changeset
|
5968 |
9189
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5969 if (channel_need_redraw) |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5970 { |
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5971 channel_need_redraw = FALSE; |
12244
d0b039e2ed56
patch 8.0.1002: unnecessarily updating screen after timer callback
Christian Brabandt <cb@256bit.org>
parents:
12240
diff
changeset
|
5972 redraw_after_callback(TRUE); |
9189
4b55d8e162d4
commit https://github.com/vim/vim/commit/cf7c11a9479ba7ce775b86c7a846fae48321d260
Christian Brabandt <cb@256bit.org>
parents:
9151
diff
changeset
|
5973 } |
15160
ec67c6b8ef12
patch 8.1.0590: when a job ends the closed channels are not handled
Bram Moolenaar <Bram@vim.org>
parents:
14950
diff
changeset
|
5974 return did_end; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5975 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5976 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5977 /* |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5978 * Create a job and return it. Implements job_start(). |
13470
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
5979 * "argv_arg" is only for Unix. |
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
5980 * When "argv_arg" is NULL then "argvars" is used. |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5981 * The returned job has a refcount of one. |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
5982 * Returns NULL when out of memory. |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5983 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5984 job_T * |
14065
e271ca6f32f9
patch 8.1.0050: $VIM_TERMINAL is also set when not in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
5985 job_start( |
e271ca6f32f9
patch 8.1.0050: $VIM_TERMINAL is also set when not in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
5986 typval_T *argvars, |
18139
59bc3cd42cf5
patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents:
18104
diff
changeset
|
5987 char **argv_arg UNUSED, |
14065
e271ca6f32f9
patch 8.1.0050: $VIM_TERMINAL is also set when not in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
14019
diff
changeset
|
5988 jobopt_T *opt_arg, |
19245
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
5989 job_T **term_job) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5990 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5991 job_T *job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5992 char_u *cmd = NULL; |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5993 char **argv = NULL; |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
5994 int argc = 0; |
19157
f2c8bc90f3c8
patch 8.2.0138: memory leak when starting a job fails
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
5995 int i; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5996 #if defined(UNIX) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5997 # define USE_ARGV |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5998 #else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5999 garray_T ga; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6000 #endif |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6001 jobopt_T opt; |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
6002 ch_part_T part; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6003 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6004 job = job_alloc(); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6005 if (job == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6006 return NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6007 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6008 job->jv_status = JOB_FAILED; |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
6009 #ifndef USE_ARGV |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
6010 ga_init2(&ga, (int)sizeof(char*), 20); |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
6011 #endif |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6012 |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
6013 if (opt_arg != NULL) |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
6014 opt = *opt_arg; |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
6015 else |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
6016 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6017 // Default mode is NL. |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
6018 clear_job_options(&opt); |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
6019 opt.jo_mode = MODE_NL; |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
6020 if (get_job_options(&argvars[1], &opt, |
12058
e78fde22faec
patch 8.0.0909: channel test fails
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
6021 JO_MODE_ALL + JO_CB_ALL + JO_TIMEOUT_ALL + JO_STOPONEXIT |
e78fde22faec
patch 8.0.0909: channel test fails
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
6022 + JO_EXIT_CB + JO_OUT_IO + JO_BLOCK_WRITE, |
e78fde22faec
patch 8.0.0909: channel test fails
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
6023 JO2_ENV + JO2_CWD) == FAIL) |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
6024 goto theend; |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
6025 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6026 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6027 // Check that when io is "file" that there is a file name. |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10253
diff
changeset
|
6028 for (part = PART_OUT; part < PART_COUNT; ++part) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6029 if ((opt.jo_set & (JO_OUT_IO << (part - PART_OUT))) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6030 && opt.jo_io[part] == JIO_FILE |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6031 && (!(opt.jo_set & (JO_OUT_NAME << (part - PART_OUT))) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6032 || *opt.jo_io_name[part] == NUL)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6033 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
6034 emsg(_("E920: _io file requires _name to be set")); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
6035 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6036 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6037 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6038 if ((opt.jo_set & JO_IN_IO) && opt.jo_io[PART_IN] == JIO_BUFFER) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6039 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6040 buf_T *buf = NULL; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6041 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6042 // check that we can find the buffer before starting the job |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6043 if (opt.jo_set & JO_IN_BUF) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6044 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6045 buf = buflist_findnr(opt.jo_io_buf[PART_IN]); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6046 if (buf == NULL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
6047 semsg(_(e_nobufnr), (long)opt.jo_io_buf[PART_IN]); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6048 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6049 else if (!(opt.jo_set & JO_IN_NAME)) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6050 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
6051 emsg(_("E915: in_io buffer requires in_buf or in_name to be set")); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6052 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6053 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6054 buf = buflist_find_by_name(opt.jo_io_name[PART_IN], FALSE); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6055 if (buf == NULL) |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
6056 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6057 if (buf->b_ml.ml_mfp == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6058 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6059 char_u numbuf[NUMBUFLEN]; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6060 char_u *s; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6061 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6062 if (opt.jo_set & JO_IN_BUF) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6063 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6064 sprintf((char *)numbuf, "%d", opt.jo_io_buf[PART_IN]); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6065 s = numbuf; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6066 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6067 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6068 s = opt.jo_io_name[PART_IN]; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
6069 semsg(_("E918: buffer must be loaded: %s"), s); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
6070 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6071 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6072 job->jv_in_buf = buf; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6073 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6074 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6075 job_set_options(job, &opt); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6076 |
13470
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
6077 #ifdef USE_ARGV |
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
6078 if (argv_arg != NULL) |
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
6079 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6080 // Make a copy of argv_arg for job->jv_argv. |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
6081 for (i = 0; argv_arg[i] != NULL; i++) |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
6082 argc++; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
6083 argv = ALLOC_MULT(char *, argc + 1); |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
6084 if (argv == NULL) |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
6085 goto theend; |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
6086 for (i = 0; i < argc; i++) |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
6087 argv[i] = (char *)vim_strsave((char_u *)argv_arg[i]); |
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
6088 argv[argc] = NULL; |
13470
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
6089 } |
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
6090 else |
6faef782f50b
patch 8.0.1609: shell commands in the GUI use a dumb terminal
Christian Brabandt <cb@256bit.org>
parents:
13438
diff
changeset
|
6091 #endif |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6092 if (argvars[0].v_type == VAR_STRING) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6093 { |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6094 // Command is a string. |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6095 cmd = argvars[0].vval.v_string; |
18943
d90138662f49
patch 8.2.0032: MS-Windows: test for blank job fails
Bram Moolenaar <Bram@vim.org>
parents:
18941
diff
changeset
|
6096 if (cmd == NULL || *skipwhite(cmd) == NUL) |
8753
df91c8263f04
commit https://github.com/vim/vim/commit/8038568722a0aad72d001edf4972c29abab57f8f
Christian Brabandt <cb@256bit.org>
parents:
8746
diff
changeset
|
6097 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
6098 emsg(_(e_invarg)); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
6099 goto theend; |
8753
df91c8263f04
commit https://github.com/vim/vim/commit/8038568722a0aad72d001edf4972c29abab57f8f
Christian Brabandt <cb@256bit.org>
parents:
8746
diff
changeset
|
6100 } |
13750
3ab6198c1f9a
patch 8.0.1747: MS-Windows: term_start() does not set job_info() cmd
Christian Brabandt <cb@256bit.org>
parents:
13748
diff
changeset
|
6101 |
3ab6198c1f9a
patch 8.0.1747: MS-Windows: term_start() does not set job_info() cmd
Christian Brabandt <cb@256bit.org>
parents:
13748
diff
changeset
|
6102 if (build_argv_from_string(cmd, &argv, &argc) == FAIL) |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
6103 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6104 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6105 else if (argvars[0].v_type != VAR_LIST |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6106 || argvars[0].vval.v_list == NULL |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6107 || argvars[0].vval.v_list->lv_len < 1) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6108 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
6109 emsg(_(e_invarg)); |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
6110 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6111 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6112 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6113 { |
13750
3ab6198c1f9a
patch 8.0.1747: MS-Windows: term_start() does not set job_info() cmd
Christian Brabandt <cb@256bit.org>
parents:
13748
diff
changeset
|
6114 list_T *l = argvars[0].vval.v_list; |
3ab6198c1f9a
patch 8.0.1747: MS-Windows: term_start() does not set job_info() cmd
Christian Brabandt <cb@256bit.org>
parents:
13748
diff
changeset
|
6115 |
3ab6198c1f9a
patch 8.0.1747: MS-Windows: term_start() does not set job_info() cmd
Christian Brabandt <cb@256bit.org>
parents:
13748
diff
changeset
|
6116 if (build_argv_from_list(l, &argv, &argc) == FAIL) |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
6117 goto theend; |
18941
70d6614aaf28
patch 8.2.0031: MS-Windows: test for empty job fails
Bram Moolenaar <Bram@vim.org>
parents:
18937
diff
changeset
|
6118 |
70d6614aaf28
patch 8.2.0031: MS-Windows: test for empty job fails
Bram Moolenaar <Bram@vim.org>
parents:
18937
diff
changeset
|
6119 // Empty command is invalid. |
70d6614aaf28
patch 8.2.0031: MS-Windows: test for empty job fails
Bram Moolenaar <Bram@vim.org>
parents:
18937
diff
changeset
|
6120 if (argc == 0 || *skipwhite((char_u *)argv[0]) == NUL) |
70d6614aaf28
patch 8.2.0031: MS-Windows: test for empty job fails
Bram Moolenaar <Bram@vim.org>
parents:
18937
diff
changeset
|
6121 { |
70d6614aaf28
patch 8.2.0031: MS-Windows: test for empty job fails
Bram Moolenaar <Bram@vim.org>
parents:
18937
diff
changeset
|
6122 emsg(_(e_invarg)); |
70d6614aaf28
patch 8.2.0031: MS-Windows: test for empty job fails
Bram Moolenaar <Bram@vim.org>
parents:
18937
diff
changeset
|
6123 goto theend; |
70d6614aaf28
patch 8.2.0031: MS-Windows: test for empty job fails
Bram Moolenaar <Bram@vim.org>
parents:
18937
diff
changeset
|
6124 } |
18943
d90138662f49
patch 8.2.0032: MS-Windows: test for blank job fails
Bram Moolenaar <Bram@vim.org>
parents:
18941
diff
changeset
|
6125 #ifndef USE_ARGV |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
6126 if (win32_build_cmd(l, &ga) == FAIL) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
6127 goto theend; |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6128 cmd = ga.ga_data; |
18941
70d6614aaf28
patch 8.2.0031: MS-Windows: test for empty job fails
Bram Moolenaar <Bram@vim.org>
parents:
18937
diff
changeset
|
6129 if (cmd == NULL || *skipwhite(cmd) == NUL) |
18937
ab97d1aea4aa
patch 8.2.0029: MS-Windows: crash with empty job command
Bram Moolenaar <Bram@vim.org>
parents:
18757
diff
changeset
|
6130 { |
ab97d1aea4aa
patch 8.2.0029: MS-Windows: crash with empty job command
Bram Moolenaar <Bram@vim.org>
parents:
18757
diff
changeset
|
6131 emsg(_(e_invarg)); |
ab97d1aea4aa
patch 8.2.0029: MS-Windows: crash with empty job command
Bram Moolenaar <Bram@vim.org>
parents:
18757
diff
changeset
|
6132 goto theend; |
ab97d1aea4aa
patch 8.2.0029: MS-Windows: crash with empty job command
Bram Moolenaar <Bram@vim.org>
parents:
18757
diff
changeset
|
6133 } |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6134 #endif |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6135 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6136 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6137 // Save the command used to start the job. |
13913
3e5c24ecc313
patch 8.0.1827: compiler warning for signed/unsigned char pointers
Christian Brabandt <cb@256bit.org>
parents:
13847
diff
changeset
|
6138 job->jv_argv = argv; |
13740
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13674
diff
changeset
|
6139 |
19245
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
6140 if (term_job != NULL) |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
6141 *term_job = job; |
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
6142 |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6143 #ifdef USE_ARGV |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6144 if (ch_log_active()) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6145 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6146 garray_T ga; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6147 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6148 ga_init2(&ga, (int)sizeof(char), 200); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6149 for (i = 0; i < argc; ++i) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6150 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6151 if (i > 0) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6152 ga_concat(&ga, (char_u *)" "); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6153 ga_concat(&ga, (char_u *)argv[i]); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6154 } |
16306
a2c598cbe220
patch 8.1.1158: json encoded string is sometimes missing the final NUL
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
6155 ga_append(&ga, NUL); |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
6156 ch_log(NULL, "Starting job: %s", (char *)ga.ga_data); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6157 ga_clear(&ga); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6158 } |
19245
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
6159 mch_job_start(argv, job, &opt, term_job != NULL); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6160 #else |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
6161 ch_log(NULL, "Starting job: %s", (char *)cmd); |
11723
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
6162 mch_job_start((char *)cmd, job, &opt); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6163 #endif |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6164 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6165 // If the channel is reading from a buffer, write lines now. |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6166 if (job->jv_channel != NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6167 channel_write_in(job->jv_channel); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6168 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6169 theend: |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
6170 #ifndef USE_ARGV |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6171 vim_free(ga.ga_data); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6172 #endif |
19168
c9258281045d
patch 8.2.0143: Coverity warning for possible use of NULL pointer
Bram Moolenaar <Bram@vim.org>
parents:
19157
diff
changeset
|
6173 if (argv != NULL && argv != job->jv_argv) |
19157
f2c8bc90f3c8
patch 8.2.0138: memory leak when starting a job fails
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
6174 { |
f2c8bc90f3c8
patch 8.2.0138: memory leak when starting a job fails
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
6175 for (i = 0; argv[i] != NULL; i++) |
f2c8bc90f3c8
patch 8.2.0138: memory leak when starting a job fails
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
6176 vim_free(argv[i]); |
13746
260256caac38
patch 8.0.1745: build failure on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
6177 vim_free(argv); |
19157
f2c8bc90f3c8
patch 8.2.0138: memory leak when starting a job fails
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
6178 } |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
6179 free_job_options(&opt); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6180 return job; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6181 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6182 |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6183 /* |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6184 * Get the status of "job" and invoke the exit callback when needed. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6185 * The returned string is not allocated. |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6186 */ |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6187 char * |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6188 job_status(job_T *job) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6189 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6190 char *result; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6191 |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10375
diff
changeset
|
6192 if (job->jv_status >= JOB_ENDED) |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6193 // No need to check, dead is dead. |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6194 result = "dead"; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6195 else if (job->jv_status == JOB_FAILED) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6196 result = "fail"; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6197 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6198 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6199 result = mch_job_status(job); |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6200 if (job->jv_status == JOB_ENDED) |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
6201 job_cleanup(job); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6202 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6203 return result; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6204 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6205 |
8502
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8498
diff
changeset
|
6206 /* |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
6207 * Send a signal to "job". Implements job_stop(). |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
6208 * When "type" is not NULL use this for the type. |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
6209 * Otherwise use argvars[1] for the type. |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
6210 */ |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6211 int |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
6212 job_stop(job_T *job, typval_T *argvars, char *type) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6213 { |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6214 char_u *arg; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6215 |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
6216 if (type != NULL) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
6217 arg = (char_u *)type; |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11672
diff
changeset
|
6218 else if (argvars[1].v_type == VAR_UNKNOWN) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6219 arg = (char_u *)""; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6220 else |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6221 { |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15160
diff
changeset
|
6222 arg = tv_get_string_chk(&argvars[1]); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6223 if (arg == NULL) |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6224 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
6225 emsg(_(e_invarg)); |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6226 return 0; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6227 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6228 } |
11727
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
6229 if (job->jv_status == JOB_FAILED) |
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
6230 { |
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
6231 ch_log(job->jv_channel, "Job failed to start, job_stop() skipped"); |
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
6232 return 0; |
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
6233 } |
11408
c9924ea60cc7
patch 8.0.0588: job_stop() often assumes the channel will be closed
Christian Brabandt <cb@256bit.org>
parents:
11317
diff
changeset
|
6234 if (job->jv_status == JOB_ENDED) |
c9924ea60cc7
patch 8.0.0588: job_stop() often assumes the channel will be closed
Christian Brabandt <cb@256bit.org>
parents:
11317
diff
changeset
|
6235 { |
c9924ea60cc7
patch 8.0.0588: job_stop() often assumes the channel will be closed
Christian Brabandt <cb@256bit.org>
parents:
11317
diff
changeset
|
6236 ch_log(job->jv_channel, "Job has already ended, job_stop() skipped"); |
c9924ea60cc7
patch 8.0.0588: job_stop() often assumes the channel will be closed
Christian Brabandt <cb@256bit.org>
parents:
11317
diff
changeset
|
6237 return 0; |
c9924ea60cc7
patch 8.0.0588: job_stop() often assumes the channel will be closed
Christian Brabandt <cb@256bit.org>
parents:
11317
diff
changeset
|
6238 } |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
6239 ch_log(job->jv_channel, "Stopping job with '%s'", (char *)arg); |
12037
85f0f557661e
patch 8.0.0899: function name mch_stop_job() is confusing
Christian Brabandt <cb@256bit.org>
parents:
12033
diff
changeset
|
6240 if (mch_signal_job(job, arg) == FAIL) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6241 return 0; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6242 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6243 // Assume that only "kill" will kill the job. |
11408
c9924ea60cc7
patch 8.0.0588: job_stop() often assumes the channel will be closed
Christian Brabandt <cb@256bit.org>
parents:
11317
diff
changeset
|
6244 if (job->jv_channel != NULL && STRCMP(arg, "kill") == 0) |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6245 job->jv_channel->ch_job_killed = TRUE; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6246 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6247 // We don't try freeing the job, obviously the caller still has a |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6248 // reference to it. |
8498
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6249 return 1; |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6250 } |
42277980a76d
commit https://github.com/vim/vim/commit/8e2c942ce49f2555d7dc2088cf3aa856820c5e32
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
6251 |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6252 void |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6253 invoke_prompt_callback(void) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6254 { |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6255 typval_T rettv; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6256 typval_T argv[2]; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6257 char_u *text; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6258 char_u *prompt; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6259 linenr_T lnum = curbuf->b_ml.ml_line_count; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6260 |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6261 // Add a new line for the prompt before invoking the callback, so that |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6262 // text can always be inserted above the last line. |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6263 ml_append(lnum, (char_u *)"", 0, FALSE); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6264 curwin->w_cursor.lnum = lnum + 1; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6265 curwin->w_cursor.col = 0; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6266 |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
6267 if (curbuf->b_prompt_callback.cb_name == NULL |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
6268 || *curbuf->b_prompt_callback.cb_name == NUL) |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6269 return; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6270 text = ml_get(lnum); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6271 prompt = prompt_text(); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6272 if (STRLEN(text) >= STRLEN(prompt)) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6273 text += STRLEN(prompt); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6274 argv[0].v_type = VAR_STRING; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6275 argv[0].vval.v_string = vim_strsave(text); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6276 argv[1].v_type = VAR_UNKNOWN; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6277 |
17606
ff097edaae89
patch 8.1.1800: function call functions have too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
6278 call_callback(&curbuf->b_prompt_callback, -1, &rettv, 1, argv); |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6279 clear_tv(&argv[0]); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6280 clear_tv(&rettv); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6281 } |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
13915
diff
changeset
|
6282 |
14103
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6283 /* |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6284 * Return TRUE when the interrupt callback was invoked. |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6285 */ |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6286 int |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6287 invoke_prompt_interrupt(void) |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6288 { |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6289 typval_T rettv; |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6290 typval_T argv[1]; |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6291 |
16872
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
6292 if (curbuf->b_prompt_interrupt.cb_name == NULL |
a836d122231a
patch 8.1.1437: code to handle callbacks is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
6293 || *curbuf->b_prompt_interrupt.cb_name == NUL) |
14103
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6294 return FALSE; |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6295 argv[0].v_type = VAR_UNKNOWN; |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6296 |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6297 got_int = FALSE; // don't skip executing commands |
17606
ff097edaae89
patch 8.1.1800: function call functions have too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
6298 call_callback(&curbuf->b_prompt_interrupt, -1, &rettv, 0, argv); |
14103
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6299 clear_tv(&rettv); |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6300 return TRUE; |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6301 } |
d053ec57d886
patch 8.1.0069: cannot handle pressing CTRL-C in a prompt buffer
Christian Brabandt <cb@256bit.org>
parents:
14065
diff
changeset
|
6302 |
17170
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6303 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6304 * "prompt_setcallback({buffer}, {callback})" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6305 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6306 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6307 f_prompt_setcallback(typval_T *argvars, typval_T *rettv UNUSED) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6308 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6309 buf_T *buf; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6310 callback_T callback; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6311 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6312 if (check_secure()) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6313 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6314 buf = tv_get_buf(&argvars[0], FALSE); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6315 if (buf == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6316 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6317 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6318 callback = get_callback(&argvars[1]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6319 if (callback.cb_name == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6320 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6321 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6322 free_callback(&buf->b_prompt_callback); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6323 set_callback(&buf->b_prompt_callback, &callback); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6324 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6325 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6326 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6327 * "prompt_setinterrupt({buffer}, {callback})" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6328 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6329 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6330 f_prompt_setinterrupt(typval_T *argvars, typval_T *rettv UNUSED) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6331 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6332 buf_T *buf; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6333 callback_T callback; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6334 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6335 if (check_secure()) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6336 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6337 buf = tv_get_buf(&argvars[0], FALSE); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6338 if (buf == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6339 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6340 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6341 callback = get_callback(&argvars[1]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6342 if (callback.cb_name == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6343 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6344 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6345 free_callback(&buf->b_prompt_interrupt); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6346 set_callback(&buf->b_prompt_interrupt, &callback); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6347 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6348 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6349 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6350 * "prompt_setprompt({buffer}, {text})" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6351 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6352 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6353 f_prompt_setprompt(typval_T *argvars, typval_T *rettv UNUSED) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6354 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6355 buf_T *buf; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6356 char_u *text; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6357 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6358 if (check_secure()) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6359 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6360 buf = tv_get_buf(&argvars[0], FALSE); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6361 if (buf == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6362 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6363 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6364 text = tv_get_string(&argvars[1]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6365 vim_free(buf->b_prompt_text); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6366 buf->b_prompt_text = vim_strsave(text); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6367 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6368 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6369 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6370 * "ch_canread()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6371 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6372 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6373 f_ch_canread(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6374 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6375 channel_T *channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6376 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6377 rettv->vval.v_number = 0; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6378 if (channel != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6379 rettv->vval.v_number = channel_has_readahead(channel, PART_SOCK) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6380 || channel_has_readahead(channel, PART_OUT) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6381 || channel_has_readahead(channel, PART_ERR); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6382 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6383 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6384 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6385 * "ch_close()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6386 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6387 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6388 f_ch_close(typval_T *argvars, typval_T *rettv UNUSED) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6389 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6390 channel_T *channel = get_channel_arg(&argvars[0], TRUE, FALSE, 0); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6391 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6392 if (channel != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6393 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6394 channel_close(channel, FALSE); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6395 channel_clear(channel); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6396 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6397 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6398 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6399 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6400 * "ch_close()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6401 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6402 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6403 f_ch_close_in(typval_T *argvars, typval_T *rettv UNUSED) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6404 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6405 channel_T *channel = get_channel_arg(&argvars[0], TRUE, FALSE, 0); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6406 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6407 if (channel != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6408 channel_close_in(channel); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6409 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6410 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6411 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6412 * "ch_getbufnr()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6413 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6414 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6415 f_ch_getbufnr(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6416 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6417 channel_T *channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6418 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6419 rettv->vval.v_number = -1; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6420 if (channel != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6421 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6422 char_u *what = tv_get_string(&argvars[1]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6423 int part; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6424 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6425 if (STRCMP(what, "err") == 0) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6426 part = PART_ERR; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6427 else if (STRCMP(what, "out") == 0) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6428 part = PART_OUT; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6429 else if (STRCMP(what, "in") == 0) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6430 part = PART_IN; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6431 else |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6432 part = PART_SOCK; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6433 if (channel->ch_part[part].ch_bufref.br_buf != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6434 rettv->vval.v_number = |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6435 channel->ch_part[part].ch_bufref.br_buf->b_fnum; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6436 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6437 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6438 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6439 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6440 * "ch_getjob()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6441 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6442 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6443 f_ch_getjob(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6444 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6445 channel_T *channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6446 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6447 if (channel != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6448 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6449 rettv->v_type = VAR_JOB; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6450 rettv->vval.v_job = channel->ch_job; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6451 if (channel->ch_job != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6452 ++channel->ch_job->jv_refcount; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6453 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6454 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6455 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6456 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6457 * "ch_info()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6458 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6459 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6460 f_ch_info(typval_T *argvars, typval_T *rettv UNUSED) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6461 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6462 channel_T *channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6463 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6464 if (channel != NULL && rettv_dict_alloc(rettv) != FAIL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6465 channel_info(channel, rettv->vval.v_dict); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6466 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6467 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6468 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6469 * "ch_log()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6470 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6471 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6472 f_ch_log(typval_T *argvars, typval_T *rettv UNUSED) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6473 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6474 char_u *msg = tv_get_string(&argvars[0]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6475 channel_T *channel = NULL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6476 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6477 if (argvars[1].v_type != VAR_UNKNOWN) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6478 channel = get_channel_arg(&argvars[1], FALSE, FALSE, 0); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6479 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6480 ch_log(channel, "%s", msg); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6481 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6482 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6483 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6484 * "ch_logfile()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6485 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6486 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6487 f_ch_logfile(typval_T *argvars, typval_T *rettv UNUSED) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6488 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6489 char_u *fname; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6490 char_u *opt = (char_u *)""; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6491 char_u buf[NUMBUFLEN]; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6492 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6493 // Don't open a file in restricted mode. |
17170
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6494 if (check_restricted() || check_secure()) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6495 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6496 fname = tv_get_string(&argvars[0]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6497 if (argvars[1].v_type == VAR_STRING) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6498 opt = tv_get_string_buf(&argvars[1], buf); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6499 ch_logfile(fname, opt); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6500 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6501 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6502 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6503 * "ch_open()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6504 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6505 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6506 f_ch_open(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6507 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6508 rettv->v_type = VAR_CHANNEL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6509 if (check_restricted() || check_secure()) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6510 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6511 rettv->vval.v_channel = channel_open_func(argvars); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6512 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6513 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6514 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6515 * "ch_read()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6516 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6517 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6518 f_ch_read(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6519 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6520 common_channel_read(argvars, rettv, FALSE, FALSE); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6521 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6522 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6523 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6524 * "ch_readblob()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6525 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6526 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6527 f_ch_readblob(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6528 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6529 common_channel_read(argvars, rettv, TRUE, TRUE); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6530 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6531 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6532 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6533 * "ch_readraw()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6534 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6535 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6536 f_ch_readraw(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6537 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6538 common_channel_read(argvars, rettv, TRUE, FALSE); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6539 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6540 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6541 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6542 * "ch_evalexpr()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6543 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6544 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6545 f_ch_evalexpr(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6546 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6547 ch_expr_common(argvars, rettv, TRUE); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6548 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6549 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6550 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6551 * "ch_sendexpr()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6552 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6553 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6554 f_ch_sendexpr(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6555 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6556 ch_expr_common(argvars, rettv, FALSE); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6557 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6558 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6559 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6560 * "ch_evalraw()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6561 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6562 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6563 f_ch_evalraw(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6564 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6565 ch_raw_common(argvars, rettv, TRUE); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6566 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6567 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6568 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6569 * "ch_sendraw()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6570 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6571 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6572 f_ch_sendraw(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6573 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6574 ch_raw_common(argvars, rettv, FALSE); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6575 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6576 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6577 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6578 * "ch_setoptions()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6579 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6580 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6581 f_ch_setoptions(typval_T *argvars, typval_T *rettv UNUSED) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6582 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6583 channel_T *channel; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6584 jobopt_T opt; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6585 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6586 channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6587 if (channel == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6588 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6589 clear_job_options(&opt); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6590 if (get_job_options(&argvars[1], &opt, |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6591 JO_CB_ALL + JO_TIMEOUT_ALL + JO_MODE_ALL, 0) == OK) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6592 channel_set_options(channel, &opt); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6593 free_job_options(&opt); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6594 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6595 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6596 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6597 * "ch_status()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6598 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6599 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6600 f_ch_status(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6601 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6602 channel_T *channel; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6603 jobopt_T opt; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6604 int part = -1; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6605 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6606 // return an empty string by default |
17170
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6607 rettv->v_type = VAR_STRING; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6608 rettv->vval.v_string = NULL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6609 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6610 channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6611 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6612 if (argvars[1].v_type != VAR_UNKNOWN) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6613 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6614 clear_job_options(&opt); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6615 if (get_job_options(&argvars[1], &opt, JO_PART, 0) == OK |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6616 && (opt.jo_set & JO_PART)) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6617 part = opt.jo_part; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6618 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6619 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6620 rettv->vval.v_string = vim_strsave((char_u *)channel_status(channel, part)); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6621 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6622 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6623 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6624 * Get the job from the argument. |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6625 * Returns NULL if the job is invalid. |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6626 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6627 static job_T * |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6628 get_job_arg(typval_T *tv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6629 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6630 job_T *job; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6631 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6632 if (tv->v_type != VAR_JOB) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6633 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6634 semsg(_(e_invarg2), tv_get_string(tv)); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6635 return NULL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6636 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6637 job = tv->vval.v_job; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6638 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6639 if (job == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6640 emsg(_("E916: not a valid job")); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6641 return job; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6642 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6643 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6644 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6645 * "job_getchannel()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6646 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6647 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6648 f_job_getchannel(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6649 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6650 job_T *job = get_job_arg(&argvars[0]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6651 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6652 if (job != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6653 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6654 rettv->v_type = VAR_CHANNEL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6655 rettv->vval.v_channel = job->jv_channel; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6656 if (job->jv_channel != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6657 ++job->jv_channel->ch_refcount; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6658 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6659 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6660 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6661 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6662 * Implementation of job_info(). |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6663 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6664 static void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6665 job_info(job_T *job, dict_T *dict) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6666 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6667 dictitem_T *item; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6668 varnumber_T nr; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6669 list_T *l; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6670 int i; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6671 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6672 dict_add_string(dict, "status", (char_u *)job_status(job)); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6673 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6674 item = dictitem_alloc((char_u *)"channel"); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6675 if (item == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6676 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6677 item->di_tv.v_type = VAR_CHANNEL; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6678 item->di_tv.vval.v_channel = job->jv_channel; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6679 if (job->jv_channel != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6680 ++job->jv_channel->ch_refcount; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6681 if (dict_add(dict, item) == FAIL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6682 dictitem_free(item); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6683 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6684 #ifdef UNIX |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6685 nr = job->jv_pid; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6686 #else |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6687 nr = job->jv_proc_info.dwProcessId; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6688 #endif |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6689 dict_add_number(dict, "process", nr); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6690 dict_add_string(dict, "tty_in", job->jv_tty_in); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6691 dict_add_string(dict, "tty_out", job->jv_tty_out); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6692 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6693 dict_add_number(dict, "exitval", job->jv_exitval); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6694 dict_add_string(dict, "exit_cb", job->jv_exit_cb.cb_name); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6695 dict_add_string(dict, "stoponexit", job->jv_stoponexit); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6696 #ifdef UNIX |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6697 dict_add_string(dict, "termsig", job->jv_termsig); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6698 #endif |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6699 #ifdef MSWIN |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6700 dict_add_string(dict, "tty_type", job->jv_tty_type); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6701 #endif |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6702 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6703 l = list_alloc(); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6704 if (l != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6705 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6706 dict_add_list(dict, "cmd", l); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6707 if (job->jv_argv != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6708 for (i = 0; job->jv_argv[i] != NULL; i++) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6709 list_append_string(l, (char_u *)job->jv_argv[i], -1); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6710 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6711 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6712 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6713 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6714 * Implementation of job_info() to return info for all jobs. |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6715 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6716 static void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6717 job_info_all(list_T *l) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6718 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6719 job_T *job; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6720 typval_T tv; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6721 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19820
diff
changeset
|
6722 FOR_ALL_JOBS(job) |
17170
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6723 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6724 tv.v_type = VAR_JOB; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6725 tv.vval.v_job = job; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6726 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6727 if (list_append_tv(l, &tv) != OK) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6728 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6729 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6730 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6731 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6732 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6733 * "job_info()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6734 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6735 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6736 f_job_info(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6737 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6738 if (argvars[0].v_type != VAR_UNKNOWN) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6739 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6740 job_T *job = get_job_arg(&argvars[0]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6741 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6742 if (job != NULL && rettv_dict_alloc(rettv) != FAIL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6743 job_info(job, rettv->vval.v_dict); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6744 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6745 else if (rettv_list_alloc(rettv) == OK) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6746 job_info_all(rettv->vval.v_list); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6747 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6748 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6749 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6750 * "job_setoptions()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6751 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6752 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6753 f_job_setoptions(typval_T *argvars, typval_T *rettv UNUSED) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6754 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6755 job_T *job = get_job_arg(&argvars[0]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6756 jobopt_T opt; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6757 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6758 if (job == NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6759 return; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6760 clear_job_options(&opt); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6761 if (get_job_options(&argvars[1], &opt, JO_STOPONEXIT + JO_EXIT_CB, 0) == OK) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6762 job_set_options(job, &opt); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6763 free_job_options(&opt); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6764 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6765 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6766 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6767 * "job_start()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6768 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6769 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6770 f_job_start(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6771 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6772 rettv->v_type = VAR_JOB; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6773 if (check_restricted() || check_secure()) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6774 return; |
19245
5ed8297121fa
patch 8.2.0181: problems parsing :term arguments
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
6775 rettv->vval.v_job = job_start(argvars, NULL, NULL, NULL); |
17170
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6776 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6777 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6778 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6779 * "job_status()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6780 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6781 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6782 f_job_status(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6783 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6784 job_T *job = get_job_arg(&argvars[0]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6785 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6786 if (job != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6787 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6788 rettv->v_type = VAR_STRING; |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6789 rettv->vval.v_string = vim_strsave((char_u *)job_status(job)); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6790 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6791 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6792 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6793 /* |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6794 * "job_stop()" function |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6795 */ |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6796 void |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6797 f_job_stop(typval_T *argvars, typval_T *rettv) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6798 { |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6799 job_T *job = get_job_arg(&argvars[0]); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6800 |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6801 if (job != NULL) |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6802 rettv->vval.v_number = job_stop(job, argvars, NULL); |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6803 } |
cee12488e4bc
patch 8.1.1584: the evalfunc.c file is getting too big
Bram Moolenaar <Bram@vim.org>
parents:
17151
diff
changeset
|
6804 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18191
diff
changeset
|
6805 #endif // FEAT_JOB_CHANNEL |