Mercurial > vim
annotate src/macros.h @ 32032:265476b2cfeb
Added tag v9.0.1347 for changeset e9b8deedab606e4e7bd40237c853df9ac5e4bf41
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 23 Feb 2023 21:15:04 +0100 |
parents | 50555279168b |
children | 04d9dff67d99 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9925
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 */ | |
8 | |
9 /* | |
10 * macros.h: macro definitions for often used code | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
11 * |
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
12 * Macros should be ALL_CAPS. An exception is for where a function is |
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
13 * replaced and an argument is not used more than once. |
7 | 14 */ |
15 | |
16 /* | |
14216
12bdbf9f7e20
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
17 * PBYTE(lp, c) - put byte 'c' at position 'lp' |
7 | 18 */ |
14216
12bdbf9f7e20
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
19 #define PBYTE(lp, c) (*(ml_get_buf(curbuf, (lp).lnum, TRUE) + (lp).col) = (c)) |
7 | 20 |
21 /* | |
22 * Position comparisons | |
23 */ | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
24 #define LT_POS(a, b) (((a).lnum != (b).lnum) \ |
7 | 25 ? (a).lnum < (b).lnum \ |
26 : (a).col != (b).col \ | |
27 ? (a).col < (b).col \ | |
28 : (a).coladd < (b).coladd) | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
29 #define LT_POSP(a, b) (((a)->lnum != (b)->lnum) \ |
7 | 30 ? (a)->lnum < (b)->lnum \ |
31 : (a)->col != (b)->col \ | |
32 ? (a)->col < (b)->col \ | |
33 : (a)->coladd < (b)->coladd) | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15605
diff
changeset
|
34 #define EQUAL_POS(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col) && ((a).coladd == (b).coladd)) |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
35 #define CLEAR_POS(a) do {(a)->lnum = 0; (a)->col = 0; (a)->coladd = 0;} while (0) |
20647
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20392
diff
changeset
|
36 #define EMPTY_POS(a) ((a).lnum == 0 && (a).col == 0 && (a).coladd == 0) |
7 | 37 |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10344
diff
changeset
|
38 #define LTOREQ_POS(a, b) (LT_POS(a, b) || EQUAL_POS(a, b)) |
7 | 39 |
40 /* | |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19629
diff
changeset
|
41 * VIM_ISWHITE() differs from isspace() because it doesn't include <CR> and |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19629
diff
changeset
|
42 * <LF> and the like. |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
43 */ |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19629
diff
changeset
|
44 #define VIM_ISWHITE(x) ((x) == ' ' || (x) == '\t') |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19629
diff
changeset
|
45 #define IS_WHITE_OR_NUL(x) ((x) == ' ' || (x) == '\t' || (x) == NUL) |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
46 |
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
47 /* |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10344
diff
changeset
|
48 * LINEEMPTY() - return TRUE if the line is empty |
7 | 49 */ |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10344
diff
changeset
|
50 #define LINEEMPTY(p) (*ml_get(p) == NUL) |
7 | 51 |
52 /* | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10344
diff
changeset
|
53 * BUFEMPTY() - return TRUE if the current buffer is empty |
7 | 54 */ |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10344
diff
changeset
|
55 #define BUFEMPTY() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == NUL) |
7 | 56 |
57 /* | |
58 * toupper() and tolower() that use the current locale. | |
1365 | 59 * On some systems toupper()/tolower() only work on lower/uppercase |
60 * characters, first use islower() or isupper() then. | |
7 | 61 * Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the |
62 * range 0 - 255. toupper()/tolower() on some systems can't handle others. | |
1365 | 63 * Note: It is often better to use MB_TOLOWER() and MB_TOUPPER(), because many |
64 * toupper() and tolower() implementations only work for ASCII. | |
7 | 65 */ |
66 #ifdef MSWIN | |
67 # define TOUPPER_LOC(c) toupper_tab[(c) & 255] | |
68 # define TOLOWER_LOC(c) tolower_tab[(c) & 255] | |
69 #else | |
70 # ifdef BROKEN_TOUPPER | |
71 # define TOUPPER_LOC(c) (islower(c) ? toupper(c) : (c)) | |
72 # define TOLOWER_LOC(c) (isupper(c) ? tolower(c) : (c)) | |
73 # else | |
74 # define TOUPPER_LOC toupper | |
75 # define TOLOWER_LOC tolower | |
76 # endif | |
77 #endif | |
78 | |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
79 // toupper() and tolower() for ASCII only and ignore the current locale. |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27342
diff
changeset
|
80 #define TOUPPER_ASC(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A')) |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27342
diff
changeset
|
81 #define TOLOWER_ASC(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A')) |
7 | 82 |
83 /* | |
84 * MB_ISLOWER() and MB_ISUPPER() are to be used on multi-byte characters. But | |
492 | 85 * don't use them for negative values! |
7 | 86 */ |
15605
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15034
diff
changeset
|
87 #define MB_ISLOWER(c) vim_islower(c) |
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15034
diff
changeset
|
88 #define MB_ISUPPER(c) vim_isupper(c) |
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15034
diff
changeset
|
89 #define MB_TOLOWER(c) vim_tolower(c) |
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15034
diff
changeset
|
90 #define MB_TOUPPER(c) vim_toupper(c) |
20772
097f5b5c907b
patch 8.2.0938: NFA regexp uses tolower ()to compare ignore-case
Bram Moolenaar <Bram@vim.org>
parents:
20647
diff
changeset
|
91 #define MB_CASEFOLD(c) (enc_utf8 ? utf_fold(c) : MB_TOLOWER(c)) |
7 | 92 |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
93 // Use our own isdigit() replacement, because on MS-Windows isdigit() returns |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
94 // non-zero for superscript 1. Also avoids that isdigit() crashes for numbers |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
95 // below 0 and above 255. |
4857
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4849
diff
changeset
|
96 #define VIM_ISDIGIT(c) ((unsigned)(c) - '0' < 10) |
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4849
diff
changeset
|
97 |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
98 // Like isalpha() but reject non-ASCII characters. Can't be used with a |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
99 // special key (negative value). |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27342
diff
changeset
|
100 #define ASCII_ISLOWER(c) ((unsigned)(c) - 'a' < 26) |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27342
diff
changeset
|
101 #define ASCII_ISUPPER(c) ((unsigned)(c) - 'A' < 26) |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27342
diff
changeset
|
102 #define ASCII_ISALPHA(c) (ASCII_ISUPPER(c) || ASCII_ISLOWER(c)) |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27342
diff
changeset
|
103 #define ASCII_ISALNUM(c) (ASCII_ISALPHA(c) || VIM_ISDIGIT(c)) |
7 | 104 |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
105 // Returns empty string if it is NULL. |
8247
6ee794dc950e
commit https://github.com/vim/vim/commit/669cac0a805333e69b9e1176425083914eada659
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
106 #define EMPTY_IF_NULL(x) ((x) ? (x) : (char_u *)"") |
6909 | 107 |
7 | 108 #ifdef FEAT_LANGMAP |
109 /* | |
110 * Adjust chars in a language according to 'langmap' option. | |
1811 | 111 * NOTE that there is no noticeable overhead if 'langmap' is not set. |
112 * When set the overhead for characters < 256 is small. | |
6339 | 113 * Don't apply 'langmap' if the character comes from the Stuff buffer or from |
114 * a mapping and the langnoremap option was set. | |
7 | 115 * The do-while is just to ignore a ';' after the macro. |
116 */ | |
15605
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15034
diff
changeset
|
117 # define LANGMAP_ADJUST(c, condition) \ |
1811 | 118 do { \ |
6339 | 119 if (*p_langmap \ |
120 && (condition) \ | |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9898
diff
changeset
|
121 && (p_lrm || (!p_lrm && KeyTyped)) \ |
6339 | 122 && !KeyStuffed \ |
123 && (c) >= 0) \ | |
1811 | 124 { \ |
125 if ((c) < 256) \ | |
126 c = langmap_mapchar[c]; \ | |
127 else \ | |
128 c = langmap_adjust_mb(c); \ | |
129 } \ | |
7 | 130 } while (0) |
1811 | 131 #else |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
132 # define LANGMAP_ADJUST(c, condition) // nop |
7 | 133 #endif |
134 | |
135 /* | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
136 * VIM_ISBREAK() is used very often if 'linebreak' is set, use a macro to make |
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
137 * it work fast. Only works for single byte characters! |
7 | 138 */ |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
139 #define VIM_ISBREAK(c) ((c) < 256 && breakat_flags[(char_u)(c)]) |
7 | 140 |
141 /* | |
142 * On VMS file names are different and require a translation. | |
143 * On the Mac open() has only two arguments. | |
144 */ | |
145 #ifdef VMS | |
146 # define mch_access(n, p) access(vms_fixfilename(n), (p)) | |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
147 // see mch_open() comment |
7 | 148 # define mch_fopen(n, p) fopen(vms_fixfilename(n), (p)) |
23408
bdda90ed5f6c
patch 8.2.2247: VMS: various smaller problems
Bram Moolenaar <Bram@vim.org>
parents:
21640
diff
changeset
|
149 # define mch_fstat(n, p) fstat((n), (p)) |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
150 # undef HAVE_LSTAT // VMS does not have lstat() |
7 | 151 # define mch_stat(n, p) stat(vms_fixfilename(n), (p)) |
152 #else | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
153 # ifndef MSWIN |
7 | 154 # define mch_access(n, p) access((n), (p)) |
155 # endif | |
21640
e7801d132dcb
patch 8.2.1370: MS-Windows: warning for using fstat() with stat_T
Bram Moolenaar <Bram@vim.org>
parents:
20772
diff
changeset
|
156 |
27342
41a940219183
patch 8.2.4199: MS-Windows: Support for MSVC 2003 is not useful
Bram Moolenaar <Bram@vim.org>
parents:
25477
diff
changeset
|
157 // Use 64-bit fstat function on MS-Windows. |
21640
e7801d132dcb
patch 8.2.1370: MS-Windows: warning for using fstat() with stat_T
Bram Moolenaar <Bram@vim.org>
parents:
20772
diff
changeset
|
158 // NOTE: This condition is the same as for the stat_T type. |
27342
41a940219183
patch 8.2.4199: MS-Windows: Support for MSVC 2003 is not useful
Bram Moolenaar <Bram@vim.org>
parents:
25477
diff
changeset
|
159 # ifdef MSWIN |
21640
e7801d132dcb
patch 8.2.1370: MS-Windows: warning for using fstat() with stat_T
Bram Moolenaar <Bram@vim.org>
parents:
20772
diff
changeset
|
160 # define mch_fstat(n, p) _fstat64((n), (p)) |
e7801d132dcb
patch 8.2.1370: MS-Windows: warning for using fstat() with stat_T
Bram Moolenaar <Bram@vim.org>
parents:
20772
diff
changeset
|
161 # else |
e7801d132dcb
patch 8.2.1370: MS-Windows: warning for using fstat() with stat_T
Bram Moolenaar <Bram@vim.org>
parents:
20772
diff
changeset
|
162 # define mch_fstat(n, p) fstat((n), (p)) |
e7801d132dcb
patch 8.2.1370: MS-Windows: warning for using fstat() with stat_T
Bram Moolenaar <Bram@vim.org>
parents:
20772
diff
changeset
|
163 # endif |
e7801d132dcb
patch 8.2.1370: MS-Windows: warning for using fstat() with stat_T
Bram Moolenaar <Bram@vim.org>
parents:
20772
diff
changeset
|
164 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
165 # ifdef MSWIN // has its own mch_stat() function |
7 | 166 # define mch_stat(n, p) vim_stat((n), (p)) |
167 # else | |
168 # ifdef STAT_IGNORES_SLASH | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
169 # define mch_stat(n, p) vim_stat((n), (p)) |
7 | 170 # else |
171 # define mch_stat(n, p) stat((n), (p)) | |
172 # endif | |
173 # endif | |
174 #endif | |
175 | |
21 | 176 #ifdef HAVE_LSTAT |
177 # define mch_lstat(n, p) lstat((n), (p)) | |
178 #else | |
179 # define mch_lstat(n, p) mch_stat((n), (p)) | |
180 #endif | |
181 | |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
11921
diff
changeset
|
182 #ifdef VMS |
7 | 183 /* |
184 * It is possible to force some record format with: | |
185 * # define mch_open(n, m, p) open(vms_fixfilename(n), (m), (p)), "rat=cr", "rfm=stmlf", "mrs=0") | |
1199 | 186 * but it is not recommended, because it can destroy indexes etc. |
7 | 187 */ |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
11921
diff
changeset
|
188 # define mch_open(n, m, p) open(vms_fixfilename(n), (m), (p)) |
7 | 189 #endif |
190 | |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
191 // mch_open_rw(): invoke mch_open() with third argument for user R/W. |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
192 #if defined(UNIX) || defined(VMS) // open in rw------- mode |
7 | 193 # define mch_open_rw(n, f) mch_open((n), (f), (mode_t)0600) |
194 #else | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
195 # if defined(MSWIN) // open read/write |
7 | 196 # define mch_open_rw(n, f) mch_open((n), (f), S_IREAD | S_IWRITE) |
197 # else | |
198 # define mch_open_rw(n, f) mch_open((n), (f), 0) | |
199 # endif | |
200 #endif | |
201 | |
202 #ifdef STARTUPTIME | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
203 # define TIME_MSG(s) do { if (time_fd != NULL) time_msg(s, NULL); } while (0) |
7 | 204 #else |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
205 # define TIME_MSG(s) do { /**/ } while (0) |
7 | 206 #endif |
207 | |
14424
0a69e6e708f9
patch 8.1.0226: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
14216
diff
changeset
|
208 #define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG)) |
7 | 209 |
210 #ifdef FEAT_ARABIC | |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
211 # define ARABIC_CHAR(ch) (((ch) & 0xFF00) == 0x0600) |
7 | 212 # define UTF_COMPOSINGLIKE(p1, p2) utf_composinglike((p1), (p2)) |
213 #else | |
214 # define UTF_COMPOSINGLIKE(p1, p2) utf_iscomposing(utf_ptr2char(p2)) | |
215 #endif | |
216 | |
217 #ifdef FEAT_RIGHTLEFT | |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
218 // Whether to draw the vertical bar on the right side of the cell. |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28226
diff
changeset
|
219 # define CURSOR_BAR_RIGHT (curwin->w_p_rl && (!(State & MODE_CMDLINE) || cmdmsg_rl)) |
7 | 220 #endif |
13 | 221 |
39 | 222 /* |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
223 * MB_PTR_ADV(): advance a pointer to the next character, taking care of |
39 | 224 * multi-byte characters if needed. |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
225 * MB_PTR_BACK(): backup a pointer to the previous character, taking care of |
39 | 226 * multi-byte characters if needed. |
98 | 227 * MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers. |
456 | 228 * PTR2CHAR(): get character from pointer. |
39 | 229 */ |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
230 // Advance multi-byte pointer, skip over composing chars. |
18251
c8a53c0daeed
patch 8.1.2120: some MB_ macros are more complicated than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18249
diff
changeset
|
231 #define MB_PTR_ADV(p) p += (*mb_ptr2len)(p) |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
232 // Advance multi-byte pointer, do not skip over composing chars. |
18251
c8a53c0daeed
patch 8.1.2120: some MB_ macros are more complicated than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18249
diff
changeset
|
233 #define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p) |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
234 // Backup multi-byte pointer. Only use with "p" > "s" ! |
28226
89c181c99e23
patch 8.2.4639: not sufficient parenthesis in preprocessor macros
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
235 #define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, (p) - 1) + 1) : 1 |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
236 // get length of multi-byte char, not including composing chars |
15605
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15034
diff
changeset
|
237 #define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p)) |
474 | 238 |
28226
89c181c99e23
patch 8.2.4639: not sufficient parenthesis in preprocessor macros
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
239 #define MB_COPY_CHAR(f, t) do { if (has_mbyte) mb_copy_char(&(f), &(t)); else *(t)++ = *(f)++; } while (0) |
15605
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15034
diff
changeset
|
240 #define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p)) |
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15034
diff
changeset
|
241 #define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1) |
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15034
diff
changeset
|
242 #define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p)) |
24055
90d1636a8fcb
patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents:
24043
diff
changeset
|
243 #define MB_CHAR2BYTES(c, b) do { if (has_mbyte) (b) += (*mb_char2bytes)((c), (b)); else *(b)++ = (c); } while(0) |
961 | 244 |
245 #ifdef FEAT_AUTOCHDIR | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
246 # define DO_AUTOCHDIR do { if (p_acd) do_autochdir(); } while (0) |
961 | 247 #else |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
248 # define DO_AUTOCHDIR do { /**/ } while (0) |
961 | 249 #endif |
2583 | 250 |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
251 #define RESET_BINDING(wp) do { (wp)->w_p_scb = FALSE; (wp)->w_p_crb = FALSE; \ |
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
252 } while (0) |
7103
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
6909
diff
changeset
|
253 |
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
6909
diff
changeset
|
254 #ifdef FEAT_DIFF |
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
6909
diff
changeset
|
255 # define PLINES_NOFILL(x) plines_nofill(x) |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30316
diff
changeset
|
256 # define PLINES_WIN_NOFILL(w, l, h) plines_win_nofill((w), (l), (h)) |
7103
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
6909
diff
changeset
|
257 #else |
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
6909
diff
changeset
|
258 # define PLINES_NOFILL(x) plines(x) |
31577
3c21865e8068
patch 9.0.1121: cursor positioning and display problems with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30316
diff
changeset
|
259 # define PLINES_WIN_NOFILL(w, l, h) plines_win((w), (l), (h)) |
7103
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
6909
diff
changeset
|
260 #endif |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7103
diff
changeset
|
261 |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8395
diff
changeset
|
262 #if defined(FEAT_JOB_CHANNEL) || defined(FEAT_CLIENTSERVER) |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7103
diff
changeset
|
263 # define MESSAGE_QUEUE |
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7103
diff
changeset
|
264 #endif |
8289
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
265 |
30316
f0afaca0bf74
patch 9.0.0494: small build misses float function declaraitons
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
266 #include <float.h> |
f0afaca0bf74
patch 9.0.0494: small build misses float function declaraitons
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
267 #if defined(HAVE_MATH_H) |
f0afaca0bf74
patch 9.0.0494: small build misses float function declaraitons
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
268 // for isnan() and isinf() |
f0afaca0bf74
patch 9.0.0494: small build misses float function declaraitons
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
269 # include <math.h> |
f0afaca0bf74
patch 9.0.0494: small build misses float function declaraitons
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
270 #endif |
f0afaca0bf74
patch 9.0.0494: small build misses float function declaraitons
Bram Moolenaar <Bram@vim.org>
parents:
30310
diff
changeset
|
271 |
30310
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
272 #if defined(FEAT_EVAL) |
8295
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
273 # ifdef USING_FLOAT_STUFF |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
274 # ifdef MSWIN |
8295
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
275 # ifndef isnan |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
276 # define isnan(x) _isnan(x) |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
277 static __inline int isinf(double x) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
278 { return !_finite(x) && !_isnan(x); } |
8295
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
279 # endif |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
280 # else |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
281 # ifndef HAVE_ISNAN |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
282 static inline int isnan(double x) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
283 { return x != x; } |
8295
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
284 # endif |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
285 # ifndef HAVE_ISINF |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
286 static inline int isinf(double x) |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
287 { return !isnan(x) && isnan(x - x); } |
8295
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
288 # endif |
8289
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
289 # endif |
8295
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
290 # if !defined(INFINITY) |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
291 # if defined(DBL_MAX) |
10344
e70ff5756201
commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
292 # ifdef VMS |
e70ff5756201
commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
293 # define INFINITY DBL_MAX |
e70ff5756201
commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
294 # else |
e70ff5756201
commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
295 # define INFINITY (DBL_MAX+DBL_MAX) |
e70ff5756201
commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
296 # endif |
8295
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
297 # else |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
298 # define INFINITY (1.0 / 0.0) |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
299 # endif |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
300 # endif |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
301 # if !defined(NAN) |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
302 # define NAN (INFINITY-INFINITY) |
8289
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
303 # endif |
11461
5be73ebf6a15
patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
304 # if !defined(DBL_EPSILON) |
5be73ebf6a15
patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
305 # define DBL_EPSILON 2.2204460492503131e-16 |
5be73ebf6a15
patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
306 # endif |
8289
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
307 # endif |
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
308 #endif |
9570
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
309 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
310 #ifdef FEAT_EVAL |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
311 # define FUNCARG(fp, j) ((char_u **)(fp->uf_args.ga_data))[j] |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
312 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
313 |
9570
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
314 /* |
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
315 * In a hashtab item "hi_key" points to "di_key" in a dictitem. |
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
316 * This avoids adding a pointer to the hashtab item. |
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
317 * DI2HIKEY() converts a dictitem pointer to a hashitem key pointer. |
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
318 * HIKEY2DI() converts a hashitem key pointer to a dictitem pointer. |
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
319 * HI2DI() converts a hashitem pointer to a dictitem pointer. |
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
320 */ |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
321 #define DI2HIKEY(di) ((di)->di_key) |
28226
89c181c99e23
patch 8.2.4639: not sufficient parenthesis in preprocessor macros
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
322 #define HIKEY2DI(p) ((dictitem_T *)((p) - offsetof(dictitem_T, di_key))) |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
323 #define HI2DI(hi) HIKEY2DI((hi)->hi_key) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
324 |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
325 /* |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
326 * Flush control functions. |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
327 */ |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
328 #ifdef FEAT_GUI |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
329 # define mch_enable_flush() gui_enable_flush() |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
330 # define mch_disable_flush() gui_disable_flush() |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
331 #else |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
332 # define mch_enable_flush() |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
333 # define mch_disable_flush() |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
334 #endif |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
335 |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
336 /* |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
337 * Like vim_free(), and also set the pointer to NULL. |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
338 */ |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
339 #define VIM_CLEAR(p) \ |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
340 do { \ |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
341 if ((p) != NULL) \ |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
31577
diff
changeset
|
342 { \ |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
343 vim_free(p); \ |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
344 (p) = NULL; \ |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
345 } \ |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
346 } while (0) |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
347 |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
348 // Whether a command index indicates a user command. |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
349 #define IS_USER_CMDIDX(idx) ((int)(idx) < 0) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
350 |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16874
diff
changeset
|
351 // Give an error in curwin is a popup window and evaluate to TRUE. |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18753
diff
changeset
|
352 #ifdef FEAT_PROP_POPUP |
19542
9e428147e4ee
patch 8.2.0328: no redraw when leaving term-normal mode in popup terminal
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
353 # define WIN_IS_POPUP(wp) ((wp)->w_popup_flags != 0) |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19269
diff
changeset
|
354 # define ERROR_IF_POPUP_WINDOW error_if_popup_window(FALSE) |
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19269
diff
changeset
|
355 # define ERROR_IF_ANY_POPUP_WINDOW error_if_popup_window(TRUE) |
19269
a8a915898b35
patch 8.2.0193: still build failure without +terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
356 #else |
19542
9e428147e4ee
patch 8.2.0328: no redraw when leaving term-normal mode in popup terminal
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
357 # define WIN_IS_POPUP(wp) 0 |
19269
a8a915898b35
patch 8.2.0193: still build failure without +terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
358 # define ERROR_IF_POPUP_WINDOW 0 |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19269
diff
changeset
|
359 # define ERROR_IF_ANY_POPUP_WINDOW 0 |
19269
a8a915898b35
patch 8.2.0193: still build failure without +terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
360 #endif |
a8a915898b35
patch 8.2.0193: still build failure without +terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
361 #if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL) |
19265
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
362 # define ERROR_IF_TERM_POPUP_WINDOW error_if_term_popup_window() |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
363 #else |
19265
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
364 # define ERROR_IF_TERM_POPUP_WINDOW 0 |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
365 #endif |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
366 |
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
367 |
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
368 #ifdef ABORT_ON_INTERNAL_ERROR |
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
369 # define ESTACK_CHECK_DECLARATION int estack_len_before; |
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
370 # define ESTACK_CHECK_SETUP estack_len_before = exestack.ga_len; |
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
371 # define ESTACK_CHECK_NOW if (estack_len_before != exestack.ga_len) \ |
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
372 siemsg("Exestack length expected: %d, actual: %d", estack_len_before, exestack.ga_len); |
19629
804322d6c6ba
patch 8.2.0371: crash with combination of terminal popup and autocmd
Bram Moolenaar <Bram@vim.org>
parents:
19542
diff
changeset
|
373 # define CHECK_CURBUF if (curwin != NULL && curwin->w_buffer != curbuf) \ |
804322d6c6ba
patch 8.2.0371: crash with combination of terminal popup and autocmd
Bram Moolenaar <Bram@vim.org>
parents:
19542
diff
changeset
|
374 iemsg("curbuf != curwin->w_buffer") |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
375 #else |
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
376 # define ESTACK_CHECK_DECLARATION |
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
377 # define ESTACK_CHECK_SETUP |
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
378 # define ESTACK_CHECK_NOW |
19629
804322d6c6ba
patch 8.2.0371: crash with combination of terminal popup and autocmd
Bram Moolenaar <Bram@vim.org>
parents:
19542
diff
changeset
|
379 # define CHECK_CURBUF |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
380 #endif |
20392
4c317d8c1051
patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents:
20013
diff
changeset
|
381 |
4c317d8c1051
patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents:
20013
diff
changeset
|
382 // Inline the condition for performance. |
4c317d8c1051
patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents:
20013
diff
changeset
|
383 #define CHECK_LIST_MATERIALIZE(l) if ((l)->lv_first == &range_list_item) range_list_materialize(l) |
4c317d8c1051
patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents:
20013
diff
changeset
|
384 |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
385 // Inlined version of ga_grow() with optimized condition that it fails. |
28226
89c181c99e23
patch 8.2.4639: not sufficient parenthesis in preprocessor macros
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
386 #define GA_GROW_FAILS(gap, n) unlikely((((gap)->ga_maxlen - (gap)->ga_len < (n)) ? ga_grow_inner((gap), (n)) : OK) == FAIL) |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
387 // Inlined version of ga_grow() with optimized condition that it succeeds. |
28226
89c181c99e23
patch 8.2.4639: not sufficient parenthesis in preprocessor macros
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
388 #define GA_GROW_OK(gap, n) likely((((gap)->ga_maxlen - (gap)->ga_len < (n)) ? ga_grow_inner((gap), (n)) : OK) == OK) |
24043
15408ab5fed7
patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents:
23503
diff
changeset
|
389 |
15408ab5fed7
patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents:
23503
diff
changeset
|
390 #ifndef MIN |
15408ab5fed7
patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents:
23503
diff
changeset
|
391 # define MIN(a, b) ((a) < (b) ? (a) : (b)) |
15408ab5fed7
patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents:
23503
diff
changeset
|
392 #endif |
15408ab5fed7
patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents:
23503
diff
changeset
|
393 #ifndef MAX |
15408ab5fed7
patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents:
23503
diff
changeset
|
394 # define MAX(a, b) ((a) > (b) ? (a) : (b)) |
15408ab5fed7
patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents:
23503
diff
changeset
|
395 #endif |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24055
diff
changeset
|
396 |
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24055
diff
changeset
|
397 // Length of the array. |
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24055
diff
changeset
|
398 #define ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0])) |