aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.git-blame-ignore-revs2
-rw-r--r--src/nvim/buffer.h2
-rw-r--r--src/nvim/buffer_defs.h4
-rw-r--r--src/nvim/charset.c4
-rw-r--r--src/nvim/eval/funcs.c2
-rw-r--r--src/nvim/ex_cmds.h2
-rw-r--r--src/nvim/ex_cmds_defs.h4
-rw-r--r--src/nvim/fileio.c2
-rw-r--r--src/nvim/fold.c2
-rw-r--r--src/nvim/getchar.c2
-rw-r--r--src/nvim/getchar.h4
-rw-r--r--src/nvim/globals.h8
-rw-r--r--src/nvim/macros.h4
-rw-r--r--src/nvim/memline.c2
-rw-r--r--src/nvim/mouse.h4
-rw-r--r--src/nvim/normal.c2
-rw-r--r--src/nvim/option_defs.h4
-rw-r--r--src/nvim/os/win_defs.h2
-rw-r--r--src/nvim/quickfix.c20
-rw-r--r--src/nvim/regexp.c18
-rw-r--r--src/nvim/regexp_defs.h2
-rw-r--r--src/nvim/screen.c14
-rw-r--r--src/nvim/screen.h4
-rw-r--r--src/nvim/search.c10
-rw-r--r--src/nvim/sha256.c15
-rw-r--r--src/nvim/spell.c12
-rw-r--r--src/nvim/spell_defs.h6
-rw-r--r--src/nvim/spellfile.c2
-rw-r--r--src/nvim/syntax.c6
-rw-r--r--src/nvim/syntax_defs.h2
-rw-r--r--src/nvim/vim.h6
-rw-r--r--src/nvim/window.c2
32 files changed, 88 insertions, 87 deletions
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index 737a9a249e..fce35b54ee 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -45,6 +45,8 @@ a68faed02dc8e37b8f10da14dc02e33e6ed93947
38dd53c525054daf83dba27d7d46e90e8b41fa50
6059784770c4c88fb6fe528b9f7634192fa1164e
ee031eb5256bb83e0d6add2bae6fd943a4186ffe
+69e11b58b4db0952f11a5ff85aa7150b5f5b8db8
+271bb32855853b011fceaf0ad2f829bce66b2a19
# typos
d238b8f6003d34cae7f65ff7585b48a2cd9449fb
diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h
index 9e2ca999e4..850ab175a5 100644
--- a/src/nvim/buffer.h
+++ b/src/nvim/buffer.h
@@ -23,7 +23,7 @@ enum getf_retvalues {
GETFILE_ERROR = 1, // normal error
GETFILE_NOT_WRITTEN = 2, // "not written" error
GETFILE_SAME_FILE = 0, // success, same file
- GETFILE_OPEN_OTHER = -1, // success, opened another file
+ GETFILE_OPEN_OTHER = (-1), // success, opened another file
GETFILE_UNUSED = 8,
};
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 08ca1a6247..422741cc2f 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -661,7 +661,7 @@ struct file_buffer {
// flags for use of ":lmap" and IM control
long b_p_iminsert; // input mode for insert
long b_p_imsearch; // input mode for search
-#define B_IMODE_USE_INSERT -1 // Use b_p_iminsert value for search
+#define B_IMODE_USE_INSERT (-1) // Use b_p_iminsert value for search
#define B_IMODE_NONE 0 // Input via none
#define B_IMODE_LMAP 1 // Input via langmap
#define B_IMODE_LAST 1
@@ -1420,7 +1420,7 @@ struct window_S {
int w_briopt_list; // additional indent for lists
// transform a pointer to a "onebuf" option into a "allbuf" option
-#define GLOBAL_WO(p) ((char *)p + sizeof(winopt_T))
+#define GLOBAL_WO(p) ((char *)(p) + sizeof(winopt_T))
long w_scbind_pos;
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 986a89b0a5..ec1866e9cc 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -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) {
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 92672be8d0..f7d9f76534 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -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;
diff --git a/src/nvim/ex_cmds.h b/src/nvim/ex_cmds.h
index 241674c24c..1c95b75001 100644
--- a/src/nvim/ex_cmds.h
+++ b/src/nvim/ex_cmds.h
@@ -21,7 +21,7 @@
// for lnum argument in do_ecmd()
#define ECMD_LASTL (linenr_T)0 // use last position in loaded file
-#define ECMD_LAST (linenr_T)-1 // use last position in all files
+#define ECMD_LAST ((linenr_T)-1) // use last position in all files
#define ECMD_ONE (linenr_T)1 // use first line
/// Previous :substitute replacement string definition
diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h
index 92675499be..39dfc1b94c 100644
--- a/src/nvim/ex_cmds_defs.h
+++ b/src/nvim/ex_cmds_defs.h
@@ -87,8 +87,8 @@ typedef struct exarg exarg_T;
// behavior for bad character, "++bad=" argument
#define BAD_REPLACE '?' // replace it with '?' (default)
-#define BAD_KEEP -1 // leave it
-#define BAD_DROP -2 // erase it
+#define BAD_KEEP (-1) // leave it
+#define BAD_DROP (-2) // erase it
typedef void (*ex_func_T)(exarg_T *eap);
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 5e11a9683e..64ad9a6d80 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -80,7 +80,7 @@
#define FIO_ENDIAN_L 0x80 // little endian
#define FIO_NOCONVERT 0x2000 // skip encoding conversion
#define FIO_UCSBOM 0x4000 // check for BOM at start of file
-#define FIO_ALL -1 // allow all formats
+#define FIO_ALL (-1) // allow all formats
/* When converting, a read() or write() may leave some bytes to be converted
* for the next call. The value is guessed... */
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index 54430d46af..3643ceb460 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -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)
{
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 8190c20c1c..669d181364 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -2571,7 +2571,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 (;;) {
diff --git a/src/nvim/getchar.h b/src/nvim/getchar.h
index f24a4e7c7c..9b8605f1df 100644
--- a/src/nvim/getchar.h
+++ b/src/nvim/getchar.h
@@ -61,8 +61,8 @@ typedef struct map_arguments MapArguments;
#define MAP_ARGUMENTS_INIT { false, false, false, false, false, false, false, \
{ 0 }, 0, NULL, 0, LUA_NOREF, false, NULL, 0, NULL }
-#define KEYLEN_PART_KEY -1 // keylen value for incomplete key-code
-#define KEYLEN_PART_MAP -2 // keylen value for incomplete mapping
+#define KEYLEN_PART_KEY (-1) // keylen value for incomplete key-code
+#define KEYLEN_PART_MAP (-2) // keylen value for incomplete mapping
/// Maximum number of streams to read script from
enum { NSCRIPT = 15, };
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 605a2183f3..ace7647b35 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -430,7 +430,7 @@ EXTERN win_T *lastwin; // last window
EXTERN win_T *prevwin INIT(= NULL); // previous window
#define ONE_WINDOW (firstwin == lastwin)
#define FOR_ALL_FRAMES(frp, first_frame) \
- for (frp = first_frame; frp != NULL; frp = frp->fr_next) // NOLINT
+ for ((frp) = first_frame; (frp) != NULL; (frp) = (frp)->fr_next) // NOLINT
// When using this macro "break" only breaks out of the inner loop. Use "goto"
// to break out of the tabpage loop.
@@ -461,7 +461,7 @@ EXTERN tabpage_T *lastused_tabpage;
EXTERN bool redraw_tabline INIT(= false); // need to redraw tabline
// Iterates over all tabs in the tab list
-#define FOR_ALL_TABS(tp) for (tabpage_T *tp = first_tabpage; tp != NULL; tp = tp->tp_next)
+#define FOR_ALL_TABS(tp) for (tabpage_T *(tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next)
// All buffers are linked in a list. 'firstbuf' points to the first entry,
// 'lastbuf' to the last entry and 'curbuf' to the currently active buffer.
@@ -477,7 +477,7 @@ EXTERN buf_T *curbuf INIT(= NULL); // currently active buffer
// Iterate through all the signs placed in a buffer
#define FOR_ALL_SIGNS_IN_BUF(buf, sign) \
- for (sign = buf->b_signlist; sign != NULL; sign = sign->se_next) // NOLINT
+ for ((sign) = (buf)->b_signlist; (sign) != NULL; (sign) = (sign)->se_next) // NOLINT
// List of files being edited (global argument list). curwin->w_alist points
@@ -618,7 +618,7 @@ EXTERN int inhibit_delete_count INIT(= 0);
#define DBCS_CHT 950 // taiwan
#define DBCS_CHTU 9950 // euc-tw
#define DBCS_2BYTE 1 // 2byte-
-#define DBCS_DEBUG -1
+#define DBCS_DEBUG (-1)
/// Encoding used when 'fencs' is set to "default"
EXTERN char_u *fenc_default INIT(= NULL);
diff --git a/src/nvim/macros.h b/src/nvim/macros.h
index d5611f587b..be1ab935c0 100644
--- a/src/nvim/macros.h
+++ b/src/nvim/macros.h
@@ -103,7 +103,7 @@
// MB_PTR_BACK(): backup a pointer to the previous character, taking care of
// multi-byte characters if needed. Only use with "p" > "s" !
#define MB_PTR_BACK(s, p) \
- (p -= utf_head_off((char_u *)s, (char_u *)p - 1) + 1)
+ (p -= utf_head_off((char_u *)(s), (char_u *)(p) - 1) + 1)
// MB_CHAR2BYTES(): convert character to bytes and advance pointer to bytes
#define MB_CHAR2BYTES(c, b) ((b) += utf_char2bytes((c), (b)))
@@ -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)
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 1df32f79e1..418887a6b1 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -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 {
diff --git a/src/nvim/mouse.h b/src/nvim/mouse.h
index bf4f9c57e5..04acb88bb3 100644
--- a/src/nvim/mouse.h
+++ b/src/nvim/mouse.h
@@ -38,8 +38,8 @@
// Direction for nv_mousescroll() and ins_mousescroll()
#define MSCR_DOWN 0 // DOWN must be FALSE
#define MSCR_UP 1
-#define MSCR_LEFT -1
-#define MSCR_RIGHT -2
+#define MSCR_LEFT (-1)
+#define MSCR_RIGHT (-2)
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 8332b8bbd6..5e46bd468d 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -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;
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index 98c2b84770..6ce95ea690 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -57,7 +57,7 @@
#define ENC_DFLT "utf-8"
// end-of-line style
-#define EOL_UNKNOWN -1 // not defined yet
+#define EOL_UNKNOWN (-1) // not defined yet
#define EOL_UNIX 0 // NL
#define EOL_DOS 1 // CR NL
#define EOL_MAC 2 // CR
@@ -899,7 +899,7 @@ enum {
};
// Value for b_p_ul indicating the global value must be used.
-#define NO_LOCAL_UNDOLEVEL -123456
+#define NO_LOCAL_UNDOLEVEL (-123456)
#define SB_MAX 100000 // Maximum 'scrollback' value.
diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h
index efef77be7b..1ae86d6bbe 100644
--- a/src/nvim/os/win_defs.h
+++ b/src/nvim/os/win_defs.h
@@ -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
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index c8d9e91fb5..1d589e8ca0 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -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
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index d3c43e530a..53add57736 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -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
diff --git a/src/nvim/regexp_defs.h b/src/nvim/regexp_defs.h
index 1d112bd64a..913cfb2074 100644
--- a/src/nvim/regexp_defs.h
+++ b/src/nvim/regexp_defs.h
@@ -34,7 +34,7 @@
// In the NFA engine: how many states are allowed.
#define NFA_MAX_STATES 100000
-#define NFA_TOO_EXPENSIVE -1
+#define NFA_TOO_EXPENSIVE (-1)
// Which regexp engine to use? Needed for vim_regcomp().
// Must match with 'regexpengine'.
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index f922a50260..baeb2fcb03 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -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;
diff --git a/src/nvim/screen.h b/src/nvim/screen.h
index d15e4b7e45..5e86dacd25 100644
--- a/src/nvim/screen.h
+++ b/src/nvim/screen.h
@@ -65,8 +65,8 @@ extern StlClickDefinition *tab_page_click_defs;
/// Size of the tab_page_click_defs array
extern long tab_page_click_defs_size;
-#define W_ENDCOL(wp) (wp->w_wincol + wp->w_width)
-#define W_ENDROW(wp) (wp->w_winrow + wp->w_height)
+#define W_ENDCOL(wp) ((wp)->w_wincol + (wp)->w_width)
+#define W_ENDROW(wp) ((wp)->w_winrow + (wp)->w_height)
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "screen.h.generated.h"
diff --git a/src/nvim/search.c b/src/nvim/search.c
index a69bd641f8..c30e69391f 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -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
diff --git a/src/nvim/sha256.c b/src/nvim/sha256.c
index 9d6a2f2c41..2c6199bf8b 100644
--- a/src/nvim/sha256.c
+++ b/src/nvim/sha256.c
@@ -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];
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index fb644daa39..97f39c925a 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -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().
diff --git a/src/nvim/spell_defs.h b/src/nvim/spell_defs.h
index 220f51cd2f..12e44cb7ff 100644
--- a/src/nvim/spell_defs.h
+++ b/src/nvim/spell_defs.h
@@ -93,9 +93,9 @@ typedef int salfirst_T;
// Values for SP_*ERROR are negative, positive values are used by
// read_cnt_string().
-#define SP_TRUNCERROR -1 // spell file truncated error
-#define SP_FORMERROR -2 // format error in spell file
-#define SP_OTHERERROR -3 // other error while reading spell file
+#define SP_TRUNCERROR (-1) // spell file truncated error
+#define SP_FORMERROR (-2) // format error in spell file
+#define SP_OTHERERROR (-3) // other error while reading spell file
// Structure used to store words and other info for one language, loaded from
// a .spl file.
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 07058b34fd..3d3e6e728c 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -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
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index f829b6a270..a82e8fa103 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -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
diff --git a/src/nvim/syntax_defs.h b/src/nvim/syntax_defs.h
index a005f67209..c656f21181 100644
--- a/src/nvim/syntax_defs.h
+++ b/src/nvim/syntax_defs.h
@@ -7,7 +7,7 @@
#define SST_MAX_ENTRIES 1000 // maximal size for state stack array
#define SST_FIX_STATES 7 // size of sst_stack[].
#define SST_DIST 16 // normal distance between entries
-#define SST_INVALID (synstate_T *)-1 // invalid syn_state pointer
+#define SST_INVALID ((synstate_T *)-1) // invalid syn_state pointer
typedef struct syn_state synstate_T;
diff --git a/src/nvim/vim.h b/src/nvim/vim.h
index 5d632b1b25..f65dd4f0d4 100644
--- a/src/nvim/vim.h
+++ b/src/nvim/vim.h
@@ -264,7 +264,7 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
// Prefer using semsg(), because perror() may send the output to the wrong
// destination and mess up the screen.
-#define PERROR(msg) (void)semsg("%s: %s", msg, strerror(errno))
+#define PERROR(msg) (void)semsg("%s: %s", (msg), strerror(errno))
#define SHOWCMD_COLS 10 // columns needed by shown command
@@ -319,7 +319,7 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
#endif
// Replacement for nchar used by nv_replace().
-#define REPLACE_CR_NCHAR -1
-#define REPLACE_NL_NCHAR -2
+#define REPLACE_CR_NCHAR (-1)
+#define REPLACE_NL_NCHAR (-2)
#endif // NVIM_VIM_H
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 632e9b3f44..9ac51bb108 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -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())