Mercurial > vim
comparison src/macros.h @ 28226:89c181c99e23 v8.2.4639
patch 8.2.4639: not sufficient parenthesis in preprocessor macros
Commit: https://github.com/vim/vim/commit/9dac9b1751dd43c02470cc6a2aecaeea27abcc80
Author: kylo252 <59826753+kylo252@users.noreply.github.com>
Date: Sun Mar 27 20:05:17 2022 +0100
patch 8.2.4639: not sufficient parenthesis in preprocessor macros
Problem: Not sufficient parenthesis in preprocessor macros.
Solution: Add more parenthesis. (closes https://github.com/vim/vim/issues/10031)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 27 Mar 2022 21:15:04 +0200 |
parents | fb4c30606b4a |
children | d770568e6c98 |
comparison
equal
deleted
inserted
replaced
28225:584f657538df | 28226:89c181c99e23 |
---|---|
230 // Advance multi-byte pointer, skip over composing chars. | 230 // Advance multi-byte pointer, skip over composing chars. |
231 #define MB_PTR_ADV(p) p += (*mb_ptr2len)(p) | 231 #define MB_PTR_ADV(p) p += (*mb_ptr2len)(p) |
232 // Advance multi-byte pointer, do not skip over composing chars. | 232 // Advance multi-byte pointer, do not skip over composing chars. |
233 #define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p) | 233 #define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p) |
234 // Backup multi-byte pointer. Only use with "p" > "s" ! | 234 // Backup multi-byte pointer. Only use with "p" > "s" ! |
235 #define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1 | 235 #define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, (p) - 1) + 1) : 1 |
236 // get length of multi-byte char, not including composing chars | 236 // get length of multi-byte char, not including composing chars |
237 #define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p)) | 237 #define MB_CPTR2LEN(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p)) |
238 | 238 |
239 #define MB_COPY_CHAR(f, t) do { if (has_mbyte) mb_copy_char(&f, &t); else *t++ = *f++; } while (0) | 239 #define MB_COPY_CHAR(f, t) do { if (has_mbyte) mb_copy_char(&(f), &(t)); else *(t)++ = *(f)++; } while (0) |
240 #define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p)) | 240 #define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p)) |
241 #define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1) | 241 #define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1) |
242 #define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p)) | 242 #define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p)) |
243 #define MB_CHAR2BYTES(c, b) do { if (has_mbyte) (b) += (*mb_char2bytes)((c), (b)); else *(b)++ = (c); } while(0) | 243 #define MB_CHAR2BYTES(c, b) do { if (has_mbyte) (b) += (*mb_char2bytes)((c), (b)); else *(b)++ = (c); } while(0) |
244 | 244 |
311 * DI2HIKEY() converts a dictitem pointer to a hashitem key pointer. | 311 * DI2HIKEY() converts a dictitem pointer to a hashitem key pointer. |
312 * HIKEY2DI() converts a hashitem key pointer to a dictitem pointer. | 312 * HIKEY2DI() converts a hashitem key pointer to a dictitem pointer. |
313 * HI2DI() converts a hashitem pointer to a dictitem pointer. | 313 * HI2DI() converts a hashitem pointer to a dictitem pointer. |
314 */ | 314 */ |
315 #define DI2HIKEY(di) ((di)->di_key) | 315 #define DI2HIKEY(di) ((di)->di_key) |
316 #define HIKEY2DI(p) ((dictitem_T *)(p - offsetof(dictitem_T, di_key))) | 316 #define HIKEY2DI(p) ((dictitem_T *)((p) - offsetof(dictitem_T, di_key))) |
317 #define HI2DI(hi) HIKEY2DI((hi)->hi_key) | 317 #define HI2DI(hi) HIKEY2DI((hi)->hi_key) |
318 | 318 |
319 /* | 319 /* |
320 * Flush control functions. | 320 * Flush control functions. |
321 */ | 321 */ |
374 | 374 |
375 // Inline the condition for performance. | 375 // Inline the condition for performance. |
376 #define CHECK_LIST_MATERIALIZE(l) if ((l)->lv_first == &range_list_item) range_list_materialize(l) | 376 #define CHECK_LIST_MATERIALIZE(l) if ((l)->lv_first == &range_list_item) range_list_materialize(l) |
377 | 377 |
378 // Inlined version of ga_grow() with optimized condition that it fails. | 378 // Inlined version of ga_grow() with optimized condition that it fails. |
379 #define GA_GROW_FAILS(gap, n) unlikely((((gap)->ga_maxlen - (gap)->ga_len < n) ? ga_grow_inner((gap), (n)) : OK) == FAIL) | 379 #define GA_GROW_FAILS(gap, n) unlikely((((gap)->ga_maxlen - (gap)->ga_len < (n)) ? ga_grow_inner((gap), (n)) : OK) == FAIL) |
380 // Inlined version of ga_grow() with optimized condition that it succeeds. | 380 // Inlined version of ga_grow() with optimized condition that it succeeds. |
381 #define GA_GROW_OK(gap, n) likely((((gap)->ga_maxlen - (gap)->ga_len < n) ? ga_grow_inner((gap), (n)) : OK) == OK) | 381 #define GA_GROW_OK(gap, n) likely((((gap)->ga_maxlen - (gap)->ga_len < (n)) ? ga_grow_inner((gap), (n)) : OK) == OK) |
382 | 382 |
383 #ifndef MIN | 383 #ifndef MIN |
384 # define MIN(a, b) ((a) < (b) ? (a) : (b)) | 384 # define MIN(a, b) ((a) < (b) ? (a) : (b)) |
385 #endif | 385 #endif |
386 #ifndef MAX | 386 #ifndef MAX |