mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 14:28:18 +00:00
refactor: clint (#20600)
This commit is contained in:
@@ -271,11 +271,9 @@ typval_T decode_string(const char *const s, const size_t len, const TriState has
|
||||
list_T *const list = tv_list_alloc(kListLenMayKnow);
|
||||
tv_list_ref(list);
|
||||
create_special_dict(&tv, kMPString,
|
||||
((typval_T){
|
||||
.v_type = VAR_LIST,
|
||||
(typval_T){ .v_type = VAR_LIST,
|
||||
.v_lock = VAR_UNLOCKED,
|
||||
.vval = { .v_list = list },
|
||||
}));
|
||||
.vval = { .v_list = list } });
|
||||
const int elw_ret = encode_list_write((void *)list, s, len);
|
||||
if (s_allocated) {
|
||||
xfree((void *)s);
|
||||
@@ -368,7 +366,7 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len,
|
||||
goto parse_json_string_fail;
|
||||
}
|
||||
} else {
|
||||
uint8_t p_byte = (uint8_t)*p;
|
||||
uint8_t p_byte = (uint8_t)(*p);
|
||||
// unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
|
||||
if (p_byte < 0x20) {
|
||||
semsg(_("E474: ASCII control characters cannot be present "
|
||||
@@ -469,7 +467,7 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len,
|
||||
['r'] = CAR,
|
||||
['f'] = FF,
|
||||
};
|
||||
*str_end++ = escapes[(int)*t];
|
||||
*str_end++ = escapes[(int)(*t)];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -838,12 +836,10 @@ json_decode_string_cycle_start:
|
||||
.v_lock = VAR_UNLOCKED,
|
||||
.vval = { .v_list = list },
|
||||
};
|
||||
kv_push(container_stack, ((ContainerStackItem) {
|
||||
.stack_index = kv_size(stack),
|
||||
kv_push(container_stack, ((ContainerStackItem) { .stack_index = kv_size(stack),
|
||||
.s = p,
|
||||
.container = tv,
|
||||
.special_val = NULL,
|
||||
}));
|
||||
.special_val = NULL }));
|
||||
kv_push(stack, OBJ(tv, false, didcomma, didcolon));
|
||||
break;
|
||||
}
|
||||
@@ -862,12 +858,10 @@ json_decode_string_cycle_start:
|
||||
.vval = { .v_dict = dict },
|
||||
};
|
||||
}
|
||||
kv_push(container_stack, ((ContainerStackItem) {
|
||||
.stack_index = kv_size(stack),
|
||||
kv_push(container_stack, ((ContainerStackItem) { .stack_index = kv_size(stack),
|
||||
.s = p,
|
||||
.container = tv,
|
||||
.special_val = val_list,
|
||||
}));
|
||||
.special_val = val_list }));
|
||||
kv_push(stack, OBJ(tv, false, didcomma, didcolon));
|
||||
break;
|
||||
}
|
||||
@@ -1089,11 +1083,9 @@ msgpack_to_vim_generic_map: {}
|
||||
tv_list_append_number(list, mobj.via.ext.type);
|
||||
list_T *const ext_val_list = tv_list_alloc(kListLenMayKnow);
|
||||
tv_list_append_list(list, ext_val_list);
|
||||
create_special_dict(rettv, kMPExt, ((typval_T) {
|
||||
.v_type = VAR_LIST,
|
||||
create_special_dict(rettv, kMPExt, ((typval_T) { .v_type = VAR_LIST,
|
||||
.v_lock = VAR_UNLOCKED,
|
||||
.vval = { .v_list = list },
|
||||
}));
|
||||
.vval = { .v_list = list } }));
|
||||
if (encode_list_write((void *)ext_val_list, mobj.via.ext.ptr,
|
||||
mobj.via.ext.size) == -1) {
|
||||
return FAIL;
|
||||
|
@@ -266,13 +266,12 @@ void ex_align(exarg_T *eap)
|
||||
}
|
||||
|
||||
for (curwin->w_cursor.lnum = eap->line1;
|
||||
curwin->w_cursor.lnum <= eap->line2; ++curwin->w_cursor.lnum) {
|
||||
curwin->w_cursor.lnum <= eap->line2; curwin->w_cursor.lnum++) {
|
||||
if (eap->cmdidx == CMD_left) { // left align
|
||||
new_indent = indent;
|
||||
} else {
|
||||
has_tab = false; // avoid uninit warnings
|
||||
len = linelen(eap->cmdidx == CMD_right ? &has_tab
|
||||
: NULL) - get_indent();
|
||||
len = linelen(eap->cmdidx == CMD_right ? &has_tab : NULL) - get_indent();
|
||||
|
||||
if (len <= 0) { // skip blank lines
|
||||
continue;
|
||||
|
@@ -539,9 +539,7 @@ static void discard_exception(except_T *excp, bool was_finished)
|
||||
if (debug_break_level > 0 || *p_vfile == NUL) {
|
||||
msg_scroll = true; // always scroll up, don't overwrite
|
||||
}
|
||||
smsg(was_finished ? _("Exception finished: %s")
|
||||
: _("Exception discarded: %s"),
|
||||
excp->value);
|
||||
smsg(was_finished ? _("Exception finished: %s") : _("Exception discarded: %s"), excp->value);
|
||||
msg_puts("\n"); // don't overwrite this either
|
||||
if (debug_break_level > 0 || *p_vfile == NUL) {
|
||||
cmdline_row = msg_row;
|
||||
@@ -1950,7 +1948,7 @@ void rewind_conditionals(cstack_T *cstack, int idx, int cond_type, int *cond_lev
|
||||
{
|
||||
while (cstack->cs_idx > idx) {
|
||||
if (cstack->cs_flags[cstack->cs_idx] & cond_type) {
|
||||
--*cond_level;
|
||||
(*cond_level)--;
|
||||
}
|
||||
if (cstack->cs_flags[cstack->cs_idx] & CSF_FOR) {
|
||||
free_for_info(cstack->cs_forinfo[cstack->cs_idx]);
|
||||
|
@@ -308,7 +308,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
|
||||
goto error_return;
|
||||
}
|
||||
path += 2;
|
||||
} else
|
||||
} else // NOLINT(readability/braces)
|
||||
#endif
|
||||
if (os_dirname((char_u *)ff_expand_buffer, MAXPATHL) == FAIL) {
|
||||
goto error_return;
|
||||
@@ -619,16 +619,15 @@ char_u *vim_findfile(void *search_ctx_arg)
|
||||
#endif
|
||||
ff_free_stack_element(stackp);
|
||||
continue;
|
||||
}
|
||||
#ifdef FF_VERBOSE
|
||||
else if (p_verbose >= 5) {
|
||||
} else if (p_verbose >= 5) {
|
||||
verbose_enter_scroll();
|
||||
smsg("Searching: %s (%s)",
|
||||
stackp->ffs_fix_path, stackp->ffs_wc_path);
|
||||
msg_puts("\n"); // don't overwrite this either
|
||||
verbose_leave_scroll();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// check depth
|
||||
if (stackp->ffs_level <= 0) {
|
||||
|
@@ -1048,9 +1048,8 @@ retry:
|
||||
conv_error = curbuf->b_ml.ml_line_count
|
||||
- linecnt + 1;
|
||||
}
|
||||
}
|
||||
} else if (illegal_byte == 0) {
|
||||
// Remember the first linenr with an illegal byte
|
||||
else if (illegal_byte == 0) {
|
||||
illegal_byte = curbuf->b_ml.ml_line_count
|
||||
- linecnt + 1;
|
||||
}
|
||||
@@ -1066,7 +1065,7 @@ retry:
|
||||
#ifdef HAVE_ICONV
|
||||
|| iconv_fd != (iconv_t)-1
|
||||
#endif
|
||||
)) {
|
||||
)) { // NOLINT(whitespace/parens)
|
||||
while (conv_restlen > 0) {
|
||||
*(--ptr) = (char)bad_char_behavior;
|
||||
conv_restlen--;
|
||||
@@ -3039,8 +3038,10 @@ nobackup:
|
||||
// false.
|
||||
while ((fd = os_open(wfname,
|
||||
O_WRONLY |
|
||||
(append ?
|
||||
(forceit ? (O_APPEND | O_CREAT) : O_APPEND)
|
||||
(append
|
||||
? (forceit
|
||||
? (O_APPEND | O_CREAT)
|
||||
: O_APPEND)
|
||||
: (O_CREAT | O_TRUNC)),
|
||||
perm < 0 ? 0666 : (perm & 0777))) < 0) {
|
||||
// A forced write will try to create a new file if the old one
|
||||
@@ -3336,7 +3337,7 @@ restore_backup:
|
||||
} else {
|
||||
errmsg_allocated = true;
|
||||
SET_ERRMSG(xmalloc(300));
|
||||
vim_snprintf(errmsg, 300,
|
||||
vim_snprintf(errmsg, 300, // NOLINT(runtime/printf)
|
||||
_("E513: write error, conversion failed in line %" PRIdLINENR
|
||||
" (make 'fenc' empty to override)"),
|
||||
write_info.bw_conv_error_lnum);
|
||||
@@ -4258,7 +4259,7 @@ char *modname(const char *fname, const char *ext, bool prepend_dot)
|
||||
} else {
|
||||
fnamelen = strlen(fname);
|
||||
retval = xmalloc(fnamelen + extlen + 3);
|
||||
strcpy(retval, fname);
|
||||
strcpy(retval, fname); // NOLINT(runtime/printf)
|
||||
}
|
||||
|
||||
// Search backwards until we hit a '/', '\' or ':'.
|
||||
@@ -4276,12 +4277,11 @@ char *modname(const char *fname, const char *ext, bool prepend_dot)
|
||||
ptr[BASENAMELEN] = '\0';
|
||||
}
|
||||
|
||||
char *s;
|
||||
s = ptr + strlen(ptr);
|
||||
char *s = ptr + strlen(ptr);
|
||||
|
||||
// Append the extension.
|
||||
// ext can start with '.' and cannot exceed 3 more characters.
|
||||
strcpy(s, ext);
|
||||
strcpy(s, ext); // NOLINT(runtime/printf)
|
||||
|
||||
char *e;
|
||||
// Prepend the dot if needed.
|
||||
|
@@ -167,7 +167,7 @@ char *ga_concat_strings_sep(const garray_T *gap, const char *sep)
|
||||
s = xstpcpy(s, strings[i]);
|
||||
s = xstpcpy(s, sep);
|
||||
}
|
||||
strcpy(s, strings[nelem - 1]);
|
||||
strcpy(s, strings[nelem - 1]); // NOLINT(runtime/printf)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@@ -1274,9 +1274,8 @@ scripterror:
|
||||
kFileReadOnly|kFileNonBlocking);
|
||||
assert(stdin_dup != NULL);
|
||||
scriptin[0] = stdin_dup;
|
||||
} else if ((scriptin[0] =
|
||||
file_open_new(&error, argv[0], kFileReadOnly|kFileNonBlocking,
|
||||
0)) == NULL) {
|
||||
} else if ((scriptin[0] = file_open_new(&error, argv[0],
|
||||
kFileReadOnly|kFileNonBlocking, 0)) == NULL) {
|
||||
vim_snprintf((char *)IObuff, IOSIZE,
|
||||
_("Cannot open for reading: \"%s\": %s\n"),
|
||||
argv[0], os_strerror(error));
|
||||
|
@@ -813,8 +813,7 @@ void curs_columns(win_T *wp, int may_scroll)
|
||||
if ((wp->w_wrow >= wp->w_height_inner
|
||||
|| ((prev_skipcol > 0
|
||||
|| wp->w_wrow + so >= wp->w_height_inner)
|
||||
&& (plines =
|
||||
plines_win_nofill(wp, wp->w_cursor.lnum, false)) - 1
|
||||
&& (plines = plines_win_nofill(wp, wp->w_cursor.lnum, false)) - 1
|
||||
>= wp->w_height_inner))
|
||||
&& wp->w_height_inner != 0
|
||||
&& wp->w_cursor.lnum == wp->w_topline
|
||||
|
@@ -207,7 +207,7 @@ void set_init_1(bool clean_arg)
|
||||
p = "/tmp";
|
||||
# endif
|
||||
mustfree = false;
|
||||
} else
|
||||
} else // NOLINT(readability/braces)
|
||||
#endif
|
||||
{
|
||||
p = vim_getenv(names[n]);
|
||||
@@ -2042,10 +2042,9 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va
|
||||
}
|
||||
redraw_titles();
|
||||
modified_was_set = value;
|
||||
}
|
||||
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
else if ((int *)varp == &p_ssl) {
|
||||
} else if ((int *)varp == &p_ssl) {
|
||||
if (p_ssl) {
|
||||
psepc = '/';
|
||||
psepcN = '\\';
|
||||
@@ -2060,9 +2059,8 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va
|
||||
buflist_slash_adjust();
|
||||
alist_slash_adjust();
|
||||
scriptnames_slash_adjust();
|
||||
}
|
||||
#endif
|
||||
else if ((int *)varp == &curwin->w_p_wrap) {
|
||||
} else if ((int *)varp == &curwin->w_p_wrap) {
|
||||
// If 'wrap' is set, set w_leftcol to zero.
|
||||
if (curwin->w_p_wrap) {
|
||||
curwin->w_leftcol = 0;
|
||||
@@ -2681,7 +2679,7 @@ int findoption_len(const char *const arg, const size_t len)
|
||||
// letter. There are 26 letters, plus the first "t_" option.
|
||||
if (quick_tab[1] == 0) {
|
||||
p = options[0].fullname;
|
||||
for (short int i = 1; (s = options[i].fullname) != NULL; i++) {
|
||||
for (uint16_t i = 1; (s = options[i].fullname) != NULL; i++) {
|
||||
if (s[0] != p[0]) {
|
||||
if (s[0] == 't' && s[1] == '_') {
|
||||
quick_tab[26] = i;
|
||||
@@ -3598,8 +3596,7 @@ void unset_global_local_option(char *name, void *from)
|
||||
}
|
||||
p = &(options[opt_idx]);
|
||||
|
||||
switch ((int)p->indir)
|
||||
{
|
||||
switch ((int)p->indir) {
|
||||
// global option with local value: use local value if it's been set
|
||||
case PV_EP:
|
||||
clear_string_option(&buf->b_p_ep);
|
||||
@@ -4862,7 +4859,7 @@ static void option_value2string(vimoption_T *opp, int opt_flags)
|
||||
snprintf((char *)NameBuff,
|
||||
sizeof(NameBuff),
|
||||
"%" PRId64,
|
||||
(int64_t)*(long *)varp);
|
||||
(int64_t)(*(long *)varp));
|
||||
}
|
||||
} else { // P_STRING
|
||||
varp = *(char_u **)(varp);
|
||||
|
@@ -645,7 +645,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in
|
||||
#ifndef MSWIN
|
||||
|| (!p_fic && (flags & EW_ICASE) && mb_isalpha(utf_ptr2char((char *)path_end)))
|
||||
#endif
|
||||
)) {
|
||||
)) { // NOLINT(whitespace/parens)
|
||||
e = p;
|
||||
}
|
||||
len = (size_t)(utfc_ptr2len((char *)path_end));
|
||||
@@ -787,7 +787,7 @@ static int find_previous_pathsep(char_u *path, char_u **psep)
|
||||
{
|
||||
// skip the current separator
|
||||
if (*psep > path && vim_ispathsep(**psep)) {
|
||||
--*psep;
|
||||
(*psep)--;
|
||||
}
|
||||
|
||||
// find the previous separator
|
||||
|
@@ -220,8 +220,7 @@ bool do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
if (*tag != NUL
|
||||
&& (type == DT_TAG || type == DT_SELECT || type == DT_JUMP
|
||||
|| type == DT_LTAG
|
||||
|| type == DT_CSCOPE
|
||||
)) {
|
||||
|| type == DT_CSCOPE)) {
|
||||
if (g_do_tagpreview != 0) {
|
||||
if (ptag_entry.tagname != NULL
|
||||
&& strcmp(ptag_entry.tagname, tag) == 0) {
|
||||
|
@@ -2583,7 +2583,7 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, tabpage_T *prev
|
||||
|
||||
// save index for tabclosed event
|
||||
char_u prev_idx[NUMBUFLEN];
|
||||
sprintf((char *)prev_idx, "%i", tabpage_index(prev_curtab));
|
||||
snprintf((char *)prev_idx, NUMBUFLEN, "%i", tabpage_index(prev_curtab));
|
||||
|
||||
// Safety check: Autocommands may have closed the window when jumping
|
||||
// to the other tab page.
|
||||
|
Reference in New Issue
Block a user