mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
refactor: missing parenthesis may cause unexpected problems (#17443)
related vim-8.2.{4402,4639}
This commit is contained in:
parent
f246a929e7
commit
7b952793d5
@ -45,6 +45,7 @@ IncludeCategories:
|
||||
Priority: 1
|
||||
SortPriority: 1
|
||||
CaseSensitive: false
|
||||
AlignConsecutiveMacros: AcrossEmptyLines
|
||||
IndentPPDirectives: AfterHash
|
||||
SpaceBeforeParens: ControlStatementsExceptControlMacros
|
||||
ForEachMacros:
|
||||
@ -62,4 +63,4 @@ ForEachMacros:
|
||||
- RBUFFER_EACH_REVERSE
|
||||
- RBUFFER_UNTIL_EMPTY
|
||||
- RBUFFER_UNTIL_FULL
|
||||
- kl_iter
|
||||
- kl_iter
|
||||
|
@ -1931,13 +1931,13 @@ static void write_msg(String message, bool to_err)
|
||||
static char out_line_buf[LINE_BUFFER_SIZE], err_line_buf[LINE_BUFFER_SIZE];
|
||||
|
||||
#define PUSH_CHAR(i, pos, line_buf, msg) \
|
||||
if (message.data[i] == NL || pos == LINE_BUFFER_SIZE - 1) { \
|
||||
line_buf[pos] = NUL; \
|
||||
if (message.data[i] == NL || (pos) == LINE_BUFFER_SIZE - 1) { \
|
||||
(line_buf)[pos] = NUL; \
|
||||
msg(line_buf); \
|
||||
pos = 0; \
|
||||
(pos) = 0; \
|
||||
continue; \
|
||||
} \
|
||||
line_buf[pos++] = message.data[i];
|
||||
(line_buf)[(pos)++] = message.data[i];
|
||||
|
||||
no_wait_return++;
|
||||
for (uint32_t i = 0; i < message.size; i++) {
|
||||
|
@ -1556,10 +1556,10 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, cons
|
||||
} \
|
||||
const uvarnumber_T digit = (uvarnumber_T)(conv); \
|
||||
/* avoid ubsan error for overflow */ \
|
||||
if (un < UVARNUMBER_MAX / base \
|
||||
|| (un == UVARNUMBER_MAX / base \
|
||||
&& (base != 10 || digit <= UVARNUMBER_MAX % 10))) { \
|
||||
un = base * un + digit; \
|
||||
if (un < UVARNUMBER_MAX / (base) \
|
||||
|| (un == UVARNUMBER_MAX / (base) \
|
||||
&& ((base) != 10 || digit <= UVARNUMBER_MAX % 10))) { \
|
||||
un = (base) * un + digit; \
|
||||
} else { \
|
||||
un = UVARNUMBER_MAX; \
|
||||
} \
|
||||
|
@ -444,7 +444,7 @@ bool dbg_check_skipped(exarg_T *eap)
|
||||
|
||||
static garray_T dbg_breakp = { 0, 0, sizeof(struct debuggy), 4, NULL };
|
||||
#define BREAKP(idx) (((struct debuggy *)dbg_breakp.ga_data)[idx])
|
||||
#define DEBUGGY(gap, idx) (((struct debuggy *)gap->ga_data)[idx])
|
||||
#define DEBUGGY(gap, idx) (((struct debuggy *)(gap)->ga_data)[idx])
|
||||
static int last_breakp = 0; // nr of last defined breakpoint
|
||||
|
||||
// Profiling uses file and func names similar to breakpoints.
|
||||
|
@ -2351,9 +2351,9 @@ static int ins_compl_add(char_u *const str, int len, char_u *const fname,
|
||||
}
|
||||
#define FREE_CPTEXT(cptext, cptext_allocated) \
|
||||
do { \
|
||||
if (cptext != NULL && cptext_allocated) { \
|
||||
if ((cptext) != NULL && (cptext_allocated)) { \
|
||||
for (size_t i = 0; i < CPT_COUNT; i++) { \
|
||||
xfree(cptext[i]); \
|
||||
xfree((cptext)[i]); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -124,13 +124,13 @@ typedef struct {
|
||||
|
||||
#define VV(idx, name, type, flags) \
|
||||
[idx] = { \
|
||||
.vv_name = name, \
|
||||
.vv_name = (name), \
|
||||
.vv_di = { \
|
||||
.di_tv = { .v_type = type }, \
|
||||
.di_tv = { .v_type = (type) }, \
|
||||
.di_flags = 0, \
|
||||
.di_key = { 0 }, \
|
||||
}, \
|
||||
.vv_flags = flags, \
|
||||
.vv_flags = (flags), \
|
||||
}
|
||||
|
||||
#define VIMVAR_KEY_LEN 16 // Maximum length of the key of v:variables
|
||||
|
@ -414,9 +414,9 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len,
|
||||
bool hasnul = false;
|
||||
#define PUT_FST_IN_PAIR(fst_in_pair, str_end) \
|
||||
do { \
|
||||
if (fst_in_pair != 0) { \
|
||||
str_end += utf_char2bytes(fst_in_pair, str_end); \
|
||||
fst_in_pair = 0; \
|
||||
if ((fst_in_pair) != 0) { \
|
||||
(str_end) += utf_char2bytes(fst_in_pair, (str_end)); \
|
||||
(fst_in_pair) = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
for (const char *t = s; t < p; t++) {
|
||||
|
@ -293,8 +293,8 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_STRING(tv, buf, len) \
|
||||
do { \
|
||||
const char *const buf_ = (const char *)buf; \
|
||||
if (buf == NULL) { \
|
||||
const char *const buf_ = (const char *)(buf); \
|
||||
if ((buf) == NULL) { \
|
||||
ga_concat(gap, "''"); \
|
||||
} else { \
|
||||
const size_t len_ = (len); \
|
||||
@ -383,14 +383,14 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, len) \
|
||||
do { \
|
||||
if (len != 0) { \
|
||||
if ((len) != 0) { \
|
||||
ga_concat(gap, ", "); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, len) \
|
||||
do { \
|
||||
if ((ptrdiff_t)len != -1) { \
|
||||
if ((ptrdiff_t)(len) != -1) { \
|
||||
ga_concat(gap, ", "); \
|
||||
} \
|
||||
} while (0)
|
||||
@ -452,12 +452,12 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s
|
||||
size_t backref = 0; \
|
||||
for (; backref < kv_size(*mpstack); backref++) { \
|
||||
const MPConvStackVal mpval = kv_A(*mpstack, backref); \
|
||||
if (mpval.type == conv_type) { \
|
||||
if (conv_type == kMPConvDict) { \
|
||||
if (mpval.type == (conv_type)) { \
|
||||
if ((conv_type) == kMPConvDict) { \
|
||||
if ((void *)mpval.data.d.dict == (void *)(val)) { \
|
||||
break; \
|
||||
} \
|
||||
} else if (conv_type == kMPConvList) { \
|
||||
} else if ((conv_type) == kMPConvList) { \
|
||||
if ((void *)mpval.data.l.list == (void *)(val)) { \
|
||||
break; \
|
||||
} \
|
||||
@ -487,19 +487,19 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s
|
||||
size_t backref = 0; \
|
||||
for (; backref < kv_size(*mpstack); backref++) { \
|
||||
const MPConvStackVal mpval = kv_A(*mpstack, backref); \
|
||||
if (mpval.type == conv_type) { \
|
||||
if (conv_type == kMPConvDict) { \
|
||||
if ((void *)mpval.data.d.dict == (void *)val) { \
|
||||
if (mpval.type == (conv_type)) { \
|
||||
if ((conv_type) == kMPConvDict) { \
|
||||
if ((void *)mpval.data.d.dict == (void *)(val)) { \
|
||||
break; \
|
||||
} \
|
||||
} else if (conv_type == kMPConvList) { \
|
||||
if ((void *)mpval.data.l.list == (void *)val) { \
|
||||
} else if ((conv_type) == kMPConvList) { \
|
||||
if ((void *)mpval.data.l.list == (void *)(val)) { \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
if (conv_type == kMPConvDict) { \
|
||||
if ((conv_type) == kMPConvDict) { \
|
||||
vim_snprintf(ebuf, ARRAY_SIZE(ebuf), "{...@%zu}", backref); \
|
||||
} else { \
|
||||
vim_snprintf(ebuf, ARRAY_SIZE(ebuf), "[...@%zu]", backref); \
|
||||
@ -609,7 +609,7 @@ static inline int convert_to_json_string(garray_T *const gap, const char *const
|
||||
// This is done to make resulting values displayable on screen also not from
|
||||
// Neovim.
|
||||
#define ENCODE_RAW(ch) \
|
||||
(ch >= 0x20 && utf_printable(ch))
|
||||
((ch) >= 0x20 && utf_printable(ch))
|
||||
for (size_t i = 0; i < utf_len;) {
|
||||
const int ch = utf_ptr2char(utf_buf + i);
|
||||
const size_t shift = (ch == 0 ? 1 : ((size_t)utf_ptr2len(utf_buf + i)));
|
||||
@ -788,7 +788,7 @@ bool encode_check_json_key(const typval_T *const tv)
|
||||
#undef TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK
|
||||
#define TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK(label, key) \
|
||||
do { \
|
||||
if (!encode_check_json_key(&key)) { \
|
||||
if (!encode_check_json_key(&(key))) { \
|
||||
emsg(_("E474: Invalid key in special dictionary")); \
|
||||
goto label; \
|
||||
} \
|
||||
@ -911,7 +911,7 @@ char *encode_tv2json(typval_T *tv, size_t *len)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_STRING(tv, buf, len) \
|
||||
do { \
|
||||
if (buf == NULL) { \
|
||||
if ((buf) == NULL) { \
|
||||
msgpack_pack_bin(packer, 0); \
|
||||
} else { \
|
||||
const size_t len_ = (len); \
|
||||
@ -922,7 +922,7 @@ char *encode_tv2json(typval_T *tv, size_t *len)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_STR_STRING(tv, buf, len) \
|
||||
do { \
|
||||
if (buf == NULL) { \
|
||||
if ((buf) == NULL) { \
|
||||
msgpack_pack_str(packer, 0); \
|
||||
} else { \
|
||||
const size_t len_ = (len); \
|
||||
@ -933,11 +933,11 @@ char *encode_tv2json(typval_T *tv, size_t *len)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_EXT_STRING(tv, buf, len, type) \
|
||||
do { \
|
||||
if (buf == NULL) { \
|
||||
msgpack_pack_ext(packer, 0, (int8_t)type); \
|
||||
if ((buf) == NULL) { \
|
||||
msgpack_pack_ext(packer, 0, (int8_t)(type)); \
|
||||
} else { \
|
||||
const size_t len_ = (len); \
|
||||
msgpack_pack_ext(packer, len_, (int8_t)type); \
|
||||
msgpack_pack_ext(packer, len_, (int8_t)(type)); \
|
||||
msgpack_pack_ext_body(packer, buf, len_); \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -879,9 +879,9 @@ void tv_list_reverse(list_T *const l)
|
||||
list_log(l, NULL, NULL, "reverse");
|
||||
#define SWAP(a, b) \
|
||||
do { \
|
||||
tmp = a; \
|
||||
a = b; \
|
||||
b = tmp; \
|
||||
tmp = (a); \
|
||||
(a) = (b); \
|
||||
(b) = tmp; \
|
||||
} while (0)
|
||||
listitem_T *tmp;
|
||||
|
||||
@ -2262,36 +2262,36 @@ void tv_blob_copy(typval_T *const from, typval_T *const to)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_NIL(tv) \
|
||||
do { \
|
||||
tv->vval.v_special = kSpecialVarNull; \
|
||||
tv->v_lock = VAR_UNLOCKED; \
|
||||
(tv)->vval.v_special = kSpecialVarNull; \
|
||||
(tv)->v_lock = VAR_UNLOCKED; \
|
||||
} while (0)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_BOOL(tv, num) \
|
||||
do { \
|
||||
tv->vval.v_bool = kBoolVarFalse; \
|
||||
tv->v_lock = VAR_UNLOCKED; \
|
||||
(tv)->vval.v_bool = kBoolVarFalse; \
|
||||
(tv)->v_lock = VAR_UNLOCKED; \
|
||||
} while (0)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_NUMBER(tv, num) \
|
||||
do { \
|
||||
(void)num; \
|
||||
tv->vval.v_number = 0; \
|
||||
tv->v_lock = VAR_UNLOCKED; \
|
||||
(void)(num); \
|
||||
(tv)->vval.v_number = 0; \
|
||||
(tv)->v_lock = VAR_UNLOCKED; \
|
||||
} while (0)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER(tv, num)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_FLOAT(tv, flt) \
|
||||
do { \
|
||||
tv->vval.v_float = 0; \
|
||||
tv->v_lock = VAR_UNLOCKED; \
|
||||
(tv)->vval.v_float = 0; \
|
||||
(tv)->v_lock = VAR_UNLOCKED; \
|
||||
} while (0)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_STRING(tv, buf, len) \
|
||||
do { \
|
||||
xfree(buf); \
|
||||
tv->vval.v_string = NULL; \
|
||||
tv->v_lock = VAR_UNLOCKED; \
|
||||
(tv)->vval.v_string = NULL; \
|
||||
(tv)->v_lock = VAR_UNLOCKED; \
|
||||
} while (0)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_STR_STRING(tv, buf, len)
|
||||
@ -2300,9 +2300,9 @@ void tv_blob_copy(typval_T *const from, typval_T *const to)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_BLOB(tv, blob, len) \
|
||||
do { \
|
||||
tv_blob_unref(tv->vval.v_blob); \
|
||||
tv->vval.v_blob = NULL; \
|
||||
tv->v_lock = VAR_UNLOCKED; \
|
||||
tv_blob_unref((tv)->vval.v_blob); \
|
||||
(tv)->vval.v_blob = NULL; \
|
||||
(tv)->v_lock = VAR_UNLOCKED; \
|
||||
} while (0)
|
||||
|
||||
static inline int _nothing_conv_func_start(typval_T *const tv, char_u *const fun)
|
||||
@ -2359,9 +2359,9 @@ static inline void _nothing_conv_func_end(typval_T *const tv, const int copyID)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_EMPTY_LIST(tv) \
|
||||
do { \
|
||||
tv_list_unref(tv->vval.v_list); \
|
||||
tv->vval.v_list = NULL; \
|
||||
tv->v_lock = VAR_UNLOCKED; \
|
||||
tv_list_unref((tv)->vval.v_list); \
|
||||
(tv)->vval.v_list = NULL; \
|
||||
(tv)->v_lock = VAR_UNLOCKED; \
|
||||
} while (0)
|
||||
|
||||
static inline void _nothing_conv_empty_dict(typval_T *const tv, dict_T **const dictp)
|
||||
@ -2375,8 +2375,8 @@ static inline void _nothing_conv_empty_dict(typval_T *const tv, dict_T **const d
|
||||
}
|
||||
#define TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, dict) \
|
||||
do { \
|
||||
assert((void *)&dict != (void *)&TYPVAL_ENCODE_NODICT_VAR); \
|
||||
_nothing_conv_empty_dict(tv, ((dict_T **)&dict)); \
|
||||
assert((void *)&(dict) != (void *)&TYPVAL_ENCODE_NODICT_VAR); \
|
||||
_nothing_conv_empty_dict(tv, ((dict_T **)&(dict))); \
|
||||
} while (0)
|
||||
|
||||
static inline int _nothing_conv_real_list_after_start(typval_T *const tv,
|
||||
@ -2397,7 +2397,7 @@ static inline int _nothing_conv_real_list_after_start(typval_T *const tv,
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_REAL_LIST_AFTER_START(tv, mpsv) \
|
||||
do { \
|
||||
if (_nothing_conv_real_list_after_start(tv, &mpsv) != NOTDONE) { \
|
||||
if (_nothing_conv_real_list_after_start(tv, &(mpsv)) != NOTDONE) { \
|
||||
goto typval_encode_stop_converting_one_item; \
|
||||
} \
|
||||
} while (0)
|
||||
@ -2437,8 +2437,9 @@ static inline int _nothing_conv_real_dict_after_start(typval_T *const tv, dict_T
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_REAL_DICT_AFTER_START(tv, dict, mpsv) \
|
||||
do { \
|
||||
if (_nothing_conv_real_dict_after_start(tv, (dict_T **)&dict, (void *)&TYPVAL_ENCODE_NODICT_VAR, \
|
||||
&mpsv) != NOTDONE) { \
|
||||
if (_nothing_conv_real_dict_after_start(tv, (dict_T **)&(dict), \
|
||||
(void *)&TYPVAL_ENCODE_NODICT_VAR, &(mpsv)) \
|
||||
!= NOTDONE) { \
|
||||
goto typval_encode_stop_converting_one_item; \
|
||||
} \
|
||||
} while (0)
|
||||
@ -2457,7 +2458,7 @@ static inline void _nothing_conv_dict_end(typval_T *const tv, dict_T **const dic
|
||||
}
|
||||
}
|
||||
#define TYPVAL_ENCODE_CONV_DICT_END(tv, dict) \
|
||||
_nothing_conv_dict_end(tv, (dict_T **)&dict, \
|
||||
_nothing_conv_dict_end(tv, (dict_T **)&(dict), \
|
||||
(void *)&TYPVAL_ENCODE_NODICT_VAR)
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_RECURSE(val, conv_type)
|
||||
@ -2639,9 +2640,9 @@ void tv_item_lock(typval_T *const tv, const int deep, const bool lock, const boo
|
||||
// lock/unlock the item itself
|
||||
#define CHANGE_LOCK(lock, var) \
|
||||
do { \
|
||||
var = ((VarLockStatus[]) { \
|
||||
[VAR_UNLOCKED] = (lock ? VAR_LOCKED : VAR_UNLOCKED), \
|
||||
[VAR_LOCKED] = (lock ? VAR_LOCKED : VAR_UNLOCKED), \
|
||||
(var) = ((VarLockStatus[]) { \
|
||||
[VAR_UNLOCKED] = ((lock) ? VAR_LOCKED : VAR_UNLOCKED), \
|
||||
[VAR_LOCKED] = ((lock) ? VAR_LOCKED : VAR_UNLOCKED), \
|
||||
[VAR_FIXED] = VAR_FIXED, \
|
||||
})[var]; \
|
||||
} while (0)
|
||||
|
@ -7425,7 +7425,7 @@ static void ex_goto(exarg_T *eap)
|
||||
/// Clear an argument list: free all file names and reset it to zero entries.
|
||||
void alist_clear(alist_T *al)
|
||||
{
|
||||
#define FREE_AENTRY_FNAME(arg) xfree(arg->ae_fname)
|
||||
#define FREE_AENTRY_FNAME(arg) xfree((arg)->ae_fname)
|
||||
GA_DEEP_CLEAR(&al->al_ga, aentry_T, FREE_AENTRY_FNAME);
|
||||
}
|
||||
|
||||
|
@ -2195,11 +2195,11 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
|
||||
linenr_T lnum;
|
||||
long nchars;
|
||||
#define SET_ERRMSG_NUM(num, msg) \
|
||||
errnum = num, errmsg = msg, errmsgarg = 0
|
||||
errnum = (num), errmsg = (msg), errmsgarg = 0
|
||||
#define SET_ERRMSG_ARG(msg, error) \
|
||||
errnum = NULL, errmsg = msg, errmsgarg = error
|
||||
errnum = NULL, errmsg = (msg), errmsgarg = error
|
||||
#define SET_ERRMSG(msg) \
|
||||
errnum = NULL, errmsg = msg, errmsgarg = 0
|
||||
errnum = NULL, errmsg = (msg), errmsgarg = 0
|
||||
const char *errnum = NULL;
|
||||
char *errmsg = NULL;
|
||||
int errmsgarg = 0;
|
||||
|
@ -3799,7 +3799,7 @@ bool map_to_exists(const char *const str, const char *const modechars, const boo
|
||||
#define MAPMODE(mode, modechars, chr, modeflags) \
|
||||
do { \
|
||||
if (strchr(modechars, chr) != NULL) { \
|
||||
mode |= modeflags; \
|
||||
(mode) |= (modeflags); \
|
||||
} \
|
||||
} while (0)
|
||||
MAPMODE(mode, modechars, 'n', MODE_NORMAL);
|
||||
|
@ -33,11 +33,11 @@
|
||||
#define handle_T_eq kh_int_hash_equal
|
||||
|
||||
#if defined(ARCH_64)
|
||||
# define ptr_t_hash(key) uint64_t_hash((uint64_t)key)
|
||||
# define ptr_t_eq(a, b) uint64_t_eq((uint64_t)a, (uint64_t)b)
|
||||
# define ptr_t_hash(key) uint64_t_hash((uint64_t)(key))
|
||||
# define ptr_t_eq(a, b) uint64_t_eq((uint64_t)(a), (uint64_t)(b))
|
||||
#elif defined(ARCH_32)
|
||||
# define ptr_t_hash(key) uint32_t_hash((uint32_t)key)
|
||||
# define ptr_t_eq(a, b) uint32_t_eq((uint32_t)a, (uint32_t)b)
|
||||
# define ptr_t_hash(key) uint32_t_hash((uint32_t)(key))
|
||||
# define ptr_t_eq(a, b) uint32_t_eq((uint32_t)(a), (uint32_t)(b))
|
||||
#endif
|
||||
|
||||
#define INITIALIZER(T, U) T##_##U##_initializer
|
||||
|
@ -58,7 +58,7 @@
|
||||
|
||||
#define ID_INCR (((uint64_t)1) << 2)
|
||||
|
||||
#define rawkey(itr) (itr->node->key[itr->i])
|
||||
#define rawkey(itr) ((itr)->node->key[(itr)->i])
|
||||
|
||||
static bool pos_leq(mtpos_t a, mtpos_t b)
|
||||
{
|
||||
|
@ -6027,7 +6027,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm
|
||||
|
||||
#define ADD_STATE_IF_MATCH(state) \
|
||||
if (result) { \
|
||||
add_state = state->out; \
|
||||
add_state = (state)->out; \
|
||||
add_off = clen; \
|
||||
}
|
||||
|
||||
|
@ -512,8 +512,8 @@ static inline void hmll_init(HMLList *const hmll, const size_t size)
|
||||
///
|
||||
/// @return `for` cycle header (use `HMLL_FORALL(hmll, cur_entry) {body}`).
|
||||
#define HMLL_FORALL(hmll, cur_entry, code) \
|
||||
for (HMLListEntry *cur_entry = (hmll)->first; cur_entry != NULL; \
|
||||
cur_entry = cur_entry->next) { \
|
||||
for (HMLListEntry *(cur_entry) = (hmll)->first; (cur_entry) != NULL; \
|
||||
(cur_entry) = (cur_entry)->next) { \
|
||||
code \
|
||||
} \
|
||||
|
||||
@ -1072,13 +1072,13 @@ static inline bool marks_equal(const pos_T a, const pos_T b)
|
||||
entry, fname_cond, free_func, fin_func, \
|
||||
idxadj_func, afterfree_func) \
|
||||
do { \
|
||||
const int jl_len = (int)jumps_size; \
|
||||
const int jl_len = (int)(jumps_size); \
|
||||
int i; \
|
||||
for (i = jl_len; i > 0; i--) { \
|
||||
const jumps_type jl_entry = jumps[i - 1]; \
|
||||
if (jl_entry.timestamp_attr <= entry.timestamp) { \
|
||||
if (marks_equal(jl_entry.mark_attr, entry.data.filemark.mark) \
|
||||
&& fname_cond) { \
|
||||
const jumps_type jl_entry = (jumps)[i - 1]; \
|
||||
if (jl_entry.timestamp_attr <= (entry).timestamp) { \
|
||||
if (marks_equal(jl_entry.mark_attr, (entry).data.filemark.mark) \
|
||||
&& (fname_cond)) { \
|
||||
i = -1; \
|
||||
} \
|
||||
break; \
|
||||
@ -1086,30 +1086,30 @@ static inline bool marks_equal(const pos_T a, const pos_T b)
|
||||
} \
|
||||
if (i > 0) { \
|
||||
if (jl_len == JUMPLISTSIZE) { \
|
||||
free_func(jumps[0]); \
|
||||
free_func((jumps)[0]); \
|
||||
i--; \
|
||||
if (i > 0) { \
|
||||
memmove(&jumps[0], &jumps[1], sizeof(jumps[1]) * (size_t)i); \
|
||||
memmove(&(jumps)[0], &(jumps)[1], sizeof((jumps)[1]) * (size_t)i); \
|
||||
} \
|
||||
} else if (i != jl_len) { \
|
||||
memmove(&jumps[i + 1], &jumps[i], \
|
||||
sizeof(jumps[0]) * (size_t)(jl_len - i)); \
|
||||
memmove(&(jumps)[i + 1], &(jumps)[i], \
|
||||
sizeof((jumps)[0]) * (size_t)(jl_len - i)); \
|
||||
} \
|
||||
} else if (i == 0) { \
|
||||
if (jl_len == JUMPLISTSIZE) { \
|
||||
i = -1; \
|
||||
} else if (jl_len > 0) { \
|
||||
memmove(&jumps[1], &jumps[0], sizeof(jumps[0]) * (size_t)jl_len); \
|
||||
memmove(&(jumps)[1], &(jumps)[0], sizeof((jumps)[0]) * (size_t)jl_len); \
|
||||
} \
|
||||
} \
|
||||
if (i != -1) { \
|
||||
jumps[i] = fin_func(entry); \
|
||||
(jumps)[i] = fin_func(entry); \
|
||||
if (jl_len < JUMPLISTSIZE) { \
|
||||
jumps_size++; \
|
||||
(jumps_size)++; \
|
||||
} \
|
||||
idxadj_func(i); \
|
||||
} else { \
|
||||
shada_free_shada_entry(&entry); \
|
||||
shada_free_shada_entry(&(entry)); \
|
||||
afterfree_func(entry); \
|
||||
} \
|
||||
} while (0)
|
||||
@ -1304,7 +1304,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
|
||||
} else {
|
||||
#define SDE_TO_XFMARK(entry) fm
|
||||
#define ADJUST_IDX(i) \
|
||||
if (curwin->w_jumplistidx >= i \
|
||||
if (curwin->w_jumplistidx >= (i) \
|
||||
&& curwin->w_jumplistidx + 1 <= curwin->w_jumplistlen) { \
|
||||
curwin->w_jumplistidx++; \
|
||||
}
|
||||
@ -1547,7 +1547,7 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, ShadaEntr
|
||||
} \
|
||||
} while (0)
|
||||
#define CHECK_DEFAULT(entry, attr) \
|
||||
(sd_default_values[entry.type].data.attr == entry.data.attr)
|
||||
(sd_default_values[(entry).type].data.attr == (entry).data.attr)
|
||||
#define ONE_IF_NOT_DEFAULT(entry, attr) \
|
||||
((size_t)(!CHECK_DEFAULT(entry, attr)))
|
||||
switch (entry.type) {
|
||||
@ -1637,7 +1637,7 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, ShadaEntr
|
||||
do { \
|
||||
if (!CHECK_DEFAULT(entry, search_pattern.attr)) { \
|
||||
PACK_STATIC_STR(name); \
|
||||
if (sd_default_values[entry.type].data.search_pattern.attr) { \
|
||||
if (sd_default_values[(entry).type].data.search_pattern.attr) { \
|
||||
msgpack_pack_false(spacker); \
|
||||
} else { \
|
||||
msgpack_pack_true(spacker); \
|
||||
@ -2221,12 +2221,12 @@ static inline ShaDaWriteResult shada_read_when_writing(ShaDaReadDef *const sd_re
|
||||
} else {
|
||||
#define FREE_POSSIBLY_FREED_SHADA_ENTRY(entry) \
|
||||
do { \
|
||||
if (entry.can_free_entry) { \
|
||||
shada_free_shada_entry(&entry.data); \
|
||||
if ((entry).can_free_entry) { \
|
||||
shada_free_shada_entry(&(entry).data); \
|
||||
} \
|
||||
} while (0)
|
||||
#define SDE_TO_PFSDE(entry) \
|
||||
((PossiblyFreedShadaEntry) { .can_free_entry = true, .data = entry })
|
||||
((PossiblyFreedShadaEntry) { .can_free_entry = true, .data = (entry) })
|
||||
#define AFTERFREE_DUMMY(entry)
|
||||
#define DUMMY_IDX_ADJ(i)
|
||||
MERGE_JUMPS(filemarks->changes_size, filemarks->changes,
|
||||
@ -2814,8 +2814,8 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, ShaDaReadDef
|
||||
#define PACK_WMS_ARRAY(wms_array) \
|
||||
do { \
|
||||
for (size_t i_ = 0; i_ < ARRAY_SIZE(wms_array); i_++) { \
|
||||
if (wms_array[i_].data.type != kSDItemMissing) { \
|
||||
if (shada_pack_pfreed_entry(packer, wms_array[i_], max_kbyte) \
|
||||
if ((wms_array)[i_].data.type != kSDItemMissing) { \
|
||||
if (shada_pack_pfreed_entry(packer, (wms_array)[i_], max_kbyte) \
|
||||
== kSDWriteFailed) { \
|
||||
ret = kSDWriteFailed; \
|
||||
goto shada_write_exit; \
|
||||
@ -2835,7 +2835,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, ShaDaReadDef
|
||||
}
|
||||
#define PACK_WMS_ENTRY(wms_entry) \
|
||||
do { \
|
||||
if (wms_entry.data.type != kSDItemMissing) { \
|
||||
if ((wms_entry).data.type != kSDItemMissing) { \
|
||||
if (shada_pack_pfreed_entry(packer, wms_entry, max_kbyte) \
|
||||
== kSDWriteFailed) { \
|
||||
ret = kSDWriteFailed; \
|
||||
@ -3312,16 +3312,16 @@ static ShaDaReadResult msgpack_read_uint64(ShaDaReadDef *const sd_reader, const
|
||||
RERR "Error while reading ShaDa file: " \
|
||||
entry_name " entry at position %" PRIu64 " " \
|
||||
error_desc
|
||||
#define CHECK_KEY(key, expected) ( \
|
||||
key.via.str.size == sizeof(expected) - 1 \
|
||||
&& STRNCMP(key.via.str.ptr, expected, sizeof(expected) - 1) == 0)
|
||||
#define CHECK_KEY(key, \
|
||||
expected) ((key).via.str.size == (sizeof(expected) - 1) \
|
||||
&& STRNCMP((key).via.str.ptr, expected, (sizeof(expected) - 1)) == 0)
|
||||
#define CLEAR_GA_AND_ERROR_OUT(ga) \
|
||||
do { \
|
||||
ga_clear(&ga); \
|
||||
ga_clear(&(ga)); \
|
||||
goto shada_read_next_item_error; \
|
||||
} while (0)
|
||||
#define ID(s) s
|
||||
#define BINDUP(b) xmemdupz(b.ptr, b.size)
|
||||
#define BINDUP(b) xmemdupz((b).ptr, (b).size)
|
||||
#define TOINT(s) ((int)(s))
|
||||
#define TOLONG(s) ((long)(s))
|
||||
#define TOCHAR(s) ((char)(s))
|
||||
@ -3334,28 +3334,31 @@ static ShaDaReadResult msgpack_read_uint64(ShaDaReadDef *const sd_reader, const
|
||||
semsg(_(READERR(entry_name, error_desc)), initial_fpos); \
|
||||
CLEAR_GA_AND_ERROR_OUT(ad_ga); \
|
||||
} \
|
||||
tgt = proc(obj.via.attr); \
|
||||
(tgt) = proc((obj).via.attr); \
|
||||
} while (0)
|
||||
#define CHECK_KEY_IS_STR(un, entry_name) \
|
||||
if (un.data.via.map.ptr[i].key.type != MSGPACK_OBJECT_STR) { \
|
||||
if ((un).data.via.map.ptr[i].key.type != MSGPACK_OBJECT_STR) { \
|
||||
semsg(_(READERR(entry_name, "has key which is not a string")), \
|
||||
initial_fpos); \
|
||||
CLEAR_GA_AND_ERROR_OUT(ad_ga); \
|
||||
} else if (un.data.via.map.ptr[i].key.via.str.size == 0) { \
|
||||
} else if ((un).data.via.map.ptr[i].key.via.str.size == 0) { \
|
||||
semsg(_(READERR(entry_name, "has empty key")), initial_fpos); \
|
||||
CLEAR_GA_AND_ERROR_OUT(ad_ga); \
|
||||
}
|
||||
#define CHECKED_KEY(un, entry_name, name, error_desc, tgt, condition, attr, \
|
||||
proc) \
|
||||
else if (CHECK_KEY( /* NOLINT(readability/braces) */ \
|
||||
un.data.via.map.ptr[i].key, name)) { \
|
||||
CHECKED_ENTRY(condition, "has " name " key value " error_desc, \
|
||||
entry_name, un.data.via.map.ptr[i].val, \
|
||||
tgt, attr, proc); \
|
||||
#define CHECKED_KEY(un, entry_name, name, error_desc, tgt, condition, attr, proc) \
|
||||
else if (CHECK_KEY((un).data.via.map.ptr[i].key, name)) /* NOLINT(readability/braces) */ \
|
||||
{ \
|
||||
CHECKED_ENTRY(condition, \
|
||||
"has " name " key value " error_desc, \
|
||||
entry_name, \
|
||||
(un).data.via.map.ptr[i].val, \
|
||||
tgt, \
|
||||
attr, \
|
||||
proc); \
|
||||
}
|
||||
#define TYPED_KEY(un, entry_name, name, type_name, tgt, objtype, attr, proc) \
|
||||
CHECKED_KEY(un, entry_name, name, "which is not " type_name, tgt, \
|
||||
un.data.via.map.ptr[i].val.type == MSGPACK_OBJECT_##objtype, \
|
||||
(un).data.via.map.ptr[i].val.type == MSGPACK_OBJECT_##objtype, \
|
||||
attr, proc)
|
||||
#define BOOLEAN_KEY(un, entry_name, name, tgt) \
|
||||
TYPED_KEY(un, entry_name, name, "a boolean", tgt, BOOLEAN, boolean, ID)
|
||||
@ -3366,9 +3369,9 @@ static ShaDaReadResult msgpack_read_uint64(ShaDaReadDef *const sd_reader, const
|
||||
BIN_CONVERTED)
|
||||
#define INT_KEY(un, entry_name, name, tgt, proc) \
|
||||
CHECKED_KEY(un, entry_name, name, "which is not an integer", tgt, \
|
||||
((un.data.via.map.ptr[i].val.type \
|
||||
(((un).data.via.map.ptr[i].val.type \
|
||||
== MSGPACK_OBJECT_POSITIVE_INTEGER) \
|
||||
|| (un.data.via.map.ptr[i].val.type \
|
||||
|| ((un).data.via.map.ptr[i].val.type \
|
||||
== MSGPACK_OBJECT_NEGATIVE_INTEGER)), \
|
||||
i64, proc)
|
||||
#define INTEGER_KEY(un, entry_name, name, tgt) \
|
||||
@ -3379,12 +3382,12 @@ static ShaDaReadResult msgpack_read_uint64(ShaDaReadDef *const sd_reader, const
|
||||
else { /* NOLINT(readability/braces) */ \
|
||||
ga_grow(&ad_ga, 1); \
|
||||
memcpy(((char *)ad_ga.ga_data) + ((size_t)ad_ga.ga_len \
|
||||
* sizeof(*un.data.via.map.ptr)), \
|
||||
un.data.via.map.ptr + i, \
|
||||
sizeof(*un.data.via.map.ptr)); \
|
||||
* sizeof(*(un).data.via.map.ptr)), \
|
||||
(un).data.via.map.ptr + i, \
|
||||
sizeof(*(un).data.via.map.ptr)); \
|
||||
ad_ga.ga_len++; \
|
||||
}
|
||||
#define BIN_CONVERTED(b) (xmemdupz((b.ptr), (b.size)))
|
||||
#define BIN_CONVERTED(b) (xmemdupz(((b).ptr), ((b).size)))
|
||||
#define SET_ADDITIONAL_DATA(tgt, name) \
|
||||
do { \
|
||||
if (ad_ga.ga_len) { \
|
||||
@ -3407,7 +3410,7 @@ static ShaDaReadResult msgpack_read_uint64(ShaDaReadDef *const sd_reader, const
|
||||
tv_clear(&adtv); \
|
||||
goto shada_read_next_item_error; \
|
||||
} \
|
||||
tgt = adtv.vval.v_dict; \
|
||||
(tgt) = adtv.vval.v_dict; \
|
||||
} \
|
||||
ga_clear(&ad_ga); \
|
||||
} while (0)
|
||||
|
@ -3519,7 +3519,7 @@ static void spell_suggest_intern(suginfo_T *su, bool interactive)
|
||||
// Free the info put in "*su" by spell_find_suggest().
|
||||
static void spell_find_cleanup(suginfo_T *su)
|
||||
{
|
||||
#define FREE_SUG_WORD(sug) xfree(sug->st_word)
|
||||
#define FREE_SUG_WORD(sug) xfree((sug)->st_word)
|
||||
// Free the suggestions.
|
||||
GA_DEEP_CLEAR(&su->su_ga, suggest_T, FREE_SUG_WORD);
|
||||
GA_DEEP_CLEAR(&su->su_sga, suggest_T, FREE_SUG_WORD);
|
||||
|
@ -146,7 +146,7 @@ char *vim_strnsave_unquoted(const char *const string, const size_t length)
|
||||
FUNC_ATTR_NONNULL_RET
|
||||
{
|
||||
#define ESCAPE_COND(p, inquote, string_end) \
|
||||
(*p == '\\' && inquote && p + 1 < string_end && (p[1] == '\\' || p[1] == '"'))
|
||||
(*(p) == '\\' && (inquote) && (p) + 1 < (string_end) && ((p)[1] == '\\' || (p)[1] == '"'))
|
||||
size_t ret_length = 0;
|
||||
bool inquote = false;
|
||||
const char *const string_end = string + length;
|
||||
|
Loading…
Reference in New Issue
Block a user