Mercurial > vim
annotate src/macros.h @ 10365:0dd0c7fb1096 v8.0.0077
commit https://github.com/vim/vim/commit/e3505dfc858260a21f2bbc6056f5769dea2f273d
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Nov 11 21:57:45 2016 +0100
patch 8.0.0077
Problem: The GUI code is not tested by Travis.
Solution: Install the virtual framebuffer.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 11 Nov 2016 22:00:04 +0100 |
parents | e70ff5756201 |
children | 778c10516955 |
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 | |
11 */ | |
12 | |
13 /* | |
14 * pchar(lp, c) - put character 'c' at position 'lp' | |
15 */ | |
16 #define pchar(lp, c) (*(ml_get_buf(curbuf, (lp).lnum, TRUE) + (lp).col) = (c)) | |
17 | |
18 /* | |
19 * Position comparisons | |
20 */ | |
21 #ifdef FEAT_VIRTUALEDIT | |
22 # define lt(a, b) (((a).lnum != (b).lnum) \ | |
23 ? (a).lnum < (b).lnum \ | |
24 : (a).col != (b).col \ | |
25 ? (a).col < (b).col \ | |
26 : (a).coladd < (b).coladd) | |
27 # define ltp(a, b) (((a)->lnum != (b)->lnum) \ | |
28 ? (a)->lnum < (b)->lnum \ | |
29 : (a)->col != (b)->col \ | |
30 ? (a)->col < (b)->col \ | |
31 : (a)->coladd < (b)->coladd) | |
32 # define equalpos(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col) && ((a).coladd == (b).coladd)) | |
698 | 33 # define clearpos(a) {(a)->lnum = 0; (a)->col = 0; (a)->coladd = 0;} |
7 | 34 #else |
35 # define lt(a, b) (((a).lnum != (b).lnum) \ | |
36 ? ((a).lnum < (b).lnum) : ((a).col < (b).col)) | |
37 # define ltp(a, b) (((a)->lnum != (b)->lnum) \ | |
38 ? ((a)->lnum < (b)->lnum) : ((a)->col < (b)->col)) | |
39 # define equalpos(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col)) | |
698 | 40 # define clearpos(a) {(a)->lnum = 0; (a)->col = 0;} |
7 | 41 #endif |
42 | |
43 #define ltoreq(a, b) (lt(a, b) || equalpos(a, b)) | |
44 | |
45 /* | |
46 * lineempty() - return TRUE if the line is empty | |
47 */ | |
48 #define lineempty(p) (*ml_get(p) == NUL) | |
49 | |
50 /* | |
51 * bufempty() - return TRUE if the current buffer is empty | |
52 */ | |
53 #define bufempty() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == NUL) | |
54 | |
55 /* | |
56 * toupper() and tolower() that use the current locale. | |
1365 | 57 * On some systems toupper()/tolower() only work on lower/uppercase |
58 * characters, first use islower() or isupper() then. | |
7 | 59 * Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the |
60 * range 0 - 255. toupper()/tolower() on some systems can't handle others. | |
1365 | 61 * Note: It is often better to use MB_TOLOWER() and MB_TOUPPER(), because many |
62 * toupper() and tolower() implementations only work for ASCII. | |
7 | 63 */ |
64 #ifdef MSWIN | |
65 # define TOUPPER_LOC(c) toupper_tab[(c) & 255] | |
66 # define TOLOWER_LOC(c) tolower_tab[(c) & 255] | |
67 #else | |
68 # ifdef BROKEN_TOUPPER | |
69 # define TOUPPER_LOC(c) (islower(c) ? toupper(c) : (c)) | |
70 # define TOLOWER_LOC(c) (isupper(c) ? tolower(c) : (c)) | |
71 # else | |
72 # define TOUPPER_LOC toupper | |
73 # define TOLOWER_LOC tolower | |
74 # endif | |
75 #endif | |
76 | |
77 /* toupper() and tolower() for ASCII only and ignore the current locale. */ | |
78 #ifdef EBCDIC | |
79 # define TOUPPER_ASC(c) (islower(c) ? toupper(c) : (c)) | |
80 # define TOLOWER_ASC(c) (isupper(c) ? tolower(c) : (c)) | |
81 #else | |
82 # define TOUPPER_ASC(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A')) | |
83 # define TOLOWER_ASC(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A')) | |
84 #endif | |
85 | |
86 /* | |
87 * MB_ISLOWER() and MB_ISUPPER() are to be used on multi-byte characters. But | |
492 | 88 * don't use them for negative values! |
7 | 89 */ |
90 #ifdef FEAT_MBYTE | |
492 | 91 # define MB_ISLOWER(c) vim_islower(c) |
92 # define MB_ISUPPER(c) vim_isupper(c) | |
93 # define MB_TOLOWER(c) vim_tolower(c) | |
94 # define MB_TOUPPER(c) vim_toupper(c) | |
7 | 95 #else |
96 # define MB_ISLOWER(c) islower(c) | |
97 # define MB_ISUPPER(c) isupper(c) | |
98 # define MB_TOLOWER(c) TOLOWER_LOC(c) | |
99 # define MB_TOUPPER(c) TOUPPER_LOC(c) | |
100 #endif | |
101 | |
4857
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4849
diff
changeset
|
102 /* Use our own isdigit() replacement, because on MS-Windows isdigit() returns |
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4849
diff
changeset
|
103 * non-zero for superscript 1. Also avoids that isdigit() crashes for numbers |
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4849
diff
changeset
|
104 * below 0 and above 255. */ |
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4849
diff
changeset
|
105 #define VIM_ISDIGIT(c) ((unsigned)(c) - '0' < 10) |
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4849
diff
changeset
|
106 |
7 | 107 /* Like isalpha() but reject non-ASCII characters. Can't be used with a |
108 * special key (negative value). */ | |
109 #ifdef EBCDIC | |
110 # define ASCII_ISALPHA(c) isalpha(c) | |
111 # define ASCII_ISALNUM(c) isalnum(c) | |
112 # define ASCII_ISLOWER(c) islower(c) | |
113 # define ASCII_ISUPPER(c) isupper(c) | |
114 #else | |
4849
fc7f985df537
updated for version 7.3.1171
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
115 # define ASCII_ISLOWER(c) ((unsigned)(c) - 'a' < 26) |
fc7f985df537
updated for version 7.3.1171
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
116 # define ASCII_ISUPPER(c) ((unsigned)(c) - 'A' < 26) |
4857
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4849
diff
changeset
|
117 # define ASCII_ISALPHA(c) (ASCII_ISUPPER(c) || ASCII_ISLOWER(c)) |
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4849
diff
changeset
|
118 # define ASCII_ISALNUM(c) (ASCII_ISALPHA(c) || VIM_ISDIGIT(c)) |
7 | 119 #endif |
120 | |
6909 | 121 /* 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
|
122 #define EMPTY_IF_NULL(x) ((x) ? (x) : (char_u *)"") |
6909 | 123 |
7 | 124 #ifdef FEAT_LANGMAP |
125 /* | |
126 * Adjust chars in a language according to 'langmap' option. | |
1811 | 127 * NOTE that there is no noticeable overhead if 'langmap' is not set. |
128 * When set the overhead for characters < 256 is small. | |
6339 | 129 * Don't apply 'langmap' if the character comes from the Stuff buffer or from |
130 * a mapping and the langnoremap option was set. | |
7 | 131 * The do-while is just to ignore a ';' after the macro. |
132 */ | |
1811 | 133 # ifdef FEAT_MBYTE |
134 # define LANGMAP_ADJUST(c, condition) \ | |
135 do { \ | |
6339 | 136 if (*p_langmap \ |
137 && (condition) \ | |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9898
diff
changeset
|
138 && (p_lrm || (!p_lrm && KeyTyped)) \ |
6339 | 139 && !KeyStuffed \ |
140 && (c) >= 0) \ | |
1811 | 141 { \ |
142 if ((c) < 256) \ | |
143 c = langmap_mapchar[c]; \ | |
144 else \ | |
145 c = langmap_adjust_mb(c); \ | |
146 } \ | |
7 | 147 } while (0) |
1811 | 148 # else |
149 # define LANGMAP_ADJUST(c, condition) \ | |
150 do { \ | |
6339 | 151 if (*p_langmap \ |
152 && (condition) \ | |
9925
3fba3e8326a7
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents:
9898
diff
changeset
|
153 && (p_lrm || (!p_lrm && KeyTyped)) \ |
6339 | 154 && !KeyStuffed \ |
155 && (c) >= 0 && (c) < 256) \ | |
2330 | 156 c = langmap_mapchar[c]; \ |
1811 | 157 } while (0) |
158 # endif | |
159 #else | |
160 # define LANGMAP_ADJUST(c, condition) /* nop */ | |
7 | 161 #endif |
162 | |
163 /* | |
164 * vim_isbreak() is used very often if 'linebreak' is set, use a macro to make | |
165 * it work fast. | |
166 */ | |
167 #define vim_isbreak(c) (breakat_flags[(char_u)(c)]) | |
168 | |
169 /* | |
170 * On VMS file names are different and require a translation. | |
171 * On the Mac open() has only two arguments. | |
172 */ | |
173 #ifdef VMS | |
174 # define mch_access(n, p) access(vms_fixfilename(n), (p)) | |
175 /* see mch_open() comment */ | |
176 # define mch_fopen(n, p) fopen(vms_fixfilename(n), (p)) | |
177 # define mch_fstat(n, p) fstat(vms_fixfilename(n), (p)) | |
178 /* VMS does not have lstat() */ | |
179 # define mch_stat(n, p) stat(vms_fixfilename(n), (p)) | |
10328
299f1669c20e
commit https://github.com/vim/vim/commit/de5e2c219b99895445fb75ae3541ee69282a5846
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
180 # define mch_rmdir(n) rmdir(vms_fixfilename(n)) |
7 | 181 #else |
182 # ifndef WIN32 | |
183 # define mch_access(n, p) access((n), (p)) | |
184 # endif | |
185 # if !(defined(FEAT_MBYTE) && defined(WIN3264)) | |
186 # define mch_fopen(n, p) fopen((n), (p)) | |
187 # endif | |
188 # define mch_fstat(n, p) fstat((n), (p)) | |
189 # ifdef MSWIN /* has it's own mch_stat() function */ | |
190 # define mch_stat(n, p) vim_stat((n), (p)) | |
191 # else | |
192 # ifdef STAT_IGNORES_SLASH | |
193 /* On Solaris stat() accepts "file/" as if it was "file". Return -1 if | |
194 * the name ends in "/" and it's not a directory. */ | |
195 # define mch_stat(n, p) (illegal_slash(n) ? -1 : stat((n), (p))) | |
196 # else | |
197 # define mch_stat(n, p) stat((n), (p)) | |
198 # endif | |
199 # endif | |
200 #endif | |
201 | |
21 | 202 #ifdef HAVE_LSTAT |
203 # define mch_lstat(n, p) lstat((n), (p)) | |
204 #else | |
205 # define mch_lstat(n, p) mch_stat((n), (p)) | |
206 #endif | |
207 | |
7 | 208 #ifdef MACOS_CLASSIC |
209 /* MacOS classic doesn't support perm but MacOS X does. */ | |
210 # define mch_open(n, m, p) open((n), (m)) | |
211 #else | |
212 # ifdef VMS | |
213 /* | |
214 * It is possible to force some record format with: | |
215 * # define mch_open(n, m, p) open(vms_fixfilename(n), (m), (p)), "rat=cr", "rfm=stmlf", "mrs=0") | |
1199 | 216 * but it is not recommended, because it can destroy indexes etc. |
7 | 217 */ |
218 # define mch_open(n, m, p) open(vms_fixfilename(n), (m), (p)) | |
219 # else | |
220 # if !(defined(FEAT_MBYTE) && defined(WIN3264)) | |
221 # define mch_open(n, m, p) open((n), (m), (p)) | |
222 # endif | |
223 # endif | |
224 #endif | |
225 | |
226 /* mch_open_rw(): invoke mch_open() with third argument for user R/W. */ | |
227 #if defined(UNIX) || defined(VMS) /* open in rw------- mode */ | |
228 # define mch_open_rw(n, f) mch_open((n), (f), (mode_t)0600) | |
229 #else | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
230 # if defined(MSWIN) /* open read/write */ |
7 | 231 # define mch_open_rw(n, f) mch_open((n), (f), S_IREAD | S_IWRITE) |
232 # else | |
233 # define mch_open_rw(n, f) mch_open((n), (f), 0) | |
234 # endif | |
235 #endif | |
236 | |
237 #ifdef STARTUPTIME | |
1972 | 238 # define TIME_MSG(s) { if (time_fd != NULL) time_msg(s, NULL); } |
7 | 239 #else |
240 # define TIME_MSG(s) | |
241 #endif | |
242 | |
243 #ifdef FEAT_VREPLACE | |
244 # define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG)) | |
245 #else | |
246 # define REPLACE_NORMAL(s) ((s) & REPLACE_FLAG) | |
247 #endif | |
248 | |
249 #ifdef FEAT_ARABIC | |
250 # define UTF_COMPOSINGLIKE(p1, p2) utf_composinglike((p1), (p2)) | |
251 #else | |
252 # define UTF_COMPOSINGLIKE(p1, p2) utf_iscomposing(utf_ptr2char(p2)) | |
253 #endif | |
254 | |
255 #ifdef FEAT_RIGHTLEFT | |
256 /* Whether to draw the vertical bar on the right side of the cell. */ | |
257 # define CURSOR_BAR_RIGHT (curwin->w_p_rl && (!(State & CMDLINE) || cmdmsg_rl)) | |
258 #endif | |
13 | 259 |
39 | 260 /* |
261 * mb_ptr_adv(): advance a pointer to the next character, taking care of | |
262 * multi-byte characters if needed. | |
263 * mb_ptr_back(): backup a pointer to the previous character, taking care of | |
264 * multi-byte characters if needed. | |
98 | 265 * MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers. |
456 | 266 * PTR2CHAR(): get character from pointer. |
39 | 267 */ |
268 #ifdef FEAT_MBYTE | |
3693 | 269 /* Get the length of the character p points to */ |
270 # define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1) | |
474 | 271 /* Advance multi-byte pointer, skip over composing chars. */ |
272 # define mb_ptr_adv(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1 | |
273 /* Advance multi-byte pointer, do not skip over composing chars. */ | |
274 # define mb_cptr_adv(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1 | |
5905 | 275 /* Backup multi-byte pointer. Only use with "p" > "s" ! */ |
377 | 276 # define mb_ptr_back(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1 |
474 | 277 /* get length of multi-byte char, not including composing chars */ |
9898
bff8a09016a5
commit https://github.com/vim/vim/commit/d3c907b5d2b352482b580a0cf687cbbea4c19ea1
Christian Brabandt <cb@256bit.org>
parents:
9570
diff
changeset
|
278 # define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p)) |
474 | 279 |
98 | 280 # define MB_COPY_CHAR(f, t) if (has_mbyte) mb_copy_char(&f, &t); else *t++ = *f++ |
1883 | 281 # define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p)) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
3693
diff
changeset
|
282 # define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1) |
474 | 283 # define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p)) |
39 | 284 #else |
3693 | 285 # define MB_PTR2LEN(p) 1 |
9898
bff8a09016a5
commit https://github.com/vim/vim/commit/d3c907b5d2b352482b580a0cf687cbbea4c19ea1
Christian Brabandt <cb@256bit.org>
parents:
9570
diff
changeset
|
286 # define MB_CPTR2LEN(p) 1 |
456 | 287 # define mb_ptr_adv(p) ++p |
474 | 288 # define mb_cptr_adv(p) ++p |
456 | 289 # define mb_ptr_back(s, p) --p |
290 # define MB_COPY_CHAR(f, t) *t++ = *f++ | |
291 # define MB_CHARLEN(p) STRLEN(p) | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
3693
diff
changeset
|
292 # define MB_CHAR2LEN(c) 1 |
474 | 293 # define PTR2CHAR(p) ((int)*(p)) |
39 | 294 #endif |
961 | 295 |
296 #ifdef FEAT_AUTOCHDIR | |
297 # define DO_AUTOCHDIR if (p_acd) do_autochdir(); | |
298 #else | |
299 # define DO_AUTOCHDIR | |
300 #endif | |
2583 | 301 |
302 #if defined(FEAT_SCROLLBIND) && defined(FEAT_CURSORBIND) | |
303 # define RESET_BINDING(wp) (wp)->w_p_scb = FALSE; (wp)->w_p_crb = FALSE | |
304 #else | |
305 # if defined(FEAT_SCROLLBIND) | |
306 # define RESET_BINDING(wp) (wp)->w_p_scb = FALSE | |
307 # else | |
308 # if defined(FEAT_CURSORBIND) | |
309 # define RESET_BINDING(wp) (wp)->w_p_crb = FALSE | |
310 # else | |
311 # define RESET_BINDING(wp) | |
312 # endif | |
313 # endif | |
314 #endif | |
7103
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
6909
diff
changeset
|
315 |
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
6909
diff
changeset
|
316 #ifdef FEAT_DIFF |
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
6909
diff
changeset
|
317 # define PLINES_NOFILL(x) plines_nofill(x) |
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
6909
diff
changeset
|
318 #else |
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
6909
diff
changeset
|
319 # define PLINES_NOFILL(x) plines(x) |
84d318257a45
commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents:
6909
diff
changeset
|
320 #endif |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7103
diff
changeset
|
321 |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8395
diff
changeset
|
322 #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
|
323 # define MESSAGE_QUEUE |
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7103
diff
changeset
|
324 #endif |
8289
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
325 |
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
326 #if defined(FEAT_EVAL) && defined(FEAT_FLOAT) |
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
327 # include <float.h> |
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
328 # if defined(HAVE_MATH_H) |
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
329 /* for isnan() and isinf() */ |
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
330 # include <math.h> |
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
331 # endif |
8295
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
332 # ifdef USING_FLOAT_STUFF |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
333 # if defined(WIN32) |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
334 # ifndef isnan |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
335 # define isnan(x) _isnan(x) |
8395
8137d5b642f3
commit https://github.com/vim/vim/commit/0c171716c0430458741fbf18a6fd4baea4c0390b
Christian Brabandt <cb@256bit.org>
parents:
8390
diff
changeset
|
336 static __inline int isinf(double x) { return !_finite(x) && !_isnan(x); } |
8295
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
337 # endif |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
338 # else |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
339 # ifndef HAVE_ISNAN |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
340 static inline int isnan(double x) { return x != x; } |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
341 # endif |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
342 # ifndef HAVE_ISINF |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
343 static inline int isinf(double x) { return !isnan(x) && isnan(x - x); } |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
344 # endif |
8289
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
345 # endif |
8295
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
346 # if !defined(INFINITY) |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
347 # if defined(DBL_MAX) |
10344
e70ff5756201
commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
348 # ifdef VMS |
e70ff5756201
commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
349 # define INFINITY DBL_MAX |
e70ff5756201
commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
350 # else |
e70ff5756201
commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
351 # define INFINITY (DBL_MAX+DBL_MAX) |
e70ff5756201
commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents:
10328
diff
changeset
|
352 # endif |
8295
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
353 # else |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
354 # define INFINITY (1.0 / 0.0) |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
355 # endif |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
356 # endif |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
357 # if !defined(NAN) |
18fd94bd4eb8
commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents:
8289
diff
changeset
|
358 # define NAN (INFINITY-INFINITY) |
8289
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
359 # endif |
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
360 # endif |
6ae3fb4fe7c1
commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents:
8247
diff
changeset
|
361 #endif |
9570
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
362 |
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
363 /* |
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
364 * 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
|
365 * 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
|
366 * 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
|
367 * 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
|
368 * 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
|
369 */ |
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
370 # define DI2HIKEY(di) ((di)->di_key) |
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
371 # define HIKEY2DI(p) ((dictitem_T *)(p - offsetof(dictitem_T, di_key))) |
695186e11daa
commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
372 # define HI2DI(hi) HIKEY2DI((hi)->hi_key) |