annotate src/macros.h @ 13471:198769450820

Added tag v8.0.1609 for changeset 6faef782f50b5ec0184ab33144c4d55340922ee0
author Christian Brabandt <cb@256bit.org>
date Fri, 16 Mar 2018 21:00:09 +0100
parents 6740c499de13
children cec5137d5332
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: 9925
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 */
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 * 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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 /*
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
17 * PCHAR(lp, c) - put character 'c' at position 'lp'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 */
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
19 #define PCHAR(lp, c) (*(ml_get_buf(curbuf, (lp).lnum, TRUE) + (lp).col) = (c))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 * Position comparisons
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 #ifdef FEAT_VIRTUALEDIT
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
25 # define LT_POS(a, b) (((a).lnum != (b).lnum) \
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 ? (a).lnum < (b).lnum \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 : (a).col != (b).col \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 ? (a).col < (b).col \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 : (a).coladd < (b).coladd)
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
30 # define LT_POSP(a, b) (((a)->lnum != (b)->lnum) \
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 ? (a)->lnum < (b)->lnum \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 : (a)->col != (b)->col \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 ? (a)->col < (b)->col \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 : (a)->coladd < (b)->coladd)
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
35 # define EQUAL_POS(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col) && ((a).coladd == (b).coladd))
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
36 # define CLEAR_POS(a) {(a)->lnum = 0; (a)->col = 0; (a)->coladd = 0;}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 #else
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
38 # define LT_POS(a, b) (((a).lnum != (b).lnum) \
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 ? ((a).lnum < (b).lnum) : ((a).col < (b).col))
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
40 # define LT_POSP(a, b) (((a)->lnum != (b)->lnum) \
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 ? ((a)->lnum < (b)->lnum) : ((a)->col < (b)->col))
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
42 # define EQUAL_POS(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col))
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
43 # define CLEAR_POS(a) {(a)->lnum = 0; (a)->col = 0;}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
46 #define LTOREQ_POS(a, b) (LT_POS(a, b) || EQUAL_POS(a, b))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 /*
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
49 * VIM_ISWHITE() is used for "^" and the like. It differs from isspace()
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
50 * because it doesn't include <CR> and <LF> and the like.
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
51 */
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
52 #define VIM_ISWHITE(x) ((x) == ' ' || (x) == '\t')
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
53
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
54 /*
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
55 * LINEEMPTY() - return TRUE if the line is empty
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 */
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
57 #define LINEEMPTY(p) (*ml_get(p) == NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 /*
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
60 * BUFEMPTY() - return TRUE if the current buffer is empty
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 */
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10344
diff changeset
62 #define BUFEMPTY() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 * toupper() and tolower() that use the current locale.
1365
79a23c19108a updated for version 7.1-079
vimboss
parents: 1199
diff changeset
66 * On some systems toupper()/tolower() only work on lower/uppercase
79a23c19108a updated for version 7.1-079
vimboss
parents: 1199
diff changeset
67 * characters, first use islower() or isupper() then.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 * Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 * range 0 - 255. toupper()/tolower() on some systems can't handle others.
1365
79a23c19108a updated for version 7.1-079
vimboss
parents: 1199
diff changeset
70 * Note: It is often better to use MB_TOLOWER() and MB_TOUPPER(), because many
79a23c19108a updated for version 7.1-079
vimboss
parents: 1199
diff changeset
71 * toupper() and tolower() implementations only work for ASCII.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 #ifdef MSWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 # define TOUPPER_LOC(c) toupper_tab[(c) & 255]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 # define TOLOWER_LOC(c) tolower_tab[(c) & 255]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 # ifdef BROKEN_TOUPPER
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 # define TOUPPER_LOC(c) (islower(c) ? toupper(c) : (c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 # define TOLOWER_LOC(c) (isupper(c) ? tolower(c) : (c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 # define TOUPPER_LOC toupper
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 # define TOLOWER_LOC tolower
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 /* toupper() and tolower() for ASCII only and ignore the current locale. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 #ifdef EBCDIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 # define TOUPPER_ASC(c) (islower(c) ? toupper(c) : (c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 # define TOLOWER_ASC(c) (isupper(c) ? tolower(c) : (c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 # define TOUPPER_ASC(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 # define TOLOWER_ASC(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 * MB_ISLOWER() and MB_ISUPPER() are to be used on multi-byte characters. But
492
81c06952fb1d updated for version 7.0135
vimboss
parents: 474
diff changeset
97 * don't use them for negative values!
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 #ifdef FEAT_MBYTE
492
81c06952fb1d updated for version 7.0135
vimboss
parents: 474
diff changeset
100 # define MB_ISLOWER(c) vim_islower(c)
81c06952fb1d updated for version 7.0135
vimboss
parents: 474
diff changeset
101 # define MB_ISUPPER(c) vim_isupper(c)
81c06952fb1d updated for version 7.0135
vimboss
parents: 474
diff changeset
102 # define MB_TOLOWER(c) vim_tolower(c)
81c06952fb1d updated for version 7.0135
vimboss
parents: 474
diff changeset
103 # define MB_TOUPPER(c) vim_toupper(c)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 # define MB_ISLOWER(c) islower(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 # define MB_ISUPPER(c) isupper(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 # define MB_TOLOWER(c) TOLOWER_LOC(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 # define MB_TOUPPER(c) TOUPPER_LOC(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110
4857
84a8d1ba81c3 updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents: 4849
diff changeset
111 /* 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
112 * 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
113 * below 0 and above 255. */
84a8d1ba81c3 updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents: 4849
diff changeset
114 #define VIM_ISDIGIT(c) ((unsigned)(c) - '0' < 10)
84a8d1ba81c3 updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents: 4849
diff changeset
115
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 /* Like isalpha() but reject non-ASCII characters. Can't be used with a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 * special key (negative value). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 #ifdef EBCDIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 # define ASCII_ISALPHA(c) isalpha(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 # define ASCII_ISALNUM(c) isalnum(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 # define ASCII_ISLOWER(c) islower(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 # define ASCII_ISUPPER(c) isupper(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 #else
4849
fc7f985df537 updated for version 7.3.1171
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
124 # define ASCII_ISLOWER(c) ((unsigned)(c) - 'a' < 26)
fc7f985df537 updated for version 7.3.1171
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
125 # 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
126 # 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
127 # define ASCII_ISALNUM(c) (ASCII_ISALPHA(c) || VIM_ISDIGIT(c))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
6909
676906c33768 patch 7.4.774
Bram Moolenaar <bram@vim.org>
parents: 6339
diff changeset
130 /* 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
131 #define EMPTY_IF_NULL(x) ((x) ? (x) : (char_u *)"")
6909
676906c33768 patch 7.4.774
Bram Moolenaar <bram@vim.org>
parents: 6339
diff changeset
132
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 #ifdef FEAT_LANGMAP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 * Adjust chars in a language according to 'langmap' option.
1811
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
136 * NOTE that there is no noticeable overhead if 'langmap' is not set.
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
137 * When set the overhead for characters < 256 is small.
6339
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5905
diff changeset
138 * Don't apply 'langmap' if the character comes from the Stuff buffer or from
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5905
diff changeset
139 * a mapping and the langnoremap option was set.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 * The do-while is just to ignore a ';' after the macro.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 */
1811
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
142 # ifdef FEAT_MBYTE
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
143 # define LANGMAP_ADJUST(c, condition) \
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
144 do { \
6339
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5905
diff changeset
145 if (*p_langmap \
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5905
diff changeset
146 && (condition) \
9925
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9898
diff changeset
147 && (p_lrm || (!p_lrm && KeyTyped)) \
6339
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5905
diff changeset
148 && !KeyStuffed \
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5905
diff changeset
149 && (c) >= 0) \
1811
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
150 { \
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
151 if ((c) < 256) \
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
152 c = langmap_mapchar[c]; \
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
153 else \
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
154 c = langmap_adjust_mb(c); \
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
155 } \
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 } while (0)
1811
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
157 # else
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
158 # define LANGMAP_ADJUST(c, condition) \
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
159 do { \
6339
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5905
diff changeset
160 if (*p_langmap \
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5905
diff changeset
161 && (condition) \
9925
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9898
diff changeset
162 && (p_lrm || (!p_lrm && KeyTyped)) \
6339
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5905
diff changeset
163 && !KeyStuffed \
7b28dc1d756e updated for version 7.4.502
Bram Moolenaar <bram@vim.org>
parents: 5905
diff changeset
164 && (c) >= 0 && (c) < 256) \
2330
ea4bf6df1a8a Whitespace cleanup.
Bram Moolenaar <bram@vim.org>
parents: 2244
diff changeset
165 c = langmap_mapchar[c]; \
1811
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
166 } while (0)
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
167 # endif
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
168 #else
d88bdbabfbc6 updated for version 7.2-109
vimboss
parents: 1365
diff changeset
169 # define LANGMAP_ADJUST(c, condition) /* nop */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 /*
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11121
diff changeset
173 * 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
174 * it work fast. Only works for single byte characters!
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 */
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11121
diff changeset
176 #define VIM_ISBREAK(c) ((c) < 256 && breakat_flags[(char_u)(c)])
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 * On VMS file names are different and require a translation.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 * On the Mac open() has only two arguments.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 #ifdef VMS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 # define mch_access(n, p) access(vms_fixfilename(n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 /* see mch_open() comment */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 # define mch_fopen(n, p) fopen(vms_fixfilename(n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 # define mch_fstat(n, p) fstat(vms_fixfilename(n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 /* VMS does not have lstat() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 # 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
189 # define mch_rmdir(n) rmdir(vms_fixfilename(n))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 # ifndef WIN32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 # define mch_access(n, p) access((n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 # define mch_fstat(n, p) fstat((n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 # ifdef MSWIN /* has it's own mch_stat() function */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 # define mch_stat(n, p) vim_stat((n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 # 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
199 # define mch_stat(n, p) vim_stat((n), (p))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 # define mch_stat(n, p) stat((n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205
21
db5102f7e29f updated for version 7.0013
vimboss
parents: 13
diff changeset
206 #ifdef HAVE_LSTAT
db5102f7e29f updated for version 7.0013
vimboss
parents: 13
diff changeset
207 # define mch_lstat(n, p) lstat((n), (p))
db5102f7e29f updated for version 7.0013
vimboss
parents: 13
diff changeset
208 #else
db5102f7e29f updated for version 7.0013
vimboss
parents: 13
diff changeset
209 # define mch_lstat(n, p) mch_stat((n), (p))
db5102f7e29f updated for version 7.0013
vimboss
parents: 13
diff changeset
210 #endif
db5102f7e29f updated for version 7.0013
vimboss
parents: 13
diff changeset
211
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 11921
diff changeset
212 #ifdef VMS
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 * It is possible to force some record format with:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 * # define mch_open(n, m, p) open(vms_fixfilename(n), (m), (p)), "rat=cr", "rfm=stmlf", "mrs=0")
1199
3acf7c922a04 updated for version 7.1b
vimboss
parents: 961
diff changeset
216 * but it is not recommended, because it can destroy indexes etc.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 */
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 11921
diff changeset
218 # define mch_open(n, m, p) open(vms_fixfilename(n), (m), (p))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 /* mch_open_rw(): invoke mch_open() with third argument for user R/W. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 #if defined(UNIX) || defined(VMS) /* open in rw------- mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 # define mch_open_rw(n, f) mch_open((n), (f), (mode_t)0600)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 #else
8212
05b88224cea1 commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
225 # if defined(MSWIN) /* open read/write */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 # define mch_open_rw(n, f) mch_open((n), (f), S_IREAD | S_IWRITE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 # define mch_open_rw(n, f) mch_open((n), (f), 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 #ifdef STARTUPTIME
1972
82f866f19e91 updated for version 7.2-269
vimboss
parents: 1883
diff changeset
233 # define TIME_MSG(s) { if (time_fd != NULL) time_msg(s, NULL); }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 # define TIME_MSG(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 #ifdef FEAT_VREPLACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 # define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 # define REPLACE_NORMAL(s) ((s) & REPLACE_FLAG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 #ifdef FEAT_ARABIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 # define UTF_COMPOSINGLIKE(p1, p2) utf_composinglike((p1), (p2))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 # define UTF_COMPOSINGLIKE(p1, p2) utf_iscomposing(utf_ptr2char(p2))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 /* Whether to draw the vertical bar on the right side of the cell. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 # define CURSOR_BAR_RIGHT (curwin->w_p_rl && (!(State & CMDLINE) || cmdmsg_rl))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 #endif
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 7
diff changeset
254
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
255 /*
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11121
diff changeset
256 * MB_PTR_ADV(): advance a pointer to the next character, taking care of
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
257 * 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
258 * MB_PTR_BACK(): backup a pointer to the previous character, taking care of
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
259 * multi-byte characters if needed.
98
98435a8ddb09 updated for version 7.0038
vimboss
parents: 39
diff changeset
260 * MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers.
456
c4d200412ae9 updated for version 7.0121
vimboss
parents: 377
diff changeset
261 * PTR2CHAR(): get character from pointer.
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
262 */
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
263 #ifdef FEAT_MBYTE
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 11921
diff changeset
264 /* Get the length of the character p points to, including composing chars */
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11121
diff changeset
265 # define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1)
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
266 /* Advance multi-byte pointer, skip over composing chars. */
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11121
diff changeset
267 # define MB_PTR_ADV(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
268 /* Advance multi-byte pointer, do not skip over composing chars. */
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11121
diff changeset
269 # define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1
5905
662ae48e7e24 updated for version 7.4.295
Bram Moolenaar <bram@vim.org>
parents: 4857
diff changeset
270 /* Backup multi-byte pointer. Only use with "p" > "s" ! */
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11121
diff changeset
271 # define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
272 /* 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
273 # define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p))
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
274
98
98435a8ddb09 updated for version 7.0038
vimboss
parents: 39
diff changeset
275 # define MB_COPY_CHAR(f, t) if (has_mbyte) mb_copy_char(&f, &t); else *t++ = *f++
1883
c8f343a465a2 updated for version 7.2-180
vimboss
parents: 1811
diff changeset
276 # 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
277 # define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1)
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
278 # define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p))
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
279 #else
3693
c612d154bcdd updated for version 7.3.606
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
280 # define MB_PTR2LEN(p) 1
9898
bff8a09016a5 commit https://github.com/vim/vim/commit/d3c907b5d2b352482b580a0cf687cbbea4c19ea1
Christian Brabandt <cb@256bit.org>
parents: 9570
diff changeset
281 # define MB_CPTR2LEN(p) 1
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11121
diff changeset
282 # define MB_PTR_ADV(p) ++p
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11121
diff changeset
283 # define MB_CPTR_ADV(p) ++p
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11121
diff changeset
284 # define MB_PTR_BACK(s, p) --p
456
c4d200412ae9 updated for version 7.0121
vimboss
parents: 377
diff changeset
285 # define MB_COPY_CHAR(f, t) *t++ = *f++
c4d200412ae9 updated for version 7.0121
vimboss
parents: 377
diff changeset
286 # define MB_CHARLEN(p) STRLEN(p)
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 3693
diff changeset
287 # define MB_CHAR2LEN(c) 1
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
288 # define PTR2CHAR(p) ((int)*(p))
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
289 #endif
961
c06c658691e2 updated for version 7.0-087
vimboss
parents: 698
diff changeset
290
c06c658691e2 updated for version 7.0-087
vimboss
parents: 698
diff changeset
291 #ifdef FEAT_AUTOCHDIR
c06c658691e2 updated for version 7.0-087
vimboss
parents: 698
diff changeset
292 # define DO_AUTOCHDIR if (p_acd) do_autochdir();
c06c658691e2 updated for version 7.0-087
vimboss
parents: 698
diff changeset
293 #else
c06c658691e2 updated for version 7.0-087
vimboss
parents: 698
diff changeset
294 # define DO_AUTOCHDIR
c06c658691e2 updated for version 7.0-087
vimboss
parents: 698
diff changeset
295 #endif
2583
7c2e6ba1d702 updated for version 7.3.008
Bram Moolenaar <bram@vim.org>
parents: 2330
diff changeset
296
13384
6740c499de13 patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
297 #define RESET_BINDING(wp) (wp)->w_p_scb = FALSE; (wp)->w_p_crb = FALSE
7103
84d318257a45 commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents: 6909
diff changeset
298
84d318257a45 commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents: 6909
diff changeset
299 #ifdef FEAT_DIFF
84d318257a45 commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents: 6909
diff changeset
300 # 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
301 #else
84d318257a45 commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents: 6909
diff changeset
302 # define PLINES_NOFILL(x) plines(x)
84d318257a45 commit https://github.com/vim/vim/commit/43335ea394fe247132b9701c55cccf51e6c36425
Christian Brabandt <cb@256bit.org>
parents: 6909
diff changeset
303 #endif
7109
fa95595fbc52 commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents: 7103
diff changeset
304
8493
caed4b2d305f commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents: 8395
diff changeset
305 #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
306 # define MESSAGE_QUEUE
fa95595fbc52 commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents: 7103
diff changeset
307 #endif
8289
6ae3fb4fe7c1 commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents: 8247
diff changeset
308
6ae3fb4fe7c1 commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents: 8247
diff changeset
309 #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
310 # include <float.h>
6ae3fb4fe7c1 commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents: 8247
diff changeset
311 # if defined(HAVE_MATH_H)
6ae3fb4fe7c1 commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents: 8247
diff changeset
312 /* for isnan() and isinf() */
6ae3fb4fe7c1 commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents: 8247
diff changeset
313 # include <math.h>
6ae3fb4fe7c1 commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents: 8247
diff changeset
314 # endif
8295
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
315 # ifdef USING_FLOAT_STUFF
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
316 # if defined(WIN32)
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
317 # ifndef isnan
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
318 # define isnan(x) _isnan(x)
8395
8137d5b642f3 commit https://github.com/vim/vim/commit/0c171716c0430458741fbf18a6fd4baea4c0390b
Christian Brabandt <cb@256bit.org>
parents: 8390
diff changeset
319 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
320 # endif
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
321 # else
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
322 # ifndef HAVE_ISNAN
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
323 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
324 # endif
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
325 # ifndef HAVE_ISINF
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
326 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
327 # endif
8289
6ae3fb4fe7c1 commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents: 8247
diff changeset
328 # endif
8295
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
329 # if !defined(INFINITY)
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
330 # if defined(DBL_MAX)
10344
e70ff5756201 commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents: 10328
diff changeset
331 # ifdef VMS
e70ff5756201 commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents: 10328
diff changeset
332 # define INFINITY DBL_MAX
e70ff5756201 commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents: 10328
diff changeset
333 # else
e70ff5756201 commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents: 10328
diff changeset
334 # define INFINITY (DBL_MAX+DBL_MAX)
e70ff5756201 commit https://github.com/vim/vim/commit/98500fdc6119eb5f02d7a52ab6ffcac3085181be
Christian Brabandt <cb@256bit.org>
parents: 10328
diff changeset
335 # endif
8295
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
336 # else
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
337 # define INFINITY (1.0 / 0.0)
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
338 # endif
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
339 # endif
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
340 # if !defined(NAN)
18fd94bd4eb8 commit https://github.com/vim/vim/commit/fefecb0fbe14c44d46f91036d76bbb6c28162da8
Christian Brabandt <cb@256bit.org>
parents: 8289
diff changeset
341 # define NAN (INFINITY-INFINITY)
8289
6ae3fb4fe7c1 commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents: 8247
diff changeset
342 # endif
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
343 # if !defined(DBL_EPSILON)
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
344 # 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
345 # endif
8289
6ae3fb4fe7c1 commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents: 8247
diff changeset
346 # endif
6ae3fb4fe7c1 commit https://github.com/vim/vim/commit/136f29a91dbafce424e31a4af133155f997e8f78
Christian Brabandt <cb@256bit.org>
parents: 8247
diff changeset
347 #endif
9570
695186e11daa commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents: 8493
diff changeset
348
695186e11daa commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents: 8493
diff changeset
349 /*
695186e11daa commit https://github.com/vim/vim/commit/840268400dc8fda62a14f8a084e8b1ea46619454
Christian Brabandt <cb@256bit.org>
parents: 8493
diff changeset
350 * 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
351 * 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
352 * 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
353 * 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
354 * 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
355 */
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
356 #define DI2HIKEY(di) ((di)->di_key)
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
357 #define HIKEY2DI(p) ((dictitem_T *)(p - offsetof(dictitem_T, di_key)))
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
358 #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
359
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
360 /*
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
361 * Flush control functions.
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
362 */
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
363 #ifdef FEAT_GUI
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
364 # 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
365 # 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
366 #else
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
367 # define mch_enable_flush()
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
368 # define mch_disable_flush()
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
369 #endif
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
370
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
371 /*
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
372 * 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
373 */
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
374 #define VIM_CLEAR(p) \
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
375 do { \
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
376 if ((p) != NULL) { \
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
377 vim_free(p); \
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
378 (p) = NULL; \
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
379 } \
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
380 } while (0)