Mercurial > vim
comparison src/macros.h @ 11127:506f5d8b7d8b v8.0.0451
patch 8.0.0451: some macros are in lower case
commit https://github.com/vim/vim/commit/91acfffc1e6c0d8c2abfb186a0e79a5bf19c3f3f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 12 19:22:36 2017 +0100
patch 8.0.0451: some macros are in lower case
Problem: Some macros are in lower case.
Solution: Make a few more macros upper case. Avoid lower case macros use an
argument twice.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 12 Mar 2017 19:30:05 +0100 |
parents | 778c10516955 |
children | f4ea50924c6d |
comparison
equal
deleted
inserted
replaced
11126:48599a3eae0b | 11127:506f5d8b7d8b |
---|---|
6 * Do ":help credits" in Vim to see a list of people who contributed. | 6 * Do ":help credits" in Vim to see a list of people who contributed. |
7 */ | 7 */ |
8 | 8 |
9 /* | 9 /* |
10 * macros.h: macro definitions for often used code | 10 * macros.h: macro definitions for often used code |
11 * | |
12 * Macros should be ALL_CAPS. An exception is for where a function is | |
13 * replaced and an argument is not used more than once. | |
11 */ | 14 */ |
12 | 15 |
13 /* | 16 /* |
14 * PCHAR(lp, c) - put character 'c' at position 'lp' | 17 * PCHAR(lp, c) - put character 'c' at position 'lp' |
15 */ | 18 */ |
159 #else | 162 #else |
160 # define LANGMAP_ADJUST(c, condition) /* nop */ | 163 # define LANGMAP_ADJUST(c, condition) /* nop */ |
161 #endif | 164 #endif |
162 | 165 |
163 /* | 166 /* |
164 * vim_isbreak() is used very often if 'linebreak' is set, use a macro to make | 167 * VIM_ISBREAK() is used very often if 'linebreak' is set, use a macro to make |
165 * it work fast. | 168 * it work fast. Only works for single byte characters! |
166 */ | 169 */ |
167 #define vim_isbreak(c) (breakat_flags[(char_u)(c)]) | 170 #define VIM_ISBREAK(c) ((c) < 256 && breakat_flags[(char_u)(c)]) |
168 | 171 |
169 /* | 172 /* |
170 * On VMS file names are different and require a translation. | 173 * On VMS file names are different and require a translation. |
171 * On the Mac open() has only two arguments. | 174 * On the Mac open() has only two arguments. |
172 */ | 175 */ |
188 # define mch_fstat(n, p) fstat((n), (p)) | 191 # define mch_fstat(n, p) fstat((n), (p)) |
189 # ifdef MSWIN /* has it's own mch_stat() function */ | 192 # ifdef MSWIN /* has it's own mch_stat() function */ |
190 # define mch_stat(n, p) vim_stat((n), (p)) | 193 # define mch_stat(n, p) vim_stat((n), (p)) |
191 # else | 194 # else |
192 # ifdef STAT_IGNORES_SLASH | 195 # ifdef STAT_IGNORES_SLASH |
193 /* On Solaris stat() accepts "file/" as if it was "file". Return -1 if | 196 # define mch_stat(n, p) vim_stat((n), (p)) |
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 # else |
197 # define mch_stat(n, p) stat((n), (p)) | 198 # define mch_stat(n, p) stat((n), (p)) |
198 # endif | 199 # endif |
199 # endif | 200 # endif |
200 #endif | 201 #endif |
256 /* Whether to draw the vertical bar on the right side of the cell. */ | 257 /* 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 # define CURSOR_BAR_RIGHT (curwin->w_p_rl && (!(State & CMDLINE) || cmdmsg_rl)) |
258 #endif | 259 #endif |
259 | 260 |
260 /* | 261 /* |
261 * mb_ptr_adv(): advance a pointer to the next character, taking care of | 262 * MB_PTR_ADV(): advance a pointer to the next character, taking care of |
262 * multi-byte characters if needed. | 263 * multi-byte characters if needed. |
263 * mb_ptr_back(): backup a pointer to the previous character, taking care of | 264 * MB_PTR_BACK(): backup a pointer to the previous character, taking care of |
264 * multi-byte characters if needed. | 265 * multi-byte characters if needed. |
265 * MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers. | 266 * MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers. |
266 * PTR2CHAR(): get character from pointer. | 267 * PTR2CHAR(): get character from pointer. |
267 */ | 268 */ |
268 #ifdef FEAT_MBYTE | 269 #ifdef FEAT_MBYTE |
269 /* Get the length of the character p points to */ | 270 /* Get the length of the character p points to */ |
270 # define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1) | 271 # define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1) |
271 /* Advance multi-byte pointer, skip over composing chars. */ | 272 /* Advance multi-byte pointer, skip over composing chars. */ |
272 # define mb_ptr_adv(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1 | 273 # define MB_PTR_ADV(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1 |
273 /* Advance multi-byte pointer, do not skip over composing chars. */ | 274 /* 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 | 275 # define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1 |
275 /* Backup multi-byte pointer. Only use with "p" > "s" ! */ | 276 /* Backup multi-byte pointer. Only use with "p" > "s" ! */ |
276 # define mb_ptr_back(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1 | 277 # define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1 |
277 /* get length of multi-byte char, not including composing chars */ | 278 /* get length of multi-byte char, not including composing chars */ |
278 # define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p)) | 279 # define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p)) |
279 | 280 |
280 # define MB_COPY_CHAR(f, t) if (has_mbyte) mb_copy_char(&f, &t); else *t++ = *f++ | 281 # define MB_COPY_CHAR(f, t) if (has_mbyte) mb_copy_char(&f, &t); else *t++ = *f++ |
281 # define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p)) | 282 # define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p)) |
282 # define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1) | 283 # define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1) |
283 # define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p)) | 284 # define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p)) |
284 #else | 285 #else |
285 # define MB_PTR2LEN(p) 1 | 286 # define MB_PTR2LEN(p) 1 |
286 # define MB_CPTR2LEN(p) 1 | 287 # define MB_CPTR2LEN(p) 1 |
287 # define mb_ptr_adv(p) ++p | 288 # define MB_PTR_ADV(p) ++p |
288 # define mb_cptr_adv(p) ++p | 289 # define MB_CPTR_ADV(p) ++p |
289 # define mb_ptr_back(s, p) --p | 290 # define MB_PTR_BACK(s, p) --p |
290 # define MB_COPY_CHAR(f, t) *t++ = *f++ | 291 # define MB_COPY_CHAR(f, t) *t++ = *f++ |
291 # define MB_CHARLEN(p) STRLEN(p) | 292 # define MB_CHARLEN(p) STRLEN(p) |
292 # define MB_CHAR2LEN(c) 1 | 293 # define MB_CHAR2LEN(c) 1 |
293 # define PTR2CHAR(p) ((int)*(p)) | 294 # define PTR2CHAR(p) ((int)*(p)) |
294 #endif | 295 #endif |