Macros
macros.h File Reference

Go to the source code of this file.

Macros

#define EXTERN   extern
 
#define INIT(...)
 
#define MIN(X, Y)   ((X) < (Y) ? (X) : (Y))
 
#define MAX(X, Y)   ((X) > (Y) ? (X) : (Y))
 
#define S_LEN(s)   (s), (sizeof(s) - 1)
 
#define LINEEMPTY(p)   (*ml_get(p) == NUL)
 LINEEMPTY() - return TRUE if the line is empty. More...
 
#define BUFEMPTY()
 BUFEMPTY() - return TRUE if the current buffer is empty. More...
 
#define TOUPPER_LOC   toupper
 
#define TOLOWER_LOC   tolower
 
#define TOUPPER_ASC(c)   (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A'))
 
#define TOLOWER_ASC(c)   (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A'))
 
#define ASCII_ISLOWER(c)   ((unsigned)(c) >= 'a' && (unsigned)(c) <= 'z')
 
#define ASCII_ISUPPER(c)   ((unsigned)(c) >= 'A' && (unsigned)(c) <= 'Z')
 
#define ASCII_ISALPHA(c)   (ASCII_ISUPPER(c) || ASCII_ISLOWER(c))
 
#define ASCII_ISALNUM(c)   (ASCII_ISALPHA(c) || ascii_isdigit(c))
 
#define EMPTY_IF_NULL(x)   ((x) ? (x) : (char_u *)"")
 
#define LANGMAP_ADJUST(c, condition)
 
#define WRITEBIN   "wb" /* no CR-LF translation */
 
#define READBIN   "rb"
 
#define APPENDBIN   "ab"
 
#define mch_fopen(n, p)   fopen((n), (p))
 
#define mch_open_rw(n, f)   os_open((n), (f), 0)
 
#define REPLACE_NORMAL(s)   (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
 
#define UTF_COMPOSINGLIKE(p1, p2)   utf_composinglike((p1), (p2))
 
#define CURSOR_BAR_RIGHT   (curwin->w_p_rl && (!(State & CMDLINE) || cmdmsg_rl))
 
#define MB_PTR2LEN(p)   mb_ptr2len(p)
 
#define MB_PTR_ADV(p)   (p += mb_ptr2len((char_u *)p))
 
#define MB_CPTR_ADV(p)   (p += utf_ptr2len(p))
 
#define MB_PTR_BACK(s, p)   (p -= utf_head_off((char_u *)s, (char_u *)p - 1) + 1)
 
#define MB_CPTR2LEN(p)   utf_ptr2len(p)
 
#define MB_COPY_CHAR(f, t)   mb_copy_char((const char_u **)(&f), &t);
 
#define MB_CHARLEN(p)   mb_charlen(p)
 
#define MB_CHAR2LEN(c)   mb_char2len(c)
 
#define PTR2CHAR(p)   utf_ptr2char(p)
 
#define RESET_BINDING(wp)   (wp)->w_p_scb = FALSE; (wp)->w_p_crb = FALSE
 
#define ARRAY_SIZE(arr)
 
#define ARRAY_LAST_ENTRY(arr)   (arr)[ARRAY_SIZE(arr) - 1]
 
#define RGB_(r, g, b)   ((r << 16) | (g << 8) | b)
 
#define STR_(x)   #x
 
#define STR(x)   STR_(x)
 
#define NVIM_HAS_ATTRIBUTE(x)   0
 
#define FALLTHROUGH
 
#define STRUCT_CAST(Type, obj)   ((Type *)(obj))
 
#define UV_BUF_LEN(x)   (x)
 
#define IO_COUNT(x)   (x)
 
#define PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES
 
#define PRAGMA_DIAG_POP
 

Macro Definition Documentation

#define APPENDBIN   "ab"
#define ARRAY_LAST_ENTRY (   arr)    (arr)[ARRAY_SIZE(arr) - 1]

Get last array entry

This should be called with a real array. Calling this with a pointer is an error.

#define ARRAY_SIZE (   arr)
Value:
((sizeof(arr)/sizeof((arr)[0])) \
/ ((size_t)(!(sizeof(arr) % sizeof((arr)[0])))))

Calculate the length of a C array

This should be called with a real array. Calling this with a pointer is an error. A mechanism to detect many (though not all) of those errors at compile time is implemented. It works by the second division producing a division by zero in those cases (-Wdiv-by-zero in GCC).

#define ASCII_ISALNUM (   c)    (ASCII_ISALPHA(c) || ascii_isdigit(c))
#define ASCII_ISALPHA (   c)    (ASCII_ISUPPER(c) || ASCII_ISLOWER(c))
#define ASCII_ISLOWER (   c)    ((unsigned)(c) >= 'a' && (unsigned)(c) <= 'z')
#define ASCII_ISUPPER (   c)    ((unsigned)(c) >= 'A' && (unsigned)(c) <= 'Z')
#define BUFEMPTY ( )
Value:
(curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == \
char_u * ml_get(linenr_T lnum)
Definition: memline.c:1717
#define NUL
Definition: ascii.h:19
long linenr_T
Definition: pos.h:4

BUFEMPTY() - return TRUE if the current buffer is empty.

#define CURSOR_BAR_RIGHT   (curwin->w_p_rl && (!(State & CMDLINE) || cmdmsg_rl))
#define EMPTY_IF_NULL (   x)    ((x) ? (x) : (char_u *)"")
#define EXTERN   extern
#define FALLTHROUGH
#define INIT (   ...)
#define IO_COUNT (   x)    (x)
#define LANGMAP_ADJUST (   c,
  condition 
)
Value:
do { \
&& (condition) \
&& (p_lrm || (vgetc_busy ? typebuf_maplen() == 0 : KeyTyped)) \
&& !KeyStuffed \
&& (c) >= 0) \
{ \
if ((c) < 256) \
c = langmap_mapchar[c]; \
else \
} \
} while (0)
if(len)
Definition: encode.c:222
EXTERN int KeyStuffed
Definition: globals.h:749
EXTERN char_u * p_langmap
Definition: option_defs.h:481
EXTERN char_u langmap_mapchar[256]
Definition: globals.h:819
int typebuf_maplen(void)
Definition: getchar.c:1018
EXTERN bool KeyTyped
Definition: globals.h:748
int langmap_adjust_mb(int c)
Definition: option.c:6369
EXTERN int p_lrm
Definition: option_defs.h:483
#define LINEEMPTY (   p)    (*ml_get(p) == NUL)

LINEEMPTY() - return TRUE if the line is empty.

#define MAX (   X,
 
)    ((X) > (Y) ? (X) : (Y))
#define MB_CHAR2LEN (   c)    mb_char2len(c)
#define MB_CHARLEN (   p)    mb_charlen(p)
#define MB_COPY_CHAR (   f,
 
)    mb_copy_char((const char_u **)(&f), &t);
#define MB_CPTR2LEN (   p)    utf_ptr2len(p)
#define MB_CPTR_ADV (   p)    (p += utf_ptr2len(p))
#define MB_PTR2LEN (   p)    mb_ptr2len(p)
#define MB_PTR_ADV (   p)    (p += mb_ptr2len((char_u *)p))
#define MB_PTR_BACK (   s,
  p 
)    (p -= utf_head_off((char_u *)s, (char_u *)p - 1) + 1)
#define mch_fopen (   n,
  p 
)    fopen((n), (p))
#define mch_open_rw (   n,
 
)    os_open((n), (f), 0)
#define MIN (   X,
 
)    ((X) < (Y) ? (X) : (Y))
#define NVIM_HAS_ATTRIBUTE (   x)    0
#define PRAGMA_DIAG_POP
#define PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES

PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES

#define PTR2CHAR (   p)    utf_ptr2char(p)
#define READBIN   "rb"
#define REPLACE_NORMAL (   s)    (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
#define RESET_BINDING (   wp)    (wp)->w_p_scb = FALSE; (wp)->w_p_crb = FALSE
#define RGB_ (   r,
  g,
 
)    ((r << 16) | (g << 8) | b)
#define S_LEN (   s)    (s), (sizeof(s) - 1)

String with length

For use in functions which accept (char *s, size_t len) pair in arguments.

Parameters
[in]sStatic string.
Returns
s, sizeof(s) - 1
#define STR (   x)    STR_(x)
#define STR_ (   x)    #x
#define STRUCT_CAST (   Type,
  obj 
)    ((Type *)(obj))

Change type of structure pointers: cast struct a * to struct b *

Used to silence PVS errors.

Parameters
TypeStructure to cast to.
objObject to cast.
Returns
((Type *)obj).
#define TOLOWER_ASC (   c)    (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A'))
#define TOLOWER_LOC   tolower
#define TOUPPER_ASC (   c)    (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A'))
#define TOUPPER_LOC   toupper
#define UTF_COMPOSINGLIKE (   p1,
  p2 
)    utf_composinglike((p1), (p2))
#define UV_BUF_LEN (   x)    (x)
#define WRITEBIN   "wb" /* no CR-LF translation */