vim-patch:8.2.4402: missing parenthesis may cause unexpected problems

Problem:    Missing parenthesis may cause unexpected problems.
Solution:   Add more parenthesis is macros.
ae6f1d8b14
This commit is contained in:
Brian Leung 2022-04-03 02:36:01 -07:00
parent 271bb32855
commit 69e11b58b4
No known key found for this signature in database
GPG Key ID: 3ADC75F013D678F9
17 changed files with 58 additions and 59 deletions

View File

@ -425,9 +425,9 @@ char_u *str_foldcase(char_u *str, int orglen, char_u *buf, int buflen)
int len = orglen;
#define GA_CHAR(i) ((char_u *)ga.ga_data)[i]
#define GA_PTR(i) ((char_u *)ga.ga_data + i)
#define GA_PTR(i) ((char_u *)ga.ga_data + (i))
#define STR_CHAR(i) (buf == NULL ? GA_CHAR(i) : buf[i])
#define STR_PTR(i) (buf == NULL ? GA_PTR(i) : buf + i)
#define STR_PTR(i) (buf == NULL ? GA_PTR(i) : buf + (i))
// Copy "str" into "buf" or allocated memory, unmodified.
if (buf == NULL) {

View File

@ -6550,7 +6550,7 @@ static inline uint32_t shuffle_xoshiro128starstar(uint32_t *const x, uint32_t *c
uint32_t *const z, uint32_t *const w)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE
{
#define ROTL(x, k) ((x << k) | (x >> (32 - k)))
#define ROTL(x, k) (((x) << (k)) | ((x) >> (32 - (k))))
const uint32_t result = ROTL(*y * 5, 7) * 9;
const uint32_t t = *y << 9;
*z ^= *x;

View File

@ -2753,7 +2753,7 @@ static void truncate_fold(win_T *const wp, fold_T *fp, linenr_T end)
#define FOLD_END(fp) ((fp)->fd_top + (fp)->fd_len - 1)
#define VALID_FOLD(fp, gap) \
((gap)->ga_len > 0 && (fp) < ((fold_T *)(gap)->ga_data + (gap)->ga_len))
#define FOLD_INDEX(fp, gap) ((size_t)(fp - ((fold_T *)(gap)->ga_data)))
#define FOLD_INDEX(fp, gap) ((size_t)((fp) - ((fold_T *)(gap)->ga_data)))
void foldMoveRange(win_T *const wp, garray_T *gap, const linenr_T line1, const linenr_T line2,
const linenr_T dest)
{

View File

@ -2573,7 +2573,7 @@ int inchar(char_u *buf, int maxlen, long wait_time)
// Don't use buf[] here, closescript() may have freed typebuf.tb_buf[]
// and buf may be pointing inside typebuf.tb_buf[].
if (got_int) {
#define DUM_LEN MAXMAPLEN * 3 + 3
#define DUM_LEN (MAXMAPLEN * 3 + 3)
char_u dum[DUM_LEN + 1];
for (;;) {

View File

@ -133,7 +133,7 @@
#define ARRAY_LAST_ENTRY(arr) (arr)[ARRAY_SIZE(arr) - 1]
// Duplicated in os/win_defs.h to avoid include-order sensitivity.
#define RGB_(r, g, b) ((r << 16) | (g << 8) | b)
#define RGB_(r, g, b) (((r) << 16) | ((g) << 8) | (b))
#define STR_(x) #x
#define STR(x) STR_(x)

View File

@ -230,7 +230,7 @@ static linenr_T lowest_marked = 0;
#define ML_INSERT 0x12 // insert line
#define ML_FIND 0x13 // just find the line
#define ML_FLUSH 0x02 // flush locked block
#define ML_SIMPLE(x) (x & 0x10) // DEL, INS or FIND
#define ML_SIMPLE(x) ((x) & 0x10) // DEL, INS or FIND
// argument for ml_upd_block0()
typedef enum {

View File

@ -2616,7 +2616,7 @@ void may_clear_cmdline(void)
}
// Routines for displaying a partly typed command
#define SHOWCMD_BUFLEN SHOWCMD_COLS + 1 + 30
#define SHOWCMD_BUFLEN (SHOWCMD_COLS + 1 + 30)
static char_u showcmd_buf[SHOWCMD_BUFLEN];
static char_u old_showcmd_buf[SHOWCMD_BUFLEN]; // For push_showcmd()
static bool showcmd_is_clear = true;

View File

@ -36,7 +36,7 @@
// Windows defines a RGB macro that produces 0x00bbggrr color values for use
// with GDI. Our macro is different, and we don't use GDI.
// Duplicated from macros.h to avoid include-order sensitivity.
#define RGB_(r, g, b) ((r << 16) | (g << 8) | b)
#define RGB_(r, g, b) (((r) << 16) | ((g) << 8) | (b))
#ifdef _MSC_VER
# ifndef inline

View File

@ -229,28 +229,28 @@ typedef struct vgr_args_S {
static char_u *e_no_more_items = (char_u *)N_("E553: No more items");
// Quickfix window check helper macro
#define IS_QF_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref == NULL)
#define IS_QF_WINDOW(wp) (bt_quickfix((wp)->w_buffer) && (wp)->w_llist_ref == NULL)
// Location list window check helper macro
#define IS_LL_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
#define IS_LL_WINDOW(wp) (bt_quickfix((wp)->w_buffer) && (wp)->w_llist_ref != NULL)
// Quickfix and location list stack check helper macros
#define IS_QF_STACK(qi) (qi->qfl_type == QFLT_QUICKFIX)
#define IS_LL_STACK(qi) (qi->qfl_type == QFLT_LOCATION)
#define IS_QF_LIST(qfl) (qfl->qfl_type == QFLT_QUICKFIX)
#define IS_LL_LIST(qfl) (qfl->qfl_type == QFLT_LOCATION)
#define IS_QF_STACK(qi) ((qi)->qfl_type == QFLT_QUICKFIX)
#define IS_LL_STACK(qi) ((qi)->qfl_type == QFLT_LOCATION)
#define IS_QF_LIST(qfl) ((qfl)->qfl_type == QFLT_QUICKFIX)
#define IS_LL_LIST(qfl) ((qfl)->qfl_type == QFLT_LOCATION)
//
// Return location list for window 'wp'
// For location list window, return the referenced location list
//
#define GET_LOC_LIST(wp) (IS_LL_WINDOW(wp) ? wp->w_llist_ref : wp->w_llist)
#define GET_LOC_LIST(wp) (IS_LL_WINDOW(wp) ? (wp)->w_llist_ref : (wp)->w_llist)
// Macro to loop through all the items in a quickfix list
// Quickfix item index starts from 1, so i below starts at 1
#define FOR_ALL_QFL_ITEMS(qfl, qfp, i) \
for (i = 1, qfp = qfl->qf_start; /* NOLINT(readability/braces) */ \
!got_int && i <= qfl->qf_count && qfp != NULL; \
i++, qfp = qfp->qf_next)
for ((i) = 1, (qfp) = (qfl)->qf_start; /* NOLINT(readability/braces) */ \
!got_int && (i) <= (qfl)->qf_count && (qfp) != NULL; \
(i)++, (qfp) = (qfp)->qf_next)
// Looking up a buffer can be slow if there are many. Remember the last one

View File

@ -279,15 +279,15 @@ static void init_class_tab(void)
done = true;
}
# define ri_digit(c) (c < 0x100 && (class_tab[c] & RI_DIGIT))
# define ri_hex(c) (c < 0x100 && (class_tab[c] & RI_HEX))
# define ri_octal(c) (c < 0x100 && (class_tab[c] & RI_OCTAL))
# define ri_word(c) (c < 0x100 && (class_tab[c] & RI_WORD))
# define ri_head(c) (c < 0x100 && (class_tab[c] & RI_HEAD))
# define ri_alpha(c) (c < 0x100 && (class_tab[c] & RI_ALPHA))
# define ri_lower(c) (c < 0x100 && (class_tab[c] & RI_LOWER))
# define ri_upper(c) (c < 0x100 && (class_tab[c] & RI_UPPER))
# define ri_white(c) (c < 0x100 && (class_tab[c] & RI_WHITE))
# define ri_digit(c) ((c) < 0x100 && (class_tab[c] & RI_DIGIT))
# define ri_hex(c) ((c) < 0x100 && (class_tab[c] & RI_HEX))
# define ri_octal(c) ((c) < 0x100 && (class_tab[c] & RI_OCTAL))
# define ri_word(c) ((c) < 0x100 && (class_tab[c] & RI_WORD))
# define ri_head(c) ((c) < 0x100 && (class_tab[c] & RI_HEAD))
# define ri_alpha(c) ((c) < 0x100 && (class_tab[c] & RI_ALPHA))
# define ri_lower(c) ((c) < 0x100 && (class_tab[c] & RI_LOWER))
# define ri_upper(c) ((c) < 0x100 && (class_tab[c] & RI_UPPER))
# define ri_white(c) ((c) < 0x100 && (class_tab[c] & RI_WHITE))
// flags for regflags
#define RF_ICASE 1 // ignore case

View File

@ -2119,13 +2119,13 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
// draw_state: items that are drawn in sequence:
#define WL_START 0 // nothing done yet
#define WL_CMDLINE WL_START + 1 // cmdline window column
#define WL_FOLD WL_CMDLINE + 1 // 'foldcolumn'
#define WL_SIGN WL_FOLD + 1 // column for signs
#define WL_NR WL_SIGN + 1 // line number
#define WL_BRI WL_NR + 1 // 'breakindent'
#define WL_SBR WL_BRI + 1 // 'showbreak' or 'diff'
#define WL_LINE WL_SBR + 1 // text in the line
#define WL_CMDLINE (WL_START + 1) // cmdline window column
#define WL_FOLD (WL_CMDLINE + 1) // 'foldcolumn'
#define WL_SIGN (WL_FOLD + 1) // column for signs
#define WL_NR (WL_SIGN + 1) // line number
#define WL_BRI (WL_NR + 1) // 'breakindent'
#define WL_SBR (WL_BRI + 1) // 'showbreak' or 'diff'
#define WL_LINE (WL_SBR + 1) // text in the line
int draw_state = WL_START; // what to draw next
int syntax_flags = 0;

View File

@ -4830,15 +4830,15 @@ typedef struct {
/// bonus if the first letter is matched
#define FIRST_LETTER_BONUS 15
/// penalty applied for every letter in str before the first match
#define LEADING_LETTER_PENALTY -5
#define LEADING_LETTER_PENALTY (-5)
/// maximum penalty for leading letters
#define MAX_LEADING_LETTER_PENALTY -15
#define MAX_LEADING_LETTER_PENALTY (-15)
/// penalty for every letter that doesn't match
#define UNMATCHED_LETTER_PENALTY -1
#define UNMATCHED_LETTER_PENALTY (-1)
/// penalty for gap in matching positions (-2 * k)
#define GAP_PENALTY -2
#define GAP_PENALTY (-2)
/// Score for a string that doesn't fuzzy match the pattern
#define SCORE_NONE -9999
#define SCORE_NONE (-9999)
#define FUZZY_MATCH_RECURSION_LIMIT 10

View File

@ -73,8 +73,8 @@ static void sha256_process(context_sha256_T *ctx, const char_u data[SHA256_BUFFE
GET_UINT32(W[14], data, 56);
GET_UINT32(W[15], data, 60);
#define SHR(x, n) ((x & 0xFFFFFFFF) >> n)
#define ROTR(x, n) (SHR(x, n) | (x << (32 - n)))
#define SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
#define S0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))
#define S1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10))
@ -82,17 +82,16 @@ static void sha256_process(context_sha256_T *ctx, const char_u data[SHA256_BUFFE
#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
#define F0(x, y, z) ((x & y) | (z & (x | y)))
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
#define R(t) \
(W[t] = S1(W[t - 2]) + W[t - 7] + \
S0(W[t - 15]) + W[t - 16])
(W[t] = S1(W[(t) - 2]) + W[(t) - 7] + S0(W[(t) - 15]) + W[(t) - 16])
#define P(a, b, c, d, e, f, g, h, x, K) { \
temp1 = h + S3(e) + F1(e, f, g) + K + x; \
temp1 = (h) + S3(e) + F1(e, f, g) + (K) + (x); \
temp2 = S2(a) + F0(a, b, c); \
d += temp1; h = temp1 + temp2; \
(d) += temp1; (h) = temp1 + temp2; \
}
A = ctx->state[0];

View File

@ -62,11 +62,11 @@
// Disadvantage: When "the" is typed as "hte" it sounds quite different ("@"
// vs "ht") and goes down in the list.
// Used when 'spellsuggest' is set to "best".
#define RESCORE(word_score, sound_score) ((3 * word_score + sound_score) / 4)
#define RESCORE(word_score, sound_score) ((3 * (word_score) + (sound_score)) / 4)
// Do the opposite: based on a maximum end score and a known sound score,
// compute the maximum word score that can be used.
#define MAXSCORE(word_score, sound_score) ((4 * word_score - sound_score) / 3)
#define MAXSCORE(word_score, sound_score) ((4 * (word_score) - (sound_score)) / 3)
#include <assert.h>
#include <inttypes.h>
@ -122,7 +122,7 @@
#define WF_CAPMASK (WF_ONECAP | WF_ALLCAP | WF_KEEPCAP | WF_FIXCAP)
// Result values. Lower number is accepted over higher one.
#define SP_BANNED -1
#define SP_BANNED (-1)
#define SP_RARE 0
#define SP_OK 1
#define SP_LOCAL 2
@ -176,7 +176,7 @@ typedef struct {
#define SUG(ga, i) (((suggest_T *)(ga).ga_data)[i])
// True if a word appears in the list of banned words.
#define WAS_BANNED(su, word) (!HASHITEM_EMPTY(hash_find(&su->su_banned, word)))
#define WAS_BANNED(su, word) (!HASHITEM_EMPTY(hash_find(&(su)->su_banned, word)))
// Number of suggestions kept when cleaning up. We need to keep more than
// what is displayed, because when rescore_suggestions() is called the score
@ -225,7 +225,7 @@ typedef struct {
#define SCORE_SFMAX2 300 // maximum score for second try
#define SCORE_SFMAX3 400 // maximum score for third try
#define SCORE_BIG SCORE_INS * 3 // big difference
#define SCORE_BIG (SCORE_INS * 3) // big difference
#define SCORE_MAXMAX 999999 // accept any score
#define SCORE_LIMITMAX 350 // for spell_edit_score_limit()
@ -5284,7 +5284,7 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char_u *
}
static sftword_T dumsft;
#define HIKEY2SFT(p) ((sftword_T *)(p - (dumsft.sft_word - (char_u *)&dumsft)))
#define HIKEY2SFT(p) ((sftword_T *)((p) - (dumsft.sft_word - (char_u *)&dumsft)))
#define HI2SFT(hi) HIKEY2SFT((hi)->hi_key)
// Prepare for calling suggest_try_soundalike().

View File

@ -1850,7 +1850,7 @@ static void spell_reload_one(char_u *fname, bool added_word)
// In the postponed prefixes tree wn_flags is used to store the WFP_ flags,
// but it must be negative to indicate the prefix tree to tree_add_word().
// Use a negative number with the lower 8 bits zero.
#define PFX_FLAGS -256
#define PFX_FLAGS (-256)
// flags for "condit" argument of store_aff_word()
#define CONDIT_COMB 1 // affix must combine

View File

@ -181,7 +181,7 @@ static char *(spo_name_tab[SPO_COUNT]) =
#define SYN_ITEMS(buf) ((synpat_T *)((buf)->b_syn_patterns.ga_data))
#define NONE_IDX -2 // value of sp_sync_idx for "NONE"
#define NONE_IDX (-2) // value of sp_sync_idx for "NONE"
/*
* Flags for b_syn_sync_flags:
@ -267,9 +267,9 @@ static int keepend_level = -1;
static char msg_no_items[] = N_("No Syntax items defined for this buffer");
// value of si_idx for keywords
#define KEYWORD_IDX -1
#define KEYWORD_IDX (-1)
// valid of si_cont_list for containing all but contained groups
#define ID_LIST_ALL (int16_t *)-1
#define ID_LIST_ALL ((int16_t *)-1)
static int next_seqnr = 1; // value to use for si_seqnr

View File

@ -59,7 +59,7 @@
#endif
#define NOWIN (win_T *)-1 // non-existing window
#define NOWIN ((win_T *)-1) // non-existing window
#define ROWS_AVAIL (Rows - p_ch - tabline_height() - global_stl_height())