aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/macros.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/macros.h')
-rw-r--r--src/nvim/macros.h32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/nvim/macros.h b/src/nvim/macros.h
index c2b2c89abf..a896a406d1 100644
--- a/src/nvim/macros.h
+++ b/src/nvim/macros.h
@@ -56,12 +56,14 @@
// Returns empty string if it is NULL.
#define EMPTY_IF_NULL(x) (char *)((x) ? (x) : (char_u *)"")
-// Adjust chars in a language according to 'langmap' option.
-// NOTE that there is no noticeable overhead if 'langmap' is not set.
-// When set the overhead for characters < 256 is small.
-// Don't apply 'langmap' if the character comes from the Stuff buffer or from a
-// mapping and the langnoremap option was set.
-// The do-while is just to ignore a ';' after the macro.
+/// Adjust chars in a language according to 'langmap' option.
+/// NOTE that there is no noticeable overhead if 'langmap' is not set.
+/// When set the overhead for characters < 256 is small.
+/// Don't apply 'langmap' if the character comes from the Stuff buffer or from a
+/// mapping and the langnoremap option was set.
+/// The do-while is just to ignore a ';' after the macro.
+///
+/// -V:LANGMAP_ADJUST:560
#define LANGMAP_ADJUST(c, condition) \
do { \
if (*p_langmap \
@@ -83,27 +85,29 @@
// mch_open_rw(): invoke os_open() with third argument for user R/W.
#if defined(UNIX) // open in rw------- mode
-# define mch_open_rw(n, f) os_open((n), (f), (mode_t)0600)
+# define MCH_OPEN_RW(n, f) os_open((n), (f), (mode_t)0600)
#elif defined(WIN32)
-# define mch_open_rw(n, f) os_open((n), (f), S_IREAD | S_IWRITE)
+# define MCH_OPEN_RW(n, f) os_open((n), (f), S_IREAD | S_IWRITE)
#else
-# define mch_open_rw(n, f) os_open((n), (f), 0)
+# define MCH_OPEN_RW(n, f) os_open((n), (f), 0)
#endif
#define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
-
// MB_PTR_ADV(): advance a pointer to the next character, taking care of
// multi-byte characters if needed. Skip over composing chars.
-#define MB_PTR_ADV(p) (p += utfc_ptr2len((char_u *)p))
+#define MB_PTR_ADV(p) (p += utfc_ptr2len((char *)p))
// Advance multi-byte pointer, do not skip over composing chars.
-#define MB_CPTR_ADV(p) (p += utf_ptr2len(p))
+#define MB_CPTR_ADV(p) (p += utf_ptr2len((char *)p))
// 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), ((char *)b)))
#define RESET_BINDING(wp) \
do { \
@@ -130,7 +134,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)