annotate src/macros.h @ 825:6675076019ae v7.0d

updated for version 7.0d
author vimboss
date Mon, 10 Apr 2006 14:55:34 +0000
parents e402b0af6083
children c06c658691e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 * pchar(lp, c) - put character 'c' at position 'lp'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 #define pchar(lp, c) (*(ml_get_buf(curbuf, (lp).lnum, TRUE) + (lp).col) = (c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 * Position comparisons
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 #ifdef FEAT_VIRTUALEDIT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 # define lt(a, b) (((a).lnum != (b).lnum) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 ? (a).lnum < (b).lnum \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 : (a).col != (b).col \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 ? (a).col < (b).col \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 : (a).coladd < (b).coladd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 # define ltp(a, b) (((a)->lnum != (b)->lnum) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 ? (a)->lnum < (b)->lnum \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 : (a)->col != (b)->col \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 ? (a)->col < (b)->col \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 : (a)->coladd < (b)->coladd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 # define equalpos(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col) && ((a).coladd == (b).coladd))
698
e402b0af6083 updated for version 7.0211
vimboss
parents: 492
diff changeset
33 # define clearpos(a) {(a)->lnum = 0; (a)->col = 0; (a)->coladd = 0;}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 # define lt(a, b) (((a).lnum != (b).lnum) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 ? ((a).lnum < (b).lnum) : ((a).col < (b).col))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 # define ltp(a, b) (((a)->lnum != (b)->lnum) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 ? ((a)->lnum < (b)->lnum) : ((a)->col < (b)->col))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 # define equalpos(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col))
698
e402b0af6083 updated for version 7.0211
vimboss
parents: 492
diff changeset
40 # define clearpos(a) {(a)->lnum = 0; (a)->col = 0;}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 #define ltoreq(a, b) (lt(a, b) || equalpos(a, b))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 * lineempty() - return TRUE if the line is empty
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 #define lineempty(p) (*ml_get(p) == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 * bufempty() - return TRUE if the current buffer is empty
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 #define bufempty() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 * toupper() and tolower() that use the current locale.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 * On some systems toupper()/tolower() only work on lower/uppercase characters
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 * Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 * range 0 - 255. toupper()/tolower() on some systems can't handle others.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 * Note: for UTF-8 use utf_toupper() and utf_tolower().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 #ifdef MSWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 # define TOUPPER_LOC(c) toupper_tab[(c) & 255]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 # define TOLOWER_LOC(c) tolower_tab[(c) & 255]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 # ifdef BROKEN_TOUPPER
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 # define TOUPPER_LOC(c) (islower(c) ? toupper(c) : (c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 # define TOLOWER_LOC(c) (isupper(c) ? tolower(c) : (c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 # define TOUPPER_LOC toupper
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 # define TOLOWER_LOC tolower
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 /* toupper() and tolower() for ASCII only and ignore the current locale. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 #ifdef EBCDIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 # define TOUPPER_ASC(c) (islower(c) ? toupper(c) : (c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 # define TOLOWER_ASC(c) (isupper(c) ? tolower(c) : (c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 # define TOUPPER_ASC(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 # define TOLOWER_ASC(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 * 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
86 * don't use them for negative values!
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 #ifdef FEAT_MBYTE
492
81c06952fb1d updated for version 7.0135
vimboss
parents: 474
diff changeset
89 # define MB_ISLOWER(c) vim_islower(c)
81c06952fb1d updated for version 7.0135
vimboss
parents: 474
diff changeset
90 # define MB_ISUPPER(c) vim_isupper(c)
81c06952fb1d updated for version 7.0135
vimboss
parents: 474
diff changeset
91 # define MB_TOLOWER(c) vim_tolower(c)
81c06952fb1d updated for version 7.0135
vimboss
parents: 474
diff changeset
92 # define MB_TOUPPER(c) vim_toupper(c)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 # define MB_ISLOWER(c) islower(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 # define MB_ISUPPER(c) isupper(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 # define MB_TOLOWER(c) TOLOWER_LOC(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 # define MB_TOUPPER(c) TOUPPER_LOC(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 /* Like isalpha() but reject non-ASCII characters. Can't be used with a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 * special key (negative value). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 #ifdef EBCDIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 # define ASCII_ISALPHA(c) isalpha(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 # define ASCII_ISALNUM(c) isalnum(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 # define ASCII_ISLOWER(c) islower(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 # define ASCII_ISUPPER(c) isupper(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 # define ASCII_ISALPHA(c) ((c) < 0x7f && isalpha(c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 # define ASCII_ISALNUM(c) ((c) < 0x7f && isalnum(c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 # define ASCII_ISLOWER(c) ((c) < 0x7f && islower(c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 # define ASCII_ISUPPER(c) ((c) < 0x7f && isupper(c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 /* Use our own isdigit() replacement, because on MS-Windows isdigit() returns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 * non-zero for superscript 1. Also avoids that isdigit() crashes for numbers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 * below 0 and above 255. For complicated arguments and in/decrement use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 * vim_isdigit() instead. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 #define VIM_ISDIGIT(c) ((c) >= '0' && (c) <= '9')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 /* macro version of chartab().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 * Only works with values 0-255!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 * Doesn't work for UTF-8 mode with chars >= 0x80. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 #define CHARSIZE(c) (chartab[c] & CT_CELL_MASK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 #ifdef FEAT_LANGMAP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 * Adjust chars in a language according to 'langmap' option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 * NOTE that there is NO overhead if 'langmap' is not set; but even
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 * when set we only have to do 2 ifs and an array lookup.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 * Don't apply 'langmap' if the character comes from the Stuff buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 * The do-while is just to ignore a ';' after the macro.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 # define LANGMAP_ADJUST(c, condition) do { \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 if (*p_langmap && (condition) && !KeyStuffed && (c) >= 0 && (c) < 256) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 c = langmap_mapchar[c]; \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 } while (0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 * vim_isbreak() is used very often if 'linebreak' is set, use a macro to make
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 * it work fast.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 #define vim_isbreak(c) (breakat_flags[(char_u)(c)])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 * On VMS file names are different and require a translation.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 * On the Mac open() has only two arguments.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 #ifdef VMS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 # define mch_access(n, p) access(vms_fixfilename(n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 /* see mch_open() comment */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 # define mch_fopen(n, p) fopen(vms_fixfilename(n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 # define mch_fstat(n, p) fstat(vms_fixfilename(n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 /* VMS does not have lstat() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 # define mch_stat(n, p) stat(vms_fixfilename(n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 # ifndef WIN32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 # define mch_access(n, p) access((n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 # if !(defined(FEAT_MBYTE) && defined(WIN3264))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 # define mch_fopen(n, p) fopen((n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 # define mch_fstat(n, p) fstat((n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 # ifdef MSWIN /* has it's own mch_stat() function */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 # define mch_stat(n, p) vim_stat((n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 # ifdef STAT_IGNORES_SLASH
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 /* On Solaris stat() accepts "file/" as if it was "file". Return -1 if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 * the name ends in "/" and it's not a directory. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 # define mch_stat(n, p) (illegal_slash(n) ? -1 : stat((n), (p)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 # define mch_stat(n, p) stat((n), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176
21
db5102f7e29f updated for version 7.0013
vimboss
parents: 13
diff changeset
177 #ifdef HAVE_LSTAT
db5102f7e29f updated for version 7.0013
vimboss
parents: 13
diff changeset
178 # define mch_lstat(n, p) lstat((n), (p))
db5102f7e29f updated for version 7.0013
vimboss
parents: 13
diff changeset
179 #else
db5102f7e29f updated for version 7.0013
vimboss
parents: 13
diff changeset
180 # define mch_lstat(n, p) mch_stat((n), (p))
db5102f7e29f updated for version 7.0013
vimboss
parents: 13
diff changeset
181 #endif
db5102f7e29f updated for version 7.0013
vimboss
parents: 13
diff changeset
182
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 #ifdef MACOS_CLASSIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 /* MacOS classic doesn't support perm but MacOS X does. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 # define mch_open(n, m, p) open((n), (m))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 # ifdef VMS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 * It is possible to force some record format with:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 * # define mch_open(n, m, p) open(vms_fixfilename(n), (m), (p)), "rat=cr", "rfm=stmlf", "mrs=0")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 * but it is not recomended, because it can destroy indexes etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 # define mch_open(n, m, p) open(vms_fixfilename(n), (m), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 # if !(defined(FEAT_MBYTE) && defined(WIN3264))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 # define mch_open(n, m, p) open((n), (m), (p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 /* mch_open_rw(): invoke mch_open() with third argument for user R/W. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 #if defined(UNIX) || defined(VMS) /* open in rw------- mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 # define mch_open_rw(n, f) mch_open((n), (f), (mode_t)0600)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 # if defined(MSDOS) || defined(MSWIN) || defined(OS2) /* open read/write */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 # define mch_open_rw(n, f) mch_open((n), (f), S_IREAD | S_IWRITE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 # define mch_open_rw(n, f) mch_open((n), (f), 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 * Encryption macros. Mohsin Ahmed, mosh@sasi.com 98-09-24
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 * Based on zip/crypt sources.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 #ifdef FEAT_CRYPT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 /* encode byte c, using temp t. Warning: c must not have side effects. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 # define ZENCODE(c, t) (t = decrypt_byte(), update_keys(c), t^(c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 /* decode byte c in place */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 # define ZDECODE(c) update_keys(c ^= decrypt_byte())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 #ifdef STARTUPTIME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 # define TIME_MSG(s) time_msg(s, NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 # define TIME_MSG(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 #ifdef FEAT_VREPLACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 # define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 # define REPLACE_NORMAL(s) ((s) & REPLACE_FLAG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 #ifdef FEAT_ARABIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 # define UTF_COMPOSINGLIKE(p1, p2) utf_composinglike((p1), (p2))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 # define UTF_COMPOSINGLIKE(p1, p2) utf_iscomposing(utf_ptr2char(p2))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 /* Whether to draw the vertical bar on the right side of the cell. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 # define CURSOR_BAR_RIGHT (curwin->w_p_rl && (!(State & CMDLINE) || cmdmsg_rl))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 #endif
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 7
diff changeset
249
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
250 /*
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
251 * mb_ptr_adv(): advance a pointer to the next character, taking care of
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
252 * multi-byte characters if needed.
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
253 * mb_ptr_back(): backup a pointer to the previous character, taking care of
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
254 * multi-byte characters if needed.
98
98435a8ddb09 updated for version 7.0038
vimboss
parents: 39
diff changeset
255 * 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
256 * PTR2CHAR(): get character from pointer.
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
257 */
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
258 #ifdef FEAT_MBYTE
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
259 /* Advance multi-byte pointer, skip over composing chars. */
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
260 # define mb_ptr_adv(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
261 /* Advance multi-byte pointer, do not skip over composing chars. */
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
262 # define mb_cptr_adv(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
263 /* Backup multi-byte pointer. */
377
0fd7ac767ecd updated for version 7.0098
vimboss
parents: 325
diff changeset
264 # 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
265 /* get length of multi-byte char, not including composing chars */
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
266 # define mb_cptr2len(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p))
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
267
98
98435a8ddb09 updated for version 7.0038
vimboss
parents: 39
diff changeset
268 # define MB_COPY_CHAR(f, t) if (has_mbyte) mb_copy_char(&f, &t); else *t++ = *f++
377
0fd7ac767ecd updated for version 7.0098
vimboss
parents: 325
diff changeset
269 # define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : STRLEN(p))
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
270 # define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p))
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
271 #else
456
c4d200412ae9 updated for version 7.0121
vimboss
parents: 377
diff changeset
272 # define mb_ptr_adv(p) ++p
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
273 # define mb_cptr_adv(p) ++p
456
c4d200412ae9 updated for version 7.0121
vimboss
parents: 377
diff changeset
274 # define mb_ptr_back(s, p) --p
c4d200412ae9 updated for version 7.0121
vimboss
parents: 377
diff changeset
275 # define MB_COPY_CHAR(f, t) *t++ = *f++
c4d200412ae9 updated for version 7.0121
vimboss
parents: 377
diff changeset
276 # define MB_CHARLEN(p) STRLEN(p)
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 456
diff changeset
277 # define PTR2CHAR(p) ((int)*(p))
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 21
diff changeset
278 #endif