annotate src/ex_cmds2.c @ 20288:40f2361f79e1

Added tag v8.2.0699 for changeset ce1b73835822d5a5aa2d9f8a97a5855e4e9dfd93
author Bram Moolenaar <Bram@vim.org>
date Tue, 05 May 2020 21:30:04 +0200
parents aadd1cae2ff5
children 5788b78a1af0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 9812
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * ex_cmds2.c: some more functions for command line commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 #include "version.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 * If 'autowrite' option set, try to write the file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 * Careful: autocommands may make "buf" invalid!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 * return FAIL for failure, OK otherwise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
24 autowrite(buf_T *buf, int forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 {
1069
f628d19361d9 updated for version 7.0-195
vimboss
parents: 1061
diff changeset
26 int r;
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
27 bufref_T bufref;
1069
f628d19361d9 updated for version 7.0-195
vimboss
parents: 1061
diff changeset
28
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 if (!(p_aw || p_awa) || !p_write
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 #ifdef FEAT_QUICKFIX
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
31 // never autowrite a "nofile" or "nowrite" buffer
1069
f628d19361d9 updated for version 7.0-195
vimboss
parents: 1061
diff changeset
32 || bt_dontwrite(buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 #endif
1069
f628d19361d9 updated for version 7.0-195
vimboss
parents: 1061
diff changeset
34 || (!forceit && buf->b_p_ro) || buf->b_ffname == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 return FAIL;
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
36 set_bufref(&bufref, buf);
1069
f628d19361d9 updated for version 7.0-195
vimboss
parents: 1061
diff changeset
37 r = buf_write_all(buf, forceit);
f628d19361d9 updated for version 7.0-195
vimboss
parents: 1061
diff changeset
38
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
39 // Writing may succeed but the buffer still changed, e.g., when there is a
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
40 // conversion error. We do want to return FAIL then.
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
41 if (bufref_valid(&bufref) && bufIsChanged(buf))
1069
f628d19361d9 updated for version 7.0-195
vimboss
parents: 1061
diff changeset
42 r = FAIL;
f628d19361d9 updated for version 7.0-195
vimboss
parents: 1061
diff changeset
43 return r;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 /*
14642
96858d612aff patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents: 14303
diff changeset
47 * Flush all buffers, except the ones that are readonly or are never written.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
50 autowrite_all(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 if (!(p_aw || p_awa) || !p_write)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 return;
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9626
diff changeset
56 FOR_ALL_BUFFERS(buf)
14642
96858d612aff patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents: 14303
diff changeset
57 if (bufIsChanged(buf) && !buf->b_p_ro && !bt_dontwrite(buf))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 {
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
59 bufref_T bufref;
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
60
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
61 set_bufref(&bufref, buf);
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13302
diff changeset
62
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 (void)buf_write_all(buf, FALSE);
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13302
diff changeset
64
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
65 // an autocommand may have deleted the buffer
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
66 if (!bufref_valid(&bufref))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 buf = firstbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 /*
5464
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5027
diff changeset
72 * Return TRUE if buffer was changed and cannot be abandoned.
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5027
diff changeset
73 * For flags use the CCGD_ values.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
76 check_changed(buf_T *buf, int flags)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 {
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
78 int forceit = (flags & CCGD_FORCEIT);
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
79 bufref_T bufref;
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
80
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
81 set_bufref(&bufref, buf);
5464
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5027
diff changeset
82
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 if ( !forceit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 && bufIsChanged(buf)
5464
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5027
diff changeset
85 && ((flags & CCGD_MULTWIN) || buf->b_nwindows <= 1)
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5027
diff changeset
86 && (!(flags & CCGD_AW) || autowrite(buf, forceit) == FAIL))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 if ((p_confirm || cmdmod.confirm) && p_write)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 buf_T *buf2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 int count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93
5464
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5027
diff changeset
94 if (flags & CCGD_ALLBUF)
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9626
diff changeset
95 FOR_ALL_BUFFERS(buf2)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 if (bufIsChanged(buf2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 && (buf2->b_ffname != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 # ifdef FEAT_BROWSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 || cmdmod.browse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 ))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 ++count;
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
103 if (!bufref_valid(&bufref))
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
104 // Autocommand deleted buffer, oops! It's not changed now.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 return FALSE;
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13302
diff changeset
106
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 dialog_changed(buf, count > 1);
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13302
diff changeset
108
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
109 if (!bufref_valid(&bufref))
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
110 // Autocommand deleted buffer, oops! It's not changed now.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 return bufIsChanged(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 #endif
5464
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5027
diff changeset
115 if (flags & CCGD_EXCMD)
12146
59c1e09cf1a9 patch 8.0.0953: get "no write since last change" error in terminal window
Christian Brabandt <cb@256bit.org>
parents: 12039
diff changeset
116 no_write_message();
5464
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5027
diff changeset
117 else
13302
b5806be0b36d patch 8.0.1525: using :wqa exits even if a job runs in a terminal window
Christian Brabandt <cb@256bit.org>
parents: 13274
diff changeset
118 no_write_message_nobang(curbuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 #if defined(FEAT_BROWSE) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 * When wanting to write a file without a file name, ask the user for a name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
131 browse_save_fname(buf_T *buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 if (buf->b_fname == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 char_u *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 22
diff changeset
137 fname = do_browse(BROWSE_SAVE, (char_u *)_("Save As"),
ac33b7c03fac updated for version 7.0018
vimboss
parents: 22
diff changeset
138 NULL, NULL, NULL, NULL, buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 if (fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 if (setfname(buf, fname, NULL, TRUE) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 buf->b_flags |= BF_NOTEDITED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 vim_free(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 /*
2849
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
150 * Ask the user what to do when abandoning a changed buffer.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 * Must check 'write' option first!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
154 dialog_changed(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
155 buf_T *buf,
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
156 int checkall) // may abandon all changed buffers
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 {
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2711
diff changeset
158 char_u buff[DIALOG_MSG_SIZE];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 int ret;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 buf_T *buf2;
3486
f9a865d97614 updated for version 7.3.507
Bram Moolenaar <bram@vim.org>
parents: 3429
diff changeset
161 exarg_T ea;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162
12206
bd8d767fb36f patch 8.0.0983: unnecessary check for NULL pointer
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
163 dialog_msg(buff, _("Save changes to \"%s\"?"), buf->b_fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 if (checkall)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, buff, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168
16619
8f0ea605ec96 patch 8.1.1312: Coverity warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
169 // Init ea pseudo-structure, this is needed for the check_overwrite()
8f0ea605ec96 patch 8.1.1312: Coverity warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
170 // function.
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19888
diff changeset
171 CLEAR_FIELD(ea);
3486
f9a865d97614 updated for version 7.3.507
Bram Moolenaar <bram@vim.org>
parents: 3429
diff changeset
172
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 if (ret == VIM_YES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 #ifdef FEAT_BROWSE
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
176 // May get file name, when there is none
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 browse_save_fname(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 #endif
3486
f9a865d97614 updated for version 7.3.507
Bram Moolenaar <bram@vim.org>
parents: 3429
diff changeset
179 if (buf->b_fname != NULL && check_overwrite(&ea, buf,
f9a865d97614 updated for version 7.3.507
Bram Moolenaar <bram@vim.org>
parents: 3429
diff changeset
180 buf->b_fname, buf->b_ffname, FALSE) == OK)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
181 // didn't hit Cancel
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 (void)buf_write_all(buf, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 else if (ret == VIM_NO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 {
16996
d5e1e09a829f patch 8.1.1498: ":write" increments b:changedtick even though nothing changed
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
186 unchanged(buf, TRUE, FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 else if (ret == VIM_ALL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 * Write all modified files that can be written.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 * Skip readonly buffers, these need to be confirmed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 * individually.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 */
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9626
diff changeset
195 FOR_ALL_BUFFERS(buf2)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 if (bufIsChanged(buf2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 && (buf2->b_ffname != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 #ifdef FEAT_BROWSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 || cmdmod.browse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 && !buf2->b_p_ro)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 {
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
205 bufref_T bufref;
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
206
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
207 set_bufref(&bufref, buf2);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 #ifdef FEAT_BROWSE
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
209 // May get file name, when there is none
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 browse_save_fname(buf2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 #endif
3486
f9a865d97614 updated for version 7.3.507
Bram Moolenaar <bram@vim.org>
parents: 3429
diff changeset
212 if (buf2->b_fname != NULL && check_overwrite(&ea, buf2,
f9a865d97614 updated for version 7.3.507
Bram Moolenaar <bram@vim.org>
parents: 3429
diff changeset
213 buf2->b_fname, buf2->b_ffname, FALSE) == OK)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
214 // didn't hit Cancel
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 (void)buf_write_all(buf2, FALSE);
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13302
diff changeset
216
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
217 // an autocommand may have deleted the buffer
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
218 if (!bufref_valid(&bufref))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 buf2 = firstbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 else if (ret == VIM_DISCARDALL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 * mark all buffers as unchanged
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 */
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9626
diff changeset
228 FOR_ALL_BUFFERS(buf2)
16996
d5e1e09a829f patch 8.1.1498: ":write" increments b:changedtick even though nothing changed
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
229 unchanged(buf2, TRUE, FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 * Return TRUE if the buffer "buf" can be abandoned, either by making it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 * hidden, autowriting it or unloading it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
239 can_abandon(buf_T *buf, int forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 {
11957
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11935
diff changeset
241 return ( buf_hide(buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 || !bufIsChanged(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 || buf->b_nwindows > 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 || autowrite(buf, forceit) == OK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 || forceit);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
248 /*
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
249 * Add a buffer number to "bufnrs", unless it's already there.
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
250 */
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
251 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
252 add_bufnum(int *bufnrs, int *bufnump, int nr)
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
253 {
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
254 int i;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
255
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
256 for (i = 0; i < *bufnump; ++i)
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
257 if (bufnrs[i] == nr)
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
258 return;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
259 bufnrs[*bufnump] = nr;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
260 *bufnump = *bufnump + 1;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
261 }
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
262
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 * Return TRUE if any buffer was changed and cannot be abandoned.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 * That changed buffer becomes the current buffer.
13438
33eea5ce5415 patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
266 * When "unload" is TRUE the current buffer is unloaded instead of making it
7469
15eefe1b0dad commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents: 7107
diff changeset
267 * hidden. This is used for ":q!".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
270 check_changed_any(
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
271 int hidden, // Only check hidden buffers
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
272 int unload)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 {
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
274 int ret = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 int save;
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
277 int i;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
278 int bufnum = 0;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
279 int bufcount = 0;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
280 int *bufnrs;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
281 tabpage_T *tp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
284 // Make a list of all buffers, with the most important ones first.
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9626
diff changeset
285 FOR_ALL_BUFFERS(buf)
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
286 ++bufcount;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
287
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
288 if (bufcount == 0)
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
289 return FALSE;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
290
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
291 bufnrs = ALLOC_MULT(int, bufcount);
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
292 if (bufnrs == NULL)
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
293 return FALSE;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
294
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
295 // curbuf
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
296 bufnrs[bufnum++] = curbuf->b_fnum;
13438
33eea5ce5415 patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
297
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
298 // buffers in current tab
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
299 FOR_ALL_WINDOWS(wp)
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
300 if (wp->w_buffer != curbuf)
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
301 add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
302
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
303 // buffers in other tabs
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9626
diff changeset
304 FOR_ALL_TABPAGES(tp)
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
305 if (tp != curtab)
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19396
diff changeset
306 FOR_ALL_WINDOWS_IN_TAB(tp, wp)
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
307 add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
13438
33eea5ce5415 patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
308
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
309 // any other buffer
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9626
diff changeset
310 FOR_ALL_BUFFERS(buf)
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
311 add_bufnum(bufnrs, &bufnum, buf->b_fnum);
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
312
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
313 for (i = 0; i < bufnum; ++i)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 {
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
315 buf = buflist_findnr(bufnrs[i]);
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
316 if (buf == NULL)
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
317 continue;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
318 if ((!hidden || buf->b_nwindows == 0) && bufIsChanged(buf))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 {
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
320 bufref_T bufref;
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
321
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
322 set_bufref(&bufref, buf);
13438
33eea5ce5415 patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
323 #ifdef FEAT_TERMINAL
33eea5ce5415 patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
324 if (term_job_running(buf->b_term))
33eea5ce5415 patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
325 {
33eea5ce5415 patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
326 if (term_try_stop_job(buf) == FAIL)
33eea5ce5415 patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
327 break;
33eea5ce5415 patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
328 }
33eea5ce5415 patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
329 else
33eea5ce5415 patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
330 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
331 // Try auto-writing the buffer. If this fails but the buffer no
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
332 // longer exists it's not changed, that's OK.
5464
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5027
diff changeset
333 if (check_changed(buf, (p_awa ? CCGD_AW : 0)
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5027
diff changeset
334 | CCGD_MULTWIN
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
335 | CCGD_ALLBUF) && bufref_valid(&bufref))
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
336 break; // didn't save - still changes
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
340 if (i >= bufnum)
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
341 goto theend;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
342
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
343 // Get here if "buf" cannot be abandoned.
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
344 ret = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 exiting = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 * When ":confirm" used, don't give an error message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 if (!(p_confirm || cmdmod.confirm))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
353 // There must be a wait_return for this message, do_buffer()
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
354 // may cause a redraw. But wait_return() is a no-op when vgetc()
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
355 // is busy (Quit used from window menu), then make sure we don't
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
356 // cause a scroll up.
823
9ab23f1e137f updated for version 7.0c12
vimboss
parents: 819
diff changeset
357 if (vgetc_busy > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 msg_row = cmdline_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 msg_didout = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 }
11957
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11935
diff changeset
363 if (
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11935
diff changeset
364 #ifdef FEAT_TERMINAL
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11935
diff changeset
365 term_job_running(buf->b_term)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15448
diff changeset
366 ? semsg(_("E947: Job still running in buffer \"%s\""),
11957
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11935
diff changeset
367 buf->b_fname)
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11935
diff changeset
368 :
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11935
diff changeset
369 #endif
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15448
diff changeset
370 semsg(_("E162: No write since last change for buffer \"%s\""),
3839
8115f449a574 updated for version 7.3.677
Bram Moolenaar <bram@vim.org>
parents: 3620
diff changeset
371 buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 save = no_wait_return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 no_wait_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 wait_return(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 no_wait_return = save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
380 // Try to find a window that contains the buffer.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 if (buf != curbuf)
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
382 FOR_ALL_TAB_WINDOWS(tp, wp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 if (wp->w_buffer == buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 {
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
385 bufref_T bufref;
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
386
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
387 set_bufref(&bufref, buf);
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13302
diff changeset
388
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
389 goto_tabpage_win(tp, wp);
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13302
diff changeset
390
15967
ddd82b1c9e9d patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents: 15868
diff changeset
391 // Paranoia: did autocmd wipe out the buffer with changes?
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9410
diff changeset
392 if (!bufref_valid(&bufref))
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
393 goto theend;
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
394 goto buf_found;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 }
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
396 buf_found:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
398 // Open the changed buffer in the current window.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 if (buf != curbuf)
7469
15eefe1b0dad commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents: 7107
diff changeset
400 set_curbuf(buf, unload ? DOBUF_UNLOAD : DOBUF_GOTO);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401
3429
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
402 theend:
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
403 vim_free(bufnrs);
b35844f3eb49 updated for version 7.3.480
Bram Moolenaar <bram@vim.org>
parents: 3378
diff changeset
404 return ret;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 * return FAIL if there is no file name, OK if there is one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 * give error message for FAIL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
412 check_fname(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 if (curbuf->b_ffname == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15448
diff changeset
416 emsg(_(e_noname));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 * flush the contents of a buffer, unless it has no file name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 * return FAIL for failure, OK otherwise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
428 buf_write_all(buf_T *buf, int forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 int retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 buf_T *old_curbuf = curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 retval = (buf_write(buf, buf->b_ffname, buf->b_fname,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 (linenr_T)1, buf->b_ml.ml_line_count, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 FALSE, forceit, TRUE, FALSE));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 if (curbuf != old_curbuf)
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 15
diff changeset
437 {
11158
501f46f7644c patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
438 msg_source(HL_ATTR(HLF_W));
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
439 msg(_("Warning: Entered other buffer unexpectedly (check autocommands)"));
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 15
diff changeset
440 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 /*
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
445 * ":argdo", ":windo", ":bufdo", ":tabdo", ":cdo", ":ldo", ":cfdo" and ":lfdo"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
448 ex_listdo(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 int i;
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
451 win_T *wp;
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
452 tabpage_T *tp;
6641
ceda6d8af447 updated for version 7.4.646
Bram Moolenaar <bram@vim.org>
parents: 6474
diff changeset
453 buf_T *buf = curbuf;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 int next_fnum = 0;
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13302
diff changeset
455 #if defined(FEAT_SYN_HL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 char_u *save_ei = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 #endif
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 29
diff changeset
458 char_u *p_shm_save;
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
459 #ifdef FEAT_QUICKFIX
7107
84efaf06f195 commit https://github.com/vim/vim/commit/ed84b76021df763619cabaedddc44eb5ee849136
Christian Brabandt <cb@256bit.org>
parents: 7092
diff changeset
460 int qf_size = 0;
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
461 int qf_idx;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
462 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463
8220
ad9edad64d22 commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents: 8212
diff changeset
464 #ifndef FEAT_QUICKFIX
ad9edad64d22 commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents: 8212
diff changeset
465 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo ||
ad9edad64d22 commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents: 8212
diff changeset
466 eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo)
ad9edad64d22 commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents: 8212
diff changeset
467 {
ad9edad64d22 commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents: 8212
diff changeset
468 ex_ni(eap);
ad9edad64d22 commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents: 8212
diff changeset
469 return;
ad9edad64d22 commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents: 8212
diff changeset
470 }
ad9edad64d22 commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents: 8212
diff changeset
471 #endif
ad9edad64d22 commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents: 8212
diff changeset
472
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13302
diff changeset
473 #if defined(FEAT_SYN_HL)
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 794
diff changeset
474 if (eap->cmdidx != CMD_windo && eap->cmdidx != CMD_tabdo)
17596
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
475 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
476 // Don't do syntax HL autocommands. Skipping the syntax file is a
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
477 // great speed improvement.
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 45
diff changeset
478 save_ei = au_event_disable(",Syntax");
17596
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
479
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19396
diff changeset
480 FOR_ALL_BUFFERS(buf)
17596
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
481 buf->b_flags &= ~BF_SYN_SET;
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
482 buf = curbuf;
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
483 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 #endif
6116
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5808
diff changeset
485 #ifdef FEAT_CLIPBOARD
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5808
diff changeset
486 start_global_changes();
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5808
diff changeset
487 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 if (eap->cmdidx == CMD_windo
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
490 || eap->cmdidx == CMD_tabdo
11957
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11935
diff changeset
491 || buf_hide(curbuf)
5464
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5027
diff changeset
492 || !check_changed(curbuf, CCGD_AW
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5027
diff changeset
493 | (eap->forceit ? CCGD_FORCEIT : 0)
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5027
diff changeset
494 | CCGD_EXCMD))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 i = 0;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
497 // start at the eap->line1 argument/window/buffer
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
498 wp = firstwin;
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
499 tp = first_tabpage;
6474
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
500 switch (eap->cmdidx)
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
501 {
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
502 case CMD_windo:
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
503 for ( ; wp != NULL && i + 1 < eap->line1; wp = wp->w_next)
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
504 i++;
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
505 break;
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
506 case CMD_tabdo:
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
507 for( ; tp != NULL && i + 1 < eap->line1; tp = tp->tp_next)
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
508 i++;
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
509 break;
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
510 case CMD_argdo:
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
511 i = eap->line1 - 1;
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
512 break;
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
513 default:
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
514 break;
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
515 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
516 // set pcmark now
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 if (eap->cmdidx == CMD_bufdo)
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
518 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
519 // Advance to the first listed buffer after "eap->line1".
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
520 for (buf = firstbuf; buf != NULL && (buf->b_fnum < eap->line1
6641
ceda6d8af447 updated for version 7.4.646
Bram Moolenaar <bram@vim.org>
parents: 6474
diff changeset
521 || !buf->b_p_bl); buf = buf->b_next)
ceda6d8af447 updated for version 7.4.646
Bram Moolenaar <bram@vim.org>
parents: 6474
diff changeset
522 if (buf->b_fnum > eap->line2)
ceda6d8af447 updated for version 7.4.646
Bram Moolenaar <bram@vim.org>
parents: 6474
diff changeset
523 {
ceda6d8af447 updated for version 7.4.646
Bram Moolenaar <bram@vim.org>
parents: 6474
diff changeset
524 buf = NULL;
ceda6d8af447 updated for version 7.4.646
Bram Moolenaar <bram@vim.org>
parents: 6474
diff changeset
525 break;
ceda6d8af447 updated for version 7.4.646
Bram Moolenaar <bram@vim.org>
parents: 6474
diff changeset
526 }
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
527 if (buf != NULL)
6641
ceda6d8af447 updated for version 7.4.646
Bram Moolenaar <bram@vim.org>
parents: 6474
diff changeset
528 goto_buffer(eap, DOBUF_FIRST, FORWARD, buf->b_fnum);
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
529 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
530 #ifdef FEAT_QUICKFIX
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
531 else if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
532 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
533 {
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16381
diff changeset
534 qf_size = qf_get_valid_size(eap);
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
535 if (qf_size <= 0 || eap->line1 > qf_size)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
536 buf = NULL;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
537 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
538 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
539 ex_cc(eap);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
540
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
541 buf = curbuf;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
542 i = eap->line1 - 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
543 if (eap->addr_count <= 0)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
544 // default is all the quickfix/location list entries
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
545 eap->line2 = qf_size;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
546 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
547 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
548 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 setpcmark();
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
551 listcmd_busy = TRUE; // avoids setting pcmark below
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552
6641
ceda6d8af447 updated for version 7.4.646
Bram Moolenaar <bram@vim.org>
parents: 6474
diff changeset
553 while (!got_int && buf != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 if (eap->cmdidx == CMD_argdo)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
557 // go to argument "i"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 if (i == ARGCOUNT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
560 // Don't call do_argfile() when already there, it will try
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
561 // reloading the file.
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 20
diff changeset
562 if (curwin->w_arg_idx != i || !editing_arg_idx(curwin))
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 29
diff changeset
563 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
564 // Clear 'shm' to avoid that the file message overwrites
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
565 // any output from the command.
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 29
diff changeset
566 p_shm_save = vim_strsave(p_shm);
410fa1a31baf updated for version 7.0023
vimboss
parents: 29
diff changeset
567 set_option_value((char_u *)"shm", 0L, (char_u *)"", 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 do_argfile(eap, i);
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 29
diff changeset
569 set_option_value((char_u *)"shm", 0L, p_shm_save, 0);
410fa1a31baf updated for version 7.0023
vimboss
parents: 29
diff changeset
570 vim_free(p_shm_save);
410fa1a31baf updated for version 7.0023
vimboss
parents: 29
diff changeset
571 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 if (curwin->w_arg_idx != i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 else if (eap->cmdidx == CMD_windo)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
577 // go to window "wp"
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
578 if (!win_valid(wp))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 break;
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
580 win_goto(wp);
1115
11c004cc1a4d updated for version 7.0-241
vimboss
parents: 1069
diff changeset
581 if (curwin != wp)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
582 break; // something must be wrong
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
583 wp = curwin->w_next;
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
584 }
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
585 else if (eap->cmdidx == CMD_tabdo)
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
586 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
587 // go to window "tp"
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
588 if (!valid_tabpage(tp))
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
589 break;
4354
c80838526eeb updated for version 7.3.926
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
590 goto_tabpage_tp(tp, TRUE, TRUE);
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 683
diff changeset
591 tp = tp->tp_next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 else if (eap->cmdidx == CMD_bufdo)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
595 // Remember the number of the next listed buffer, in case
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
596 // ":bwipe" is used or autocommands do something strange.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 next_fnum = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 for (buf = curbuf->b_next; buf != NULL; buf = buf->b_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 if (buf->b_p_bl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 next_fnum = buf->b_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605
6474
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
606 ++i;
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
607
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
608 // execute the command
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 do_cmdline(eap->arg, eap->getline, eap->cookie,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 DOCMD_VERBOSE + DOCMD_NOWAIT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 if (eap->cmdidx == CMD_bufdo)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
614 // Done?
6474
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
615 if (next_fnum < 0 || next_fnum > eap->line2)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
617 // Check if the buffer still exists.
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9626
diff changeset
618 FOR_ALL_BUFFERS(buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 if (buf->b_fnum == next_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 if (buf == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 break;
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 29
diff changeset
623
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
624 // Go to the next buffer. Clear 'shm' to avoid that the file
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
625 // message overwrites any output from the command.
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 29
diff changeset
626 p_shm_save = vim_strsave(p_shm);
410fa1a31baf updated for version 7.0023
vimboss
parents: 29
diff changeset
627 set_option_value((char_u *)"shm", 0L, (char_u *)"", 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 goto_buffer(eap, DOBUF_FIRST, FORWARD, next_fnum);
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 29
diff changeset
629 set_option_value((char_u *)"shm", 0L, p_shm_save, 0);
410fa1a31baf updated for version 7.0023
vimboss
parents: 29
diff changeset
630 vim_free(p_shm_save);
410fa1a31baf updated for version 7.0023
vimboss
parents: 29
diff changeset
631
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
632 // If autocommands took us elsewhere, quit here.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 if (curbuf->b_fnum != next_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
637 #ifdef FEAT_QUICKFIX
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
638 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
639 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
640 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
641 if (i >= qf_size || i >= eap->line2)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
642 break;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
643
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
644 qf_idx = qf_get_cur_idx(eap);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
645
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
646 ex_cnext(eap);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
647
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
648 // If jumping to the next quickfix entry fails, quit here
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
649 if (qf_get_cur_idx(eap) == qf_idx)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
650 break;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
651 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
652 #endif
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7009
diff changeset
653
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 if (eap->cmdidx == CMD_windo)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
656 validate_cursor(); // cursor may have moved
13384
6740c499de13 patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13380
diff changeset
657
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
658 // required when 'scrollbind' has been set
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 if (curwin->w_p_scb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 do_check_scrollbind(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 }
6474
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
662
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
663 if (eap->cmdidx == CMD_windo || eap->cmdidx == CMD_tabdo)
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
664 if (i+1 > eap->line2)
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
665 break;
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
666 if (eap->cmdidx == CMD_argdo && i >= eap->line2)
a88d4dc02bf4 updated for version 7.4.566
Bram Moolenaar <bram@vim.org>
parents: 6375
diff changeset
667 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 listcmd_busy = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13302
diff changeset
672 #if defined(FEAT_SYN_HL)
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
673 if (save_ei != NULL)
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
674 {
17596
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
675 buf_T *bnext;
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
676 aco_save_T aco;
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
677
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
678 au_event_restore(save_ei);
17596
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
679
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
680 for (buf = firstbuf; buf != NULL; buf = bnext)
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
681 {
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
682 bnext = buf->b_next;
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
683 if (buf->b_nwindows > 0 && (buf->b_flags & BF_SYN_SET))
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
684 {
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
685 buf->b_flags &= ~BF_SYN_SET;
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
686
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
687 // buffer was opened while Syntax autocommands were disabled,
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
688 // need to trigger them now.
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
689 if (buf == curbuf)
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
690 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
691 curbuf->b_fname, TRUE, curbuf);
17596
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
692 else
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
693 {
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
694 aucmd_prepbuf(&aco, buf);
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
695 apply_autocmds(EVENT_SYNTAX, buf->b_p_syn,
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
696 buf->b_fname, TRUE, buf);
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
697 aucmd_restbuf(&aco);
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
698 }
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
699
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
700 // start over, in case autocommands messed things up.
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
701 bnext = firstbuf;
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
702 }
892b4ea3bad6 patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents: 17381
diff changeset
703 }
154
1a145815483e updated for version 7.0047
vimboss
parents: 148
diff changeset
704 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 #endif
6116
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5808
diff changeset
706 #ifdef FEAT_CLIPBOARD
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5808
diff changeset
707 end_global_changes();
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5808
diff changeset
708 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 * ":compiler[!] {name}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
716 ex_compiler(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 char_u *old_cur_comp = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 if (*eap->arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
724 // List all compiler scripts.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')");
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
726 // ) keep the indenter happy...
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 {
16764
ef00b6bc186b patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 16738
diff changeset
730 buf = alloc(STRLEN(eap->arg) + 14);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 if (buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 if (eap->forceit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
735 // ":compiler! {name}" sets global options
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 do_cmdline_cmd((char_u *)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 "command -nargs=* CompilerSet set <args>");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
741 // ":compiler! {name}" sets local options.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
742 // To remain backwards compatible "current_compiler" is always
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
743 // used. A user's compiler plugin may set it, the distributed
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
744 // plugin will then skip the settings. Afterwards set
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
745 // "b:current_compiler" and restore "current_compiler".
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
746 // Explicitly prepend "g:" to make it work in a function.
2051
ef2890033e88 updated for version 7.2.337
Bram Moolenaar <bram@zimbu.org>
parents: 1882
diff changeset
747 old_cur_comp = get_var_value((char_u *)"g:current_compiler");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 if (old_cur_comp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 old_cur_comp = vim_strsave(old_cur_comp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 do_cmdline_cmd((char_u *)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 "command -nargs=* CompilerSet setlocal <args>");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 }
2051
ef2890033e88 updated for version 7.2.337
Bram Moolenaar <bram@zimbu.org>
parents: 1882
diff changeset
753 do_unlet((char_u *)"g:current_compiler", TRUE);
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 123
diff changeset
754 do_unlet((char_u *)"b:current_compiler", TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 sprintf((char *)buf, "compiler/%s.vim", eap->arg);
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 8522
diff changeset
757 if (source_runtime(buf, DIP_ALL) == FAIL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15448
diff changeset
758 semsg(_("E666: compiler not supported: %s"), eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 do_cmdline_cmd((char_u *)":delcommand CompilerSet");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
763 // Set "b:current_compiler" from "current_compiler".
2051
ef2890033e88 updated for version 7.2.337
Bram Moolenaar <bram@zimbu.org>
parents: 1882
diff changeset
764 p = get_var_value((char_u *)"g:current_compiler");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 set_internal_string_var((char_u *)"b:current_compiler", p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
768 // Restore "current_compiler" for ":compiler {name}".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 if (!eap->forceit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 if (old_cur_comp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 {
2051
ef2890033e88 updated for version 7.2.337
Bram Moolenaar <bram@zimbu.org>
parents: 1882
diff changeset
773 set_internal_string_var((char_u *)"g:current_compiler",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 old_cur_comp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 vim_free(old_cur_comp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 else
2051
ef2890033e88 updated for version 7.2.337
Bram Moolenaar <bram@zimbu.org>
parents: 1882
diff changeset
778 do_unlet((char_u *)"g:current_compiler", TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
785 #if defined(FEAT_PYTHON3) || defined(FEAT_PYTHON) || defined(PROTO)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
786
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
787 # if (defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)) || defined(PROTO)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
788 /*
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
789 * Detect Python 3 or 2, and initialize 'pyxversion'.
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
790 */
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
791 void
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
792 init_pyxversion(void)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
793 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
794 if (p_pyx == 0)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
795 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
796 if (python3_enabled(FALSE))
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
797 p_pyx = 3;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
798 else if (python_enabled(FALSE))
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
799 p_pyx = 2;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
800 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
801 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
802 # endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
803
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
804 /*
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
805 * Does a file contain one of the following strings at the beginning of any
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
806 * line?
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
807 * "#!(any string)python2" => returns 2
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
808 * "#!(any string)python3" => returns 3
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
809 * "# requires python 2.x" => returns 2
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
810 * "# requires python 3.x" => returns 3
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
811 * otherwise return 0.
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
812 */
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
813 static int
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
814 requires_py_version(char_u *filename)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
815 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
816 FILE *file;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
817 int requires_py_version = 0;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
818 int i, lines;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
819
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
820 lines = (int)p_mls;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
821 if (lines < 0)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
822 lines = 5;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
823
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
824 file = mch_fopen((char *)filename, "r");
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
825 if (file != NULL)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
826 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
827 for (i = 0; i < lines; i++)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
828 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
829 if (vim_fgets(IObuff, IOSIZE, file))
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
830 break;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
831 if (i == 0 && IObuff[0] == '#' && IObuff[1] == '!')
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
832 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
833 // Check shebang.
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
834 if (strstr((char *)IObuff + 2, "python2") != NULL)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
835 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
836 requires_py_version = 2;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
837 break;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
838 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
839 if (strstr((char *)IObuff + 2, "python3") != NULL)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
840 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
841 requires_py_version = 3;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
842 break;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
843 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
844 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
845 IObuff[21] = '\0';
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
846 if (STRCMP("# requires python 2.x", IObuff) == 0)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
847 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
848 requires_py_version = 2;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
849 break;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
850 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
851 if (STRCMP("# requires python 3.x", IObuff) == 0)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
852 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
853 requires_py_version = 3;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
854 break;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
855 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
856 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
857 fclose(file);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
858 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
859 return requires_py_version;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
860 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
861
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
862
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
863 /*
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
864 * Source a python file using the requested python version.
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
865 */
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
866 static void
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
867 source_pyx_file(exarg_T *eap, char_u *fname)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
868 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
869 exarg_T ex;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
870 int v = requires_py_version(fname);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
871
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
872 # if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
873 init_pyxversion();
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
874 # endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
875 if (v == 0)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
876 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
877 # if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
878 // user didn't choose a preference, 'pyx' is used
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
879 v = p_pyx;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
880 # elif defined(FEAT_PYTHON)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
881 v = 2;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
882 # elif defined(FEAT_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
883 v = 3;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
884 # endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
885 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
886
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
887 /*
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
888 * now source, if required python version is not supported show
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
889 * unobtrusive message.
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
890 */
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
891 if (eap == NULL)
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19888
diff changeset
892 CLEAR_FIELD(ex);
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
893 else
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
894 ex = *eap;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
895 ex.arg = fname;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
896 ex.cmd = (char_u *)(v == 2 ? "pyfile" : "pyfile3");
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
897
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
898 if (v == 2)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
899 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
900 # ifdef FEAT_PYTHON
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
901 ex_pyfile(&ex);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
902 # else
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
903 vim_snprintf((char *)IObuff, IOSIZE,
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
904 _("W20: Required python version 2.x not supported, ignoring file: %s"),
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
905 fname);
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
906 msg((char *)IObuff);
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
907 # endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
908 return;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
909 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
910 else
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
911 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
912 # ifdef FEAT_PYTHON3
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
913 ex_py3file(&ex);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
914 # else
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
915 vim_snprintf((char *)IObuff, IOSIZE,
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
916 _("W21: Required python version 3.x not supported, ignoring file: %s"),
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
917 fname);
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
918 msg((char *)IObuff);
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
919 # endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
920 return;
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
921 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
922 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
923
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
924 /*
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
925 * ":pyxfile {fname}"
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
926 */
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
927 void
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
928 ex_pyxfile(exarg_T *eap)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
929 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
930 source_pyx_file(eap, eap->arg);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
931 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
932
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
933 /*
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
934 * ":pyx"
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
935 */
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
936 void
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
937 ex_pyx(exarg_T *eap)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
938 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
939 # if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
940 init_pyxversion();
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
941 if (p_pyx == 2)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
942 ex_python(eap);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
943 else
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
944 ex_py3(eap);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
945 # elif defined(FEAT_PYTHON)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
946 ex_python(eap);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
947 # elif defined(FEAT_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
948 ex_py3(eap);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
949 # endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
950 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
951
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
952 /*
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
953 * ":pyxdo"
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
954 */
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
955 void
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
956 ex_pyxdo(exarg_T *eap)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
957 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
958 # if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
959 init_pyxversion();
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
960 if (p_pyx == 2)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
961 ex_pydo(eap);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
962 else
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
963 ex_py3do(eap);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
964 # elif defined(FEAT_PYTHON)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
965 ex_pydo(eap);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
966 # elif defined(FEAT_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
967 ex_py3do(eap);
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
968 # endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
969 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
970
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
971 #endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10569
diff changeset
972
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 * ":checktime [buffer]"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
977 ex_checktime(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 int save_no_check_timestamps = no_check_timestamps;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 no_check_timestamps = 0;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
983 if (eap->addr_count == 0) // default is all buffers
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 check_timestamps(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 buf = buflist_findnr((int)eap->line2);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
988 if (buf != NULL) // cannot happen?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 (void)buf_check_timestamp(buf, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 no_check_timestamps = save_no_check_timestamps;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 && (defined(FEAT_EVAL) || defined(FEAT_MULTI_LANG))
2419
f579b934f51d Fix build warnings and problems for tiny/small Win32 build. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents: 2250
diff changeset
996 # define HAVE_GET_LOCALE_VAL
8080
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7979
diff changeset
997 static char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
998 get_locale_val(int what)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 {
8080
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7979
diff changeset
1000 char_u *loc;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1002 // Obtain the locale value from the libraries.
8080
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7979
diff changeset
1003 loc = (char_u *)setlocale(what, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15842
diff changeset
1005 # ifdef MSWIN
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 if (loc != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1010 // setocale() returns something like "LC_COLLATE=<name>;LC_..." when
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1011 // one of the values (e.g., LC_CTYPE) differs.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 p = vim_strchr(loc, '=');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 loc = ++p;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1016 while (*p != NUL) // remove trailing newline
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 {
823
9ab23f1e137f updated for version 7.0c12
vimboss
parents: 819
diff changeset
1018 if (*p < ' ' || *p == ';')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 *p = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 return loc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15842
diff changeset
1034 #ifdef MSWIN
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 * On MS-Windows locale names are strings like "German_Germany.1252", but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 * gettext expects "de". Try to translate one into another here for a few
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 * supported languages.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 gettext_lang(char_u *name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 static char *(mtable[]) = {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 "afrikaans", "af",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 "czech", "cs",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 "dutch", "nl",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 "german", "de",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 "english_united kingdom", "en_GB",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 "spanish", "es",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 "french", "fr",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 "italian", "it",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 "japanese", "ja",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 "korean", "ko",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 "norwegian", "no",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 "polish", "pl",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 "russian", "ru",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 "slovak", "sk",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 "swedish", "sv",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 "ukrainian", "uk",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 "chinese_china", "zh_CN",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 "chinese_taiwan", "zh_TW",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 NULL};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 for (i = 0; mtable[i] != NULL; i += 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 if (STRNICMP(mtable[i], name, STRLEN(mtable[i])) == 0)
8080
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7979
diff changeset
1067 return (char_u *)mtable[i + 1];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 return name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 #if defined(FEAT_MULTI_LANG) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 /*
15002
9ae60773dd03 patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents: 14927
diff changeset
1074 * Return TRUE when "lang" starts with a valid language name.
9ae60773dd03 patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents: 14927
diff changeset
1075 * Rejects NULL, empty string, "C", "C.UTF-8" and others.
9ae60773dd03 patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents: 14927
diff changeset
1076 */
9ae60773dd03 patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents: 14927
diff changeset
1077 static int
9ae60773dd03 patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents: 14927
diff changeset
1078 is_valid_mess_lang(char_u *lang)
9ae60773dd03 patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents: 14927
diff changeset
1079 {
9ae60773dd03 patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents: 14927
diff changeset
1080 return lang != NULL && ASCII_ISALPHA(lang[0]) && ASCII_ISALPHA(lang[1]);
9ae60773dd03 patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents: 14927
diff changeset
1081 }
9ae60773dd03 patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents: 14927
diff changeset
1082
9ae60773dd03 patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents: 14927
diff changeset
1083 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 * Obtain the current messages language. Used to set the default for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 * 'helplang'. May return NULL or an empty string.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1088 get_mess_lang(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091
2419
f579b934f51d Fix build warnings and problems for tiny/small Win32 build. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents: 2250
diff changeset
1092 # ifdef HAVE_GET_LOCALE_VAL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 # if defined(LC_MESSAGES)
8080
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7979
diff changeset
1094 p = get_locale_val(LC_MESSAGES);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 # else
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1096 // This is necessary for Win32, where LC_MESSAGES is not defined and $LANG
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1097 // may be set to the LCID number. LC_COLLATE is the best guess, LC_TIME
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1098 // and LC_MONETARY may be set differently for a Japanese working in the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1099 // US.
8080
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7979
diff changeset
1100 p = get_locale_val(LC_COLLATE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 p = mch_getenv((char_u *)"LC_ALL");
15002
9ae60773dd03 patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents: 14927
diff changeset
1104 if (!is_valid_mess_lang(p))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 p = mch_getenv((char_u *)"LC_MESSAGES");
15002
9ae60773dd03 patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents: 14927
diff changeset
1107 if (!is_valid_mess_lang(p))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 p = mch_getenv((char_u *)"LANG");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 # endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15842
diff changeset
1111 # ifdef MSWIN
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 p = gettext_lang(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 # endif
15002
9ae60773dd03 patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Bram Moolenaar <Bram@vim.org>
parents: 14927
diff changeset
1114 return is_valid_mess_lang(p) ? p : NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1118 // Complicated #if; matches with where get_mess_env() is used below.
45
e474bae3795f updated for version 7.0027
vimboss
parents: 41
diff changeset
1119 #if (defined(FEAT_EVAL) && !((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
e474bae3795f updated for version 7.0027
vimboss
parents: 41
diff changeset
1120 && defined(LC_MESSAGES))) \
e474bae3795f updated for version 7.0027
vimboss
parents: 41
diff changeset
1121 || ((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
e474bae3795f updated for version 7.0027
vimboss
parents: 41
diff changeset
1122 && !defined(LC_MESSAGES))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 * Get the language used for messages from the environment.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 static char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1127 get_mess_env(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 p = mch_getenv((char_u *)"LC_ALL");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 if (p == NULL || *p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 p = mch_getenv((char_u *)"LC_MESSAGES");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 if (p == NULL || *p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 p = mch_getenv((char_u *)"LANG");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 if (p != NULL && VIM_ISDIGIT(*p))
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1139 p = NULL; // ignore something like "1043"
2419
f579b934f51d Fix build warnings and problems for tiny/small Win32 build. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents: 2250
diff changeset
1140 # ifdef HAVE_GET_LOCALE_VAL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 if (p == NULL || *p == NUL)
8080
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7979
diff changeset
1142 p = get_locale_val(LC_CTYPE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 #if defined(FEAT_EVAL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 * Set the "v:lang" variable according to the current locale setting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 * Also do "v:lc_time"and "v:ctype".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1157 set_lang_var(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 char_u *loc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160
2419
f579b934f51d Fix build warnings and problems for tiny/small Win32 build. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents: 2250
diff changeset
1161 # ifdef HAVE_GET_LOCALE_VAL
8080
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7979
diff changeset
1162 loc = get_locale_val(LC_CTYPE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 # else
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1164 // setlocale() not supported: use the default value
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 loc = (char_u *)"C";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 set_vim_var_string(VV_CTYPE, loc, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1169 // When LC_MESSAGES isn't defined use the value from $LC_MESSAGES, fall
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1170 // back to LC_CTYPE if it's empty.
2419
f579b934f51d Fix build warnings and problems for tiny/small Win32 build. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents: 2250
diff changeset
1171 # if defined(HAVE_GET_LOCALE_VAL) && defined(LC_MESSAGES)
8080
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7979
diff changeset
1172 loc = get_locale_val(LC_MESSAGES);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 loc = get_mess_env();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 set_vim_var_string(VV_LANG, loc, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177
2419
f579b934f51d Fix build warnings and problems for tiny/small Win32 build. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents: 2250
diff changeset
1178 # ifdef HAVE_GET_LOCALE_VAL
8080
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7979
diff changeset
1179 loc = get_locale_val(LC_TIME);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 set_vim_var_string(VV_LC_TIME, loc, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
1185 #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) \
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 * ":language": Set the language (locale).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1190 ex_language(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 char *loc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 int what = LC_ALL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 char *whatstr = "";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 #ifdef LC_MESSAGES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 # define VIM_LC_MESSAGES LC_MESSAGES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 # define VIM_LC_MESSAGES 6789
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 name = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1205 // Check for "messages {name}", "ctype {name}" or "time {name}" argument.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1206 // Allow abbreviation, but require at least 3 characters to avoid
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1207 // confusion with a two letter language name "me" or "ct".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 p = skiptowhite(eap->arg);
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
1209 if ((*p == NUL || VIM_ISWHITE(*p)) && p - eap->arg >= 3)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 if (STRNICMP(eap->arg, "messages", p - eap->arg) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 what = VIM_LC_MESSAGES;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 name = skipwhite(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 whatstr = "messages ";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 else if (STRNICMP(eap->arg, "ctype", p - eap->arg) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 what = LC_CTYPE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 name = skipwhite(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 whatstr = "ctype ";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 else if (STRNICMP(eap->arg, "time", p - eap->arg) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 what = LC_TIME;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 name = skipwhite(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 whatstr = "time ";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 if (*name == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 #ifndef LC_MESSAGES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 if (what == VIM_LC_MESSAGES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 p = get_mess_env();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 p = (char_u *)setlocale(what, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 if (p == NULL || *p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 p = (char_u *)"Unknown";
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15448
diff changeset
1241 smsg(_("Current %slanguage: \"%s\""), whatstr, p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 #ifndef LC_MESSAGES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 if (what == VIM_LC_MESSAGES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 loc = "";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 #endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1517
diff changeset
1250 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 loc = setlocale(what, (char *)name);
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1517
diff changeset
1252 #if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1253 // Make sure strtod() uses a decimal point, not a comma.
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1517
diff changeset
1254 setlocale(LC_NUMERIC, "C");
18ee39301b82 updated for version 7.2a
vimboss
parents: 1517
diff changeset
1255 #endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 1517
diff changeset
1256 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 if (loc == NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15448
diff changeset
1258 semsg(_("E197: Cannot set language to \"%s\""), name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 #ifdef HAVE_NL_MSG_CAT_CNTR
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1262 // Need to do this for GNU gettext, otherwise cached translations
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1263 // will be used again.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 extern int _nl_msg_cat_cntr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 ++_nl_msg_cat_cntr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1268 // Reset $LC_ALL, otherwise it would overrule everything.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 vim_setenv((char_u *)"LC_ALL", (char_u *)"");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 if (what != LC_TIME)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1273 // Tell gettext() what to translate to. It apparently doesn't
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1274 // use the currently effective locale. Also do this when
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1275 // FEAT_GETTEXT isn't defined, so that shell commands use this
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1276 // value.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 if (what == LC_ALL)
534
c6296b0ad9ea updated for version 7.0151
vimboss
parents: 531
diff changeset
1278 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 vim_setenv((char_u *)"LANG", name);
5027
5751284311f3 updated for version 7.3.1257
Bram Moolenaar <bram@vim.org>
parents: 4833
diff changeset
1280
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1281 // Clear $LANGUAGE because GNU gettext uses it.
5027
5751284311f3 updated for version 7.3.1257
Bram Moolenaar <bram@vim.org>
parents: 4833
diff changeset
1282 vim_setenv((char_u *)"LANGUAGE", (char_u *)"");
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15842
diff changeset
1283 # ifdef MSWIN
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1284 // Apparently MS-Windows printf() may cause a crash when
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1285 // we give it 8-bit text while it's expecting text in the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1286 // current locale. This call avoids that.
534
c6296b0ad9ea updated for version 7.0151
vimboss
parents: 531
diff changeset
1287 setlocale(LC_CTYPE, "C");
c6296b0ad9ea updated for version 7.0151
vimboss
parents: 531
diff changeset
1288 # endif
c6296b0ad9ea updated for version 7.0151
vimboss
parents: 531
diff changeset
1289 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 if (what != LC_CTYPE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 char_u *mname;
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15842
diff changeset
1293 #ifdef MSWIN
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 mname = gettext_lang(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 mname = name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 vim_setenv((char_u *)"LC_MESSAGES", mname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 #ifdef FEAT_MULTI_LANG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 set_helplang_default(mname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 # ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1306 // Set v:lang, v:lc_time and v:ctype to the final result.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 set_lang_var();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 # endif
3149
35f098371af6 updated for version 7.3.345
Bram Moolenaar <bram@vim.org>
parents: 2921
diff changeset
1309 # ifdef FEAT_TITLE
35f098371af6 updated for version 7.3.345
Bram Moolenaar <bram@vim.org>
parents: 2921
diff changeset
1310 maketitle();
35f098371af6 updated for version 7.3.345
Bram Moolenaar <bram@vim.org>
parents: 2921
diff changeset
1311 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1316 static char_u **locales = NULL; // Array of all available locales
10569
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1317
17781
04245f071792 patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
1318 # ifndef MSWIN
2849
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1319 static int did_init_locales = FALSE;
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1320
17781
04245f071792 patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
1321 /*
04245f071792 patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
1322 * Return an array of strings for all available locales + NULL for the
04245f071792 patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
1323 * last element. Return NULL in case of error.
04245f071792 patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
1324 */
2849
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1325 static char_u **
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1326 find_locales(void)
2849
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1327 {
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1328 garray_T locales_ga;
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1329 char_u *loc;
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1330
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1331 // Find all available locales by running command "locale -a". If this
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1332 // doesn't work we won't have completion.
2849
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1333 char_u *locale_a = get_cmd_output((char_u *)"locale -a",
5808
e5f1f2ea0b4a updated for version 7.4.248
Bram Moolenaar <bram@vim.org>
parents: 5464
diff changeset
1334 NULL, SHELL_SILENT, NULL);
2849
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1335 if (locale_a == NULL)
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1336 return NULL;
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1337 ga_init2(&locales_ga, sizeof(char_u *), 20);
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1338
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1339 // Transform locale_a string where each locale is separated by "\n"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18051
diff changeset
1340 // into an array of locale strings.
2849
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1341 loc = (char_u *)strtok((char *)locale_a, "\n");
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1342
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1343 while (loc != NULL)
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1344 {
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1345 if (ga_grow(&locales_ga, 1) == FAIL)
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1346 break;
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1347 loc = vim_strsave(loc);
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1348 if (loc == NULL)
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1349 break;
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1350
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1351 ((char_u **)locales_ga.ga_data)[locales_ga.ga_len++] = loc;
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1352 loc = (char_u *)strtok(NULL, "\n");
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1353 }
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1354 vim_free(locale_a);
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1355 if (ga_grow(&locales_ga, 1) == FAIL)
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1356 {
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1357 ga_clear(&locales_ga);
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1358 return NULL;
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1359 }
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1360 ((char_u **)locales_ga.ga_data)[locales_ga.ga_len] = NULL;
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1361 return (char_u **)locales_ga.ga_data;
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1362 }
17781
04245f071792 patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
1363 # endif
10569
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1364
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1365 /*
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1366 * Lazy initialization of all available locales.
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1367 */
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1368 static void
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1369 init_locales(void)
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1370 {
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15842
diff changeset
1371 # ifndef MSWIN
10569
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1372 if (!did_init_locales)
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1373 {
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1374 did_init_locales = TRUE;
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1375 locales = find_locales();
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1376 }
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1377 # endif
0bf064e7917a patch 8.0.0174: executing "locale -a" on MS-Windows needlessly
Christian Brabandt <cb@256bit.org>
parents: 10262
diff changeset
1378 }
2849
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1379
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1380 # if defined(EXITFREE) || defined(PROTO)
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1381 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1382 free_locales(void)
2849
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1383 {
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1384 int i;
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1385 if (locales != NULL)
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1386 {
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1387 for (i = 0; locales[i] != NULL; i++)
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1388 vim_free(locales[i]);
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13190
diff changeset
1389 VIM_CLEAR(locales);
2849
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1390 }
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1391 }
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1392 # endif
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1393
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 * Function given to ExpandGeneric() to obtain the possible arguments of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 * ":language" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1399 get_lang_arg(expand_T *xp UNUSED, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 if (idx == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 return (char_u *)"messages";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 if (idx == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 return (char_u *)"ctype";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 if (idx == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 return (char_u *)"time";
2849
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1407
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1408 init_locales();
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1409 if (locales == NULL)
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1410 return NULL;
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1411 return locales[idx - 3];
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1412 }
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1413
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1414 /*
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1415 * Function given to ExpandGeneric() to obtain the available locales.
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1416 */
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1417 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1418 get_locales(expand_T *xp UNUSED, int idx)
2849
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1419 {
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1420 init_locales();
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1421 if (locales == NULL)
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1422 return NULL;
b0190e93e601 updated for version 7.3.198
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
1423 return locales[idx];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 #endif