Macros
macros.h File Reference
#include "auto/config.h"

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 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)   (char *)((x) ? (x) : (char_u *)"")
 
#define LANGMAP_ADJUST(c, condition)
 
#define WRITEBIN   "wb"
 
#define READBIN   "rb"
 
#define APPENDBIN   "ab"
 
#define mch_open_rw(n, f)   os_open((n), (f), 0)
 
#define REPLACE_NORMAL(s)   (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
 
#define MB_PTR_ADV(p)   (p += utfc_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 RESET_BINDING(wp)
 
#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_INCLUDE(x)   0
 
#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_PUSH_IGNORE_IMPLICIT_FALLTHROUGH
 
#define PRAGMA_DIAG_POP
 
#define EMPTY_POS(a)   ((a).lnum == 0 && (a).col == 0 && (a).coladd == 0)
 

Macro Definition Documentation

◆ APPENDBIN

#define APPENDBIN   "ab"

◆ ARRAY_LAST_ENTRY

#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.

◆ ARRAY_SIZE

#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).

-V:ARRAY_SIZE:1063

◆ ASCII_ISALNUM

#define ASCII_ISALNUM (   c)    (ASCII_ISALPHA(c) || ascii_isdigit(c))

◆ ASCII_ISALPHA

#define ASCII_ISALPHA (   c)    (ASCII_ISUPPER(c) || ASCII_ISLOWER(c))

◆ ASCII_ISLOWER

#define ASCII_ISLOWER (   c)    ((unsigned)(c) >= 'a' && (unsigned)(c) <= 'z')

◆ ASCII_ISUPPER

#define ASCII_ISUPPER (   c)    ((unsigned)(c) >= 'A' && (unsigned)(c) <= 'Z')

◆ EMPTY_IF_NULL

#define EMPTY_IF_NULL (   x)    (char *)((x) ? (x) : (char_u *)"")

◆ EMPTY_POS

#define EMPTY_POS (   a)    ((a).lnum == 0 && (a).col == 0 && (a).coladd == 0)

◆ EXTERN

#define EXTERN   extern

◆ FALLTHROUGH

#define FALLTHROUGH

◆ INIT

#define INIT (   ...)

◆ IO_COUNT

#define IO_COUNT (   x)    (x)

◆ LANGMAP_ADJUST

#define LANGMAP_ADJUST (   c,
  condition 
)
Value:
do { \
if (*p_langmap \
&& (condition) \
&& (p_lrm || (vgetc_busy ? typebuf_maplen() == 0 : KeyTyped)) \
&& !KeyStuffed \
&& (c) >= 0) \
{ \
if ((c) < 256) \
c = langmap_mapchar[c]; \
else \
} \
} while (0)

◆ LINEEMPTY

#define LINEEMPTY (   p)    (*ml_get(p) == NUL)

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

◆ MAX

#define MAX (   X,
 
)    ((X) > (Y) ? (X) : (Y))

◆ MB_CPTR_ADV

#define MB_CPTR_ADV (   p)    (p += utf_ptr2len(p))

◆ MB_PTR_ADV

#define MB_PTR_ADV (   p)    (p += utfc_ptr2len((char_u *)p))

◆ MB_PTR_BACK

#define MB_PTR_BACK (   s,
  p 
)    (p -= utf_head_off((char_u *)s, (char_u *)p - 1) + 1)

◆ mch_open_rw

#define mch_open_rw (   n,
 
)    os_open((n), (f), 0)

◆ MIN

#define MIN (   X,
 
)    ((X) < (Y) ? (X) : (Y))

◆ NVIM_HAS_ATTRIBUTE

#define NVIM_HAS_ATTRIBUTE (   x)    0

◆ NVIM_HAS_INCLUDE

#define NVIM_HAS_INCLUDE (   x)    0

◆ PRAGMA_DIAG_POP

#define PRAGMA_DIAG_POP

◆ PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH

#define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH

◆ PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES

#define PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES

PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES

◆ READBIN

#define READBIN   "rb"

◆ REPLACE_NORMAL

#define REPLACE_NORMAL (   s)    (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))

◆ RESET_BINDING

#define RESET_BINDING (   wp)
Value:
do { \
(wp)->w_p_scb = false; \
(wp)->w_p_crb = false; \
} while (0)

◆ RGB_

#define RGB_ (   r,
  g,
 
)    ((r << 16) | (g << 8) | b)

◆ S_LEN

#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

◆ STR

#define STR (   x)    STR_(x)

◆ STR_

#define STR_ (   x)    #x

◆ STRUCT_CAST

#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).

◆ TOLOWER_ASC

#define TOLOWER_ASC (   c)    (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A'))

◆ TOLOWER_LOC

#define TOLOWER_LOC   tolower

◆ TOUPPER_ASC

#define TOUPPER_ASC (   c)    (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A'))

◆ TOUPPER_LOC

#define TOUPPER_LOC   toupper

◆ UV_BUF_LEN

#define UV_BUF_LEN (   x)    (x)

◆ WRITEBIN

#define WRITEBIN   "wb"
langmap_adjust_mb
int langmap_adjust_mb(int c)
Apply 'langmap' to multi-byte character "c" and return the result.
Definition: option.c:6780
w_p_scb
#define w_p_scb
Definition: buffer_defs.h:236
typebuf_maplen
int typebuf_maplen(void)
Definition: getchar.c:1045
w_p_crb
#define w_p_crb
Definition: buffer_defs.h:250
p_lrm
EXTERN int p_lrm
Definition: option_defs.h:502
langmap_mapchar
EXTERN char_u langmap_mapchar[256]
Definition: globals.h:765
p_langmap
EXTERN char_u * p_langmap
Definition: option_defs.h:500
KeyTyped
EXTERN bool KeyTyped
Definition: globals.h:694
KeyStuffed
EXTERN int KeyStuffed
Definition: globals.h:695