mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
*: Fix linter errors
This commit is contained in:
@@ -5482,8 +5482,9 @@ static int list_join_inner(garray_T *const gap, list_T *const l,
|
||||
char *s;
|
||||
size_t len;
|
||||
s = encode_tv2echo(&item->li_tv, &len);
|
||||
if (s == NULL)
|
||||
if (s == NULL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
sumlen += (int) len;
|
||||
|
||||
@@ -8317,9 +8318,9 @@ static void f_deepcopy(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
if (argvars[1].v_type != VAR_UNKNOWN)
|
||||
noref = get_tv_number_chk(&argvars[1], NULL);
|
||||
if (noref < 0 || noref > 1)
|
||||
if (noref < 0 || noref > 1) {
|
||||
EMSG(_(e_invarg));
|
||||
else {
|
||||
} else {
|
||||
var_item_copy(NULL, &argvars[0], rettv, true, (noref == 0
|
||||
? get_copyID()
|
||||
: 0));
|
||||
@@ -11960,8 +11961,9 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type)
|
||||
}
|
||||
xfree(tofree);
|
||||
tofree = str = (char_u *) encode_tv2echo(&li->li_tv, NULL);
|
||||
if (str == NULL)
|
||||
if (str == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
match = vim_regexec_nl(®match, str, (colnr_T)startcol);
|
||||
@@ -17400,7 +17402,7 @@ void free_tv(typval_T *varp)
|
||||
switch (varp->v_type) {
|
||||
case VAR_FUNC:
|
||||
func_unref(varp->vval.v_string);
|
||||
/*FALLTHROUGH*/
|
||||
// FALLTHROUGH
|
||||
case VAR_STRING:
|
||||
xfree(varp->vval.v_string);
|
||||
break;
|
||||
|
@@ -53,7 +53,9 @@ EXTERN ufunc_T dumuf;
|
||||
#define HIKEY2UF(p) ((ufunc_T *)(p - (dumuf.uf_name - (char_u *)&dumuf)))
|
||||
#define HI2UF(hi) HIKEY2UF((hi)->hi_key)
|
||||
|
||||
/* Defines for Vim variables. These must match vimvars[] in eval.c! */
|
||||
/// Defines for Vim variables
|
||||
///
|
||||
/// Order must match order in vimvars[] table in eval.c.
|
||||
typedef enum {
|
||||
VV_COUNT,
|
||||
VV_COUNT1,
|
||||
|
@@ -69,6 +69,8 @@ static inline void create_special_dict(typval_T *const rettv,
|
||||
};
|
||||
}
|
||||
|
||||
#define DICT_LEN(dict) (dict)->dv_hashtab.ht_used
|
||||
|
||||
/// Helper function used for working with stack vectors used by JSON decoder
|
||||
///
|
||||
/// @param[in] obj New object.
|
||||
@@ -158,8 +160,7 @@ static inline int json_decoder_pop(ValuesStackItem obj,
|
||||
return FAIL;
|
||||
} else if (!obj.didcomma
|
||||
&& (last_container.special_val == NULL
|
||||
&& (last_container.container.vval.v_dict->dv_hashtab.ht_used
|
||||
!= 0))) {
|
||||
&& (DICT_LEN(last_container.container.vval.v_dict) != 0))) {
|
||||
EMSG2(_("E474: Expected comma before dictionary key: %s"), val_location);
|
||||
clear_tv(&obj.val);
|
||||
return FAIL;
|
||||
@@ -191,6 +192,25 @@ static inline int json_decoder_pop(ValuesStackItem obj,
|
||||
return OK;
|
||||
}
|
||||
|
||||
#define OBJ(obj_tv, is_sp_string) \
|
||||
((ValuesStackItem) { \
|
||||
.is_special_string = (is_sp_string), \
|
||||
.val = (obj_tv), \
|
||||
.didcomma = didcomma, \
|
||||
.didcolon = didcolon, \
|
||||
})
|
||||
#define POP(obj_tv, is_sp_string) \
|
||||
do { \
|
||||
if (json_decoder_pop(OBJ(obj_tv, is_sp_string), &stack, &container_stack, \
|
||||
&p, &next_map_special, &didcomma, &didcolon) \
|
||||
== FAIL) { \
|
||||
goto json_decode_string_fail; \
|
||||
} \
|
||||
if (next_map_special) { \
|
||||
goto json_decode_string_cycle_start; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/// Convert JSON string into VimL object
|
||||
///
|
||||
/// @param[in] buf String to convert. UTF-8 encoding is assumed.
|
||||
@@ -215,24 +235,6 @@ int json_decode_string(const char *const buf, const size_t len,
|
||||
bool didcomma = false;
|
||||
bool didcolon = false;
|
||||
bool next_map_special = false;
|
||||
#define OBJ(obj_tv, is_sp_string) \
|
||||
((ValuesStackItem) { \
|
||||
.is_special_string = (is_sp_string), \
|
||||
.val = (obj_tv), \
|
||||
.didcomma = didcomma, \
|
||||
.didcolon = didcolon, \
|
||||
})
|
||||
#define POP(obj_tv, is_sp_string) \
|
||||
do { \
|
||||
if (json_decoder_pop(OBJ(obj_tv, is_sp_string), &stack, &container_stack, \
|
||||
&p, &next_map_special, &didcomma, &didcolon) \
|
||||
== FAIL) { \
|
||||
goto json_decode_string_fail; \
|
||||
} \
|
||||
if (next_map_special) { \
|
||||
goto json_decode_string_cycle_start; \
|
||||
} \
|
||||
} while (0)
|
||||
const char *p = buf;
|
||||
for (; p < e; p++) {
|
||||
json_decode_string_cycle_start:
|
||||
@@ -268,7 +270,8 @@ json_decode_string_cycle_start:
|
||||
goto json_decode_string_after_cycle;
|
||||
} else {
|
||||
if (json_decoder_pop(kv_pop(stack), &stack, &container_stack, &p,
|
||||
&next_map_special, &didcomma, &didcolon) == FAIL) {
|
||||
&next_map_special, &didcomma, &didcolon)
|
||||
== FAIL) {
|
||||
goto json_decode_string_fail;
|
||||
}
|
||||
assert(!next_map_special);
|
||||
@@ -293,8 +296,7 @@ json_decode_string_cycle_start:
|
||||
goto json_decode_string_fail;
|
||||
} else if (last_container.special_val == NULL
|
||||
? (last_container.container.v_type == VAR_DICT
|
||||
? (last_container.container.vval.v_dict->dv_hashtab.ht_used
|
||||
== 0)
|
||||
? (DICT_LEN(last_container.container.vval.v_dict) == 0)
|
||||
: (last_container.container.vval.v_list->lv_len == 0))
|
||||
: (last_container.special_val->lv_len == 0)) {
|
||||
EMSG2(_("E474: Leading comma: %s"), p);
|
||||
@@ -686,8 +688,6 @@ json_decode_string_cycle_start:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#undef POP
|
||||
#undef OBJ
|
||||
json_decode_string_after_cycle:
|
||||
for (; p < e; p++) {
|
||||
switch (*p) {
|
||||
@@ -722,6 +722,11 @@ json_decode_string_ret:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef POP
|
||||
#undef OBJ
|
||||
|
||||
#undef DICT_LEN
|
||||
|
||||
/// Convert msgpack object to a VimL one
|
||||
int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
|
@@ -41,7 +41,7 @@
|
||||
|
||||
/// Like #EMSG, but for messages with two "%s" inside
|
||||
#define EMSG3(s, p, q) emsg3((char_u *)(s), (char_u *)(p), \
|
||||
(char_u *)(q))
|
||||
(char_u *)(q))
|
||||
|
||||
/// Like #EMSG, but for messages with one "%" PRId64 inside
|
||||
#define EMSGN(s, n) emsgn((char_u *)(s), (int64_t)(n))
|
||||
|
Reference in New Issue
Block a user