refactor: follow style guide

This commit is contained in:
dundargoc 2023-12-28 13:42:24 +01:00 committed by dundargoc
parent d634cd5b0b
commit c89292fcb7
90 changed files with 953 additions and 1121 deletions

View File

@ -138,7 +138,7 @@ bool try_end(Error *err)
api_set_error(err, kErrorTypeException, "Keyboard interrupt");
got_int = false;
} else if (msg_list != NULL && *msg_list != NULL) {
int should_free;
bool should_free;
char *msg = get_exception_string(*msg_list,
ET_ERROR,
NULL,

View File

@ -599,7 +599,7 @@ ArrayOf(String) nvim__get_runtime(Array pat, Boolean all, Dict(runtime) *opts, E
if (opts->do_source) {
for (size_t i = 0; i < res.size; i++) {
String name = res.items[i].data.string;
(void)do_source(name.data, false, DOSO_NONE, NULL);
do_source(name.data, false, DOSO_NONE, NULL);
}
}

View File

@ -231,8 +231,8 @@ static Object _call_function(String fn, Array args, dict_T *self, Error *err)
TRY_WRAP(err, {
// call_func() retval is deceptive, ignore it. Instead we set `msg_list`
// (see above) to capture abort-causing non-exception errors.
(void)call_func(fn.data, (int)fn.size, &rettv, (int)args.size,
vim_args, &funcexe);
call_func(fn.data, (int)fn.size, &rettv, (int)args.size,
vim_args, &funcexe);
});
if (!ERROR_SET(err)) {

View File

@ -918,7 +918,7 @@ static void arg_all_close_unused_windows(arg_all_state_T *aall)
if (!buf_hide(buf) && buf->b_nwindows <= 1 && bufIsChanged(buf)) {
bufref_T bufref;
set_bufref(&bufref, buf);
(void)autowrite(buf, false);
autowrite(buf, false);
// Check if autocommands removed the window.
if (!win_valid(wp) || !bufref_valid(&bufref)) {
wpnext = lastwin->w_floating ? lastwin : firstwin; // Start all over...
@ -1018,10 +1018,10 @@ static void arg_all_open_windows(arg_all_state_T *aall, int count)
aall->new_curwin = curwin;
aall->new_curtab = curtab;
}
(void)do_ecmd(0, alist_name(&AARGLIST(aall->alist)[i]), NULL, NULL, ECMD_ONE,
((buf_hide(curwin->w_buffer)
|| bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) + ECMD_OLDBUF,
curwin);
do_ecmd(0, alist_name(&AARGLIST(aall->alist)[i]), NULL, NULL, ECMD_ONE,
((buf_hide(curwin->w_buffer)
|| bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) + ECMD_OLDBUF,
curwin);
if (tab_drop_empty_window && i == count - 1) {
autocmd_no_enter++;
}

View File

@ -530,7 +530,7 @@ bool augroup_exists(const char *name)
}
/// ":augroup {name}".
void do_augroup(char *arg, int del_group)
void do_augroup(char *arg, bool del_group)
{
if (del_group) {
if (*arg == NUL) {
@ -755,7 +755,7 @@ void do_autocmd(exarg_T *eap, char *arg_in, int forceit)
char *arg = arg_in;
char *envpat = NULL;
char *cmd;
int need_free = false;
bool need_free = false;
bool nested = false;
bool once = false;
int group;
@ -1222,7 +1222,7 @@ void ex_doautoall(exarg_T *eap)
// Execute autocommands for the current buffer last.
if (retval == OK) {
(void)do_doautocmd(arg, false, &did_aucmd);
do_doautocmd(arg, false, &did_aucmd);
if (call_do_modelines && did_aucmd) {
do_modelines(0);
}
@ -1568,12 +1568,11 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force
bool retval = false;
static int nesting = 0;
char *save_cmdarg;
varnumber_T save_cmdbang;
static bool filechangeshell_busy = false;
proftime_T wait_time;
bool did_save_redobuff = false;
save_redo_T save_redo;
const bool save_KeyTyped = KeyTyped; // NOLINT
const bool save_KeyTyped = KeyTyped;
// Quickly return if there are no autocommands for this event or
// autocommands are blocked.
@ -1782,7 +1781,7 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force
patcmd.data = data;
// set v:cmdarg (only when there is a matching pattern)
save_cmdbang = get_vim_var_nr(VV_CMDBANG);
varnumber_T save_cmdbang = get_vim_var_nr(VV_CMDBANG);
if (eap != NULL) {
save_cmdarg = set_cmdarg(eap, NULL);
set_vim_var_nr(VV_CMDBANG, eap->forceit);
@ -1815,7 +1814,7 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force
}
if (eap != NULL) {
(void)set_cmdarg(NULL, save_cmdarg);
set_cmdarg(NULL, save_cmdarg);
set_vim_var_nr(VV_CMDBANG, save_cmdbang);
}
// delete from active_apc_list
@ -2164,7 +2163,7 @@ char *expand_get_augroup_name(expand_T *xp, int idx)
}
/// @param doautocmd true for :doauto*, false for :autocmd
char *set_context_in_autocmd(expand_T *xp, char *arg, int doautocmd)
char *set_context_in_autocmd(expand_T *xp, char *arg, bool doautocmd)
{
// check for a group name, skip it if present
autocmd_include_groups = false;
@ -2478,7 +2477,7 @@ bool au_event_is_empty(event_T event)
/// Scan over the events. "*" stands for all events.
/// true when group name was found
static char *arg_event_skip(char *arg, int have_group)
static char *arg_event_skip(char *arg, bool have_group)
{
char *pat;
char *p;

View File

@ -128,7 +128,7 @@ int get_highest_fnum(void)
/// @param read_stdin read file from stdin, otherwise fifo
/// @param eap for forced 'ff' and 'fenc' or NULL
/// @param flags extra flags for readfile()
static int read_buffer(int read_stdin, exarg_T *eap, int flags)
static int read_buffer(bool read_stdin, exarg_T *eap, int flags)
{
int retval = OK;
bool silent = shortmess(SHM_FILEINFO);
@ -269,9 +269,7 @@ int open_buffer(bool read_stdin, exarg_T *eap, int flags_arg)
if (curbuf->b_ffname != NULL) {
#ifdef UNIX
int save_bin = curbuf->b_p_bin;
int perm;
perm = os_getperm(curbuf->b_ffname);
int perm = os_getperm(curbuf->b_ffname);
if (perm >= 0 && (0 || S_ISFIFO(perm)
|| S_ISSOCK(perm)
# ifdef OPEN_CHR_FILES
@ -327,7 +325,7 @@ int open_buffer(bool read_stdin, exarg_T *eap, int flags_arg)
// if first time loading this buffer, init b_chartab[]
if (curbuf->b_flags & BF_NEVERLOADED) {
(void)buf_init_chartab(curbuf, false);
buf_init_chartab(curbuf, false);
parse_cino(curbuf);
}
@ -937,8 +935,8 @@ void goto_buffer(exarg_T *eap, int start, int dir, int count)
if (swap_exists_action == SEA_NONE) {
swap_exists_action = SEA_DIALOG;
}
(void)do_buffer(*eap->cmd == 's' ? DOBUF_SPLIT : DOBUF_GOTO,
start, dir, count, eap->forceit);
do_buffer(*eap->cmd == 's' ? DOBUF_SPLIT : DOBUF_GOTO,
start, dir, count, eap->forceit);
if (swap_exists_action == SEA_QUIT && *eap->cmd == 's') {
cleanup_T cs;
@ -1046,7 +1044,7 @@ char *do_bufdel(int command, char *arg, int addr_count, int start_bnr, int end_b
int bnr; // buffer number
if (addr_count == 0) {
(void)do_buffer(command, DOBUF_CURRENT, FORWARD, 0, forceit);
do_buffer(command, DOBUF_CURRENT, FORWARD, 0, forceit);
} else {
if (addr_count == 2) {
if (*arg) { // both range and argument is not allowed
@ -1125,7 +1123,7 @@ char *do_bufdel(int command, char *arg, int addr_count, int start_bnr, int end_b
/// Make the current buffer empty.
/// Used when it is wiped out and it's the last buffer.
static int empty_curbuf(int close_others, int forceit, int action)
static int empty_curbuf(bool close_others, int forceit, int action)
{
buf_T *buf = curbuf;
@ -1197,8 +1195,8 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
{
buf_T *buf;
buf_T *bp;
int unload = (action == DOBUF_UNLOAD || action == DOBUF_DEL
|| action == DOBUF_WIPE);
bool unload = (action == DOBUF_UNLOAD || action == DOBUF_DEL
|| action == DOBUF_WIPE);
switch (start) {
case DOBUF_FIRST:
@ -1374,9 +1372,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
if (au_new_curbuf.br_buf != NULL && bufref_valid(&au_new_curbuf)) {
buf = au_new_curbuf.br_buf;
} else if (curwin->w_jumplistlen > 0) {
int jumpidx;
jumpidx = curwin->w_jumplistidx - 1;
int jumpidx = curwin->w_jumplistidx - 1;
if (jumpidx < 0) {
jumpidx = curwin->w_jumplistlen - 1;
}
@ -1665,7 +1661,7 @@ void enter_buffer(buf_T *buf)
need_fileinfo = true; // display file info after redraw
}
// check if file changed
(void)buf_check_timestamp(curbuf);
buf_check_timestamp(curbuf);
curwin->w_topline = 1;
curwin->w_topfill = 0;
@ -1690,12 +1686,12 @@ void enter_buffer(buf_T *buf)
do_autochdir();
if (curbuf->b_kmap_state & KEYMAP_INIT) {
(void)keymap_init();
keymap_init();
}
// May need to set the spell language. Can only do this after the buffer
// has been properly setup.
if (!curbuf->b_help && curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) {
(void)parse_spelllang(curwin);
parse_spelllang(curwin);
}
curbuf->b_last_used = time(NULL);
@ -1961,7 +1957,7 @@ bool curbuf_reusable(void)
/// Free the memory for the options of a buffer.
/// If "free_p_ff" is true also free 'fileformat', 'buftype' and
/// 'fileencoding'.
void free_buf_options(buf_T *buf, int free_p_ff)
void free_buf_options(buf_T *buf, bool free_p_ff)
{
if (free_p_ff) {
clear_string_option(&buf->b_p_fenc);
@ -2224,7 +2220,7 @@ int buflist_findpat(const char *pattern, const char *pattern_end, bool unlisted,
return -1;
}
char *patend = pat + strlen(pat) - 1;
int toggledollar = (patend > pat && *patend == '$');
bool toggledollar = (patend > pat && *patend == '$');
// First try finding a listed buffer. If not found and "unlisted"
// is true, try finding an unlisted buffer.
@ -2755,8 +2751,6 @@ linenr_T buflist_findlnum(buf_T *buf)
void buflist_list(exarg_T *eap)
{
buf_T *buf = firstbuf;
int len;
int i;
garray_T buflist;
buf_T **buflist_data = NULL;
@ -2821,21 +2815,21 @@ void buflist_list(exarg_T *eap)
}
msg_putchar('\n');
len = vim_snprintf(IObuff, IOSIZE - 20, "%3d%c%c%c%c%c \"%s\"",
buf->b_fnum,
buf->b_p_bl ? ' ' : 'u',
buf == curbuf ? '%' : (curwin->w_alt_fnum == buf->b_fnum ? '#' : ' '),
buf->b_ml.ml_mfp == NULL ? ' ' : (buf->b_nwindows == 0 ? 'h' : 'a'),
ro_char,
changed_char,
NameBuff);
int len = vim_snprintf(IObuff, IOSIZE - 20, "%3d%c%c%c%c%c \"%s\"",
buf->b_fnum,
buf->b_p_bl ? ' ' : 'u',
buf == curbuf ? '%' : (curwin->w_alt_fnum == buf->b_fnum ? '#' : ' '),
buf->b_ml.ml_mfp == NULL ? ' ' : (buf->b_nwindows == 0 ? 'h' : 'a'),
ro_char,
changed_char,
NameBuff);
if (len > IOSIZE - 20) {
len = IOSIZE - 20;
}
// put "line 999" in column 40 or after the file name
i = 40 - vim_strsize(IObuff);
int i = 40 - vim_strsize(IObuff);
do {
IObuff[len++] = ' ';
} while (--i > 0 && len < IOSIZE - 18);
@ -3134,7 +3128,7 @@ static bool buf_same_file_id(buf_T *buf, FileID *file_id)
/// Print info about the current buffer.
///
/// @param fullname when non-zero print full path
void fileinfo(int fullname, int shorthelp, int dont_truncate)
void fileinfo(int fullname, int shorthelp, bool dont_truncate)
{
char *name;
int n;
@ -3208,7 +3202,7 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate)
(int)curwin->w_cursor.col + 1, (int)curwin->w_virtcol + 1);
}
(void)append_arg_number(curwin, buffer, IOSIZE);
append_arg_number(curwin, buffer, IOSIZE);
if (dont_truncate) {
// Temporarily set msg_scroll to avoid the message being truncated.
@ -3251,7 +3245,6 @@ void maketitle(void)
char *title_str = NULL;
char *icon_str = NULL;
int maxlen = 0;
int len;
char buf[IOSIZE];
if (!redrawing()) {
@ -3374,7 +3367,7 @@ void maketitle(void)
#undef SPACE_FOR_ARGNR
}
}
int mustset = value_change(title_str, &lasttitle);
bool mustset = value_change(title_str, &lasttitle);
if (p_icon) {
icon_str = buf;
@ -3394,7 +3387,7 @@ void maketitle(void)
}
*icon_str = NUL;
// Truncate name at 100 bytes.
len = (int)strlen(buf_p);
int len = (int)strlen(buf_p);
if (len > 100) {
len -= 100;
len += utf_cp_tail_off(buf_p, buf_p + len) + 1;
@ -3556,16 +3549,12 @@ bool bt_prompt(buf_T *buf)
/// Open a window for a number of buffers.
void ex_buffer_all(exarg_T *eap)
{
buf_T *buf;
win_T *wp, *wpnext;
int split_ret = OK;
bool p_ea_save;
int open_wins = 0;
int r;
linenr_T count; // Maximum number of windows to open.
int all; // When true also load inactive buffers.
int had_tab = cmdmod.cmod_tab;
tabpage_T *tpnext;
if (eap->addr_count == 0) { // make as many windows as possible
count = 9999;
@ -3590,7 +3579,7 @@ void ex_buffer_all(exarg_T *eap)
goto_tabpage_tp(first_tabpage, true, true);
}
while (true) {
tpnext = curtab->tp_next;
tabpage_T *tpnext = curtab->tp_next;
// Try to close floating windows first
for (wp = lastwin->w_floating ? lastwin : firstwin; wp != NULL; wp = wpnext) {
wpnext = wp->w_floating
@ -3635,7 +3624,7 @@ void ex_buffer_all(exarg_T *eap)
// lastwin may be aucmd_win
win_enter(lastwin_nofloating(), false);
autocmd_no_leave++;
for (buf = firstbuf; buf != NULL && open_wins < count; buf = buf->b_next) {
for (buf_T *buf = firstbuf; buf != NULL && open_wins < count; buf = buf->b_next) {
// Check if this buffer needs a window
if ((!all && buf->b_ml.ml_mfp == NULL) || !buf->b_p_bl) {
continue;
@ -3665,7 +3654,7 @@ void ex_buffer_all(exarg_T *eap)
bufref_T bufref;
set_bufref(&bufref, buf);
// Split the window and put the buffer in it.
p_ea_save = p_ea;
bool p_ea_save = p_ea;
p_ea = true; // use space from all windows
split_ret = win_split(0, WSP_ROOM | WSP_BELOW);
open_wins++;
@ -3706,7 +3695,7 @@ void ex_buffer_all(exarg_T *eap)
os_breakcheck();
if (got_int) {
(void)vgetc(); // only break the file loading, not the rest
vgetc(); // only break the file loading, not the rest
break;
}
// Autocommands deleted the buffer or aborted script processing!!!
@ -3724,8 +3713,8 @@ void ex_buffer_all(exarg_T *eap)
// Close superfluous windows.
for (wp = lastwin; open_wins > count;) {
r = (buf_hide(wp->w_buffer) || !bufIsChanged(wp->w_buffer)
|| autowrite(wp->w_buffer, false) == OK) && !is_aucmd_win(wp);
bool r = (buf_hide(wp->w_buffer) || !bufIsChanged(wp->w_buffer)
|| autowrite(wp->w_buffer, false) == OK) && !is_aucmd_win(wp);
if (!win_valid(wp)) {
// BufWrite Autocommands made the window invalid, start over
wp = lastwin;
@ -3798,8 +3787,8 @@ static int chk_modeline(linenr_T lnum, int flags)
int prev = -1;
for (s = ml_get(lnum); *s != NUL; s++) {
if (prev == -1 || ascii_isspace(prev)) {
if ((prev != -1 && strncmp(s, "ex:", (size_t)3) == 0)
|| strncmp(s, "vi:", (size_t)3) == 0) {
if ((prev != -1 && strncmp(s, "ex:", 3) == 0)
|| strncmp(s, "vi:", 3) == 0) {
break;
}
// Accept both "vim" and "Vim".
@ -3864,8 +3853,8 @@ static int chk_modeline(linenr_T lnum, int flags)
// "vi:set opt opt opt: foo" -- foo not interpreted
// "vi:opt opt opt: foo" -- foo interpreted
// Accept "se" for compatibility with Elvis.
if (strncmp(s, "set ", (size_t)4) == 0
|| strncmp(s, "se ", (size_t)3) == 0) {
if (strncmp(s, "set ", 4) == 0
|| strncmp(s, "se ", 3) == 0) {
if (*e != ':') { // no terminating ':'?
break;
}
@ -4140,7 +4129,7 @@ int buf_open_scratch(handle_T bufnr, char *bufname)
return FAIL;
}
apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, false, curbuf);
(void)setfname(curbuf, bufname, NULL, true);
setfname(curbuf, bufname, NULL, true);
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, curbuf);
set_option_value_give_err(kOptBufhidden, STATIC_CSTR_AS_OPTVAL("hide"), OPT_LOCAL);
set_option_value_give_err(kOptBuftype, STATIC_CSTR_AS_OPTVAL("nofile"), OPT_LOCAL);

View File

@ -186,7 +186,7 @@ static int buf_write_convert_with_iconv(struct bw_info *ip, char **bufp, int *le
size_t save_len = tolen;
// output the initial shift state sequence
(void)iconv(ip->bw_iconv_fd, NULL, NULL, &to, &tolen);
iconv(ip->bw_iconv_fd, NULL, NULL, &to, &tolen);
// There is a bug in iconv() on Linux (which appears to be
// wide-spread) which sets "to" to NULL and messes up "tolen".
@ -378,7 +378,7 @@ static int make_bom(char *buf_in, char *name)
return 3;
}
char *p = (char *)buf;
(void)ucs2bytes(0xfeff, &p, flags);
ucs2bytes(0xfeff, &p, flags);
return (int)((uint8_t *)p - buf);
}
@ -480,8 +480,7 @@ static int buf_write_do_autocmds(buf_T *buf, char **fnamep, char **sfnamep, char
semsg(_(e_no_matching_autocommands_for_buftype_str_buffer), curbuf->b_p_bt);
}
if (nofile_err
|| aborting()) {
if (nofile_err || aborting()) {
// An aborting error, interrupt or exception in the
// autocommands.
return FAIL;
@ -720,7 +719,7 @@ static int get_fileinfo(buf_T *buf, char *fname, bool overwriting, bool forceit,
static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_old, vim_acl_T acl,
int perm, unsigned bkc, bool file_readonly, bool forceit,
int *backup_copyp, char **backupp, Error_T *err)
bool *backup_copyp, char **backupp, Error_T *err)
{
FileInfo file_info;
const bool no_prepend_dot = false;
@ -897,7 +896,7 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o
// set file protection same as original file, but
// strip s-bit.
(void)os_setperm(*backupp, perm & 0777);
os_setperm(*backupp, perm & 0777);
#ifdef UNIX
//
@ -1134,8 +1133,8 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
fname = sfname;
#endif
// true if writing over original
int overwriting = buf->b_ffname != NULL && path_fnamecmp(ffname, buf->b_ffname) == 0;
// true if writing over original
bool overwriting = buf->b_ffname != NULL && path_fnamecmp(ffname, buf->b_ffname) == 0;
no_wait_return++; // don't wait for return yet
@ -1218,7 +1217,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
dobackup = false;
}
int backup_copy = false; // copy the original file?
bool backup_copy = false; // copy the original file?
// Save the value of got_int and reset it. We don't want a previous
// interruption cancel writing, only hitting CTRL-C while writing should
@ -1251,7 +1250,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
&& file_info_old.stat.st_uid == getuid()
&& vim_strchr(p_cpo, CPO_FWRITE) == NULL) {
perm |= 0200;
(void)os_setperm(fname, perm);
os_setperm(fname, perm);
made_writable = true;
}
#endif
@ -1278,8 +1277,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
// This makes all block numbers positive so that recovery does not need
// the original file.
// Don't do this if there is a backup file and we are exiting.
if (reset_changed && !newfile && overwriting
&& !(exiting && backup != NULL)) {
if (reset_changed && !newfile && overwriting && !(exiting && backup != NULL)) {
ml_preserve(buf, false, !!p_fs);
if (got_int) {
err = set_err(_(e_interr));
@ -1303,7 +1301,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
}
// Check if the file needs to be converted.
int converted = need_conversion(fenc);
bool converted = need_conversion(fenc);
int wb_flags = 0;
// Check if UTF-8 to UCS-2/4 or Latin1 conversion needs to be done. Or
@ -1367,7 +1365,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
int nchars;
linenr_T lnum;
int fileformat;
int checking_conversion;
bool checking_conversion;
int fd;
@ -1605,7 +1603,7 @@ restore_backup:
if (!buf->b_p_fixeol && buf->b_p_eof) {
// write trailing CTRL-Z
(void)write_eintr(write_info.bw_fd, "\x1a", 1);
write_eintr(write_info.bw_fd, "\x1a", 1);
}
// Stop when writing done or an error was encountered.
@ -1654,7 +1652,7 @@ restore_backup:
|| file_info.stat.st_gid != file_info_old.stat.st_gid) {
os_fchown(fd, (uv_uid_t)file_info_old.stat.st_uid, (uv_gid_t)file_info_old.stat.st_gid);
if (perm >= 0) { // Set permission again, may have changed.
(void)os_setperm(wfname, perm);
os_setperm(wfname, perm);
}
}
buf_set_file_id(buf);
@ -1675,7 +1673,7 @@ restore_backup:
}
#endif
if (perm >= 0) { // Set perm. of new file same as old file.
(void)os_setperm(wfname, perm);
os_setperm(wfname, perm);
}
// Probably need to set the ACL before changing the user (can't set the
// ACL on a file the user doesn't own).

View File

@ -85,7 +85,7 @@ void change_warning(buf_T *buf, int col)
msg_puts_attr(_(w_readonly), HL_ATTR(HLF_W) | MSG_HIST);
set_vim_var_string(VV_WARNINGMSG, _(w_readonly), -1);
msg_clr_eos();
(void)msg_end();
msg_end();
if (msg_silent == 0 && !silent_mode && ui_active()) {
ui_flush();
os_delay(1002, true); // give the user time to think about it
@ -184,7 +184,7 @@ static void changed_common(buf_T *buf, linenr_T lnum, colnr_T col, linenr_T lnum
// Create a new entry if a new undo-able change was started or we
// don't have an entry yet.
if (buf->b_new_change || buf->b_changelistlen == 0) {
int add;
bool add;
if (buf->b_changelistlen == 0) {
add = true;
} else {
@ -567,7 +567,7 @@ void changed_lines(buf_T *buf, linenr_T lnum, colnr_T col, linenr_T lnume, linen
/// When `ff` is true also reset 'fileformat'.
/// When `always_inc_changedtick` is true b:changedtick is incremented even
/// when the changed flag was off.
void unchanged(buf_T *buf, int ff, bool always_inc_changedtick)
void unchanged(buf_T *buf, bool ff, bool always_inc_changedtick)
{
if (buf->b_changed || (ff && file_ff_differs(buf, false))) {
buf->b_changed = false;
@ -922,8 +922,9 @@ int del_bytes(colnr_T count, bool fixpos_arg, bool use_delcombine)
/// Copy the indent from ptr to the current line (and fill to size).
/// Leaves the cursor on the first non-blank in the line.
///
/// @return true if the line was changed.
int copy_indent(int size, char *src)
bool copy_indent(int size, char *src)
{
char *p = NULL;
char *line = NULL;
@ -1053,7 +1054,7 @@ int copy_indent(int size, char *src)
/// @param dir FORWARD or BACKWARD
///
/// @return true on success, false on failure
int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
bool open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
{
char *next_line = NULL; // copy of the next line
char *p_extra = NULL; // what goes to next line
@ -1074,7 +1075,6 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
char saved_char = NUL; // init for GCC
pos_T *pos;
bool do_si = may_do_si();
bool do_cindent;
bool no_si = false; // reset did_si afterwards
int first_char = NUL; // init for GCC
int vreplace_mode;
@ -1155,10 +1155,8 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
// "if (condition) {"
if (!trunc_line && do_si && *saved_line != NUL
&& (p_extra == NULL || first_char != '{')) {
char *ptr;
old_cursor = curwin->w_cursor;
ptr = saved_line;
char *ptr = saved_line;
if (flags & OPENLINE_DO_COM) {
lead_len = get_leader_len(ptr, NULL, false, true);
} else {
@ -1288,9 +1286,9 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
}
// May do indenting after opening a new line.
do_cindent = !p_paste && (curbuf->b_p_cin || *curbuf->b_p_inde != NUL)
&& in_cinkeys(dir == FORWARD ? KEY_OPEN_FORW : KEY_OPEN_BACK,
' ', linewhite(curwin->w_cursor.lnum));
bool do_cindent = !p_paste && (curbuf->b_p_cin || *curbuf->b_p_inde != NUL)
&& in_cinkeys(dir == FORWARD ? KEY_OPEN_FORW : KEY_OPEN_BACK,
' ', linewhite(curwin->w_cursor.lnum));
// Find out if the current line starts with a comment leader.
// This may then be inserted in front of the new line.
@ -1321,7 +1319,6 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
char lead_end[COM_MAX_LEN]; // end-comment string
char *comment_end = NULL; // where lead_end has been found
int extra_space = false; // append extra space
int current_flag;
bool require_blank = false; // requires blank after middle
char *p2;
@ -1333,7 +1330,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
continue;
}
if (*p == COM_START || *p == COM_MIDDLE) {
current_flag = (unsigned char)(*p);
int current_flag = (unsigned char)(*p);
if (*p == COM_START) {
// Doing "O" on a start of comment does not insert leader.
if (dir == BACKWARD) {
@ -1342,7 +1339,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
}
// find start of middle part
(void)copy_option_part(&p, lead_middle, COM_MAX_LEN, ",");
copy_option_part(&p, lead_middle, COM_MAX_LEN, ",");
require_blank = false;
}
@ -1353,7 +1350,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
}
p++;
}
(void)copy_option_part(&p, lead_middle, COM_MAX_LEN, ",");
copy_option_part(&p, lead_middle, COM_MAX_LEN, ",");
while (*p && p[-1] != ':') { // find end of end flags
// Check whether we allow automatic ending of comments
@ -1498,13 +1495,12 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
int repl_size = vim_strnsize(lead_repl, lead_repl_len);
int old_size = 0;
char *endp = p;
int l;
while (old_size < repl_size && p > leader) {
MB_PTR_BACK(leader, p);
old_size += ptr2cells(p);
}
l = lead_repl_len - (int)(endp - p);
int l = lead_repl_len - (int)(endp - p);
if (l != 0) {
memmove(endp + l, endp,
(size_t)((leader + lead_len) - endp));
@ -1731,7 +1727,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
if (curwin->w_cursor.lnum >= Insstart.lnum + vr_lines_changed) {
// In case we NL to a new line, BS to the previous one, and NL
// again, we don't want to save the new line for undo twice.
(void)u_save_cursor(); // errors are ignored!
u_save_cursor(); // errors are ignored!
vr_lines_changed++;
}
ml_replace(curwin->w_cursor.lnum, p_extra, true);
@ -1754,14 +1750,14 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
}
// Copy the indent
if (curbuf->b_p_ci) {
(void)copy_indent(newindent, saved_line);
copy_indent(newindent, saved_line);
// Set the 'preserveindent' option so that any further screwing
// with the line doesn't entirely destroy our efforts to preserve
// it. It gets restored at the function end.
curbuf->b_p_pi = true;
} else {
(void)set_indent(newindent, SIN_INSERT|SIN_NOMARK);
set_indent(newindent, SIN_INSERT|SIN_NOMARK);
}
less_cols -= curwin->w_cursor.col;
@ -2002,7 +1998,7 @@ int get_leader_len(char *line, char **flags, bool backward, bool include_space)
*flags = list; // remember where flags started
}
char *prev_list = list;
(void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
string = vim_strchr(part_buf, ':');
if (string == NULL) { // missing ':', ignore this part
continue;
@ -2135,7 +2131,7 @@ int get_last_leader_offset(char *line, char **flags)
// Get one option part into part_buf[]. Advance list to next one.
// put string at start of string.
(void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
char *string = vim_strchr(part_buf, ':');
if (string == NULL) { // If everything is fine, this cannot actually
// happen.
@ -2217,7 +2213,7 @@ int get_last_leader_offset(char *line, char **flags)
for (char *list = curbuf->b_p_com; *list;) {
char *flags_save = list;
(void)copy_option_part(&list, part_buf2, COM_MAX_LEN, ",");
copy_option_part(&list, part_buf2, COM_MAX_LEN, ",");
if (flags_save == com_flags) {
continue;
}

View File

@ -85,7 +85,7 @@ int init_chartab(void)
///
/// @return FAIL if 'iskeyword', 'isident', 'isfname' or 'isprint' option has
/// an error, OK otherwise.
int buf_init_chartab(buf_T *buf, int global)
int buf_init_chartab(buf_T *buf, bool global)
{
int c;
@ -490,7 +490,7 @@ char *str_foldcase(char *str, int orglen, char *buf, int buflen)
}
}
}
(void)utf_char2bytes(lc, STR_PTR(i));
utf_char2bytes(lc, STR_PTR(i));
}
// skip to next multi-byte char
@ -1446,9 +1446,9 @@ bool rem_backslash(const char *str)
&& str[1] != '?'
&& !vim_isfilec((uint8_t)str[1])));
#else // ifdef BACKSLASH_IN_FILENAME
#else
return str[0] == '\\' && str[1] != NUL;
#endif // ifdef BACKSLASH_IN_FILENAME
#endif
}
/// Halve the number of backslashes in a file name argument.

View File

@ -73,7 +73,7 @@ typedef void *(*user_expand_func_T)(const char *, int, typval_T *);
# include "cmdexpand.c.generated.h"
#endif
static int cmd_showtail; ///< Only show path tail in lists ?
static bool cmd_showtail; ///< Only show path tail in lists ?
/// "compl_match_array" points the currently displayed list of entries in the
/// popup menu. It is NULL when there is no popup menu.
@ -325,7 +325,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
beep_flush();
} else if (xp->xp_numfiles == 1) {
// free expanded pattern
(void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE);
ExpandOne(xp, NULL, NULL, 0, WILD_FREE);
}
return OK;
@ -334,7 +334,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
/// Create and display a cmdline completion popup menu with items from
/// "matches".
static int cmdline_pum_create(CmdlineInfo *ccline, expand_T *xp, char **matches, int numMatches,
int showtail)
bool showtail)
{
assert(numMatches >= 0);
// Add all the completion matches
@ -441,7 +441,7 @@ static int wildmenu_match_len(expand_T *xp, char *s)
/// If inversion is possible we use it. Else '=' characters are used.
///
/// @param matches list of matches
static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int match, int showtail)
static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int match, bool showtail)
{
int len;
int clen; // length in screen cells
@ -964,7 +964,7 @@ void ExpandCleanup(expand_T *xp)
/// @param showtail display only the tail of the full path of a file name
/// @param dir_attr highlight attribute to use for directory names
static void showmatches_oneline(expand_T *xp, char **matches, int numMatches, int lines, int linenr,
int maxlen, int showtail, int dir_attr)
int maxlen, bool showtail, int dir_attr)
{
char *p;
int lastlen = 999;
@ -1023,7 +1023,7 @@ static void showmatches_oneline(expand_T *xp, char **matches, int numMatches, in
/// Show all matches for completion on the command line.
/// Returns EXPAND_NOTHING when the character that triggered expansion should
/// be inserted like a normal character.
int showmatches(expand_T *xp, int wildmenu)
int showmatches(expand_T *xp, bool wildmenu)
{
CmdlineInfo *const ccline = get_cmdline_info();
int numMatches;
@ -1032,8 +1032,7 @@ int showmatches(expand_T *xp, int wildmenu)
int maxlen;
int lines;
int columns;
int attr;
int showtail;
bool showtail;
if (xp->xp_numfiles == -1) {
set_expand_context(xp);
@ -1102,7 +1101,7 @@ int showmatches(expand_T *xp, int wildmenu)
lines = (numMatches + columns - 1) / columns;
}
attr = HL_ATTR(HLF_D); // find out highlighting for directories
int attr = HL_ATTR(HLF_D); // find out highlighting for directories
if (xp->xp_context == EXPAND_TAGS_LISTFILES) {
msg_puts_attr(_("tagname"), HL_ATTR(HLF_T));
@ -3244,7 +3243,7 @@ void globpath(char *path, char *file, garray_T *ga, int expand_options, bool dir
char **p;
int num_p = 0;
(void)ExpandFromContext(&xpc, buf, &p, &num_p, WILD_SILENT | expand_options);
ExpandFromContext(&xpc, buf, &p, &num_p, WILD_SILENT | expand_options);
if (num_p > 0) {
ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT | expand_options);
@ -3264,7 +3263,7 @@ void globpath(char *path, char *file, garray_T *ga, int expand_options, bool dir
}
/// Translate some keys pressed when 'wildmenu' is used.
int wildmenu_translate_key(CmdlineInfo *cclp, int key, expand_T *xp, int did_wild_list)
int wildmenu_translate_key(CmdlineInfo *cclp, int key, expand_T *xp, bool did_wild_list)
{
int c = key;

View File

@ -291,7 +291,7 @@ linenr_T get_cursor_rel_lnum(win_T *wp, linenr_T lnum)
// Loop until we reach to_line, skipping folds.
for (; from_line < to_line; from_line++, retval++) {
// If from_line is in a fold, set it to the last line of that fold.
(void)hasFoldingWin(wp, from_line, NULL, &from_line, true, NULL);
hasFoldingWin(wp, from_line, NULL, &from_line, true, NULL);
}
// If to_line is in a closed fold, the line count is off by +1. Correct it.

View File

@ -101,15 +101,9 @@ Array mode_style_array(Arena *arena)
/// @returns error message for an illegal option, NULL otherwise.
const char *parse_shape_opt(int what)
{
char *colonp;
char *commap;
char *slashp;
char *p = NULL;
char *endp;
int idx = 0; // init for GCC
int all_idx;
int len;
int i;
bool found_ve = false; // found "ve" flag
// First round: check for errors; second round: do it for real.
@ -126,8 +120,8 @@ const char *parse_shape_opt(int what)
// Repeat for all comma separated parts.
char *modep = p_guicursor;
while (modep != NULL && *modep != NUL) {
colonp = vim_strchr(modep, ':');
commap = vim_strchr(modep, ',');
char *colonp = vim_strchr(modep, ':');
char *commap = vim_strchr(modep, ',');
if (colonp == NULL || (commap != NULL && commap < colonp)) {
return N_("E545: Missing colon");
@ -138,7 +132,7 @@ const char *parse_shape_opt(int what)
// Repeat for all modes before the colon.
// For the 'a' mode, we loop to handle all the modes.
all_idx = -1;
int all_idx = -1;
while (modep < colonp || all_idx >= 0) {
if (all_idx < 0) {
// Find the mode
@ -175,7 +169,7 @@ const char *parse_shape_opt(int what)
for (p = colonp + 1; *p && *p != ',';) {
{
// First handle the ones with a number argument.
i = (uint8_t)(*p);
int i = (uint8_t)(*p);
len = 0;
if (STRNICMP(p, "ver", 3) == 0) {
len = 3;
@ -221,7 +215,7 @@ const char *parse_shape_opt(int what)
}
p += 5;
} else { // must be a highlight group name then
endp = vim_strchr(p, '-');
char *endp = vim_strchr(p, '-');
if (commap == NULL) { // last part
if (endp == NULL) {
endp = p + strlen(p); // find end of part
@ -229,7 +223,7 @@ const char *parse_shape_opt(int what)
} else if (endp > commap || endp == NULL) {
endp = commap;
}
slashp = vim_strchr(p, '/');
char *slashp = vim_strchr(p, '/');
if (slashp != NULL && slashp < endp) {
// "group/langmap_group"
i = syn_check_group(p, (size_t)(slashp - p));

View File

@ -285,7 +285,7 @@ void do_debug(char *cmd)
// don't debug this command
n = debug_break_level;
debug_break_level = -1;
(void)do_cmdline(cmdline, getexline, NULL, DOCMD_VERBOSE|DOCMD_EXCRESET);
do_cmdline(cmdline, getexline, NULL, DOCMD_VERBOSE|DOCMD_EXCRESET);
debug_break_level = n;
}
lines_left = Rows - 1;
@ -408,7 +408,7 @@ static linenr_T debug_breakpoint_lnum;
/// debug_skipped_name is then set to the source name in the breakpoint case. If
/// a skipped command decides itself that a debug prompt should be displayed, it
/// can do so by calling dbg_check_skipped().
static int debug_skipped;
static bool debug_skipped;
static char *debug_skipped_name;
/// Go to debug mode when a breakpoint was encountered or "ex_nesting_level" is
@ -463,7 +463,7 @@ bool dbg_check_skipped(exarg_T *eap)
// Save the value of got_int and reset it. We don't want a previous
// interruption cause flushing the input buffer.
int prev_got_int = got_int;
bool prev_got_int = got_int;
got_int = false;
debug_breakpoint_name = debug_skipped_name;
// eap->skip is true
@ -788,7 +788,6 @@ static linenr_T debuggy_find(bool file, char *fname, linenr_T after, garray_T *g
struct debuggy *bp;
linenr_T lnum = 0;
char *name = fname;
int prev_got_int;
// Return quickly when there are no breakpoints.
if (GA_EMPTY(gap)) {
@ -813,7 +812,7 @@ static linenr_T debuggy_find(bool file, char *fname, linenr_T after, garray_T *g
// Save the value of got_int and reset it. We don't want a
// previous interruption cancel matching, only hitting CTRL-C
// while matching should abort it.
prev_got_int = got_int;
bool prev_got_int = got_int;
got_int = false;
if (vim_regexec_prog(&bp->dbg_prog, false, name, 0)) {
lnum = bp->dbg_lnum;

View File

@ -826,7 +826,7 @@ static void buf_signcols_validate_range(buf_T *buf, int row1, int row2, int add)
int *overlap = xcalloc(sizeof(int), (size_t)(row2 + 1 - row1));
// First find the number of overlapping signs at "row1".
(void)marktree_itr_get_overlap(buf->b_marktree, currow, 0, itr);
marktree_itr_get_overlap(buf->b_marktree, currow, 0, itr);
while (marktree_itr_step_overlap(buf->b_marktree, itr, &pair)) {
if (!mt_invalid(pair.start) && pair.start.flags & MT_FLAG_DECOR_SIGNTEXT) {
overlap[0]++;

View File

@ -1012,7 +1012,7 @@ static int check_external_diff(diffio_T *diffio)
if (fd == NULL) {
io_error = true;
} else {
if (fwrite("line1\n", (size_t)6, (size_t)1, fd) != 1) {
if (fwrite("line1\n", 6, 1, fd) != 1) {
io_error = true;
}
fclose(fd);
@ -1021,7 +1021,7 @@ static int check_external_diff(diffio_T *diffio)
if (fd == NULL) {
io_error = true;
} else {
if (fwrite("line2\n", (size_t)6, (size_t)1, fd) != 1) {
if (fwrite("line2\n", 6, 1, fd) != 1) {
io_error = true;
}
fclose(fd);
@ -1166,9 +1166,9 @@ static int diff_file(diffio_T *dio)
tmp_orig, tmp_new);
append_redir(cmd, len, p_srr, tmp_diff);
block_autocmds(); // Avoid ShellCmdPost stuff
(void)call_shell(cmd,
kShellOptFilter | kShellOptSilent | kShellOptDoOut,
NULL);
call_shell(cmd,
kShellOptFilter | kShellOptSilent | kShellOptDoOut,
NULL);
unblock_autocmds();
xfree(cmd);
return OK;
@ -1250,7 +1250,7 @@ void ex_diffpatch(exarg_T *eap)
vim_snprintf(buf, buflen, "patch -o %s %s < %s",
tmp_new, tmp_orig, esc_name);
block_autocmds(); // Avoid ShellCmdPost stuff
(void)call_shell(buf, kShellOptFilter, NULL);
call_shell(buf, kShellOptFilter, NULL);
unblock_autocmds();
}
@ -1398,7 +1398,7 @@ static void set_diff_option(win_T *wp, bool value)
/// Set options in window "wp" for diff mode.
///
/// @param addbuf Add buffer to diff.
void diff_win_options(win_T *wp, int addbuf)
void diff_win_options(win_T *wp, bool addbuf)
{
win_T *old_curwin = curwin;
@ -1888,7 +1888,7 @@ static void count_filler_lines_and_topline(int *curlinenum_to, int *linesfiller,
{
const diff_T *curdif = thistopdiff;
int ch_virtual_lines = 0;
int isfiller = 0;
bool isfiller = false;
while (virtual_lines_passed > 0) {
if (ch_virtual_lines) {
virtual_lines_passed--;
@ -1901,7 +1901,7 @@ static void count_filler_lines_and_topline(int *curlinenum_to, int *linesfiller,
} else {
(*linesfiller) = 0;
ch_virtual_lines = get_max_diff_length(curdif);
isfiller = (curdif->df_count[toidx] ? 0 : 1);
isfiller = (curdif->df_count[toidx] ? false : true);
if (isfiller) {
while (curdif && curdif->df_next && curdif->df_lnum[toidx] ==
curdif->df_next->df_lnum[toidx]
@ -2444,8 +2444,8 @@ void diff_set_topline(win_T *fromwin, win_T *towin)
changed_line_abv_curs_win(towin);
check_topfill(towin, false);
(void)hasFoldingWin(towin, towin->w_topline, &towin->w_topline,
NULL, true, NULL);
hasFoldingWin(towin, towin->w_topline, &towin->w_topline,
NULL, true, NULL);
}
/// This is called when 'diffopt' is changed.

View File

@ -2042,13 +2042,10 @@ char *keymap_init(void)
keymap_unload();
do_cmdline_cmd("unlet! b:keymap_name");
} else {
char *buf;
size_t buflen;
// Source the keymap file. It will contain a ":loadkeymap" command
// which will call ex_loadkeymap() below.
buflen = strlen(curbuf->b_p_keymap) + strlen(p_enc) + 14;
buf = xmalloc(buflen);
size_t buflen = strlen(curbuf->b_p_keymap) + strlen(p_enc) + 14;
char *buf = xmalloc(buflen);
// try finding "keymap/'keymap'_'encoding'.vim" in 'runtimepath'
vim_snprintf(buf, buflen, "keymap/%s_%s.vim",
@ -2130,7 +2127,7 @@ void ex_loadkeymap(exarg_T *eap)
vim_snprintf(buf, sizeof(buf), "<buffer> %s %s",
((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from,
((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].to);
(void)do_map(MAPTYPE_MAP, buf, MODE_LANGMAP, false);
do_map(MAPTYPE_MAP, buf, MODE_LANGMAP, false);
}
p_cpo = save_cpo;
@ -2167,7 +2164,7 @@ static void keymap_unload(void)
for (int i = 0; i < curbuf->b_kmap_ga.ga_len; i++) {
vim_snprintf(buf, sizeof(buf), "<buffer> %s", kp[i].from);
(void)do_map(MAPTYPE_UNMAP, buf, MODE_LANGMAP, false);
do_map(MAPTYPE_UNMAP, buf, MODE_LANGMAP, false);
}
keymap_ga_clear(&curbuf->b_kmap_ga);
@ -2193,13 +2190,12 @@ bool get_keymap_str(win_T *wp, char *fmt, char *buf, int len)
buf_T *old_curbuf = curbuf;
win_T *old_curwin = curwin;
char *s;
curbuf = wp->w_buffer;
curwin = wp;
STRCPY(buf, "b:keymap_name"); // must be writable
emsg_skip++;
s = p = eval_to_string(buf, false);
char *s = p = eval_to_string(buf, false);
emsg_skip--;
curbuf = old_curbuf;
curwin = old_curwin;

View File

@ -935,7 +935,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
int spell_attr = 0; // attributes desired by spelling
int word_end = 0; // last byte with same spell_attr
int cur_checked_col = 0; // checked column for current line
int extra_check = 0; // has syntax or linebreak
bool extra_check = 0; // has syntax or linebreak
int multi_attr = 0; // attributes desired by multibyte
int mb_l = 1; // multi-byte byte length
int mb_c = 0; // decoded multi-byte character
@ -2158,7 +2158,6 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
if (!wp->w_p_lbr || !wp->w_p_list) {
wlv.n_extra = tab_len;
} else {
char *p;
int saved_nextra = wlv.n_extra;
if (wlv.vcol_off > 0) {
@ -2184,7 +2183,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
len += wlv.n_extra - tab_len;
}
mb_c = wp->w_p_lcs_chars.tab1;
p = get_extra_buf((size_t)len + 1);
char *p = get_extra_buf((size_t)len + 1);
memset(p, ' ', (size_t)len);
p[len] = NUL;
wlv.p_extra = p;
@ -2293,10 +2292,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
wlv.c_extra = NUL;
wlv.c_final = NUL;
if (wp->w_p_lbr) {
char *p;
mb_c = (uint8_t)(*wlv.p_extra);
p = get_extra_buf((size_t)wlv.n_extra + 1);
char *p = get_extra_buf((size_t)wlv.n_extra + 1);
memset(p, ' ', (size_t)wlv.n_extra);
memcpy(p, wlv.p_extra + 1, strlen(wlv.p_extra) - 1);
p[wlv.n_extra] = NUL;

View File

@ -442,7 +442,7 @@ int update_screen(void)
// will be redrawn later or in win_update().
must_redraw = 0;
updating_screen = 1;
updating_screen = true;
display_tick++; // let syntax code know we're in a next round of
// display updating
@ -655,7 +655,7 @@ int update_screen(void)
wp->w_buffer->b_signcols.resized = false;
}
updating_screen = 0;
updating_screen = false;
// Clear or redraw the command line. Done last, because scrolling may
// mess up the command line.
@ -917,11 +917,11 @@ int showmode(void)
msg_grid_validate();
int do_mode = ((p_smd && msg_silent == 0)
&& ((State & MODE_TERMINAL)
|| (State & MODE_INSERT)
|| restart_edit != NUL
|| VIsual_active));
bool do_mode = ((p_smd && msg_silent == 0)
&& ((State & MODE_TERMINAL)
|| (State & MODE_INSERT)
|| restart_edit != NUL
|| VIsual_active));
bool can_show_mode = (p_ch != 0 || ui_has(kUIMessages));
if ((do_mode || reg_recording != 0) && can_show_mode) {
@ -1608,14 +1608,14 @@ static void win_update(win_T *wp)
}
}
(void)hasFoldingWin(wp, mod_top, &mod_top, NULL, true, NULL);
hasFoldingWin(wp, mod_top, &mod_top, NULL, true, NULL);
if (mod_top > lnumt) {
mod_top = lnumt;
}
// Now do the same for the bottom line (one above mod_bot).
mod_bot--;
(void)hasFoldingWin(wp, mod_bot, NULL, &mod_bot, true, NULL);
hasFoldingWin(wp, mod_bot, NULL, &mod_bot, true, NULL);
mod_bot++;
if (mod_bot < lnumb) {
mod_bot = lnumb;
@ -1686,17 +1686,15 @@ static void win_update(win_T *wp)
// New topline is above old topline: May scroll down.
int j;
if (hasAnyFolding(wp)) {
linenr_T ln;
// count the number of lines we are off, counting a sequence
// of folded lines as one
j = 0;
for (ln = wp->w_topline; ln < wp->w_lines[0].wl_lnum; ln++) {
for (linenr_T ln = wp->w_topline; ln < wp->w_lines[0].wl_lnum; ln++) {
j++;
if (j >= wp->w_grid.rows - 2) {
break;
}
(void)hasFoldingWin(wp, ln, NULL, &ln, true, NULL);
hasFoldingWin(wp, ln, NULL, &ln, true, NULL);
}
} else {
j = wp->w_lines[0].wl_lnum - wp->w_topline;
@ -2318,7 +2316,7 @@ static void win_update(win_T *wp)
// text doesn't need to be drawn, but the number column does.
foldinfo_T info = wp->w_p_cul && lnum == wp->w_cursor.lnum
? cursorline_fi : fold_info(wp, lnum);
(void)win_line(wp, lnum, srow, wp->w_grid.rows, true, &spv, info);
win_line(wp, lnum, srow, wp->w_grid.rows, true, &spv, info);
}
// This line does not need to be drawn, advance to the next one.

View File

@ -19,7 +19,7 @@ enum {
/// While redrawing the screen this flag is set. It means the screen size
/// ('lines' and 'rows') must not be changed.
EXTERN bool updating_screen INIT( = 0);
EXTERN bool updating_screen INIT( = false);
EXTERN match_T screen_search_hl INIT( = { 0 }); ///< used for 'hlsearch' highlight matching

View File

@ -112,7 +112,7 @@ static int did_restart_edit; // "restart_edit" when calling edit()
static bool can_cindent; // may do cindenting on this line
static int revins_on; // reverse insert mode on
static bool revins_on; // reverse insert mode on
static int revins_chars; // how much to skip after edit
static int revins_legal; // was the last char 'legal'?
static int revins_scol; // start column of revins session
@ -1598,7 +1598,7 @@ void undisplay_dollar(void)
/// @param round if true, round the indent to 'shiftwidth' (only with _INC and _Dec).
/// @param replaced replaced character, put on replace stack
/// @param call_changed_bytes call changed_bytes()
void change_indent(int type, int amount, int round, int replaced, int call_changed_bytes)
void change_indent(int type, int amount, int round, int replaced, bool call_changed_bytes)
{
int insstart_less; // reduction for Insstart.col
colnr_T orig_col = 0; // init for GCC
@ -1640,7 +1640,7 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang
// Set the new indent. The cursor will be put on the first non-blank.
if (type == INDENT_SET) {
(void)set_indent(amount, call_changed_bytes ? SIN_CHANGED : 0);
set_indent(amount, call_changed_bytes ? SIN_CHANGED : 0);
} else {
int save_State = State;
@ -2138,11 +2138,10 @@ void insertchar(int c, int flags, int second_indent)
&& !p_ri) {
#define INPUT_BUFLEN 100
char buf[INPUT_BUFLEN + 1];
int i;
colnr_T virtcol = 0;
buf[0] = (char)c;
i = 1;
int i = 1;
if (textwidth > 0) {
virtcol = get_nolist_virtcol();
}
@ -2456,9 +2455,7 @@ void beginline(int flags)
curwin->w_cursor.coladd = 0;
if (flags & (BL_WHITE | BL_SOL)) {
char *ptr;
for (ptr = get_cursor_line_ptr(); ascii_iswhite(*ptr)
for (char *ptr = get_cursor_line_ptr(); ascii_iswhite(*ptr)
&& !((flags & BL_FIX) && ptr[1] == NUL); ptr++) {
curwin->w_cursor.col++;
}
@ -2571,7 +2568,7 @@ void cursor_up_inner(win_T *wp, linenr_T n)
// Count each sequence of folded lines as one logical line.
// go to the start of the current fold
(void)hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
while (n--) {
// move up one line
@ -2583,7 +2580,7 @@ void cursor_up_inner(win_T *wp, linenr_T n)
// Insert mode or when 'foldopen' contains "all": it will open
// in a moment.
if (n > 0 || !((State & MODE_INSERT) || (fdo_flags & FDO_ALL))) {
(void)hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
}
}
if (lnum < 1) {
@ -2597,7 +2594,7 @@ void cursor_up_inner(win_T *wp, linenr_T n)
}
/// @param upd_topline When true: update topline
int cursor_up(linenr_T n, int upd_topline)
int cursor_up(linenr_T n, bool upd_topline)
{
// This fails if the cursor is already in the first line.
if (n > 0 && curwin->w_cursor.lnum <= 1) {
@ -2650,7 +2647,7 @@ void cursor_down_inner(win_T *wp, int n)
}
/// @param upd_topline When true: update topline
int cursor_down(int n, int upd_topline)
int cursor_down(int n, bool upd_topline)
{
// This fails if the cursor is already in the last line.
if (n > 0 && curwin->w_cursor.lnum >= curwin->w_buffer->b_ml.ml_line_count) {
@ -2947,7 +2944,7 @@ static void replace_do_bs(int limit_col)
getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL);
orig_vcols = win_chartabsize(curwin, get_cursor_pos_ptr(), start_vcol);
}
(void)del_char_after_col(limit_col);
del_char_after_col(limit_col);
if (l_State & VREPLACE_FLAG) {
orig_len = (int)strlen(get_cursor_pos_ptr());
}
@ -2978,7 +2975,7 @@ static void replace_do_bs(int limit_col)
// mark the buffer as changed and prepare for displaying
changed_bytes(curwin->w_cursor.lnum, curwin->w_cursor.col);
} else if (cc == 0) {
(void)del_char_after_col(limit_col);
del_char_after_col(limit_col);
}
}
@ -3005,8 +3002,8 @@ bool cindent_on(void)
bool in_cinkeys(int keytyped, int when, bool line_is_empty)
{
char *look;
int try_match;
int try_match_word;
bool try_match;
bool try_match_word;
char *p;
bool icase;
@ -3412,7 +3409,7 @@ static bool ins_esc(int *count, int cmdchar, bool nomove)
State &= ~REPLACE_FLAG;
}
(void)start_redo_ins();
start_redo_ins();
if (cmdchar == 'r' || cmdchar == 'v') {
stuffRedoReadbuff(ESC_STR); // No ESC in redo buffer
}
@ -3602,7 +3599,7 @@ static void ins_shift(int c, int lastc)
if (c == Ctrl_D && (lastc == '0' || lastc == '^')
&& curwin->w_cursor.col > 0) {
curwin->w_cursor.col--;
(void)del_char(false); // delete the '^' or '0'
del_char(false); // delete the '^' or '0'
// In Replace mode, restore the characters that '^' or '0' replaced.
if (State & REPLACE_FLAG) {
replace_pop_ins();
@ -3667,7 +3664,7 @@ static void ins_bs_one(colnr_T *vcolp)
replace_do_bs(-1);
}
} else {
(void)del_char(false);
del_char(false);
}
}
@ -3708,7 +3705,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
if (stop_arrow() == FAIL) {
return false;
}
int in_indent = inindent(0);
bool in_indent = inindent(0);
if (in_indent) {
can_cindent = false;
}
@ -3766,9 +3763,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
if (has_format_option(FO_AUTO)
&& has_format_option(FO_WHITE_PAR)) {
char *ptr = ml_get_buf_mut(curbuf, curwin->w_cursor.lnum);
int len;
len = (int)strlen(ptr);
int len = (int)strlen(ptr);
if (len > 0 && ptr[len - 1] == ' ') {
ptr[len - 1] = NUL;
}
@ -3918,7 +3913,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
char *p0 = get_cursor_pos_ptr();
has_composing = utf_composinglike(p0, p0 + utf_ptr2len(p0));
}
(void)del_char(false);
del_char(false);
// If there are combining characters and 'delcombine' is set
// move the cursor back. Don't back up before the base character.
if (has_composing) {
@ -4062,7 +4057,7 @@ static void ins_s_left(void)
if (!end_change) {
AppendCharToRedobuff(K_S_LEFT);
}
(void)bck_word(1, false, false);
bck_word(1, false, false);
curwin->w_set_curswant = true;
} else {
vim_beep(BO_CRSR);
@ -4121,7 +4116,7 @@ static void ins_s_right(void)
if (!end_change) {
AppendCharToRedobuff(K_S_RIGHT);
}
(void)fwd_word(1, false, 0);
fwd_word(1, false, 0);
curwin->w_set_curswant = true;
} else {
vim_beep(BO_CRSR);
@ -4234,7 +4229,7 @@ static bool ins_tab(void)
return false;
}
int ind = inindent(0);
bool ind = inindent(0);
if (ind) {
can_cindent = false;
}
@ -4657,7 +4652,7 @@ static void ins_try_si(int c)
if (State & VREPLACE_FLAG) {
change_indent(INDENT_SET, i, false, NUL, true);
} else {
(void)set_indent(i, SIN_CHANGED);
set_indent(i, SIN_CHANGED);
}
} else if (curwin->w_cursor.col > 0) {
// when inserting '{' after "O" reduce indent, but not
@ -4689,7 +4684,7 @@ static void ins_try_si(int c)
if (curwin->w_cursor.col > 0 && can_si && c == '#' && inindent(0)) {
// remember current indent for next line
old_indent = get_indent();
(void)set_indent(0, SIN_CHANGED);
set_indent(0, SIN_CHANGED);
}
// Adjust ai_col, the char at this position can be deleted.

View File

@ -529,7 +529,7 @@ void eval_clear(void)
free_autoload_scriptnames();
// unreferenced lists and dicts
(void)garbage_collect(false);
garbage_collect(false);
// functions not garbage collected
free_all_functions();
@ -761,7 +761,7 @@ void fill_evalarg_from_eap(evalarg_T *evalarg, exarg_T *eap, bool skip)
/// @param skip only parse, don't execute
///
/// @return true or false.
bool eval_to_bool(char *arg, bool *error, exarg_T *eap, int skip)
bool eval_to_bool(char *arg, bool *error, exarg_T *eap, bool skip)
{
typval_T tv;
bool retval = false;
@ -1726,7 +1726,7 @@ void clear_lval(lval_T *lp)
/// @param endp points to just after the parsed name.
/// @param op NULL, "+" for "+=", "-" for "-=", "*" for "*=", "/" for "/=",
/// "%" for "%=", "." for ".=" or "=" for "=".
void set_var_lval(lval_T *lp, char *endp, typval_T *rettv, int copy, const bool is_const,
void set_var_lval(lval_T *lp, char *endp, typval_T *rettv, bool copy, const bool is_const,
const char *op)
{
int cc;
@ -1795,8 +1795,8 @@ void set_var_lval(lval_T *lp, char *endp, typval_T *rettv, int copy, const bool
return;
}
(void)tv_list_assign_range(lp->ll_list, rettv->vval.v_list,
lp->ll_n1, lp->ll_n2, lp->ll_empty2, op, lp->ll_name);
tv_list_assign_range(lp->ll_list, rettv->vval.v_list,
lp->ll_n1, lp->ll_n2, lp->ll_empty2, op, lp->ll_name);
} else {
typval_T oldtv = TV_INITIAL_VALUE;
dict_T *dict = lp->ll_dict;
@ -8585,9 +8585,9 @@ char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, const char
int i = (int)(regmatch.startp[0] - tail);
memmove((char *)ga.ga_data + ga.ga_len, tail, (size_t)i);
// add the substituted text
(void)vim_regsub(&regmatch, sub, expr,
(char *)ga.ga_data + ga.ga_len + i, sublen,
REGSUB_COPY | REGSUB_MAGIC);
vim_regsub(&regmatch, sub, expr,
(char *)ga.ga_data + ga.ga_len + i, sublen,
REGSUB_COPY | REGSUB_MAGIC);
ga.ga_len += i + sublen - 1;
tail = regmatch.endp[0];
if (*tail == NUL) {
@ -8727,7 +8727,7 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments, boo
funcexe.fe_firstline = curwin->w_cursor.lnum;
funcexe.fe_lastline = curwin->w_cursor.lnum;
funcexe.fe_evaluate = true;
(void)call_func(func, name_len, &rettv, 2, argvars, &funcexe);
call_func(func, name_len, &rettv, 2, argvars, &funcexe);
tv_list_unref(arguments);
// Restore caller scope information

View File

@ -583,7 +583,8 @@ void f_getbufinfo(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
///
/// @return range (from start to end) of lines in rettv from the specified
/// buffer.
static void get_buffer_lines(buf_T *buf, linenr_T start, linenr_T end, int retlist, typval_T *rettv)
static void get_buffer_lines(buf_T *buf, linenr_T start, linenr_T end, bool retlist,
typval_T *rettv)
{
rettv->v_type = (retlist ? VAR_LIST : VAR_STRING);
rettv->vval.v_string = NULL;

View File

@ -1668,7 +1668,7 @@ static void f_exepath(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
char *path = NULL;
(void)os_can_exe(tv_get_string(&argvars[0]), &path, true);
os_can_exe(tv_get_string(&argvars[0]), &path, true);
#ifdef BACKSLASH_IN_FILENAME
if (path != NULL) {
@ -2214,8 +2214,8 @@ static void f_fnamemodify(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
len = strlen(fname);
if (*mods != NUL) {
size_t usedlen = 0;
(void)modify_fname((char *)mods, false, &usedlen,
(char **)&fname, &fbuf, &len);
modify_fname((char *)mods, false, &usedlen,
(char **)&fname, &fbuf, &len);
}
}
@ -3634,7 +3634,7 @@ static void f_inputlist(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
});
// Ask for choice.
int mouse_used;
bool mouse_used;
int selected = prompt_for_number(&mouse_used);
if (mouse_used) {
selected -= lines_left;
@ -4163,7 +4163,7 @@ static void f_jobstop(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
const char *error = NULL;
if (data->is_rpc) {
// Ignore return code, but show error later.
(void)channel_close(data->id, kChannelPartRpc, &error);
channel_close(data->id, kChannelPartRpc, &error);
}
process_stop(&data->stream.proc);
rettv->vval.v_number = 1;
@ -5211,7 +5211,7 @@ static void f_printf(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (!did_emsg) {
char *s = xmalloc((size_t)len + 1);
rettv->vval.v_string = s;
(void)vim_vsnprintf_typval(s, (size_t)len + 1, fmt, dummy_ap, argvars + 1);
vim_vsnprintf_typval(s, (size_t)len + 1, fmt, dummy_ap, argvars + 1);
}
did_emsg |= saved_did_emsg;
}
@ -5802,7 +5802,7 @@ static void f_getreginfo(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (list == NULL) {
return;
}
(void)tv_dict_add_list(dict, S_LEN("regcontents"), list);
tv_dict_add_list(dict, S_LEN("regcontents"), list);
char buf[NUMBUFLEN + 2];
buf[0] = NUL;
@ -5821,15 +5821,15 @@ static void f_getreginfo(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
case kMTUnknown:
abort();
}
(void)tv_dict_add_str(dict, S_LEN("regtype"), buf);
tv_dict_add_str(dict, S_LEN("regtype"), buf);
buf[0] = (char)get_register_name(get_unname_register());
buf[1] = NUL;
if (regname == '"') {
(void)tv_dict_add_str(dict, S_LEN("points_to"), buf);
tv_dict_add_str(dict, S_LEN("points_to"), buf);
} else {
(void)tv_dict_add_bool(dict, S_LEN("isunnamed"),
regname == buf[0] ? kBoolVarTrue : kBoolVarFalse);
tv_dict_add_bool(dict, S_LEN("isunnamed"),
regname == buf[0] ? kBoolVarTrue : kBoolVarFalse);
}
}
@ -8082,7 +8082,7 @@ static void f_str2float(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (*p == '+' || *p == '-') {
p = skipwhite(p + 1);
}
(void)string2float(p, &rettv->vval.v_float);
string2float(p, &rettv->vval.v_float);
if (isneg) {
rettv->vval.v_float *= -1;
}
@ -8397,7 +8397,7 @@ static void f_synconcealed(typval_T *argvars, typval_T *rettv, EvalFuncData fptr
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count && col >= 0
&& (size_t)col <= strlen(ml_get(lnum)) && curwin->w_p_cole > 0) {
(void)syn_get_id(curwin, lnum, col, false, NULL, false);
syn_get_id(curwin, lnum, col, false, NULL, false);
syntax_flags = get_syntax_info(&matchid);
// get the conceal character
@ -8435,7 +8435,7 @@ static void f_synstack(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
&& col >= 0
&& (size_t)col <= strlen(ml_get(lnum))) {
tv_list_alloc_ret(rettv, kListLenMayKnow);
(void)syn_get_id(curwin, lnum, col, false, NULL, true);
syn_get_id(curwin, lnum, col, false, NULL, true);
int id;
int i = 0;
@ -8509,8 +8509,8 @@ static void f_taglist(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (argvars[1].v_type != VAR_UNKNOWN) {
fname = tv_get_string(&argvars[1]);
}
(void)get_tags(tv_list_alloc_ret(rettv, kListLenUnknown),
(char *)tag_pattern, (char *)fname);
get_tags(tv_list_alloc_ret(rettv, kListLenUnknown),
(char *)tag_pattern, (char *)fname);
}
/// "tempname()" function
@ -8629,7 +8629,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
curbuf->b_p_swf = false;
apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, false, curbuf);
(void)setfname(curbuf, NameBuff, NULL, true);
setfname(curbuf, NameBuff, NULL, true);
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, curbuf);
// Save the job id and pid in b:terminal_job_{id,pid}

View File

@ -2909,7 +2909,7 @@ static int tv_blob_index(const blob_T *blob, int len, varnumber_T idx, typval_T
return OK;
}
int tv_blob_slice_or_index(const blob_T *blob, int is_range, varnumber_T n1, varnumber_T n2,
int tv_blob_slice_or_index(const blob_T *blob, bool is_range, varnumber_T n1, varnumber_T n2,
bool exclusive, typval_T *rettv)
{
int len = tv_blob_len(rettv->vval.v_blob);

View File

@ -1175,7 +1175,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
// A Lambda always has the command "return {expr}". It is much faster
// to evaluate {expr} directly.
ex_nesting_level++;
(void)eval1(&p, rettv, &EVALARG_EVALUATE);
eval1(&p, rettv, &EVALARG_EVALUATE);
ex_nesting_level--;
} else {
// call do_cmdline() to execute the lines
@ -2069,7 +2069,7 @@ char *save_function_name(char **name, bool skip, int flags, funcdict_T *fudi)
if (strncmp(p, "<lambda>", 8) == 0) {
p += 8;
(void)getdigits(&p, false, 0);
getdigits(&p, false, 0);
saved = xmemdupz(*name, (size_t)(p - *name));
if (fudi != NULL) {
CLEAR_POINTER(fudi);
@ -3658,7 +3658,7 @@ bool free_unref_funccal(int copyID, int testing)
if (did_free_funccal) {
// When a funccal was freed some more items might be garbage
// collected, so run again.
(void)garbage_collect(testing);
garbage_collect(testing);
}
return did_free;
}

View File

@ -378,7 +378,7 @@ void ex_let(exarg_T *eap)
if (!eap->skip) {
op[0] = '=';
op[1] = NUL;
(void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count, is_const, op);
ex_let_vars(eap->arg, &rettv, false, semicolon, var_count, is_const, op);
}
tv_clear(&rettv);
}
@ -415,7 +415,7 @@ void ex_let(exarg_T *eap)
clear_evalarg(&evalarg, eap);
if (!eap->skip && eval_res != FAIL) {
(void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count, is_const, op);
ex_let_vars(eap->arg, &rettv, false, semicolon, var_count, is_const, op);
}
if (eval_res != FAIL) {
tv_clear(&rettv);
@ -1303,7 +1303,7 @@ void vars_clear(hashtab_T *ht)
}
/// Like vars_clear(), but only free the value if "free_val" is true.
void vars_clear_ext(hashtab_T *ht, int free_val)
void vars_clear_ext(hashtab_T *ht, bool free_val)
{
int todo;
hashitem_T *hi;

View File

@ -675,13 +675,13 @@ static void win_move_into_split(win_T *wp, win_T *targetwin, int size, int flags
// Remove the old window and frame from the tree of frames
int dir;
(void)winframe_remove(wp, &dir, NULL);
winframe_remove(wp, &dir, NULL);
win_remove(wp, NULL);
last_status(false); // may need to remove last status line
(void)win_comp_pos(); // recompute window positions
win_comp_pos(); // recompute window positions
// Split a window on the desired side and put the old window there
(void)win_split_ins(size, flags, wp, dir);
win_split_ins(size, flags, wp, dir);
// If splitting horizontally, try to preserve height
if (size == 0 && !(flags & WSP_VERT)) {

View File

@ -156,7 +156,7 @@ void multiqueue_purge_events(MultiQueue *self)
{
assert(self);
while (!multiqueue_empty(self)) {
(void)multiqueue_remove(self);
multiqueue_remove(self);
}
}

View File

@ -283,12 +283,12 @@ void ex_align(exarg_T *eap)
// to the right.
if (has_tab) {
while (new_indent > 0) {
(void)set_indent(new_indent, 0);
set_indent(new_indent, 0);
if (linelen(NULL) <= width) {
// Now try to move the line as much as possible to
// the right. Stop when it moves too far.
do {
(void)set_indent(++new_indent, 0);
set_indent(++new_indent, 0);
} while (linelen(NULL) <= width);
new_indent--;
break;
@ -301,7 +301,7 @@ void ex_align(exarg_T *eap)
if (new_indent < 0) {
new_indent = 0;
}
(void)set_indent(new_indent, 0); // set indent
set_indent(new_indent, 0); // set indent
}
changed_lines(curbuf, eap->line1, 0, eap->line2 + 1, 0, true);
curwin->w_cursor = save_curpos;
@ -341,13 +341,13 @@ static int linelen(int *has_tab)
static char *sortbuf1;
static char *sortbuf2;
static int sort_lc; ///< sort using locale
static int sort_ic; ///< ignore case
static int sort_nr; ///< sort on number
static int sort_rx; ///< sort on regex instead of skipping it
static int sort_flt; ///< sort on floating number
static bool sort_lc; ///< sort using locale
static bool sort_ic; ///< ignore case
static bool sort_nr; ///< sort on number
static bool sort_rx; ///< sort on regex instead of skipping it
static bool sort_flt; ///< sort on floating number
static int sort_abort; ///< flag to indicate if sorting has been interrupted
static bool sort_abort; ///< flag to indicate if sorting has been interrupted
/// Struct to store info to be sorted.
typedef struct {
@ -450,7 +450,7 @@ void ex_sort(exarg_T *eap)
regmatch.regprog = NULL;
sorti_T *nrs = xmalloc(count * sizeof(sorti_T));
sort_abort = sort_ic = sort_lc = sort_rx = sort_nr = sort_flt = 0;
sort_abort = sort_ic = sort_lc = sort_rx = sort_nr = sort_flt = false;
size_t format_found = 0;
bool change_occurred = false; // Buffer contents changed.
@ -464,10 +464,10 @@ void ex_sort(exarg_T *eap)
} else if (*p == 'r') {
sort_rx = true;
} else if (*p == 'n') {
sort_nr = 1;
sort_nr = true;
format_found++;
} else if (*p == 'f') {
sort_flt = 1;
sort_flt = true;
format_found++;
} else if (*p == 'b') {
sort_what = STR2NR_BIN + STR2NR_FORCE;
@ -521,7 +521,7 @@ void ex_sort(exarg_T *eap)
// From here on "sort_nr" is used as a flag for any integer number
// sorting.
sort_nr += sort_what;
sort_nr |= sort_what;
// Make an array with all line numbers. This avoids having to copy all
// the lines into allocated memory.
@ -1305,7 +1305,7 @@ void do_shell(char *cmd, int flags)
// This ui_cursor_goto is required for when the '\n' resulted in a "delete line
// 1" command to the terminal.
ui_cursor_goto(msg_row, msg_col);
(void)call_shell(cmd, (ShellOpts)flags, NULL);
call_shell(cmd, (ShellOpts)flags, NULL);
if (msg_silent == 0) {
msg_didout = true;
}
@ -1462,7 +1462,7 @@ void append_redir(char *const buf, const size_t buflen, const char *const opt,
}
}
void print_line_no_prefix(linenr_T lnum, int use_number, int list)
void print_line_no_prefix(linenr_T lnum, int use_number, bool list)
{
char numbuf[30];
@ -1475,9 +1475,9 @@ void print_line_no_prefix(linenr_T lnum, int use_number, int list)
}
/// Print a text line. Also in silent mode ("ex -s").
void print_line(linenr_T lnum, int use_number, int list)
void print_line(linenr_T lnum, int use_number, bool list)
{
int save_silent = silent_mode;
bool save_silent = silent_mode;
// apply :filter /pat/
if (message_filtered(ml_get(lnum))) {
@ -1566,7 +1566,7 @@ void ex_file(exarg_T *eap)
void ex_update(exarg_T *eap)
{
if (curbufIsChanged()) {
(void)do_write(eap);
do_write(eap);
}
}
@ -1582,7 +1582,7 @@ void ex_write(exarg_T *eap)
if (eap->usefilter) { // input lines to shell command
do_bang(1, eap, false, true, false);
} else {
(void)do_write(eap);
do_write(eap);
}
}
@ -1605,7 +1605,7 @@ static int check_writable(const char *fname)
/// @return FAIL for failure, OK otherwise.
int do_write(exarg_T *eap)
{
int other;
bool other;
char *fname = NULL; // init to shut up gcc
int retval = FAIL;
char *free_fname = NULL;
@ -1724,7 +1724,7 @@ int do_write(exarg_T *eap)
// If 'filetype' was empty try detecting it now.
if (*curbuf->b_p_ft == NUL) {
if (augroup_exists("filetypedetect")) {
(void)do_doautocmd("filetypedetect BufRead", true, NULL);
do_doautocmd("filetypedetect BufRead", true, NULL);
}
do_modelines(0);
}
@ -1774,7 +1774,7 @@ theend:
/// @param other writing under other name
///
/// @return OK if it's OK, FAIL if it is not.
int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int other)
int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, bool other)
{
// Write to another file or b_flags set or not writing the whole file:
// overwriting only allowed with '!'
@ -1815,8 +1815,6 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int oth
// For ":w! filename" check that no swap file exists for "filename".
if (other && !emsg_silent) {
char *dir;
char *p;
char *swapname;
// We only try the first entry in 'directory', without checking if
// it's writable. If the "." directory is not writable the write
@ -1828,10 +1826,10 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int oth
STRCPY(dir, ".");
} else {
dir = xmalloc(MAXPATHL);
p = p_dir;
char *p = p_dir;
copy_option_part(&p, dir, MAXPATHL, ",");
}
swapname = makeswapname(fname, ffname, curbuf, dir);
char *swapname = makeswapname(fname, ffname, curbuf, dir);
xfree(dir);
if (os_path_exists(swapname)) {
if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) {
@ -1998,11 +1996,11 @@ static int check_readonly(int *forceit, buf_T *buf)
/// GETFILE_NOT_WRITTEN for "not written" error,
/// GETFILE_SAME_FILE for success
/// GETFILE_OPEN_OTHER for successfully opening another file.
int getfile(int fnum, char *ffname_arg, char *sfname_arg, int setpm, linenr_T lnum, int forceit)
int getfile(int fnum, char *ffname_arg, char *sfname_arg, bool setpm, linenr_T lnum, bool forceit)
{
char *ffname = ffname_arg;
char *sfname = sfname_arg;
int other;
bool other;
int retval;
char *free_me = NULL;
@ -2179,7 +2177,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
| ((flags & ECMD_FORCEIT) ? CCGD_FORCEIT : 0)
| (eap == NULL ? 0 : CCGD_EXCMD))) {
if (fnum == 0 && other_file && ffname != NULL) {
(void)setaltfname(ffname, sfname, newlnum < 0 ? 0 : newlnum);
setaltfname(ffname, sfname, newlnum < 0 ? 0 : newlnum);
}
goto theend;
}
@ -2270,7 +2268,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
// Existing memfile.
oldbuf = true;
set_bufref(&bufref, buf);
(void)buf_check_timestamp(buf);
buf_check_timestamp(buf);
// Check if autocommands made buffer invalid or changed the current
// buffer.
if (!bufref_valid(&bufref) || curbuf != old_curbuf.br_buf) {
@ -2606,7 +2604,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
// If the window options were changed may need to set the spell language.
// Can only do this after the buffer has been properly setup.
if (did_get_winopts && curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) {
(void)parse_spelllang(curwin);
parse_spelllang(curwin);
}
if (command == NULL) {
@ -2669,7 +2667,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
}
if (curbuf->b_kmap_state & KEYMAP_INIT) {
(void)keymap_init();
keymap_init();
}
RedrawingDisabled--;
@ -2722,7 +2720,7 @@ void ex_append(exarg_T *eap)
linenr_T lnum = eap->line2;
int indent = 0;
char *p;
int empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
bool empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
// the ! flag toggles autoindent
if (eap->forceit) {
@ -2824,7 +2822,7 @@ void ex_append(exarg_T *eap)
if (empty) {
ml_delete(2, false);
empty = 0;
empty = false;
}
}
State = MODE_NORMAL;
@ -3954,11 +3952,11 @@ static int do_sub(exarg_T *eap, const proftime_T timeout, const int cmdpreview_n
current_match.start.col = start_col;
textlock++;
(void)vim_regsub_multi(&regmatch,
sub_firstlnum - regmatch.startpos[0].lnum,
sub, new_end, sublen,
REGSUB_COPY | REGSUB_BACKSLASH
| (magic_isset() ? REGSUB_MAGIC : 0));
vim_regsub_multi(&regmatch,
sub_firstlnum - regmatch.startpos[0].lnum,
sub, new_end, sublen,
REGSUB_COPY | REGSUB_BACKSLASH
| (magic_isset() ? REGSUB_MAGIC : 0));
textlock--;
sub_nsubs++;
did_sub = true;
@ -4677,7 +4675,7 @@ static int show_sub(exarg_T *eap, pos_T old_cusr, PreviewLines *preview_lines, i
/// :substitute command.
void ex_substitute(exarg_T *eap)
{
(void)do_sub(eap, profile_zero(), 0, 0);
do_sub(eap, profile_zero(), 0, 0);
}
/// :substitute command preview callback.

View File

@ -100,7 +100,7 @@ void ex_perldo(exarg_T *eap)
/// Careful: autocommands may make "buf" invalid!
///
/// @return FAIL for failure, OK otherwise
int autowrite(buf_T *buf, int forceit)
int autowrite(buf_T *buf, bool forceit)
{
bufref_T bufref;
@ -132,7 +132,7 @@ void autowrite_all(void)
if (bufIsChanged(buf) && !buf->b_p_ro && !bt_dontwrite(buf)) {
bufref_T bufref;
set_bufref(&bufref, buf);
(void)buf_write_all(buf, false);
buf_write_all(buf, false);
// an autocommand may have deleted the buffer
if (!bufref_valid(&bufref)) {
buf = firstbuf;
@ -145,7 +145,7 @@ void autowrite_all(void)
/// For flags use the CCGD_ values.
bool check_changed(buf_T *buf, int flags)
{
int forceit = (flags & CCGD_FORCEIT);
bool forceit = (flags & CCGD_FORCEIT);
bufref_T bufref;
set_bufref(&bufref, buf);
@ -211,7 +211,7 @@ void dialog_changed(buf_T *buf, bool checkall)
if (buf->b_fname != NULL
&& check_overwrite(&ea, buf, buf->b_fname, buf->b_ffname, false) == OK) {
// didn't hit Cancel
(void)buf_write_all(buf, false);
buf_write_all(buf, false);
}
} else if (ret == VIM_NO) {
unchanged(buf, true, false);
@ -227,7 +227,7 @@ void dialog_changed(buf_T *buf, bool checkall)
if (buf2->b_fname != NULL
&& check_overwrite(&ea, buf2, buf2->b_fname, buf2->b_ffname, false) == OK) {
// didn't hit Cancel
(void)buf_write_all(buf2, false);
buf_write_all(buf2, false);
}
// an autocommand may have deleted the buffer
if (!bufref_valid(&bufref)) {
@ -261,7 +261,7 @@ bool dialog_close_terminal(buf_T *buf)
/// @return true if the buffer "buf" can be abandoned, either by making it
/// hidden, autowriting it or unloading it.
bool can_abandon(buf_T *buf, int forceit)
bool can_abandon(buf_T *buf, bool forceit)
{
return buf_hide(buf)
|| !bufIsChanged(buf)
@ -423,7 +423,7 @@ int check_fname(void)
/// Flush the contents of a buffer, unless it has no file name.
///
/// @return FAIL for failure, OK otherwise
int buf_write_all(buf_T *buf, int forceit)
int buf_write_all(buf_T *buf, bool forceit)
{
buf_T *old_curbuf = curbuf;
@ -744,7 +744,7 @@ void ex_checktime(exarg_T *eap)
} else {
buf_T *buf = buflist_findnr((int)eap->line2);
if (buf != NULL) { // cannot happen?
(void)buf_check_timestamp(buf);
buf_check_timestamp(buf);
}
}
no_check_timestamps = save_no_check_timestamps;
@ -763,7 +763,7 @@ static void script_host_execute(char *name, exarg_T *eap)
tv_list_append_number(args, (int)eap->line1);
tv_list_append_number(args, (int)eap->line2);
(void)eval_call_provider(name, "execute", args, true);
eval_call_provider(name, "execute", args, true);
}
}
@ -779,7 +779,7 @@ static void script_host_execute_file(char *name, exarg_T *eap)
// current range
tv_list_append_number(args, (int)eap->line1);
tv_list_append_number(args, (int)eap->line2);
(void)eval_call_provider(name, "execute_file", args, true);
eval_call_provider(name, "execute_file", args, true);
}
}
@ -790,7 +790,7 @@ static void script_host_do_range(char *name, exarg_T *eap)
tv_list_append_number(args, (int)eap->line1);
tv_list_append_number(args, (int)eap->line2);
tv_list_append_string(args, eap->arg, -1);
(void)eval_call_provider(name, "do_range", args, true);
eval_call_provider(name, "do_range", args, true);
}
}

View File

@ -190,8 +190,8 @@ static void restore_dbg_stuff(struct dbg_stuff *dsp)
trylevel = dsp->trylevel;
force_abort = dsp->force_abort;
caught_stack = dsp->caught_stack;
(void)v_exception(dsp->vv_exception);
(void)v_throwpoint(dsp->vv_throwpoint);
v_exception(dsp->vv_exception);
v_throwpoint(dsp->vv_throwpoint);
did_emsg = dsp->did_emsg;
got_int = dsp->got_int;
did_throw = dsp->did_throw;
@ -710,7 +710,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
}
// Convert an interrupt to an exception if appropriate.
(void)do_intthrow(&cstack);
do_intthrow(&cstack);
// Continue executing command lines when:
// - no CTRL-C typed, no aborting error, no exception thrown or try
@ -1703,8 +1703,8 @@ int execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo, bool preview)
&& eap->addr_type == ADDR_LINES) {
// Put the first line at the start of a closed fold, put the last line
// at the end of a closed fold.
(void)hasFolding(eap->line1, &eap->line1, NULL);
(void)hasFolding(eap->line2, NULL, &eap->line2);
hasFolding(eap->line1, &eap->line1, NULL);
hasFolding(eap->line2, NULL, &eap->line2);
}
// Use first argument as count when possible
@ -1958,7 +1958,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
}
if (!ea.skip && got_int) {
ea.skip = true;
(void)do_intthrow(cstack);
do_intthrow(cstack);
}
// 4. Parse a range specifier of the form: addr [,addr] [;addr] ..
@ -2170,8 +2170,8 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
&& ea.addr_type == ADDR_LINES) {
// Put the first line at the start of a closed fold, put the last line
// at the end of a closed fold.
(void)hasFolding(ea.line1, &ea.line1, NULL);
(void)hasFolding(ea.line2, NULL, &ea.line2);
hasFolding(ea.line1, &ea.line1, NULL);
hasFolding(ea.line2, NULL, &ea.line2);
}
// For the ":make" and ":grep" commands we insert the 'makeprg'/'grepprg'
@ -3259,7 +3259,7 @@ static const char *addr_error(cmd_addr_T addr_type)
/// @param errormsg Error message, if any
///
/// @return MAXLNUM when no Ex address was found.
static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int skip, bool silent,
static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, bool skip, bool silent,
int to_other_file, int address_count, const char **errormsg)
FUNC_ATTR_NONNULL_ALL
{
@ -3379,7 +3379,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int
fmark_T *fm = mark_get(curbuf, curwin, NULL, flag, *cmd);
cmd++;
if (fm != NULL && fm->fnum != curbuf->handle) {
(void)mark_move_to(fm, 0);
mark_move_to(fm, 0);
// Jumped to another file.
lnum = curwin->w_cursor.lnum;
} else {
@ -3553,7 +3553,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int
// closed fold after the first address.
if (addr_type == ADDR_LINES && (i == '-' || i == '+')
&& address_count >= 2) {
(void)hasFolding(lnum, NULL, &lnum);
hasFolding(lnum, NULL, &lnum);
}
if (i == '-') {
lnum -= n;
@ -3780,12 +3780,12 @@ int expand_filename(exarg_T *eap, char **cmdlinep, const char **errormsgp)
// Decide to expand wildcards *before* replacing '%', '#', etc. If
// the file name contains a wildcard it should not cause expanding.
// (it will be expanded anyway if there is a wildcard before replacing).
int has_wildcards = path_has_wildcard(p);
bool has_wildcards = path_has_wildcard(p);
while (*p != NUL) {
// Skip over `=expr`, wildcards in it are not expanded.
if (p[0] == '`' && p[1] == '=') {
p += 2;
(void)skip_expr(&p, NULL);
skip_expr(&p, NULL);
if (*p == '`') {
p++;
}
@ -3860,9 +3860,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, const char **errormsgp)
|| eap->cmdidx == CMD_bang
|| eap->cmdidx == CMD_terminal)
&& strpbrk(repl, "!") != NULL) {
char *l;
l = vim_strsave_escaped(repl, "!");
char *l = vim_strsave_escaped(repl, "!");
xfree(repl);
repl = l;
}
@ -3890,7 +3888,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, const char **errormsgp)
p = NULL;
}
if (p != NULL) {
(void)repl_cmdline(eap, eap->arg, strlen(eap->arg), p, cmdlinep);
repl_cmdline(eap, eap->arg, strlen(eap->arg), p, cmdlinep);
}
}
@ -3918,7 +3916,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, const char **errormsgp)
if (p == NULL) {
return FAIL;
}
(void)repl_cmdline(eap, eap->arg, strlen(eap->arg), p, cmdlinep);
repl_cmdline(eap, eap->arg, strlen(eap->arg), p, cmdlinep);
xfree(p);
}
}
@ -4004,7 +4002,7 @@ void separate_nextcmd(exarg_T *eap)
} else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE)) {
// Skip over `=expr` when wildcards are expanded.
p += 2;
(void)skip_expr(&p, NULL);
skip_expr(&p, NULL);
if (*p == NUL) { // stop at NUL after CTRL-V
break;
}
@ -4063,7 +4061,7 @@ static char *getargcmd(char **argp)
/// Find end of "+command" argument. Skip over "\ " and "\\".
///
/// @param rembs true to halve the number of backslashes
char *skip_cmd_arg(char *p, int rembs)
char *skip_cmd_arg(char *p, bool rembs)
{
while (*p && !ascii_isspace(*p)) {
if (*p == '\\' && p[1] != NUL) {
@ -4376,7 +4374,7 @@ static void ex_doautocmd(exarg_T *eap)
int call_do_modelines = check_nomodeline(&arg);
bool did_aucmd;
(void)do_doautocmd(arg, false, &did_aucmd);
do_doautocmd(arg, false, &did_aucmd);
// Only when there is no <nomodeline>.
if (call_do_modelines && did_aucmd) {
do_modelines(0);
@ -4508,7 +4506,7 @@ char *check_nextcmd(char *p)
/// @param message when false check only, no messages
///
/// @return FAIL and give error message if 'message' true, return OK otherwise
static int check_more(int message, bool forceit)
static int check_more(bool message, bool forceit)
{
int n = ARGCOUNT - curwin->w_arg_idx - 1;
@ -5371,9 +5369,9 @@ void do_exedit(exarg_T *eap, win_T *old_curwin)
|| eap->cmdidx == CMD_vnew) && *eap->arg == NUL) {
// ":new" or ":tabnew" without argument: edit a new empty buffer
setpcmark();
(void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE,
ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0),
old_curwin == NULL ? curwin : NULL);
do_ecmd(0, NULL, NULL, eap, ECMD_ONE,
ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0),
old_curwin == NULL ? curwin : NULL);
} else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit)
|| *eap->arg != NUL) {
// Can't edit another file when "textlock" or "curbuf->b_ro_locked" is set.
@ -5555,7 +5553,7 @@ static void ex_read(exarg_T *eap)
eap->line2, 0, (linenr_T)MAXLNUM, eap, 0, false);
} else {
if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) {
(void)setaltfname(eap->arg, eap->arg, 1);
setaltfname(eap->arg, eap->arg, 1);
}
i = readfile(eap->arg, NULL,
eap->line2, 0, (linenr_T)MAXLNUM, eap, 0, false);
@ -5826,7 +5824,7 @@ void do_sleep(int64_t msec)
// If CTRL-C was typed to interrupt the sleep, drop the CTRL-C from the
// input buffer, otherwise a following call to input() fails.
if (got_int) {
(void)vpeekc();
vpeekc();
}
}
@ -5911,7 +5909,7 @@ static void ex_operators(exarg_T *eap)
case CMD_yank:
oa.op_type = OP_YANK;
(void)op_yank(&oa, true);
op_yank(&oa, true);
break;
default: // CMD_rshift or CMD_lshift
@ -6053,7 +6051,7 @@ static void ex_at(exarg_T *eap)
// Continue until the stuff buffer is empty and all added characters
// have been consumed.
while (!stuff_empty() || typebuf.tb_len > prev_len) {
(void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE);
do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE);
}
exec_from_reg = save_efr;
@ -6227,7 +6225,7 @@ static void ex_redir(exarg_T *eap)
}
if (var_redir_start(skipwhite(arg), append) == OK) {
redir_vname = 1;
redir_vname = true;
}
} else { // TODO(vim): redirect to a buffer
semsg(_(e_invarg2), eap->arg);
@ -6333,7 +6331,7 @@ static void close_redir(void)
redir_reg = 0;
if (redir_vname) {
var_redir_stop();
redir_vname = 0;
redir_vname = false;
}
}
@ -7174,7 +7172,7 @@ static void ex_shada(exarg_T *eap)
p_shada = "'100";
}
if (eap->cmdidx == CMD_rviminfo || eap->cmdidx == CMD_rshada) {
(void)shada_read_everything(eap->arg, eap->forceit, false);
shada_read_everything(eap->arg, eap->forceit, false);
} else {
shada_write_file(eap->arg, eap->forceit);
}
@ -7245,7 +7243,7 @@ static void ex_filetype(exarg_T *eap)
}
}
if (*arg == 'd') {
(void)do_doautocmd("filetypedetect BufRead", true, NULL);
do_doautocmd("filetypedetect BufRead", true, NULL);
do_modelines(0);
}
} else if (strcmp(arg, "off") == 0) {

View File

@ -105,7 +105,7 @@ static bool cause_abort = false;
/// That is, during cancellation of an expression evaluation after an aborting
/// function call or due to a parsing error, aborting() always returns the same
/// value. "got_int" is also set by calling interrupt().
int aborting(void)
bool aborting(void)
{
return (did_emsg && force_abort) || got_int || did_throw;
}
@ -125,7 +125,7 @@ void update_force_abort(void)
/// abort the script processing. Can be used to suppress an autocommand after
/// execution of a failing subcommand as long as the error message has not been
/// displayed and actually caused the abortion.
int should_abort(int retcode)
bool should_abort(int retcode)
{
return (retcode == FAIL && trylevel != 0 && !emsg_silent) || aborting();
}
@ -134,7 +134,7 @@ int should_abort(int retcode)
/// ended on an error. This means that parsing commands is continued in order
/// to find finally clauses to be executed, and that some errors in skipped
/// commands are still reported.
int aborted_in_try(void)
bool aborted_in_try(void)
FUNC_ATTR_PURE
{
// This function is only called after an error. In this case, "force_abort"
@ -326,7 +326,7 @@ void do_errthrow(cstack_T *cstack, char *cmdname)
///
/// @return true if the current exception is discarded or,
/// false otherwise.
int do_intthrow(cstack_T *cstack)
bool do_intthrow(cstack_T *cstack)
{
// If no interrupt occurred or no try conditional is active and no exception
// is being thrown, do nothing (for compatibility of non-EH scripts).
@ -369,7 +369,7 @@ int do_intthrow(cstack_T *cstack)
}
/// Get an exception message that is to be stored in current_exception->value.
char *get_exception_string(void *value, except_type_T type, char *cmdname, int *should_free)
char *get_exception_string(void *value, except_type_T type, char *cmdname, bool *should_free)
{
char *ret;
@ -454,7 +454,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname)
excp->messages = (msglist_T *)value;
}
int should_free;
bool should_free;
excp->value = get_exception_string(value, type, cmdname, &should_free);
if (excp->value == NULL && should_free) {
goto nomem;
@ -841,7 +841,7 @@ void ex_if(exarg_T *eap)
cstack->cs_idx++;
cstack->cs_flags[cstack->cs_idx] = 0;
int skip = CHECK_SKIP;
bool skip = CHECK_SKIP;
bool error;
bool result = eval_to_bool(eap->arg, &error, eap, skip);
@ -875,7 +875,7 @@ void ex_endif(exarg_T *eap)
// discarded by throwing the interrupt exception later on.
if (!(eap->cstack->cs_flags[eap->cstack->cs_idx] & CSF_TRUE)
&& dbg_check_skipped(eap)) {
(void)do_intthrow(eap->cstack);
do_intthrow(eap->cstack);
}
eap->cstack->cs_idx--;
@ -926,7 +926,7 @@ void ex_else(exarg_T *eap)
// for a parsing errors is discarded when throwing the interrupt exception
// later on.
if (!skip && dbg_check_skipped(eap) && got_int) {
(void)do_intthrow(cstack);
do_intthrow(cstack);
skip = true;
}
@ -1132,7 +1132,7 @@ void ex_endwhile(exarg_T *eap)
}
}
// Cleanup and rewind all contained (and unclosed) conditionals.
(void)cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, false);
cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, false);
rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel);
} else if (cstack->cs_flags[cstack->cs_idx] & CSF_TRUE
&& !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)
@ -1145,7 +1145,7 @@ void ex_endwhile(exarg_T *eap)
// throw an interrupt exception if appropriate. Doing this here
// prevents that an exception for a parsing error is discarded when
// throwing the interrupt exception later on.
(void)do_intthrow(cstack);
do_intthrow(cstack);
}
// Set loop flag, so do_cmdline() will jump back to the matching
@ -1476,7 +1476,7 @@ void ex_finally(exarg_T *eap)
// occurred before the ":finally". That is, discard the
// original exception and replace it by an interrupt
// exception.
(void)do_intthrow(cstack);
do_intthrow(cstack);
}
// If there is a preceding catch clause and it caught the exception,
@ -1617,7 +1617,7 @@ void ex_endtry(exarg_T *eap)
// set "skip" and "rethrow".
if (got_int) {
skip = true;
(void)do_intthrow(cstack);
do_intthrow(cstack);
// The do_intthrow() call may have reset did_throw or
// cstack->cs_pending[idx].
rethrow = false;
@ -1649,7 +1649,7 @@ void ex_endtry(exarg_T *eap)
// was no finally clause, finish the exception now. This happens also
// after errors except when this ":endtry" is not within a ":try".
// Restore "emsg_silent" if it has been reset by this try conditional.
(void)cleanup_conditionals(cstack, CSF_TRY | CSF_SILENT, true);
cleanup_conditionals(cstack, CSF_TRY | CSF_SILENT, true);
if (cstack->cs_idx >= 0 && (cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) {
cstack->cs_idx--;

View File

@ -467,7 +467,7 @@ static void may_do_incsearch_highlighting(int firstc, int count, incsearch_state
// if interrupted while searching, behave like it failed
if (got_int) {
(void)vpeekc(); // remove <C-C> from input stream
vpeekc(); // remove <C-C> from input stream
got_int = false; // don't abandon the command line
found = 0;
} else if (char_avail()) {
@ -1052,7 +1052,7 @@ static int command_line_wildchar_complete(CommandLineState *s)
&& !s->did_wild_list
&& ((wim_flags[s->wim_index] & WIM_LIST)
|| (p_wmnu && (wim_flags[s->wim_index] & WIM_FULL) != 0))) {
(void)showmatches(&s->xpc, p_wmnu && ((wim_flags[s->wim_index] & WIM_LIST) == 0));
showmatches(&s->xpc, p_wmnu && ((wim_flags[s->wim_index] & WIM_LIST) == 0));
redrawcmd();
s->did_wild_list = true;
}
@ -1078,9 +1078,9 @@ static int command_line_wildchar_complete(CommandLineState *s)
// if interrupted while completing, behave like it failed
if (got_int) {
(void)vpeekc(); // remove <C-C> from input stream
vpeekc(); // remove <C-C> from input stream
got_int = false; // don't abandon the command line
(void)ExpandOne(&s->xpc, NULL, NULL, 0, WILD_FREE);
ExpandOne(&s->xpc, NULL, NULL, 0, WILD_FREE);
s->xpc.xp_context = EXPAND_NOTHING;
return CMDLINE_CHANGED;
}
@ -1104,7 +1104,7 @@ static int command_line_wildchar_complete(CommandLineState *s)
p_wmnu = p_wmnu_save;
}
(void)showmatches(&s->xpc, p_wmnu && ((wim_flags[s->wim_index] & WIM_LIST) == 0));
showmatches(&s->xpc, p_wmnu && ((wim_flags[s->wim_index] & WIM_LIST) == 0));
redrawcmd();
s->did_wild_list = true;
@ -1138,7 +1138,7 @@ static void command_line_end_wildmenu(CommandLineState *s)
cmdline_pum_remove();
}
if (s->xpc.xp_numfiles != -1) {
(void)ExpandOne(&s->xpc, NULL, NULL, 0, WILD_FREE);
ExpandOne(&s->xpc, NULL, NULL, 0, WILD_FREE);
}
s->did_wild_list = false;
if (!p_wmnu || (s->c != K_UP && s->c != K_DOWN)) {
@ -1250,7 +1250,7 @@ static int command_line_execute(VimState *state, int key)
// Ctrl-E: cancel the cmdline popup menu and return the original text.
if (s->c == Ctrl_E || s->c == Ctrl_Y) {
wild_type = (s->c == Ctrl_E) ? WILD_CANCEL : WILD_APPLY;
(void)nextwild(&s->xpc, wild_type, WILD_NO_BEEP, s->firstc != '@');
nextwild(&s->xpc, wild_type, WILD_NO_BEEP, s->firstc != '@');
}
}
@ -1419,7 +1419,7 @@ static int may_do_command_line_next_incsearch(int firstc, int count, incsearch_s
if (lt(s->match_start, s->match_end)) {
// start searching at the end of the match
// not at the beginning of the next column
(void)decl(&t);
decl(&t);
}
search_flags += SEARCH_COL;
} else {
@ -1447,21 +1447,21 @@ static int may_do_command_line_next_incsearch(int firstc, int count, incsearch_s
// when nv_search finishes the cursor will be
// put back on the match
s->search_start = t;
(void)decl(&s->search_start);
decl(&s->search_start);
} else if (next_match && firstc == '?') {
// move just after the current match, so that
// when nv_search finishes the cursor will be
// put back on the match
s->search_start = t;
(void)incl(&s->search_start);
incl(&s->search_start);
}
if (lt(t, s->search_start) && next_match) {
// wrap around
s->search_start = t;
if (firstc == '?') {
(void)incl(&s->search_start);
incl(&s->search_start);
} else {
(void)decl(&s->search_start);
decl(&s->search_start);
}
}
@ -2176,7 +2176,7 @@ static bool empty_pattern(char *p, int delim)
magic_T magic_val = MAGIC_ON;
if (n > 0) {
(void)skip_regexp_ex(p, delim, magic_isset(), NULL, NULL, &magic_val);
skip_regexp_ex(p, delim, magic_isset(), NULL, NULL, &magic_val);
} else {
return true;
}
@ -2939,7 +2939,7 @@ char *getexline(int c, void *cookie, int indent, bool do_concat)
{
// When executing a register, remove ':' that's in front of each line.
if (exec_from_reg && vpeekc() == ':') {
(void)vgetc();
vgetc();
}
return getcmdline(c, 1, indent, do_concat);
@ -3454,7 +3454,7 @@ void cmdline_ui_flush(void)
// Put a character on the command line. Shifts the following text to the
// right when "shift" is true. Used for CTRL-V, CTRL-K, etc.
// "c" must be printable (fit in one display cell)!
void putcmdline(char c, int shift)
void putcmdline(char c, bool shift)
{
if (cmd_silent) {
return;
@ -3501,7 +3501,7 @@ void unputcmdline(void)
// part will be redrawn, otherwise it will not. If this function is called
// twice in a row, then 'redraw' should be false and redrawcmd() should be
// called afterwards.
void put_on_cmdline(const char *str, int len, int redraw)
void put_on_cmdline(const char *str, int len, bool redraw)
{
int i;
int m;
@ -3711,7 +3711,7 @@ static bool cmdline_paste(int regname, bool literally, bool remcr)
// When "literally" is true, insert literally.
// When "literally" is false, insert as typed, but don't leave the command
// line.
void cmdline_paste_str(const char *s, int literally)
void cmdline_paste_str(const char *s, bool literally)
{
if (literally) {
put_on_cmdline(s, -1, true);

View File

@ -212,7 +212,7 @@ static int ses_do_win(win_T *wp)
/// @param flagp
///
/// @returns FAIL if writing fails.
static int ses_arglist(FILE *fd, char *cmd, garray_T *gap, int fullname, unsigned *flagp)
static int ses_arglist(FILE *fd, char *cmd, garray_T *gap, bool fullname, unsigned *flagp)
{
char *buf = NULL;
@ -225,7 +225,7 @@ static int ses_arglist(FILE *fd, char *cmd, garray_T *gap, int fullname, unsigne
if (s != NULL) {
if (fullname) {
buf = xmalloc(MAXPATHL);
(void)vim_FullName(s, buf, MAXPATHL, false);
vim_FullName(s, buf, MAXPATHL, false);
s = buf;
}
char *fname_esc = ses_escape_fname(s, flagp);
@ -322,7 +322,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
// Always restore cursor position for ":mksession". For ":mkview" only
// when 'viewoptions' contains "cursor".
int do_cursor = (flagp == &ssop_flags || *flagp & SSOP_CURSOR);
bool do_cursor = (flagp == &ssop_flags || *flagp & SSOP_CURSOR);
// Local argument list.
if (wp->w_alist == &global_alist) {
@ -975,7 +975,7 @@ void ex_mkrc(exarg_T *eap)
FILE *fd = open_exfile(fname, eap->forceit, WRITEBIN);
if (fd != NULL) {
int failed = false;
bool failed = false;
unsigned *flagp;
if (eap->cmdidx == CMD_mkview) {
flagp = &vop_flags;
@ -985,7 +985,7 @@ void ex_mkrc(exarg_T *eap)
// Write the version command for :mkvimrc
if (eap->cmdidx == CMD_mkvimrc) {
(void)put_line(fd, "version 6.0");
put_line(fd, "version 6.0");
}
if (eap->cmdidx == CMD_mksession) {

View File

@ -238,7 +238,6 @@ static const char e_path_too_long_for_completion[]
void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, int free_visited,
int find_what, void *search_ctx_arg, int tagfile, char *rel_fname)
{
char *wc_part;
ff_stack_T *sptr;
ff_search_ctx_T *search_ctx;
@ -373,7 +372,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
// split into:
// -fix path
// -wildcard_stuff (might be NULL)
wc_part = vim_strchr(path, '*');
char *wc_part = vim_strchr(path, '*');
if (wc_part != NULL) {
int64_t llevel;
int len;
@ -549,24 +548,22 @@ void vim_findfile_cleanup(void *ctx)
/// NULL if nothing found.
char *vim_findfile(void *search_ctx_arg)
{
char *file_path;
char *rest_of_wildcards;
char *path_end = NULL;
ff_stack_T *stackp = NULL;
size_t len;
char *p;
char *suf;
ff_search_ctx_T *search_ctx;
if (search_ctx_arg == NULL) {
return NULL;
}
search_ctx = (ff_search_ctx_T *)search_ctx_arg;
ff_search_ctx_T *search_ctx = (ff_search_ctx_T *)search_ctx_arg;
// filepath is used as buffer for various actions and as the storage to
// return a found filename.
file_path = xmalloc(MAXPATHL);
char *file_path = xmalloc(MAXPATHL);
// store the end of the start dir -- needed for upward search
if (search_ctx->ffsc_start_dir != NULL) {
@ -929,13 +926,11 @@ fail:
/// Can handle it if the passed search_context is NULL;
void vim_findfile_free_visited(void *search_ctx_arg)
{
ff_search_ctx_T *search_ctx;
if (search_ctx_arg == NULL) {
return;
}
search_ctx = (ff_search_ctx_T *)search_ctx_arg;
ff_search_ctx_T *search_ctx = (ff_search_ctx_T *)search_ctx_arg;
vim_findfile_free_visited_list(&search_ctx->ffsc_visited_lists_list);
vim_findfile_free_visited_list(&search_ctx->ffsc_dir_visited_lists_list);
}
@ -1157,9 +1152,7 @@ static void ff_push(ff_search_ctx_T *search_ctx, ff_stack_T *stack_ptr)
/// @return NULL if stack is empty.
static ff_stack_T *ff_pop(ff_search_ctx_T *search_ctx)
{
ff_stack_T *sptr;
sptr = search_ctx->ffsc_stack_ptr;
ff_stack_T *sptr = search_ctx->ffsc_stack_ptr;
if (search_ctx->ffsc_stack_ptr != NULL) {
search_ctx->ffsc_stack_ptr = search_ctx->ffsc_stack_ptr->ffs_prev;
}
@ -1224,8 +1217,6 @@ static void ff_clear(ff_search_ctx_T *search_ctx)
/// @return true if yes else false
static bool ff_path_in_stoplist(char *path, int path_len, char **stopdirs_v)
{
int i = 0;
// eat up trailing path separators, except the first
while (path_len > 1 && vim_ispathsep(path[path_len - 1])) {
path_len--;
@ -1236,7 +1227,7 @@ static bool ff_path_in_stoplist(char *path, int path_len, char **stopdirs_v)
return true;
}
for (i = 0; stopdirs_v[i] != NULL; i++) {
for (int i = 0; stopdirs_v[i] != NULL; i++) {
if ((int)strlen(stopdirs_v[i]) > path_len) {
// match for parent directory. So '/home' also matches
// '/home/rks'. Check for PATHSEP in stopdirs_v[i], else

View File

@ -156,14 +156,12 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
{
int retval = FAIL; // jump to "theend" instead of returning
int fd = stdin_fd >= 0 ? stdin_fd : 0;
int newfile = (flags & READ_NEW);
int check_readonly;
int filtering = (flags & READ_FILTER);
int read_stdin = (flags & READ_STDIN);
int read_buffer = (flags & READ_BUFFER);
int read_fifo = (flags & READ_FIFO);
int set_options = newfile || read_buffer
|| (eap != NULL && eap->read_edit);
bool newfile = (flags & READ_NEW);
bool filtering = (flags & READ_FILTER);
bool read_stdin = (flags & READ_STDIN);
bool read_buffer = (flags & READ_BUFFER);
bool read_fifo = (flags & READ_FIFO);
bool set_options = newfile || read_buffer || (eap != NULL && eap->read_edit);
linenr_T read_buf_lnum = 1; // next line to read from curbuf
colnr_T read_buf_col = 0; // next char to read from this line
char c;
@ -198,7 +196,6 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
linenr_T read_no_eol_lnum = 0; // non-zero lnum when last line of
// last read was missing the eol
bool file_rewind = false;
int can_retry;
linenr_T conv_error = 0; // line nr with conversion error
linenr_T illegal_byte = 0; // line nr with illegal byte
bool keep_dest_enc = false; // don't retry when char doesn't fit
@ -386,7 +383,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
// Default is r/w, can be set to r/o below.
// Don't reset it when in readonly mode
// Only set/reset b_p_ro when BF_CHECK_RO is set.
check_readonly = (newfile && (curbuf->b_flags & BF_CHECK_RO));
bool check_readonly = (newfile && (curbuf->b_flags & BF_CHECK_RO));
if (check_readonly && !readonlymode) {
curbuf->b_p_ro = false;
}
@ -557,7 +554,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
}
}
(void)os_setperm(swap_fname, swap_mode);
os_setperm(swap_fname, swap_mode);
}
#endif
}
@ -851,7 +848,7 @@ retry:
// Set "can_retry" when it's possible to rewind the file and try with
// another "fenc" value. It's false when no other "fenc" to try, reading
// stdin or fixed at a specific encoding.
can_retry = (*fenc != NUL && !read_stdin && !keep_dest_enc && !read_fifo);
bool can_retry = (*fenc != NUL && !read_stdin && !keep_dest_enc && !read_fifo);
if (!skip_read) {
linerest = 0;
@ -1149,7 +1146,6 @@ retry:
if (fio_flags != 0) {
unsigned u8c;
char *dest;
char *tail = NULL;
// Convert Unicode or Latin1 to UTF-8.
@ -1157,7 +1153,7 @@ retry:
// of bytes may increase.
// "dest" points to after where the UTF-8 bytes go, "p" points
// to after the next character to convert.
dest = ptr + real_size;
char *dest = ptr + real_size;
if (fio_flags == FIO_LATIN1 || fio_flags == FIO_UTF8) {
p = (uint8_t *)ptr + size;
if (fio_flags == FIO_UTF8) {
@ -1313,7 +1309,7 @@ retry:
assert(u8c <= INT_MAX);
// produce UTF-8
dest -= utf_char2len((int)u8c);
(void)utf_char2bytes((int)u8c, dest);
utf_char2bytes((int)u8c, dest);
}
// move the linerest to before the converted characters
@ -1530,8 +1526,7 @@ rewind_retry:
// Otherwise give an error message later.
if (try_unix
&& !read_stdin
&& (read_buffer
|| vim_lseek(fd, 0, SEEK_SET) == 0)) {
&& (read_buffer || vim_lseek(fd, 0, SEEK_SET) == 0)) {
fileformat = EOL_UNIX;
if (set_options) {
set_fileformat(EOL_UNIX, OPT_LOCAL);
@ -1628,7 +1623,7 @@ failed:
if (!read_buffer && !read_stdin) {
close(fd); // errors are ignored
} else {
(void)os_set_cloexec(fd);
os_set_cloexec(fd);
}
xfree(buffer);
@ -1936,7 +1931,7 @@ void prep_exarg(exarg_T *eap, const buf_T *buf)
}
/// Set default or forced 'fileformat' and 'binary'.
void set_file_options(int set_options, exarg_T *eap)
void set_file_options(bool set_options, exarg_T *eap)
{
// set default 'fileformat'
if (set_options) {
@ -2096,7 +2091,7 @@ int set_rw_fname(char *fname, char *sfname)
// Do filetype detection now if 'filetype' is empty.
if (*curbuf->b_p_ft == NUL) {
if (augroup_exists("filetypedetect")) {
(void)do_doautocmd("filetypedetect BufRead", false, NULL);
do_doautocmd("filetypedetect BufRead", false, NULL);
}
do_modelines(0);
}
@ -2197,7 +2192,7 @@ bool time_differs(const FileInfo *file_info, int64_t mtime, int64_t mtime_ns)
bool need_conversion(const char *fenc)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{
int same_encoding;
bool same_encoding;
int fenc_flags;
if (*fenc == NUL || strcmp(p_enc, fenc) == 0) {
@ -2634,7 +2629,7 @@ static int rename_with_tmp(const char *const from, const char *const to)
}
// Strange, the second step failed. Try moving the
// file back and return failure.
(void)os_rename(tempname, from);
os_rename(tempname, from);
return -1;
}
// If it fails for one temp name it will most likely fail
@ -3045,7 +3040,7 @@ int buf_check_timestamp(buf_T *buf)
msg_puts_attr(mesg2, HL_ATTR(HLF_W) + MSG_HIST);
}
msg_clr_eos();
(void)msg_end();
msg_end();
if (emsg_silent == 0 && !in_assert_fails) {
ui_flush();
// give the user some time to think about it
@ -3076,7 +3071,7 @@ int buf_check_timestamp(buf_T *buf)
// Trigger FileChangedShell when the file was changed in any way.
if (bufref_valid(&bufref) && retval != 0) {
(void)apply_autocmds(EVENT_FILECHANGEDSHELLPOST, buf->b_fname, buf->b_fname, false, buf);
apply_autocmds(EVENT_FILECHANGEDSHELLPOST, buf->b_fname, buf->b_fname, false, buf);
}
return retval;
}
@ -3161,7 +3156,7 @@ void buf_reload(buf_T *buf, int orig_mode, bool reload_options)
break;
}
}
(void)move_lines(savebuf, buf);
move_lines(savebuf, buf);
}
} else if (buf == curbuf) { // "buf" still valid.
// Mark the buffer as unmodified and free undo info.
@ -3276,7 +3271,7 @@ static void vim_mktempdir(void)
char user[40] = { 0 };
char appname[40] = { 0 };
(void)os_get_username(user, sizeof(user));
os_get_username(user, sizeof(user));
// Usernames may contain slashes! #19240
memchrsub(user, '/', '_', sizeof(user));
memchrsub(user, '\\', '_', sizeof(user));
@ -3302,7 +3297,7 @@ static void vim_mktempdir(void)
xstrlcat(tmp, appname, sizeof(tmp));
xstrlcat(tmp, ".", sizeof(tmp));
xstrlcat(tmp, user, sizeof(tmp));
(void)os_mkdir(tmp, 0700); // Always create, to avoid a race.
os_mkdir(tmp, 0700); // Always create, to avoid a race.
bool owned = os_file_owned(tmp);
bool isdir = os_isdir(tmp);
#ifdef UNIX
@ -3344,7 +3339,7 @@ static void vim_mktempdir(void)
// Couldn't set `vim_tempdir` to `path` so remove created directory.
os_rmdir(path);
}
(void)umask(umask_save);
umask(umask_save);
}
/// Core part of "readdir()" function.

View File

@ -371,7 +371,7 @@ void closeFold(pos_T pos, int count)
/// Close fold for current window at position `pos` recursively.
void closeFoldRecurse(pos_T pos)
{
(void)setManualFold(pos, false, true, NULL);
setManualFold(pos, false, true, NULL);
}
// opFoldRange() {{{2
@ -382,7 +382,7 @@ void closeFoldRecurse(pos_T pos)
/// @param opening true to open, false to close
/// @param recurse true to do it recursively
/// @param had_visual true when Visual selection used
void opFoldRange(pos_T firstpos, pos_T lastpos, int opening, int recurse, int had_visual)
void opFoldRange(pos_T firstpos, pos_T lastpos, int opening, int recurse, bool had_visual)
{
int done = DONE_NOTHING; // avoid error messages
linenr_T first = firstpos.lnum;
@ -395,13 +395,13 @@ void opFoldRange(pos_T firstpos, pos_T lastpos, int opening, int recurse, int ha
// Opening one level only: next fold to open is after the one going to
// be opened.
if (opening && !recurse) {
(void)hasFolding(lnum, NULL, &lnum_next);
hasFolding(lnum, NULL, &lnum_next);
}
(void)setManualFold(temp, opening, recurse, &done);
setManualFold(temp, opening, recurse, &done);
// Closing one level only: next line to close a fold is after just
// closed fold.
if (!opening && !recurse) {
(void)hasFolding(lnum, NULL, &lnum_next);
hasFolding(lnum, NULL, &lnum_next);
}
}
if (done == DONE_NOTHING) {
@ -425,7 +425,7 @@ void openFold(pos_T pos, int count)
/// Open fold for current window at position `pos` recursively.
void openFoldRecurse(pos_T pos)
{
(void)setManualFold(pos, true, true, NULL);
setManualFold(pos, true, true, NULL);
}
// foldOpenCursor() {{{2
@ -436,7 +436,7 @@ void foldOpenCursor(void)
if (hasAnyFolding(curwin)) {
while (true) {
int done = DONE_NOTHING;
(void)setManualFold(curwin->w_cursor, true, false, &done);
setManualFold(curwin->w_cursor, true, false, &done);
if (!(done & DONE_ACTION)) {
break;
}
@ -793,7 +793,7 @@ void foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
maybe_small_end = top;
}
fold_T *fp;
(void)foldFind(&wp->w_folds, maybe_small_start, &fp);
foldFind(&wp->w_folds, maybe_small_start, &fp);
while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
&& fp->fd_top <= maybe_small_end) {
fp->fd_small = kNone;
@ -1027,7 +1027,7 @@ void foldAdjustVisual(void)
/// Move the cursor to the first line of a closed fold.
void foldAdjustCursor(void)
{
(void)hasFolding(curwin->w_cursor.lnum, &curwin->w_cursor.lnum, NULL);
hasFolding(curwin->w_cursor.lnum, &curwin->w_cursor.lnum, NULL);
}
// Internal functions for "fold_T" {{{1
@ -1137,7 +1137,7 @@ static void setFoldRepeat(pos_T pos, int count, int do_open)
{
for (int n = 0; n < count; n++) {
int done = DONE_NOTHING;
(void)setManualFold(pos, do_open, false, &done);
setManualFold(pos, do_open, false, &done);
if (!(done & DONE_ACTION)) {
// Only give an error message when no fold could be opened.
if (n == 0 && !(done & DONE_FOLD)) {
@ -1154,7 +1154,7 @@ static void setFoldRepeat(pos_T pos, int count, int do_open)
///
/// @param opening true when opening, false when closing
/// @param recurse true when closing/opening recursive
static linenr_T setManualFold(pos_T pos, int opening, int recurse, int *donep)
static linenr_T setManualFold(pos_T pos, bool opening, bool recurse, int *donep)
{
if (foldmethodIsDiff(curwin) && curwin->w_p_scb) {
linenr_T dlnum;
@ -1165,7 +1165,7 @@ static linenr_T setManualFold(pos_T pos, int opening, int recurse, int *donep)
if (wp != curwin && foldmethodIsDiff(wp) && wp->w_p_scb) {
dlnum = diff_lnum_win(curwin->w_cursor.lnum, wp);
if (dlnum != 0) {
(void)setManualFoldWin(wp, dlnum, opening, recurse, NULL);
setManualFoldWin(wp, dlnum, opening, recurse, NULL);
}
}
}
@ -1186,7 +1186,7 @@ static linenr_T setManualFold(pos_T pos, int opening, int recurse, int *donep)
///
/// @return the line number of the next line that could be closed.
/// It's only valid when "opening" is true!
static linenr_T setManualFoldWin(win_T *wp, linenr_T lnum, int opening, int recurse, int *donep)
static linenr_T setManualFoldWin(win_T *wp, linenr_T lnum, bool opening, bool recurse, int *donep)
{
fold_T *fp;
fold_T *fp2;
@ -1387,7 +1387,7 @@ static void foldMarkAdjustRecurse(win_T *wp, garray_T *gap, linenr_T line1, line
// Find the fold containing or just below "line1".
fold_T *fp;
(void)foldFind(gap, line1, &fp);
foldFind(gap, line1, &fp);
// Adjust all folds below "line1" that are affected.
for (int i = (int)(fp - (fold_T *)gap->ga_data); i < gap->ga_len; i++, fp++) {
@ -1634,7 +1634,7 @@ static void foldAddMarker(buf_T *buf, pos_T pos, const char *marker, size_t mark
/// Delete the markers for a fold, causing it to be deleted.
///
/// @param lnum_off offset for fp->fd_top
static void deleteFoldMarkers(win_T *wp, fold_T *fp, int recursive, linenr_T lnum_off)
static void deleteFoldMarkers(win_T *wp, fold_T *fp, bool recursive, linenr_T lnum_off)
{
if (recursive) {
for (int i = 0; i < fp->fd_nested.ga_len; i++) {
@ -2169,7 +2169,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
// startlnum, it must be deleted.
if (getlevel == foldlevelMarker && flp->start <= flp->lvl - level
&& flp->lvl > 0) {
(void)foldFind(gap, startlnum - 1, &fp);
foldFind(gap, startlnum - 1, &fp);
if (fp != NULL
&& (fp >= ((fold_T *)gap->ga_data) + gap->ga_len
|| fp->fd_top >= startlnum)) {
@ -2235,7 +2235,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
}
}
if (lvl < level + i) {
(void)foldFind(&fp->fd_nested, flp->lnum - fp->fd_top, &fp2);
foldFind(&fp->fd_nested, flp->lnum - fp->fd_top, &fp2);
if (fp2 != NULL) {
bot = fp2->fd_top + fp2->fd_len - 1 + fp->fd_top;
}
@ -2601,7 +2601,7 @@ static void foldSplit(buf_T *buf, garray_T *const gap, const int i, const linenr
// any between top and bot, they have been removed by the caller.
garray_T *const gap1 = &fp->fd_nested;
garray_T *const gap2 = &fp[1].fd_nested;
(void)foldFind(gap1, bot + 1 - fp->fd_top, &fp2);
foldFind(gap1, bot + 1 - fp->fd_top, &fp2);
if (fp2 != NULL) {
const int len = (int)((fold_T *)gap1->ga_data + gap1->ga_len - fp2);
if (len > 0) {
@ -3232,7 +3232,7 @@ static int put_fold_open_close(FILE *fd, fold_T *fp, linenr_T off)
// }}}1
/// "foldclosed()" and "foldclosedend()" functions
static void foldclosed_both(typval_T *argvars, typval_T *rettv, int end)
static void foldclosed_both(typval_T *argvars, typval_T *rettv, bool end)
{
const linenr_T lnum = tv_get_lnum(argvars);
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count) {

View File

@ -188,15 +188,12 @@ static char *get_buffcont(buffheader_T *buffer, int dozero)
/// K_SPECIAL in the returned string is escaped.
char *get_recorded(void)
{
char *p;
size_t len;
p = get_buffcont(&recordbuff, true);
char *p = get_buffcont(&recordbuff, true);
free_buff(&recordbuff);
// Remove the characters that were added the last time, these must be the
// (possibly mapped) characters that stopped the recording.
len = strlen(p);
size_t len = strlen(p);
if (len >= last_recorded_len) {
len -= last_recorded_len;
p[len] = NUL;
@ -272,12 +269,10 @@ static void add_buff(buffheader_T *const buf, const char *const s, ptrdiff_t sle
/// Only works when it was just added.
static void delete_buff_tail(buffheader_T *buf, int slen)
{
int len;
if (buf->bh_curr == NULL) {
return; // nothing to delete
}
len = (int)strlen(buf->bh_curr->b_str);
int len = (int)strlen(buf->bh_curr->b_str);
if (len < slen) {
return;
}
@ -331,18 +326,16 @@ static void add_char_buff(buffheader_T *buf, int c)
/// if that one is empty.
/// If advance == true go to the next char.
/// No translation is done K_SPECIAL is escaped.
static int read_readbuffers(int advance)
static int read_readbuffers(bool advance)
{
int c;
c = read_readbuf(&readbuf1, advance);
int c = read_readbuf(&readbuf1, advance);
if (c == NUL) {
c = read_readbuf(&readbuf2, advance);
}
return c;
}
static int read_readbuf(buffheader_T *buf, int advance)
static int read_readbuf(buffheader_T *buf, bool advance)
{
if (buf->bh_first.b_next == NULL) { // buffer is empty
return NUL;
@ -1000,7 +993,7 @@ int ins_char_typebuf(int c, int modifiers)
unsigned len = special_to_buf(c, modifiers, true, buf);
assert(len < sizeof(buf));
buf[len] = NUL;
(void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent);
ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent);
return (int)len;
}
@ -1314,7 +1307,6 @@ void openscript(char *name, bool directly)
// always, "make test" would fail.
if (directly) {
oparg_T oa;
int oldcurscript;
int save_State = State;
int save_restart_edit = restart_edit;
int save_finish_op = finish_op;
@ -1326,11 +1318,11 @@ void openscript(char *name, bool directly)
clear_oparg(&oa);
finish_op = false;
oldcurscript = curscript;
int oldcurscript = curscript;
do {
update_topline_cursor(); // update cursor position and topline
normal_cmd(&oa, false); // execute one command
(void)vpeekc(); // check for end of file
vpeekc(); // check for end of file
} while (scriptin[oldcurscript] != NULL);
State = save_State;
@ -1450,8 +1442,6 @@ int vgetc(void)
mouse_row = old_mouse_row;
mouse_col = old_mouse_col;
} else {
int c2;
int n;
// number of characters recorded from the last vgetc() call
static size_t last_vgetc_recorded_len = 0;
@ -1481,7 +1471,7 @@ int vgetc(void)
int save_allow_keys = allow_keys;
no_mapping++;
allow_keys = 0; // make sure BS is not found
c2 = vgetorpeek(true); // no mapping for these chars
int c2 = vgetorpeek(true); // no mapping for these chars
c = vgetorpeek(true);
no_mapping--;
allow_keys = save_allow_keys;
@ -1574,6 +1564,7 @@ int vgetc(void)
// For a multi-byte character get all the bytes and return the
// converted character.
// Note: This will loop until enough bytes are received!
int n;
if ((n = MB_BYTE2LEN_CHECK(c)) > 1) {
no_mapping++;
buf[0] = (uint8_t)c;
@ -1582,8 +1573,8 @@ int vgetc(void)
if (buf[i] == K_SPECIAL) {
// Must be a K_SPECIAL - KS_SPECIAL - KE_FILLER sequence,
// which represents a K_SPECIAL (0x80).
(void)vgetorpeek(true); // skip KS_SPECIAL
(void)vgetorpeek(true); // skip KE_FILLER
vgetorpeek(true); // skip KS_SPECIAL
vgetorpeek(true); // skip KE_FILLER
}
}
no_mapping--;
@ -1605,7 +1596,7 @@ int vgetc(void)
&& !is_mouse_key(c)) {
mod_mask = 0;
int len = ins_char_typebuf(c, 0);
(void)ins_char_typebuf(ESC, 0);
ins_char_typebuf(ESC, 0);
ungetchars(len + 3); // K_SPECIAL KS_MODIFIER MOD_MASK_ALT takes 3 more bytes
continue;
}
@ -1637,9 +1628,7 @@ int vgetc(void)
/// directly from the user (ignoring typeahead).
int safe_vgetc(void)
{
int c;
c = vgetc();
int c = vgetc();
if (c == NUL) {
c = get_keystroke(NULL);
}
@ -1677,9 +1666,7 @@ int vpeekc(void)
/// buffer, it must be an ESC that is recognized as the start of a key code.
int vpeekc_any(void)
{
int c;
c = vpeekc();
int c = vpeekc();
if (c == NUL && typebuf.tb_len > 0) {
c = ESC;
}
@ -1690,10 +1677,8 @@ int vpeekc_any(void)
/// @return true if a character is available, false otherwise.
bool char_avail(void)
{
int retval;
no_mapping++;
retval = vpeekc();
int retval = vpeekc();
no_mapping--;
return retval != NUL;
}
@ -1719,7 +1704,7 @@ static void getchar_common(typval_T *argvars, typval_T *rettv)
if (!char_avail()) {
// Flush screen updates before blocking.
ui_flush();
(void)os_inchar(NULL, 0, -1, typebuf.tb_change_cnt, main_loop.events);
os_inchar(NULL, 0, -1, typebuf.tb_change_cnt, main_loop.events);
if (!multiqueue_empty(main_loop.events)) {
state_handle_k_event();
continue;
@ -1792,7 +1777,7 @@ static void getchar_common(typval_T *argvars, typval_T *rettv)
if (win == NULL) {
return;
}
(void)mouse_comp_pos(win, &row, &col, &lnum);
mouse_comp_pos(win, &row, &col, &lnum);
for (wp = firstwin; wp != win; wp = wp->w_next) {
winnr++;
}
@ -1948,7 +1933,6 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
mapblock_T *mp_match;
int mp_match_len = 0;
int max_mlen = 0;
int tb_c1;
int keylen = *keylenp;
int local_State = get_real_state();
bool is_plug_map = false;
@ -1972,7 +1956,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
// - waiting for "hit return to continue" and CR or SPACE typed
// - waiting for a char with --more--
// - in Ctrl-X mode, and we get a valid char for that mode
tb_c1 = typebuf.tb_buf[typebuf.tb_off];
int tb_c1 = typebuf.tb_buf[typebuf.tb_off];
if (no_mapping == 0
&& (no_zero_mapping == 0 || tb_c1 != '0')
&& (typebuf.tb_maplen == 0 || is_plug_map
@ -2188,7 +2172,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
// mode temporarily. Append K_SELECT to switch back to Select mode.
if (VIsual_active && VIsual_select && (mp->m_mode & MODE_VISUAL)) {
VIsual_select = false;
(void)ins_typebuf(K_SELECT_STRING, REMAP_NONE, 0, true, false);
ins_typebuf(K_SELECT_STRING, REMAP_NONE, 0, true, false);
}
// Copy the values from *mp that are used, because evaluating the
@ -2652,7 +2636,7 @@ static int vgetorpeek(bool advance)
showcmd_idx = typebuf.tb_len - SHOWCMD_COLS;
}
while (showcmd_idx < typebuf.tb_len) {
(void)add_to_showcmd(typebuf.tb_buf[typebuf.tb_off + showcmd_idx++]);
add_to_showcmd(typebuf.tb_buf[typebuf.tb_off + showcmd_idx++]);
}
curwin->w_wcol = old_wcol;
curwin->w_wrow = old_wrow;
@ -2918,7 +2902,6 @@ char *getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat)
{
garray_T line_ga;
int c1 = -1;
int c2;
int cmod = 0;
bool aborted = false;
@ -2945,7 +2928,7 @@ char *getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat)
// Get two extra bytes for special keys
if (c1 == K_SPECIAL) {
c1 = vgetorpeek(true);
c2 = vgetorpeek(true);
int c2 = vgetorpeek(true);
if (c1 == KS_MODIFIER) {
cmod = c2;
continue;

View File

@ -600,10 +600,10 @@ EXTERN int u_sync_once INIT( = 0); // Call u_sync() once when evaluating
EXTERN bool force_restart_edit INIT( = false); // force restart_edit after
// ex_normal returns
EXTERN int restart_edit INIT( = 0); // call edit when next cmd finished
EXTERN int arrow_used; // Normally false, set to true after
// hitting cursor key in insert mode.
// Used by vgetorpeek() to decide when
// to call u_sync()
EXTERN bool arrow_used; // Normally false, set to true after
// hitting cursor key in insert mode.
// Used by vgetorpeek() to decide when
// to call u_sync()
EXTERN bool ins_at_eol INIT( = false); // put cursor after eol when
// restarting edit after CTRL-O
@ -658,9 +658,9 @@ EXTERN bool typebuf_was_empty INIT( = false);
EXTERN int ex_normal_busy INIT( = 0); // recursiveness of ex_normal()
EXTERN int expr_map_lock INIT( = 0); // running expr mapping, prevent use of ex_normal() and text changes
EXTERN bool ignore_script INIT( = false); // ignore script input
EXTERN int stop_insert_mode; // for ":stopinsert"
EXTERN bool KeyTyped; // true if user typed current char
EXTERN int KeyStuffed; // true if current char from stuffbuf
EXTERN bool stop_insert_mode; // for ":stopinsert"
EXTERN bool KeyTyped; // true if user typed current char
EXTERN int KeyStuffed; // true if current char from stuffbuf
EXTERN int maptick INIT( = 0); // tick for each non-mapped char
EXTERN int must_redraw INIT( = 0); // type of redraw necessary
@ -724,7 +724,7 @@ EXTERN char *empty_string_option INIT( = "");
EXTERN bool redir_off INIT( = false); // no redirection for a moment
EXTERN FILE *redir_fd INIT( = NULL); // message redirection file
EXTERN int redir_reg INIT( = 0); // message redirection register
EXTERN int redir_vname INIT( = 0); // message redirection variable
EXTERN bool redir_vname INIT( = false); // message redirection variable
EXTERN garray_T *capture_ga INIT( = NULL); // captured output for execute()
EXTERN uint8_t langmap_mapchar[256]; // mapping for language keys

View File

@ -263,13 +263,13 @@ void grid_clear_line(ScreenGrid *grid, size_t off, int width, bool valid)
grid->chars[off + (size_t)col] = schar_from_ascii(' ');
}
int fill = valid ? 0 : -1;
(void)memset(grid->attrs + off, fill, (size_t)width * sizeof(sattr_T));
(void)memset(grid->vcols + off, -1, (size_t)width * sizeof(colnr_T));
memset(grid->attrs + off, fill, (size_t)width * sizeof(sattr_T));
memset(grid->vcols + off, -1, (size_t)width * sizeof(colnr_T));
}
void grid_invalidate(ScreenGrid *grid)
{
(void)memset(grid->attrs, -1, sizeof(sattr_T) * (size_t)grid->rows * (size_t)grid->cols);
memset(grid->attrs, -1, sizeof(sattr_T) * (size_t)grid->rows * (size_t)grid->cols);
}
static bool grid_invalid_row(ScreenGrid *grid, int row)

View File

@ -121,7 +121,7 @@ hashitem_T *hash_lookup(const hashtab_T *const ht, const char *const key, const
{
#ifdef HT_DEBUG
hash_count_lookup++;
#endif // ifdef HT_DEBUG
#endif
// Quickly handle the most common situations:
// - return if there is no item at all
@ -154,7 +154,7 @@ hashitem_T *hash_lookup(const hashtab_T *const ht, const char *const key, const
#ifdef HT_DEBUG
// count a "miss" for hashtab lookup
hash_count_perturb++;
#endif // ifdef HT_DEBUG
#endif
idx = 5 * idx + perturb + 1;
hi = &ht->ht_array[idx & ht->ht_mask];
@ -189,7 +189,7 @@ void hash_debug_results(void)
(int64_t)hash_count_perturb);
fprintf(stderr, "Percentage of perturb loops: %" PRId64 "%%\r\n",
(int64_t)(hash_count_perturb * 100 / hash_count_lookup));
#endif // ifdef HT_DEBUG
#endif
}
/// Add (empty) item for key `key` to hashtable `ht`.
@ -287,7 +287,7 @@ static void hash_may_resize(hashtab_T *ht, size_t minitems)
if (ht->ht_filled >= ht->ht_mask + 1) {
emsg("hash_may_resize(): table completely filled");
}
#endif // ifdef HT_DEBUG
#endif
size_t minsize;
const size_t oldsize = ht->ht_mask + 1;

View File

@ -171,9 +171,9 @@ void ex_help(exarg_T *eap)
// set b_p_ro flag).
// Set the alternate file to the previously edited file.
alt_fnum = curbuf->b_fnum;
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
ECMD_HIDE + ECMD_SET_HELP,
NULL); // buffer is still open, don't store info
do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
ECMD_HIDE + ECMD_SET_HELP,
NULL); // buffer is still open, don't store info
if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
curwin->w_alt_fnum = alt_fnum;
@ -251,7 +251,7 @@ char *check_help_lang(char *arg)
/// @param wrong_case no matching case
///
/// @return a heuristic indicating how well the given string matches.
int help_heuristic(char *matched_string, int offset, int wrong_case)
int help_heuristic(char *matched_string, int offset, bool wrong_case)
FUNC_ATTR_PURE
{
int num_letters = 0;
@ -618,7 +618,7 @@ void prepare_help_buffer(void)
if (strcmp(curbuf->b_p_isk, p) != 0) {
set_string_option_direct(kOptIskeyword, p, OPT_FREE|OPT_LOCAL, 0);
check_buf_options(curbuf);
(void)buf_init_chartab(curbuf, false);
buf_init_chartab(curbuf, false);
}
// Don't use the global foldmethod.

View File

@ -979,16 +979,12 @@ void do_highlight(const char *line, const bool forceit, const bool init)
// Handle ":highlight link {from} {to}" command.
if (dolink) {
const char *from_start = linep;
const char *from_end;
const char *to_start;
const char *to_end;
int from_id;
int to_id;
HlGroup *hlgroup = NULL;
from_end = skiptowhite(from_start);
to_start = skipwhite(from_end);
to_end = skiptowhite(to_start);
const char *from_end = skiptowhite(from_start);
const char *to_start = skipwhite(from_end);
const char *to_end = skiptowhite(to_start);
if (ends_excmd((uint8_t)(*from_start))
|| ends_excmd((uint8_t)(*to_start))) {
@ -1002,7 +998,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
return;
}
from_id = syn_check_group(from_start, (size_t)(from_end - from_start));
int from_id = syn_check_group(from_start, (size_t)(from_end - from_start));
if (strncmp(to_start, "NONE", 4) == 0) {
to_id = 0;
} else {
@ -1558,7 +1554,7 @@ static void highlight_list_one(const int id)
sgp->sg_blend + 1, NULL, "blend");
if (sgp->sg_link && !got_int) {
(void)syn_list_header(didh, 0, id, true);
syn_list_header(didh, 0, id, true);
didh = true;
msg_puts_attr("links to", HL_ATTR(HLF_D));
msg_putchar(' ');
@ -1688,7 +1684,7 @@ static bool highlight_list_arg(const int id, bool didh, const int type, int iarg
}
}
(void)syn_list_header(didh, vim_strsize(ts) + (int)strlen(name) + 1, id, false);
syn_list_header(didh, vim_strsize(ts) + (int)strlen(name) + 1, id, false);
didh = true;
if (!got_int) {
if (*name != NUL) {
@ -2076,7 +2072,6 @@ int syn_get_final_id(int hl_id)
bool syn_ns_get_final_id(int *ns_id, int *hl_idp)
{
int count;
int hl_id = *hl_idp;
bool used = false;
@ -2087,7 +2082,7 @@ bool syn_ns_get_final_id(int *ns_id, int *hl_idp)
// Follow links until there is no more.
// Look out for loops! Break after 100 links.
for (count = 100; --count >= 0;) {
for (int count = 100; --count >= 0;) {
HlGroup *sgp = &hl_table[hl_id - 1]; // index is ID minus one
// TODO(bfredl): when using "tmp" attribute (no link) the function might be

View File

@ -888,7 +888,7 @@ int get_breakindent_win(win_T *wp, char *line)
// non-blank in the line.
// When extra == 1: Return true if the cursor is before the first non-blank in
// the line.
int inindent(int extra)
bool inindent(int extra)
{
char *ptr;
colnr_T col;
@ -1340,7 +1340,7 @@ static int lisp_match(char *p)
char *word = *curbuf->b_p_lw != NUL ? curbuf->b_p_lw : p_lispwords;
while (*word != NUL) {
(void)copy_option_part(&word, buf, sizeof(buf), ",");
copy_option_part(&word, buf, sizeof(buf), ",");
int len = (int)strlen(buf);
if ((strncmp(buf, p, (size_t)len) == 0) && ascii_iswhite_or_nul(p[len])) {

View File

@ -158,7 +158,7 @@ int get_keystroke(MultiQueue *events)
/// When "mouse_used" is not NULL allow using the mouse.
///
/// @param colon allow colon to abort
int get_number(int colon, int *mouse_used)
int get_number(int colon, bool *mouse_used)
{
int n = 0;
int typed = 0;
@ -219,7 +219,7 @@ int get_number(int colon, int *mouse_used)
///
/// When "mouse_used" is not NULL allow using the mouse and in that case return
/// the line number.
int prompt_for_number(int *mouse_used)
int prompt_for_number(bool *mouse_used)
{
// When using ":silent" assume that <CR> was entered.
if (mouse_used != NULL) {

View File

@ -919,13 +919,11 @@ static bool ins_compl_equal(compl_T *match, char *str, size_t len)
/// Reduce the longest common string for match "match".
static void ins_compl_longest_match(compl_T *match)
{
int had_match;
if (compl_leader == NULL) {
// First match, use it as a whole.
compl_leader = xstrdup(match->cp_str);
had_match = (curwin->w_cursor.col > compl_col);
bool had_match = (curwin->w_cursor.col > compl_col);
ins_compl_delete();
ins_bytes(compl_leader + get_compl_len());
ins_redraw(false);
@ -959,7 +957,7 @@ static void ins_compl_longest_match(compl_T *match)
if (*p != NUL) {
// Leader was shortened, need to change the inserted text.
*p = NUL;
had_match = (curwin->w_cursor.col > compl_col);
bool had_match = (curwin->w_cursor.col > compl_col);
ins_compl_delete();
ins_bytes(compl_leader + get_compl_len());
ins_redraw(false);
@ -1321,7 +1319,7 @@ void compl_set_info(int pum_idx)
///
/// @param flags DICT_FIRST and/or DICT_EXACT
/// @param thesaurus Thesaurus completion
static void ins_compl_dictionaries(char *dict_start, char *pat, int flags, int thesaurus)
static void ins_compl_dictionaries(char *dict_start, char *pat, int flags, bool thesaurus)
{
char *dict = dict_start;
char *ptr;
@ -1464,8 +1462,8 @@ static int thesaurus_add_words_in_line(char *fname, char **buf_arg, int dir, con
/// Process "count" dictionary/thesaurus "files" and add the text matching
/// "regmatch".
static void ins_compl_files(int count, char **files, int thesaurus, int flags, regmatch_T *regmatch,
char *buf, Direction *dir)
static void ins_compl_files(int count, char **files, bool thesaurus, int flags,
regmatch_T *regmatch, char *buf, Direction *dir)
FUNC_ATTR_NONNULL_ARG(2, 7)
{
for (int i = 0; i < count && !got_int && !compl_interrupted; i++) {
@ -1474,7 +1472,7 @@ static void ins_compl_files(int count, char **files, int thesaurus, int flags, r
msg_hist_off = true; // reset in msg_trunc()
vim_snprintf(IObuff, IOSIZE,
_("Scanning dictionary: %s"), files[i]);
(void)msg_trunc(IObuff, true, HL_ATTR(HLF_R));
msg_trunc(IObuff, true, HL_ATTR(HLF_R));
}
if (fp == NULL) {
@ -2954,7 +2952,7 @@ static int process_next_cpt_value(ins_compl_next_state_T *st, int *compl_type_ar
: st->ins_buf->b_sfname == NULL
? st->ins_buf->b_fname
: st->ins_buf->b_sfname);
(void)msg_trunc(IObuff, true, HL_ATTR(HLF_R));
msg_trunc(IObuff, true, HL_ATTR(HLF_R));
}
} else if (*st->e_cpt == NUL) {
status = INS_COMPL_CPT_END;
@ -2982,12 +2980,12 @@ static int process_next_cpt_value(ins_compl_next_state_T *st, int *compl_type_ar
if (!shortmess(SHM_COMPLETIONSCAN)) {
msg_hist_off = true; // reset in msg_trunc()
vim_snprintf(IObuff, IOSIZE, "%s", _("Scanning tags."));
(void)msg_trunc(IObuff, true, HL_ATTR(HLF_R));
msg_trunc(IObuff, true, HL_ATTR(HLF_R));
}
}
// in any case e_cpt is advanced to the next entry
(void)copy_option_part(&st->e_cpt, IObuff, IOSIZE, ",");
copy_option_part(&st->e_cpt, IObuff, IOSIZE, ",");
st->found_all = true;
if (compl_type == -1) {
@ -3814,8 +3812,8 @@ void ins_compl_check_keys(int frequency, bool in_compl_func)
if (vim_is_ctrl_x_key(c) && c != Ctrl_X && c != Ctrl_R) {
c = safe_vgetc(); // Eat the character
compl_shows_dir = ins_compl_key2dir(c);
(void)ins_compl_next(false, ins_compl_key2count(c),
c != K_UP && c != K_DOWN, in_compl_func);
ins_compl_next(false, ins_compl_key2count(c),
c != K_UP && c != K_DOWN, in_compl_func);
} else {
// Need to get the character to have KeyTyped set. We'll put it
// back with vungetc() below. But skip K_IGNORE.
@ -3835,7 +3833,7 @@ void ins_compl_check_keys(int frequency, bool in_compl_func)
int todo = compl_pending > 0 ? compl_pending : -compl_pending;
compl_pending = 0;
(void)ins_compl_next(false, todo, true, in_compl_func);
ins_compl_next(false, todo, true, in_compl_func);
}
}
@ -3937,8 +3935,8 @@ static int get_normal_compl_info(char *line, int startcol, colnr_T curs_col)
prefix = "";
}
STRCPY(compl_pattern, prefix);
(void)quote_meta(compl_pattern + strlen(prefix),
line + compl_col, compl_length);
quote_meta(compl_pattern + strlen(prefix),
line + compl_col, compl_length);
} else if (--startcol < 0
|| !vim_iswordp(mb_prevptr(line, line + startcol + 1))) {
// Match any word of at least two chars
@ -3965,12 +3963,12 @@ static int get_normal_compl_info(char *line, int startcol, colnr_T curs_col)
// xmalloc(7) is enough -- Acevedo
compl_pattern = xmalloc(7);
STRCPY(compl_pattern, "\\<");
(void)quote_meta(compl_pattern + 2, line + compl_col, 1);
quote_meta(compl_pattern + 2, line + compl_col, 1);
STRCAT(compl_pattern, "\\k");
} else {
compl_pattern = xmalloc(quote_meta(NULL, line + compl_col, compl_length) + 2);
STRCPY(compl_pattern, "\\<");
(void)quote_meta(compl_pattern + 2, line + compl_col, compl_length);
quote_meta(compl_pattern + 2, line + compl_col, compl_length);
}
}
@ -4449,7 +4447,7 @@ int ins_complete(int c, bool enable_pum)
// Eat the ESC that vgetc() returns after a CTRL-C to avoid leaving Insert
// mode.
if (got_int && !global_busy) {
(void)vgetc();
vgetc();
got_int = false;
}

View File

@ -2172,7 +2172,7 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview)
// every possible modifier (with room to spare). If the list of possible
// modifiers grows this may need to be updated.
char buf[200] = { 0 };
(void)uc_mods(buf, &cmdmod, false);
uc_mods(buf, &cmdmod, false);
lua_pushstring(lstate, buf);
lua_setfield(lstate, -2, "mods");

View File

@ -615,7 +615,7 @@ int main(int argc, char **argv)
// WORKAROUND(mhi): #3023
if (cb_flags & CB_UNNAMEDMASK) {
(void)eval_has_provider("clipboard");
eval_has_provider("clipboard");
}
if (params.luaf != NULL) {
@ -1013,7 +1013,7 @@ static void command_line_scan(mparm_T *parmp)
char **argv = parmp->argv;
int argv_idx; // index in argv[n][]
bool had_minmin = false; // found "--" argument
int want_argument; // option argument with argument
bool want_argument; // option argument with argument
int n;
argc--;
@ -1581,7 +1581,7 @@ static void read_stdin(void)
bool save_msg_didany = msg_didany;
set_buflisted(true);
// Create memfile and read from stdin.
(void)open_buffer(true, NULL, 0);
open_buffer(true, NULL, 0);
if (buf_is_empty(curbuf) && curbuf->b_next != NULL) {
// stdin was empty, go to buffer 2 (e.g. "echo file1 | xargs nvim"). #8561
do_cmdline_cmd("silent! bnext");
@ -1703,7 +1703,7 @@ static void create_windows(mparm_T *parmp)
set_buflisted(true);
// create memfile, read file
(void)open_buffer(false, NULL, 0);
open_buffer(false, NULL, 0);
if (swap_exists_action == SEA_QUIT) {
if (got_int || only_one_window()) {
@ -1725,7 +1725,7 @@ static void create_windows(mparm_T *parmp)
}
os_breakcheck();
if (got_int) {
(void)vgetc(); // only break the file loading, not the rest
vgetc(); // only break the file loading, not the rest
break;
}
}
@ -1804,9 +1804,9 @@ static void edit_buffers(mparm_T *parmp, char *cwd)
// Edit file from arg list, if there is one. When "Quit" selected
// at the ATTENTION prompt close the window.
swap_exists_did_quit = false;
(void)do_ecmd(0, arg_idx < GARGCOUNT
? alist_name(&GARGLIST[arg_idx])
: NULL, NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin);
do_ecmd(0, arg_idx < GARGCOUNT
? alist_name(&GARGLIST[arg_idx])
: NULL, NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin);
if (swap_exists_did_quit) {
// abort or quit selected
if (got_int || only_one_window()) {
@ -1825,7 +1825,7 @@ static void edit_buffers(mparm_T *parmp, char *cwd)
}
os_breakcheck();
if (got_int) {
(void)vgetc(); // only break the file loading, not the rest
vgetc(); // only break the file loading, not the rest
break;
}
}
@ -1957,7 +1957,7 @@ static void do_system_initialization(void)
#ifdef SYS_VIMRC_FILE
// Get system wide defaults, if the file name is defined.
(void)do_source(SYS_VIMRC_FILE, false, DOSO_NONE, NULL);
do_source(SYS_VIMRC_FILE, false, DOSO_NONE, NULL);
#endif
}

View File

@ -1528,7 +1528,6 @@ bool check_abbr(int c, char *ptr, int col, int mincol)
: (mp = mp->m_next)) {
int qlen = mp->m_keylen;
char *q = mp->m_keys;
int match;
if (strchr(mp->m_keys, K_SPECIAL) != NULL) {
// Might have K_SPECIAL escaped mp->m_keys.
@ -1537,9 +1536,9 @@ bool check_abbr(int c, char *ptr, int col, int mincol)
qlen = (int)strlen(q);
}
// find entries with right mode and keys
match = (mp->m_mode & State)
&& qlen == len
&& !strncmp(q, ptr, (size_t)len);
int match = (mp->m_mode & State)
&& qlen == len
&& !strncmp(q, ptr, (size_t)len);
if (q != mp->m_keys) {
xfree(q);
}
@ -1587,7 +1586,7 @@ bool check_abbr(int c, char *ptr, int col, int mincol)
}
tb[j] = NUL;
// insert the last typed char
(void)ins_typebuf((char *)tb, 1, 0, true, mp->m_silent);
ins_typebuf((char *)tb, 1, 0, true, mp->m_silent);
}
// copy values here, calling eval_map_expr() may make "mp" invalid!
@ -1603,7 +1602,7 @@ bool check_abbr(int c, char *ptr, int col, int mincol)
}
if (s != NULL) {
// insert the to string
(void)ins_typebuf(s, noremap, 0, true, silent);
ins_typebuf(s, noremap, 0, true, silent);
// no abbrev. for these chars
typebuf.tb_no_abbr_cnt += (int)strlen(s) + j + 1;
if (expr) {
@ -1615,7 +1614,7 @@ bool check_abbr(int c, char *ptr, int col, int mincol)
tb[1] = NUL;
len = clen; // Delete characters instead of bytes
while (len-- > 0) { // delete the from string
(void)ins_typebuf((char *)tb, 1, 0, true, silent);
ins_typebuf((char *)tb, 1, 0, true, silent);
}
return true;
}
@ -2177,8 +2176,8 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
if (did_simplify) {
// When the lhs is being simplified the not-simplified keys are
// preferred for printing, like in do_map().
(void)replace_termcodes(keys, strlen(keys), &alt_keys_buf, 0,
flags | REPTERM_NO_SIMPLIFY, NULL, p_cpo);
replace_termcodes(keys, strlen(keys), &alt_keys_buf, 0,
flags | REPTERM_NO_SIMPLIFY, NULL, p_cpo);
rhs = check_map(alt_keys_buf, mode, exact, false, abbr, &mp, &buffer_local, &rhs_lua);
}
@ -2399,8 +2398,8 @@ void f_maplist(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
bool did_simplify = false;
char *lhs = str2special_save(mp->m_keys, true, false);
(void)replace_termcodes(lhs, strlen(lhs), &keys_buf, 0, flags, &did_simplify,
p_cpo);
replace_termcodes(lhs, strlen(lhs), &keys_buf, 0, flags, &did_simplify,
p_cpo);
xfree(lhs);
Dictionary dict = mapblock_fill_dict(mp,

View File

@ -929,8 +929,8 @@ void ex_delmarks(exarg_T *eap)
// clear specified marks only
const Timestamp timestamp = os_time();
for (char *p = eap->arg; *p != NUL; p++) {
int lower = ASCII_ISLOWER(*p);
int digit = ascii_isdigit(*p);
bool lower = ASCII_ISLOWER(*p);
bool digit = ascii_isdigit(*p);
if (lower || digit || ASCII_ISUPPER(*p)) {
if (p[1] == '-') {
// clear range of marks

View File

@ -2251,7 +2251,7 @@ void *my_iconv_open(char *to, char *from)
// stops for no apparent reason after about 8160 characters.
char *p = tobuf;
size_t tolen = ICONV_TESTLEN;
(void)iconv(fd, NULL, NULL, &p, &tolen);
iconv(fd, NULL, NULL, &p, &tolen);
if (p == NULL) {
iconv_working = kBroken;
iconv_close(fd);

View File

@ -205,7 +205,7 @@ void mf_close_file(buf_T *buf, bool getlines)
if (getlines) {
// get all blocks in memory by accessing all lines (clumsy!)
for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) {
(void)ml_get_buf(buf, lnum);
ml_get_buf(buf, lnum);
}
}
@ -272,7 +272,7 @@ bhdr_T *mf_new(memfile_T *mfp, bool negative, unsigned page_count)
// Init the data to all zero, to avoid reading uninitialized data.
// This also avoids that the passwd file ends up in the swap file!
(void)memset(hp->bh_data, 0, (size_t)mfp->mf_page_size * page_count);
memset(hp->bh_data, 0, (size_t)mfp->mf_page_size * page_count);
return hp;
}
@ -758,7 +758,7 @@ static bool mf_do_open(memfile_T *mfp, char *fname, int flags)
return false;
}
(void)os_set_cloexec(mfp->mf_fd);
os_set_cloexec(mfp->mf_fd);
return true;
}

View File

@ -328,7 +328,7 @@ int ml_open(buf_T *buf)
b0p->b0_dirty = buf->b_changed ? B0_DIRTY : 0;
b0p->b0_flags = (char)(get_fileformat(buf) + 1);
set_b0_fname(b0p, buf);
(void)os_get_username(b0p->b0_uname, B0_UNAME_SIZE);
os_get_username(b0p->b0_uname, B0_UNAME_SIZE);
b0p->b0_uname[B0_UNAME_SIZE - 1] = NUL;
os_get_hostname(b0p->b0_hname, B0_HNAME_SIZE);
b0p->b0_hname[B0_HNAME_SIZE - 1] = NUL;
@ -342,7 +342,7 @@ int ml_open(buf_T *buf)
// is created.
mf_put(mfp, hp, true, false);
if (!buf->b_help && !buf->b_spell) {
(void)mf_sync(mfp, 0);
mf_sync(mfp, 0);
}
// Fill in root pointer block and write page 1.
@ -448,7 +448,7 @@ void ml_setname(buf_T *buf)
emsg(_("E301: Oops, lost the swap file!!!"));
return;
}
(void)os_set_cloexec(mfp->mf_fd);
os_set_cloexec(mfp->mf_fd);
}
if (!success) {
emsg(_("E302: Could not rename swap file"));
@ -483,7 +483,7 @@ void ml_open_file(buf_T *buf)
if (buf->b_spell) {
char *fname = vim_tempname();
if (fname != NULL) {
(void)mf_open_file(mfp, fname); // consumes fname!
mf_open_file(mfp, fname); // consumes fname!
}
buf->b_may_swap = false;
return;
@ -527,8 +527,8 @@ void ml_open_file(buf_T *buf)
if (*p_dir != NUL && mfp->mf_fname == NULL) {
need_wait_return = true; // call wait_return() later
no_wait_return++;
(void)semsg(_("E303: Unable to open swap file for \"%s\", recovery impossible"),
buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname);
semsg(_("E303: Unable to open swap file for \"%s\", recovery impossible"),
buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname);
no_wait_return--;
}
@ -792,7 +792,7 @@ void ml_recover(bool checkext)
i = 1;
} else { // several swapfiles found, choose
// list the names of the swapfiles
(void)recover_names(fname, true, NULL, 0, NULL);
recover_names(fname, true, NULL, 0, NULL);
msg_putchar('\n');
msg_puts(_("Enter number of swap file to use (0 to quit): "));
i = get_number(false, NULL);
@ -801,7 +801,7 @@ void ml_recover(bool checkext)
}
}
// get the swapfile name that will be used
(void)recover_names(fname, false, NULL, i, &fname_used);
recover_names(fname, false, NULL, i, &fname_used);
}
if (fname_used == NULL) {
goto theend; // user chose invalid number.
@ -1289,7 +1289,7 @@ int recover_names(char *fname, bool do_list, list_T *ret_list, int nr, char **fn
// Isolate a directory name from *dirp and put it in dir_name (we know
// it is large enough, so use 31000 for length).
// Advance dirp to next directory name.
(void)copy_option_part(&dirp, dir_name, 31000, ",");
copy_option_part(&dirp, dir_name, 31000, ",");
if (dir_name[0] == '.' && dir_name[1] == NUL) { // check current dir
if (fname == NULL) {
@ -1400,7 +1400,7 @@ int recover_names(char *fname, bool do_list, list_T *ret_list, int nr, char **fn
msg_puts(". ");
msg_puts(path_tail(files[i]));
msg_putchar('\n');
(void)swapfile_info(files[i]);
swapfile_info(files[i]);
}
} else {
msg_puts(_(" -- none --\n"));
@ -1639,7 +1639,7 @@ static bool swapfile_unchanged(char *fname)
return ret;
}
static int recov_file_names(char **names, char *path, int prepend_dot)
static int recov_file_names(char **names, char *path, bool prepend_dot)
FUNC_ATTR_NONNULL_ALL
{
int num_names = 0;
@ -1688,7 +1688,7 @@ void ml_sync_all(int check_file, int check_char, bool do_fsync)
}
ml_flush_line(buf); // flush buffered line
// flush locked block
(void)ml_find_line(buf, 0, ML_FLUSH);
ml_find_line(buf, 0, ML_FLUSH);
if (bufIsChanged(buf) && check_file && mf_need_trans(buf->b_ml.ml_mfp)
&& buf->b_ffname != NULL) {
// If the original file does not exist anymore or has been changed
@ -1704,8 +1704,8 @@ void ml_sync_all(int check_file, int check_char, bool do_fsync)
}
}
if (buf->b_ml.ml_mfp->mf_dirty == MF_DIRTY_YES) {
(void)mf_sync(buf->b_ml.ml_mfp, (check_char ? MFS_STOP : 0)
| (do_fsync && bufIsChanged(buf) ? MFS_FLUSH : 0));
mf_sync(buf->b_ml.ml_mfp, (check_char ? MFS_STOP : 0)
| (do_fsync && bufIsChanged(buf) ? MFS_FLUSH : 0));
if (check_char && os_char_avail()) { // character available now
break;
}
@ -1721,7 +1721,7 @@ void ml_sync_all(int check_file, int check_char, bool do_fsync)
/// changed or deleted.
///
/// @param message if true, the success of preserving is reported.
void ml_preserve(buf_T *buf, int message, bool do_fsync)
void ml_preserve(buf_T *buf, bool message, bool do_fsync)
{
memfile_T *mfp = buf->b_ml.ml_mfp;
int got_int_save = got_int;
@ -1738,7 +1738,7 @@ void ml_preserve(buf_T *buf, int message, bool do_fsync)
got_int = false;
ml_flush_line(buf); // flush buffered line
(void)ml_find_line(buf, 0, ML_FLUSH); // flush locked block
ml_find_line(buf, 0, ML_FLUSH); // flush locked block
int status = mf_sync(mfp, MFS_ALL | (do_fsync ? MFS_FLUSH : 0));
// stack is invalid after mf_sync(.., MFS_ALL)
@ -1765,7 +1765,7 @@ void ml_preserve(buf_T *buf, int message, bool do_fsync)
CHECK(buf->b_ml.ml_locked_low != lnum, "low != lnum");
lnum = buf->b_ml.ml_locked_high + 1;
}
(void)ml_find_line(buf, 0, ML_FLUSH); // flush locked block
ml_find_line(buf, 0, ML_FLUSH); // flush locked block
// sync the updated pointer blocks
if (mf_sync(mfp, MFS_ALL | (do_fsync ? MFS_FLUSH : 0)) == FAIL) {
status = FAIL;
@ -1986,7 +1986,8 @@ int ml_append_buf(buf_T *buf, linenr_T lnum, char *line, colnr_T len, bool newfi
/// @param len length of line, including NUL, or 0
/// @param newfile flag, see above
/// @param mark mark the new line
static int ml_append_int(buf_T *buf, linenr_T lnum, char *line, colnr_T len, bool newfile, int mark)
static int ml_append_int(buf_T *buf, linenr_T lnum, char *line, colnr_T len, bool newfile,
bool mark)
{
// lnum out of range
if (lnum > buf->b_ml.ml_line_count || buf->b_ml.ml_mfp == NULL) {
@ -2239,7 +2240,7 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char *line, colnr_T len, boo
// pointer blocks is done below
int lineadd = buf->b_ml.ml_locked_lineadd;
buf->b_ml.ml_locked_lineadd = 0;
(void)ml_find_line(buf, 0, ML_FLUSH); // flush data block
ml_find_line(buf, 0, ML_FLUSH); // flush data block
// update pointer blocks for the new data block
for (stack_idx = buf->b_ml.ml_stack_top - 1; stack_idx >= 0; stack_idx--) {
@ -2286,8 +2287,7 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char *line, colnr_T len, boo
// fix line count for rest of blocks in the stack
ml_lineadd(buf, lineadd);
// fix stack itself
buf->b_ml.ml_stack[buf->b_ml.ml_stack_top].ip_high +=
lineadd;
buf->b_ml.ml_stack[buf->b_ml.ml_stack_top].ip_high += lineadd;
(buf->b_ml.ml_stack_top)++;
}
@ -2785,9 +2785,9 @@ static void ml_flush_line(buf_T *buf)
// that has only one line.
// Don't forget to copy the mark!
// How about handling errors???
(void)ml_append_int(buf, lnum, new_line, new_len, false,
(int)(dp->db_index[idx] & DB_MARKED));
(void)ml_delete_int(buf, lnum, false);
ml_append_int(buf, lnum, new_line, new_len, false,
(int)(dp->db_index[idx] & DB_MARKED));
ml_delete_int(buf, lnum, false);
}
}
xfree(new_line);
@ -3205,7 +3205,7 @@ static void attention_message(buf_T *buf, char *fname)
assert(buf->b_fname != NULL);
no_wait_return++;
(void)emsg(_("E325: ATTENTION"));
emsg(_("E325: ATTENTION"));
msg_puts(_("\nFound a swap file by the name \""));
msg_home_replace(fname);
msg_puts("\"\n");
@ -3308,7 +3308,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
// First allocate some memory to put the directory name in.
const size_t dir_len = strlen(*dirp) + 1;
char *dir_name = xmalloc(dir_len);
(void)copy_option_part(dirp, dir_name, dir_len, ",");
copy_option_part(dirp, dir_name, dir_len, ",");
// We try different swapfile names until we find one that does not exist yet.
char *fname = makeswapname(buf_fname, buf->b_ffname, buf, dir_name);

View File

@ -69,7 +69,7 @@ void ex_menu(exarg_T *eap)
char *map_to; // command mapped to the menu entry
int noremap;
bool silent = false;
int unmenu;
bool unmenu;
char *map_buf;
char *p;
int i;
@ -868,7 +868,7 @@ char *set_context_in_menu_cmd(expand_T *xp, const char *cmd, char *arg, bool for
char *after_dot;
char *p;
char *path_name = NULL;
int unmenu;
bool unmenu;
vimmenu_T *menu;
xp->xp_context = EXPAND_UNSUCCESSFUL;
@ -1132,7 +1132,7 @@ static bool menu_namecmp(const char *const name, const char *const mname)
/// to whether the command is a "nore" command.
/// @param[out] unmenu If not NULL, the flag it points to is set according
/// to whether the command is an "unmenu" command.
int get_menu_cmd_modes(const char *cmd, bool forceit, int *noremap, int *unmenu)
int get_menu_cmd_modes(const char *cmd, bool forceit, int *noremap, bool *unmenu)
{
int modes;

View File

@ -228,7 +228,7 @@ int verb_msg(const char *s)
/// When terminal not initialized (yet) printf("%s", ..) is used.
///
/// @return true if wait_return() not called
int msg(const char *s, const int attr)
bool msg(const char *s, const int attr)
FUNC_ATTR_NONNULL_ARG(1)
{
return msg_attr_keep(s, attr, false, false);
@ -289,7 +289,6 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
FUNC_ATTR_NONNULL_ALL
{
static int entered = 0;
char *buf = NULL;
if (keep && multiline) {
// Not implemented. 'multiline' is only used by nvim-added messages,
@ -328,7 +327,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
// Truncate the message if needed.
msg_start();
buf = msg_strtrunc(s, false);
char *buf = msg_strtrunc(s, false);
if (buf != NULL) {
s = buf;
}
@ -342,7 +341,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
if (need_clear) {
msg_clr_eos();
}
int retval = msg_end();
bool retval = msg_end();
if (keep && retval && vim_strsize(s) < (Rows - cmdline_row - 1) * Columns + sc_col) {
set_keep_msg(s, 0);
@ -461,7 +460,7 @@ void trunc_string(const char *s, char *buf, int room_in, int buflen)
}
} else if (e + 3 < buflen) {
// set the middle and copy the last part
memmove(buf + e, "...", (size_t)3);
memmove(buf + e, "...", 3);
len = (int)strlen(s + i) + 1;
if (len >= buflen - e - 3) {
len = buflen - e - 3 - 1;
@ -840,7 +839,7 @@ void siemsg(const char *s, ...)
va_list ap;
va_start(ap, s);
(void)semsgv(s, ap);
semsgv(s, ap);
va_end(ap);
#ifdef ABORT_ON_INTERNAL_ERROR
msg_putchar('\n'); // avoid overwriting the error message
@ -858,7 +857,7 @@ void internal_error(const char *where)
static void msg_semsg_event(void **argv)
{
char *s = argv[0];
(void)emsg(s);
emsg(s);
xfree(s);
}
@ -877,7 +876,7 @@ void msg_schedule_semsg(const char *const fmt, ...)
static void msg_semsg_multiline_event(void **argv)
{
char *s = argv[0];
(void)emsg_multiline(s, true);
emsg_multiline(s, true);
xfree(s);
}
@ -905,7 +904,7 @@ char *msg_trunc(char *s, bool force, int attr)
char *ts = msg_may_trunc(force, s);
msg_hist_off = true;
int n = msg(ts, attr);
bool n = msg(ts, attr);
msg_hist_off = false;
if (n) {
@ -970,7 +969,7 @@ static void add_msg_hist_multiattr(const char *s, int len, int attr, bool multil
// Don't let the message history get too big
while (msg_hist_len > MAX_MSG_HIST_LEN) {
(void)delete_first_msg();
delete_first_msg();
}
// allocate an entry and add the message at the end of the history
@ -1035,7 +1034,7 @@ void ex_messages(exarg_T *eap)
int keep = eap->addr_count == 0 ? 0 : eap->line2;
while (msg_hist_len > keep) {
(void)delete_first_msg();
delete_first_msg();
}
return;
}
@ -1250,7 +1249,7 @@ void wait_return(int redraw)
// Avoid that the mouse-up event causes visual mode to start.
if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE
|| c == K_X1MOUSE || c == K_X2MOUSE) {
(void)jump_to_mouse(MOUSE_SETPOS, NULL, 0);
jump_to_mouse(MOUSE_SETPOS, NULL, 0);
} else if (vim_strchr("\r\n ", c) == NULL && c != Ctrl_C) {
// Put the character back in the typeahead buffer. Don't use the
// stuff buffer, because lmaps wouldn't work.
@ -1797,7 +1796,7 @@ void str2specialbuf(const char *sp, char *buf, size_t len)
}
/// print line for :print or :list command
void msg_prt_line(const char *s, int list)
void msg_prt_line(const char *s, bool list)
{
int c;
int col = 0;
@ -2523,7 +2522,7 @@ void sb_text_end_cmdline(void)
/// Clear any text remembered for scrolling back.
/// When "all" is false keep the last line.
/// Called when redrawing the screen.
void clear_sb_text(int all)
void clear_sb_text(bool all)
{
msgchunk_T *mp;
msgchunk_T **lastp;
@ -2827,7 +2826,7 @@ static bool do_more_prompt(int typed_char)
grid_fill(&msg_grid_adj, 0, 1, 0, Columns, ' ', ' ',
HL_ATTR(HLF_MSG));
// display line at top
(void)disp_sb_line(0, mp);
disp_sb_line(0, mp);
} else {
// redisplay all lines
// TODO(bfredl): this case is not optimized (though only concerns
@ -2899,7 +2898,7 @@ static bool do_more_prompt(int typed_char)
return retval;
}
void msg_moremsg(int full)
void msg_moremsg(bool full)
{
int attr = hl_combine_attr(HL_ATTR(HLF_MSG), HL_ATTR(HLF_M));
grid_line_start(&msg_grid_adj, Rows - 1);
@ -2991,7 +2990,7 @@ void msg_clr_cmdline(void)
/// call wait_return() if the message does not fit in the available space
///
/// @return true if wait_return() not called.
int msg_end(void)
bool msg_end(void)
{
// If the string is larger than the window,
// or the ruler option is set and we run into it,

View File

@ -187,7 +187,7 @@ static void call_click_def_func(StlClickDefinition *click_defs, int col, int whi
}
};
typval_T rettv;
(void)call_vim_function(click_defs[col].func, ARRAY_SIZE(argv), argv, &rettv);
call_vim_function(click_defs[col].func, ARRAY_SIZE(argv), argv, &rettv);
tv_clear(&rettv);
// Make sure next click does not register as drag when callback absorbs the release event.
got_click = false;
@ -1010,7 +1010,7 @@ void do_mousescroll(cmdarg_T *cap)
// Vertical scrolling
if ((State & MODE_NORMAL) && shift_or_ctrl) {
// whole page up or down
(void)onepage(cap->arg ? FORWARD : BACKWARD, 1);
onepage(cap->arg ? FORWARD : BACKWARD, 1);
} else {
if (shift_or_ctrl) {
// whole page up or down
@ -1030,7 +1030,7 @@ void do_mousescroll(cmdarg_T *cap)
if (leftcol < 0) {
leftcol = 0;
}
(void)do_mousescroll_horiz(leftcol);
do_mousescroll_horiz(leftcol);
}
}
@ -1416,7 +1416,7 @@ retnomove:
break;
}
first = false;
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
if (curwin->w_topfill < win_get_fill(curwin, curwin->w_topline)) {
curwin->w_topfill++;
} else {
@ -1577,7 +1577,7 @@ void nv_mousescroll(cmdarg_T *cap)
/// Mouse clicks and drags.
void nv_mouse(cmdarg_T *cap)
{
(void)do_mouse(cap->oap, cap->cmdchar, BACKWARD, cap->count1, 0);
do_mouse(cap->oap, cap->cmdchar, BACKWARD, cap->count1, 0);
}
/// Compute the position in the buffer line from the posn on the screen in
@ -1626,7 +1626,7 @@ bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump)
break; // Position is in this buffer line.
}
(void)hasFoldingWin(win, lnum, NULL, &lnum, true, NULL);
hasFoldingWin(win, lnum, NULL, &lnum, true, NULL);
if (lnum == win->w_buffer->b_ml.ml_line_count) {
retval = true;
@ -1939,7 +1939,7 @@ void f_getmousepos(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
winrow = row + 1 + wp->w_winrow_off; // Adjust by 1 for top border
wincol = col + 1 + wp->w_wincol_off; // Adjust by 1 for left border
if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width) {
(void)mouse_comp_pos(wp, &row, &col, &lnum);
mouse_comp_pos(wp, &row, &col, &lnum);
col = vcol2col(wp, lnum, col, &coladd);
column = col + 1;
}

View File

@ -302,7 +302,7 @@ void update_topline(win_T *wp)
if (lnum >= wp->w_buffer->b_ml.ml_line_count || n >= halfheight) {
break;
}
(void)hasFoldingWin(wp, lnum, NULL, &lnum, true, NULL);
hasFoldingWin(wp, lnum, NULL, &lnum, true, NULL);
}
} else {
n = wp->w_topline + *so_ptr - wp->w_cursor.lnum;
@ -319,7 +319,7 @@ void update_topline(win_T *wp)
}
} else {
// Make sure topline is the first line of a fold.
(void)hasFoldingWin(wp, wp->w_topline, &wp->w_topline, NULL, true, NULL);
hasFoldingWin(wp, wp->w_topline, &wp->w_topline, NULL, true, NULL);
check_botline = true;
}
}
@ -347,7 +347,7 @@ void update_topline(win_T *wp)
int n = wp->w_empty_rows;
loff.lnum = wp->w_cursor.lnum;
// In a fold go to its last line.
(void)hasFoldingWin(wp, loff.lnum, NULL, &loff.lnum, true, NULL);
hasFoldingWin(wp, loff.lnum, NULL, &loff.lnum, true, NULL);
loff.fill = 0;
n += wp->w_filler_rows;
loff.height = 0;
@ -381,7 +381,7 @@ void update_topline(win_T *wp)
if (lnum <= 0 || line_count > wp->w_height_inner + 1) {
break;
}
(void)hasFolding(lnum, &lnum, NULL);
hasFolding(lnum, &lnum, NULL);
}
} else {
line_count = wp->w_cursor.lnum - wp->w_botline + 1 + (int)(*so_ptr);
@ -525,7 +525,7 @@ void set_topline(win_T *wp, linenr_T lnum)
linenr_T prev_topline = wp->w_topline;
// go to first of folded lines
(void)hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
// Approximate the value of w_botline
wp->w_botline += lnum - wp->w_topline;
wp->w_topline = lnum;
@ -1207,7 +1207,7 @@ bool scrolldown(linenr_T line_count, int byfold)
}
// Make sure w_topline is at the first of a sequence of folded lines.
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
validate_cursor(); // w_wrow needs to be valid
for (int todo = line_count; todo > 0; todo--) {
if (curwin->w_topfill < win_get_fill(curwin, curwin->w_topline)
@ -1332,11 +1332,11 @@ bool scrolldown(linenr_T line_count, int byfold)
///
/// @param line_count number of lines to scroll
/// @param byfold if true, count a closed fold as one line
bool scrollup(linenr_T line_count, int byfold)
bool scrollup(linenr_T line_count, bool byfold)
{
linenr_T topline = curwin->w_topline;
linenr_T botline = curwin->w_botline;
int do_sms = curwin->w_p_wrap && curwin->w_p_sms;
bool do_sms = curwin->w_p_wrap && curwin->w_p_sms;
if (do_sms || (byfold && hasAnyFolding(curwin)) || win_may_fill(curwin)) {
int width1 = curwin->w_width_inner - curwin_col_off();
@ -1359,7 +1359,7 @@ bool scrollup(linenr_T line_count, int byfold)
linenr_T lnum = curwin->w_topline;
if (byfold) {
// for a closed fold: go to the last line in the fold
(void)hasFolding(lnum, NULL, &lnum);
hasFolding(lnum, NULL, &lnum);
}
if (lnum == curwin->w_topline && do_sms) {
// 'smoothscroll': increase "w_skipcol" until it goes over
@ -1415,7 +1415,7 @@ bool scrollup(linenr_T line_count, int byfold)
if (hasAnyFolding(curwin)) {
// Make sure w_topline is at the first of a sequence of folded lines.
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
}
curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE);
@ -1577,7 +1577,7 @@ static void max_topfill(void)
// cursor off the screen.
void scrolldown_clamp(void)
{
int can_fill = (curwin->w_topfill < win_get_fill(curwin, curwin->w_topline));
bool can_fill = (curwin->w_topfill < win_get_fill(curwin, curwin->w_topline));
if (curwin->w_topline <= 1
&& !can_fill) {
@ -1609,7 +1609,7 @@ void scrolldown_clamp(void)
curwin->w_topline--;
curwin->w_topfill = 0;
}
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
curwin->w_botline--; // approximate w_botline
curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE);
}
@ -1640,7 +1640,7 @@ void scrollup_clamp(void)
if (curwin->w_topfill > 0) {
curwin->w_topfill--;
} else {
(void)hasFolding(curwin->w_topline, NULL, &curwin->w_topline);
hasFolding(curwin->w_topline, NULL, &curwin->w_topline);
curwin->w_topline++;
}
curwin->w_botline++; // approximate w_botline
@ -1869,7 +1869,7 @@ void set_empty_rows(win_T *wp, int used)
/// When scrolling scroll at least "min_scroll" lines.
/// If "set_topbot" is true, set topline and botline first (for "zb").
/// This is messy stuff!!!
void scroll_cursor_bot(int min_scroll, int set_topbot)
void scroll_cursor_bot(int min_scroll, bool set_topbot)
{
lineoff_T loff;
linenr_T old_topline = curwin->w_topline;
@ -1879,7 +1879,7 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
int old_valid = curwin->w_valid;
int old_empty_rows = curwin->w_empty_rows;
linenr_T cln = curwin->w_cursor.lnum; // Cursor Line Number
int do_sms = curwin->w_p_wrap && curwin->w_p_sms;
bool do_sms = curwin->w_p_wrap && curwin->w_p_sms;
if (set_topbot) {
bool set_skipcol = false;
@ -2098,7 +2098,7 @@ void scroll_cursor_halfway(bool atend, bool prefer_above)
linenr_T old_topline = curwin->w_topline;
lineoff_T loff = { .lnum = curwin->w_cursor.lnum };
lineoff_T boff = { .lnum = curwin->w_cursor.lnum };
(void)hasFolding(loff.lnum, &loff.lnum, &boff.lnum);
hasFolding(loff.lnum, &loff.lnum, &boff.lnum);
int used = plines_win_nofill(curwin, loff.lnum, true);
loff.fill = 0;
boff.fill = 0;
@ -2444,7 +2444,7 @@ int onepage(Direction dir, int count)
botline_forw(curwin, &loff);
botline_topline(&loff);
// We're at the wrong end of a fold now.
(void)hasFoldingWin(curwin, loff.lnum, &loff.lnum, NULL, true, NULL);
hasFoldingWin(curwin, loff.lnum, &loff.lnum, NULL, true, NULL);
// Always scroll at least one line. Avoid getting stuck on
// very long lines.
@ -2491,10 +2491,10 @@ int onepage(Direction dir, int count)
if (curwin->w_topline <= old_topline
&& old_topline < curbuf->b_ml.ml_line_count) {
curwin->w_topline = old_topline + 1;
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
}
} else if (curwin->w_botline > curbuf->b_ml.ml_line_count) {
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
}
}
@ -2593,7 +2593,7 @@ void halfpage(bool flag, linenr_T Prenum)
if (n < 0 && scrolled > 0) {
break;
}
(void)hasFolding(curwin->w_topline, NULL, &curwin->w_topline);
hasFolding(curwin->w_topline, NULL, &curwin->w_topline);
curwin->w_topline++;
curwin->w_topfill = win_get_fill(curwin, curwin->w_topline);
@ -2617,7 +2617,7 @@ void halfpage(bool flag, linenr_T Prenum)
if (i > room) {
break;
}
(void)hasFolding(curwin->w_botline, NULL, &curwin->w_botline);
hasFolding(curwin->w_botline, NULL, &curwin->w_botline);
curwin->w_botline++;
room -= i;
} while (curwin->w_botline <= curbuf->b_ml.ml_line_count);
@ -2629,8 +2629,8 @@ void halfpage(bool flag, linenr_T Prenum)
if (hasAnyFolding(curwin)) {
while (--n >= 0
&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) {
(void)hasFolding(curwin->w_cursor.lnum, NULL,
&curwin->w_cursor.lnum);
hasFolding(curwin->w_cursor.lnum, NULL,
&curwin->w_cursor.lnum);
curwin->w_cursor.lnum++;
}
} else {
@ -2652,7 +2652,7 @@ void halfpage(bool flag, linenr_T Prenum)
break;
}
curwin->w_topline--;
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
curwin->w_topfill = 0;
}
curwin->w_valid &= ~(VALID_CROW|VALID_WROW|
@ -2671,8 +2671,8 @@ void halfpage(bool flag, linenr_T Prenum)
} else if (hasAnyFolding(curwin)) {
while (--n >= 0 && curwin->w_cursor.lnum > 1) {
curwin->w_cursor.lnum--;
(void)hasFolding(curwin->w_cursor.lnum,
&curwin->w_cursor.lnum, NULL);
hasFolding(curwin->w_cursor.lnum,
&curwin->w_cursor.lnum, NULL);
}
} else {
curwin->w_cursor.lnum -= n;

View File

@ -702,7 +702,7 @@ static void normal_get_additional_char(NormalState *s)
int *cp;
bool repl = false; // get character for replace mode
bool lit = false; // get extra character literally
int lang; // getting a text character
bool lang; // getting a text character
no_mapping++;
allow_keys++; // no mapping for nchar, but allow key codes
@ -1027,7 +1027,7 @@ normal_end:
restart_VIsual_select = 0;
}
if (restart_edit != 0 && !VIsual_active && s->old_mapped_len == 0) {
(void)edit(restart_edit, false, 1);
edit(restart_edit, false, 1);
}
}
@ -1256,7 +1256,7 @@ static void normal_check_interrupt(NormalState *s)
} else if (!global_busy || !exmode_active) {
if (!quit_more) {
// flush all buffers
(void)vgetc();
vgetc();
}
got_int = false;
}
@ -1847,7 +1847,7 @@ void clear_showcmd(void)
}
if (VIsual_active && !char_avail()) {
int cursor_bot = lt(VIsual, curwin->w_cursor);
bool cursor_bot = lt(VIsual, curwin->w_cursor);
int lines;
colnr_T leftcol, rightcol;
linenr_T top, bot;
@ -1861,8 +1861,8 @@ void clear_showcmd(void)
bot = VIsual.lnum;
}
// Include closed folds as a whole.
(void)hasFolding(top, &top, NULL);
(void)hasFolding(bot, NULL, &bot);
hasFolding(top, &top, NULL);
hasFolding(bot, NULL, &bot);
lines = bot - top + 1;
if (VIsual_mode == Ctrl_V) {
@ -2185,7 +2185,7 @@ void check_scrollbind(linenr_T topline_diff, int leftcol_diff)
// do the horizontal scroll
if (want_hor) {
(void)set_leftcol(tgt_leftcol);
set_leftcol(tgt_leftcol);
}
}
@ -2256,7 +2256,7 @@ static void nv_page(cmdarg_T *cap)
goto_tabpage(cap->count0);
}
} else {
(void)onepage(cap->arg, cap->count1);
onepage(cap->arg, cap->count1);
}
}
@ -2606,7 +2606,7 @@ void nv_scroll_line(cmdarg_T *cap)
}
/// Scroll "count" lines up or down, and redraw.
void scroll_redraw(int up, linenr_T count)
void scroll_redraw(bool up, linenr_T count)
{
linenr_T prev_topline = curwin->w_topline;
int prev_skipcol = curwin->w_skipcol;
@ -2677,7 +2677,7 @@ static bool nv_z_get_count(cmdarg_T *cap, int *nchar_arg)
LANGMAP_ADJUST(nchar, true);
no_mapping--;
allow_keys--;
(void)add_to_showcmd(nchar);
add_to_showcmd(nchar);
if (nchar == K_DEL || nchar == K_KDEL) {
n /= 10;
@ -2722,7 +2722,7 @@ static int nv_zg_zw(cmdarg_T *cap, int nchar)
LANGMAP_ADJUST(nchar, true);
no_mapping--;
allow_keys--;
(void)add_to_showcmd(nchar);
add_to_showcmd(nchar);
if (vim_strchr("gGwW", nchar) == NULL) {
clearopbeep(cap->oap);
@ -2872,8 +2872,8 @@ static void nv_zet(cmdarg_T *cap)
case 'h':
case K_LEFT:
if (!curwin->w_p_wrap) {
(void)set_leftcol((colnr_T)cap->count1 > curwin->w_leftcol
? 0 : curwin->w_leftcol - (colnr_T)cap->count1);
set_leftcol((colnr_T)cap->count1 > curwin->w_leftcol
? 0 : curwin->w_leftcol - (colnr_T)cap->count1);
}
break;
@ -2886,7 +2886,7 @@ static void nv_zet(cmdarg_T *cap)
case 'l':
case K_RIGHT:
if (!curwin->w_p_wrap) {
(void)set_leftcol(curwin->w_leftcol + (colnr_T)cap->count1);
set_leftcol(curwin->w_leftcol + (colnr_T)cap->count1);
}
break;
@ -3288,8 +3288,8 @@ static void nv_ctrlo(cmdarg_T *cap)
static void nv_hat(cmdarg_T *cap)
{
if (!checkclearopq(cap->oap)) {
(void)buflist_getfile(cap->count0, 0,
GETF_SETMARK|GETF_ALT, false);
buflist_getfile(cap->count0, 0,
GETF_SETMARK|GETF_ALT, false);
}
}
@ -3554,7 +3554,7 @@ static void nv_ident(cmdarg_T *cap)
init_history();
add_to_history(HIST_SEARCH, buf, true, NUL);
(void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL);
normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL);
} else {
g_tag_at_cursor = true;
do_cmdline_cmd(buf);
@ -3638,8 +3638,8 @@ static void nv_scroll(cmdarg_T *cap)
// Count a fold for one screen line.
for (n = cap->count1 - 1; n > 0
&& curwin->w_cursor.lnum > curwin->w_topline; n--) {
(void)hasFolding(curwin->w_cursor.lnum,
&curwin->w_cursor.lnum, NULL);
hasFolding(curwin->w_cursor.lnum,
&curwin->w_cursor.lnum, NULL);
if (curwin->w_cursor.lnum > curwin->w_topline) {
curwin->w_cursor.lnum--;
}
@ -3680,7 +3680,7 @@ static void nv_scroll(cmdarg_T *cap)
// Count a fold for one screen line.
lnum = curwin->w_topline;
while (n-- > 0 && lnum < curwin->w_botline - 1) {
(void)hasFolding(lnum, NULL, &lnum);
hasFolding(lnum, NULL, &lnum);
lnum++;
}
n = lnum - curwin->w_topline;
@ -3900,7 +3900,7 @@ static void nv_gotofile(cmdarg_T *cap)
if (ptr != NULL) {
// do autowrite if necessary
if (curbufIsChanged() && curbuf->b_nwindows <= 1 && !buf_hide(curbuf)) {
(void)autowrite(curbuf, false);
autowrite(curbuf, false);
}
setpcmark();
if (do_ecmd(0, ptr, NULL, NULL, ECMD_LAST,
@ -3971,9 +3971,9 @@ static void nv_search(cmdarg_T *cap)
return;
}
(void)normal_search(cap, cap->cmdchar, cap->searchbuf,
(cap->arg || !equalpos(save_cursor, curwin->w_cursor))
? 0 : SEARCH_MARK, NULL);
normal_search(cap, cap->cmdchar, cap->searchbuf,
(cap->arg || !equalpos(save_cursor, curwin->w_cursor))
? 0 : SEARCH_MARK, NULL);
}
/// Handle "N" and "n" commands.
@ -3989,7 +3989,7 @@ static void nv_next(cmdarg_T *cap)
// an offset is given and the cursor is on the last char in the buffer:
// Repeat with count + 1.
cap->count1 += 1;
(void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL);
normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL);
cap->count1 -= 1;
}
}
@ -4123,7 +4123,7 @@ static void nv_bracket_block(cmdarg_T *cap, const pos_T *old_pos)
if (cap->nchar == 'm' || cap->nchar == 'M') {
int c;
// norm is true for "]M" and "[m"
int norm = ((findc == '{') == (cap->nchar == 'm'));
bool norm = ((findc == '{') == (cap->nchar == 'm'));
n = cap->count1;
// found a match: we were inside a method
@ -4289,9 +4289,9 @@ static void nv_brackets(cmdarg_T *cap)
} else if (cap->nchar >= K_RIGHTRELEASE && cap->nchar <= K_LEFTMOUSE) {
// [ or ] followed by a middle mouse click: put selected text with
// indent adjustment. Any other button just does as usual.
(void)do_mouse(cap->oap, cap->nchar,
(cap->cmdchar == ']') ? FORWARD : BACKWARD,
cap->count1, PUT_FIXINDENT);
do_mouse(cap->oap, cap->nchar,
(cap->cmdchar == ']') ? FORWARD : BACKWARD,
cap->count1, PUT_FIXINDENT);
} else if (cap->nchar == 'z') {
// "[z" and "]z": move to start or end of open fold.
if (foldMoveTo(false, cap->cmdchar == ']' ? FORWARD : BACKWARD,
@ -4556,7 +4556,7 @@ static void nv_replace(cmdarg_T *cap)
// Insert the newline with an insert command, takes care of
// autoindent. The insert command depends on being on the last
// character of a line or not.
(void)del_chars(cap->count1, false); // delete the characters
del_chars(cap->count1, false); // delete the characters
stuffcharReadbuff('\r');
stuffcharReadbuff(ESC);
@ -5312,7 +5312,7 @@ static void nv_g_dollar_cmd(cmdarg_T *cap)
} else {
if (cap->count1 > 1) {
// if it fails, let the cursor still move to the last char
(void)cursor_down(cap->count1 - 1, false);
cursor_down(cap->count1 - 1, false);
}
i = curwin->w_leftcol + curwin->w_width_inner - col_off - 1;
coladvance((colnr_T)i);
@ -5626,7 +5626,7 @@ static void nv_g_cmd(cmdarg_T *cap)
case K_X2DRAG:
case K_X2RELEASE:
mod_mask = MOD_MASK_CTRL;
(void)do_mouse(oap, cap->nchar, BACKWARD, cap->count1, 0);
do_mouse(oap, cap->nchar, BACKWARD, cap->count1, 0);
break;
case K_IGNORE:
@ -5699,12 +5699,12 @@ static void n_opencmd(cmdarg_T *cap)
if (cap->cmdchar == 'O') {
// Open above the first line of a folded sequence of lines
(void)hasFolding(curwin->w_cursor.lnum,
&curwin->w_cursor.lnum, NULL);
hasFolding(curwin->w_cursor.lnum,
&curwin->w_cursor.lnum, NULL);
} else {
// Open below the last line of a folded sequence of lines
(void)hasFolding(curwin->w_cursor.lnum,
NULL, &curwin->w_cursor.lnum);
hasFolding(curwin->w_cursor.lnum,
NULL, &curwin->w_cursor.lnum);
}
// trigger TextChangedI for the 'o/O' command
curbuf->b_last_changedtick_i = buf_get_changedtick(curbuf);
@ -6108,10 +6108,10 @@ static void nv_normal(cmdarg_T *cap)
/// Don't even beep if we are canceling a command.
static void nv_esc(cmdarg_T *cap)
{
int no_reason = (cap->oap->op_type == OP_NOP
&& cap->opcount == 0
&& cap->count0 == 0
&& cap->oap->regname == 0);
bool no_reason = (cap->oap->op_type == OP_NOP
&& cap->opcount == 0
&& cap->count0 == 0
&& cap->oap->regname == 0);
if (cap->arg) { // true for CTRL-C
if (restart_edit == 0 && cmdwin_type == 0 && !VIsual_active && no_reason) {
@ -6618,6 +6618,6 @@ void normal_cmd(oparg_T *oap, bool toplevel)
s.toplevel = toplevel;
s.oa = *oap;
normal_prepare(&s);
(void)normal_execute(&s.state, safe_vgetc());
normal_execute(&s.state, safe_vgetc());
*oap = s.oa;
}

View File

@ -213,7 +213,7 @@ int get_extra_op_char(int optype)
}
/// handle a shift operation
void op_shift(oparg_T *oap, int curs_top, int amount)
void op_shift(oparg_T *oap, bool curs_top, int amount)
{
int block_col = 0;
@ -287,7 +287,7 @@ void op_shift(oparg_T *oap, int curs_top, int amount)
/// leaves cursor on first blank in the line.
///
/// @param call_changed_bytes call changed_bytes()
void shift_line(int left, int round, int amount, int call_changed_bytes)
void shift_line(bool left, bool round, int amount, int call_changed_bytes)
{
const int sw_val = get_sw_value_indent(curbuf);
@ -323,7 +323,7 @@ void shift_line(int left, int round, int amount, int call_changed_bytes)
if (State & VREPLACE_FLAG) {
change_indent(INDENT_SET, count, false, NUL, call_changed_bytes);
} else {
(void)set_indent(count, call_changed_bytes ? SIN_CHANGED : 0);
set_indent(count, call_changed_bytes ? SIN_CHANGED : 0);
}
}
@ -520,7 +520,7 @@ static void shift_block(oparg_T *oap, int amount)
/// Insert string "s" (b_insert ? before : after) block :AKelly
/// Caller must prepare for undo.
static void block_insert(oparg_T *oap, char *s, int b_insert, struct block_def *bdp)
static void block_insert(oparg_T *oap, char *s, bool b_insert, struct block_def *bdp)
{
int ts_val;
int count = 0; // extra spaces to replace a cut TAB
@ -915,14 +915,14 @@ int do_record(int c)
if (p != NULL) {
// Remove escaping for K_SPECIAL in multi-byte chars.
vim_unescape_ks(p);
(void)tv_dict_add_str(dict, S_LEN("regcontents"), p);
tv_dict_add_str(dict, S_LEN("regcontents"), p);
}
// Name of requested register, or empty string for unnamed operation.
char buf[NUMBUFLEN + 2];
buf[0] = (char)regname;
buf[1] = NUL;
(void)tv_dict_add_str(dict, S_LEN("regname"), buf);
tv_dict_add_str(dict, S_LEN("regname"), buf);
tv_dict_set_keys_readonly(dict);
// Get the recorded key hits. K_SPECIAL will be escaped, this
@ -1702,8 +1702,8 @@ int op_delete(oparg_T *oap)
}
}
(void)del_bytes((colnr_T)n, !virtual_op,
oap->op_type == OP_DELETE && !oap->is_VIsual);
del_bytes((colnr_T)n, !virtual_op,
oap->op_type == OP_DELETE && !oap->is_VIsual);
} else {
// delete characters between lines
pos_T curpos;
@ -1729,10 +1729,10 @@ int op_delete(oparg_T *oap)
// delete from start of line until op_end
int n = (oap->end.col + 1 - !oap->inclusive);
curwin->w_cursor.col = 0;
(void)del_bytes((colnr_T)n, !virtual_op,
oap->op_type == OP_DELETE && !oap->is_VIsual);
del_bytes((colnr_T)n, !virtual_op,
oap->op_type == OP_DELETE && !oap->is_VIsual);
curwin->w_cursor = curpos; // restore curwin->w_cursor
(void)do_join(2, false, false, false, false);
do_join(2, false, false, false, false);
curbuf_splice_pending--;
extmark_splice(curbuf, (int)startpos.lnum - 1, startpos.col,
(int)oap->line_count - 1, n, deleted_bytes,
@ -1822,11 +1822,6 @@ static int op_replace(oparg_T *oap, int c)
// block mode replace
if (oap->motion_type == kMTBlockWise) {
int numc;
int num_chars;
char *newp;
char *oldp;
colnr_T oldlen;
bd.is_MAX = (curwin->w_curswant == MAXCOL);
for (; curwin->w_cursor.lnum <= oap->end.lnum; curwin->w_cursor.lnum++) {
curwin->w_cursor.col = 0; // make sure cursor position is valid
@ -1857,7 +1852,7 @@ static int op_replace(oparg_T *oap, int c)
&& !bd.is_oneChar
&& bd.end_char_vcols > 0) ? bd.end_char_vcols - 1 : 0;
// Figure out how many characters to replace.
numc = oap->end_vcol - oap->start_vcol + 1;
int numc = oap->end_vcol - oap->start_vcol + 1;
if (bd.is_short && (!virtual_op || bd.is_MAX)) {
numc -= (oap->end_vcol - bd.end_vcol) + 1;
}
@ -1873,11 +1868,11 @@ static int op_replace(oparg_T *oap, int c)
}
// Compute bytes needed, move character count to num_chars.
num_chars = numc;
int num_chars = numc;
numc *= utf_char2len(c);
oldp = get_cursor_line_ptr();
oldlen = (int)strlen(oldp);
char *oldp = get_cursor_line_ptr();
colnr_T oldlen = (int)strlen(oldp);
size_t newp_size = (size_t)bd.textcol + (size_t)bd.startspaces;
if (had_ctrl_v_cr || (c != '\r' && c != '\n')) {
@ -1887,7 +1882,7 @@ static int op_replace(oparg_T *oap, int c)
- bd.textcol - bd.textlen);
}
}
newp = xmallocz(newp_size);
char *newp = xmallocz(newp_size);
// copy up to deleted part
memmove(newp, oldp, (size_t)bd.textcol);
oldp += bd.textcol + bd.textlen;
@ -2038,7 +2033,7 @@ static int op_replace(oparg_T *oap, int c)
void op_tilde(oparg_T *oap)
{
struct block_def bd;
int did_change = false;
bool did_change = false;
if (u_save((linenr_T)(oap->start.lnum - 1),
(linenr_T)(oap->end.lnum + 1)) == FAIL) {
@ -2050,7 +2045,7 @@ void op_tilde(oparg_T *oap)
for (; pos.lnum <= oap->end.lnum; pos.lnum++) {
block_prep(oap, &bd, pos.lnum, false);
pos.col = bd.textcol;
int one_change = swapchars(oap->op_type, &pos, bd.textlen);
bool one_change = swapchars(oap->op_type, &pos, bd.textlen);
did_change |= one_change;
}
if (did_change) {
@ -2276,7 +2271,7 @@ void op_insert(oparg_T *oap, int count1)
pos_T t1 = oap->start;
const pos_T start_insert = curwin->w_cursor;
(void)edit(NUL, false, (linenr_T)count1);
edit(NUL, false, (linenr_T)count1);
// When a tab was inserted, and the characters in front of the tab
// have been converted to a tab as well, the column of the cursor
@ -2478,9 +2473,6 @@ int op_change(oparg_T *oap)
ins_len = (int)strlen(firstline) - pre_textlen;
if (ins_len > 0) {
int offset;
char *newp;
char *oldp;
// Subsequent calls to ml_get() flush the firstline data - take a
// copy of the inserted text.
char *ins_text = xmalloc((size_t)ins_len + 1);
@ -2495,16 +2487,16 @@ int op_change(oparg_T *oap)
// initial coladd offset as part of "startspaces"
if (bd.is_short) {
vpos.lnum = linenr;
(void)getvpos(&vpos, oap->start_vcol);
getvpos(&vpos, oap->start_vcol);
} else {
vpos.coladd = 0;
}
oldp = ml_get(linenr);
newp = xmalloc(strlen(oldp) + (size_t)vpos.coladd
+ (size_t)ins_len + 1);
char *oldp = ml_get(linenr);
char *newp = xmalloc(strlen(oldp) + (size_t)vpos.coladd
+ (size_t)ins_len + 1);
// copy up to block start
memmove(newp, oldp, (size_t)bd.textcol);
offset = bd.textcol;
int offset = bd.textcol;
memset(newp + offset, ' ', (size_t)vpos.coladd);
offset += vpos.coladd;
memmove(newp + offset, ins_text, (size_t)ins_len);
@ -2842,17 +2834,17 @@ static void do_autocmd_textyankpost(oparg_T *oap, yankreg_T *reg)
tv_list_append_string(list, reg->y_array[i], -1);
}
tv_list_set_lock(list, VAR_FIXED);
(void)tv_dict_add_list(dict, S_LEN("regcontents"), list);
tv_dict_add_list(dict, S_LEN("regcontents"), list);
// Register type.
char buf[NUMBUFLEN + 2];
format_reg_type(reg->y_type, reg->y_width, buf, ARRAY_SIZE(buf));
(void)tv_dict_add_str(dict, S_LEN("regtype"), buf);
tv_dict_add_str(dict, S_LEN("regtype"), buf);
// Name of requested register, or empty string for unnamed operation.
buf[0] = (char)oap->regname;
buf[1] = NUL;
(void)tv_dict_add_str(dict, S_LEN("regname"), buf);
tv_dict_add_str(dict, S_LEN("regname"), buf);
// Motion type: inclusive or exclusive.
tv_dict_add_bool(dict, S_LEN("inclusive"),
@ -2861,11 +2853,11 @@ static void do_autocmd_textyankpost(oparg_T *oap, yankreg_T *reg)
// Kind of operation: yank, delete, change).
buf[0] = (char)get_op_char(oap->op_type);
buf[1] = NUL;
(void)tv_dict_add_str(dict, S_LEN("operator"), buf);
tv_dict_add_str(dict, S_LEN("operator"), buf);
// Selection type: visual or not.
(void)tv_dict_add_bool(dict, S_LEN("visual"),
oap->is_VIsual ? kBoolVarTrue : kBoolVarFalse);
tv_dict_add_bool(dict, S_LEN("visual"),
oap->is_VIsual ? kBoolVarTrue : kBoolVarFalse);
tv_dict_set_keys_readonly(dict);
textlock++;
@ -2934,7 +2926,7 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags)
if (flags & PUT_LINE) {
stuffcharReadbuff(command_start_char);
for (; count > 0; count--) {
(void)stuff_inserted(NUL, 1, count != 1);
stuff_inserted(NUL, 1, count != 1);
if (count != 1) {
// To avoid 'autoindent' affecting the text, use Ctrl_U to remove any
// whitespace. Can't just insert Ctrl_U into readbuf1, this would go
@ -2946,7 +2938,7 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags)
}
}
} else {
(void)stuff_inserted(command_start_char, count, false);
stuff_inserted(command_start_char, count, false);
}
// Putting the text is done later, so can't move the cursor to the next
@ -3124,9 +3116,9 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags)
// Correct line number for closed fold. Don't move the cursor yet,
// u_save() uses it.
if (dir == BACKWARD) {
(void)hasFolding(lnum, &lnum, NULL);
hasFolding(lnum, &lnum, NULL);
} else {
(void)hasFolding(lnum, NULL, &lnum);
hasFolding(lnum, NULL, &lnum);
}
if (dir == FORWARD) {
lnum++;
@ -3350,13 +3342,11 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags)
}
curbuf->b_op_end.coladd = 0;
if (flags & PUT_CURSEND) {
colnr_T len;
curwin->w_cursor = curbuf->b_op_end;
curwin->w_cursor.col++;
// in Insert mode we might be after the NUL, correct for that
len = (colnr_T)strlen(get_cursor_line_ptr());
colnr_T len = (colnr_T)strlen(get_cursor_line_ptr());
if (curwin->w_cursor.col > len) {
curwin->w_cursor.col = len;
}
@ -3539,7 +3529,7 @@ void do_put(int regname, yankreg_T *reg, int dir, int count, int flags)
} else if ((indent = get_indent() + indent_diff) < 0) {
indent = 0;
}
(void)set_indent(indent, SIN_NOMARK);
set_indent(indent, SIN_NOMARK);
curwin->w_cursor = old_pos;
// remember how many chars were removed
if (cnt == count && i == y_size - 1) {
@ -4379,7 +4369,7 @@ void op_addsub(oparg_T *oap, linenr_T Prenum1, bool g_cmd)
length = oap->end.col - pos.col + 1;
}
}
int one_change = do_addsub(oap->op_type, &pos, length, amount);
bool one_change = do_addsub(oap->op_type, &pos, length, amount);
if (one_change) {
// Remember the start position of the first change.
if (change_cnt == 0) {
@ -4424,7 +4414,7 @@ void op_addsub(oparg_T *oap, linenr_T Prenum1, bool g_cmd)
/// @param Prenum1 Amount of addition or subtraction.
///
/// @return true if some character was changed.
int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
bool do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
{
char *buf1 = NULL;
char buf2[NUMBUFLEN];
@ -4580,7 +4570,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
curwin->w_cursor.col = col;
startpos = curwin->w_cursor;
did_change = true;
(void)del_char(false);
del_char(false);
ins_char(firstdigit);
endpos = curwin->w_cursor;
curwin->w_cursor.col = col;
@ -4688,7 +4678,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
}
}
// del_char() will mark line needing displaying
(void)del_char(false);
del_char(false);
c = gchar_cursor();
}
@ -5229,16 +5219,16 @@ static varnumber_T line_count_info(char *line, varnumber_T *wc, varnumber_T *cc,
varnumber_T i;
varnumber_T words = 0;
varnumber_T chars = 0;
int is_word = 0;
bool is_word = false;
for (i = 0; i < limit && line[i] != NUL;) {
if (is_word) {
if (ascii_isspace(line[i])) {
words++;
is_word = 0;
is_word = false;
}
} else if (!ascii_isspace(line[i])) {
is_word = 1;
is_word = true;
}
chars++;
i += utfc_ptr2len(line + i);
@ -5526,7 +5516,7 @@ static void op_colon(oparg_T *oap)
// When using !! on a closed fold the range ".!" works best to operate
// on, it will be made the whole closed fold later.
linenr_T endOfStartFold = oap->start.lnum;
(void)hasFolding(oap->start.lnum, NULL, &endOfStartFold);
hasFolding(oap->start.lnum, NULL, &endOfStartFold);
if (oap->end.lnum != oap->start.lnum && oap->end.lnum != endOfStartFold) {
// Make it a range with the end line.
stuffcharReadbuff(',');
@ -5745,7 +5735,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
const bool redo_yank = vim_strchr(p_cpo, CPO_YANK) != NULL && !gui_yank;
// Avoid a problem with unwanted linebreaks in block mode
(void)reset_lbr();
reset_lbr();
oap->is_VIsual = VIsual_active;
if (oap->motion_force == 'V') {
oap->motion_type = kMTLineWise;
@ -6131,7 +6121,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
vim_beep(BO_OPER);
CancelRedo();
} else {
(void)op_delete(oap);
op_delete(oap);
// save cursor line for undo if it wasn't saved yet
if (oap->motion_type == kMTLineWise
&& has_format_option(FO_AUTO)
@ -6150,7 +6140,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
} else {
restore_lbr(lbr_saved);
oap->excl_tr_ws = cap->cmdchar == 'z';
(void)op_yank(oap, !gui_yank);
op_yank(oap, !gui_yank);
}
check_cursor_col();
break;
@ -6281,7 +6271,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
op_insert(oap, cap->count1);
// Reset linebreak, so that formatting works correctly.
(void)reset_lbr();
reset_lbr();
// TODO(brammool): when inserting in several lines, should format all
// the lines.
@ -6355,7 +6345,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
if (!p_sol && oap->motion_type == kMTLineWise && !oap->end_adjusted
&& (oap->op_type == OP_LSHIFT || oap->op_type == OP_RSHIFT
|| oap->op_type == OP_DELETE)) {
(void)reset_lbr();
reset_lbr();
coladvance(curwin->w_curswant = old_col);
}
} else {
@ -6685,7 +6675,7 @@ static void set_clipboard(int name, yankreg_T *reg)
tv_list_append_string(args, &regtype, 1);
tv_list_append_string(args, ((char[]) { (char)name }), 1);
(void)eval_call_provider("clipboard", "set", args, true);
eval_call_provider("clipboard", "set", args, true);
}
/// Avoid slow things (clipboard) during batch operations (while/for-loops).

View File

@ -420,7 +420,7 @@ void set_init_1(bool clean_arg)
/// TODO(famiu): Refactor this when def_val uses OptVal.
static void set_option_default(const OptIndex opt_idx, int opt_flags)
{
int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
bool both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
// pointer to variable for current option
vimoption_T *opt = &options[opt_idx];
@ -616,8 +616,8 @@ void set_init_3(void)
// Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
// This is done after other initializations, where 'shell' might have been
// set, but only if they have not been set before.
int do_srr = !(options[kOptShellredir].flags & P_WAS_SET);
int do_sp = !(options[kOptShellpipe].flags & P_WAS_SET);
bool do_srr = !(options[kOptShellredir].flags & P_WAS_SET);
bool do_sp = !(options[kOptShellpipe].flags & P_WAS_SET);
size_t len = 0;
char *p = (char *)invocation_path_tail(p_sh, &len);
@ -738,7 +738,7 @@ void ex_set(exarg_T *eap)
if (eap->forceit) {
flags |= OPT_ONECOLUMN;
}
(void)do_set(eap->arg, flags);
do_set(eap->arg, flags);
}
/// Get the default value for a string option.
@ -1674,18 +1674,18 @@ static char *option_expand(OptIndex opt_idx, char *val)
static void didset_options(void)
{
// initialize the table for 'iskeyword' et.al.
(void)init_chartab();
init_chartab();
didset_string_options();
(void)spell_check_msm();
(void)spell_check_sps();
(void)compile_cap_prog(curwin->w_s);
(void)did_set_spell_option(true);
spell_check_msm();
spell_check_sps();
compile_cap_prog(curwin->w_s);
did_set_spell_option(true);
// set cedit_key
(void)did_set_cedit(NULL);
did_set_cedit(NULL);
// initialize the table for 'breakat'.
(void)did_set_breakat(NULL);
did_set_breakat(NULL);
didset_window_options(curwin, true);
}
@ -1696,17 +1696,17 @@ static void didset_options2(void)
highlight_changed();
// Parse default for 'fillchars'.
(void)set_fillchars_option(curwin, curwin->w_p_fcs, true);
set_fillchars_option(curwin, curwin->w_p_fcs, true);
// Parse default for 'listchars'.
(void)set_listchars_option(curwin, curwin->w_p_lcs, true);
set_listchars_option(curwin, curwin->w_p_lcs, true);
// Parse default for 'wildmode'.
check_opt_wim();
xfree(curbuf->b_p_vsts_array);
(void)tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array);
tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array);
xfree(curbuf->b_p_vts_array);
(void)tabstop_set(curbuf->b_p_vts, &curbuf->b_p_vts_array);
tabstop_set(curbuf->b_p_vts, &curbuf->b_p_vts_array);
}
/// Check for string options that are NULL (normally only termcap options).
@ -1852,7 +1852,7 @@ sctx_T *get_option_sctx(OptIndex opt_idx)
/// window-local value.
void set_option_sctx(OptIndex opt_idx, int opt_flags, sctx_T script_ctx)
{
int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
bool both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
int indir = (int)options[opt_idx].indir;
nlua_set_sctx(&script_ctx);
LastSet last_set = {
@ -2183,14 +2183,14 @@ static const char *did_set_laststatus(optset_T *args)
// Also clear the cmdline to remove the ruler if there is one
if (value == 3 && old_value != 3) {
frame_new_height(topframe, topframe->fr_height - STATUS_HEIGHT, false, false);
(void)win_comp_pos();
win_comp_pos();
clear_cmdline = true;
}
// When switching from global statusline, increase height of topframe by STATUS_HEIGHT
// in order to to re-add the space that was previously taken by the global statusline
if (old_value == 3 && value != 3) {
frame_new_height(topframe, topframe->fr_height + STATUS_HEIGHT, false, false);
(void)win_comp_pos();
win_comp_pos();
}
last_status(false); // (re)set last window status line.
@ -2240,7 +2240,7 @@ static const char *did_set_lisp(optset_T *args)
{
buf_T *buf = (buf_T *)args->os_buf;
// When 'lisp' option changes include/exclude '-' in keyword characters.
(void)buf_init_chartab(buf, false); // ignore errors
buf_init_chartab(buf, false); // ignore errors
return NULL;
}
@ -2381,7 +2381,7 @@ static const char *did_set_paste(optset_T *args FUNC_ATTR_UNUSED)
buf->b_p_vsts = buf->b_p_vsts_nopaste ? xstrdup(buf->b_p_vsts_nopaste) : empty_string_option;
xfree(buf->b_p_vsts_array);
if (buf->b_p_vsts && buf->b_p_vsts != empty_string_option) {
(void)tabstop_set(buf->b_p_vsts, &buf->b_p_vsts_array);
tabstop_set(buf->b_p_vsts, &buf->b_p_vsts_array);
} else {
buf->b_p_vsts_array = NULL;
}
@ -3522,7 +3522,7 @@ static const char *did_set_option(OptIndex opt_idx, void *varp, OptVal old_value
set_option_varp(opt_idx, varp, old_value, true);
// When resetting some values, need to act on it.
if (restore_chartab) {
(void)buf_init_chartab(curbuf, true);
buf_init_chartab(curbuf, true);
}
// Unset new_value as it is no longer valid.
@ -4385,7 +4385,7 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char **valuep, uint64_
if (fprintf(fd, "%s %s+=", cmd, name) < 0) {
goto fail;
}
(void)copy_option_part(&p, part, size, ",");
copy_option_part(&p, part, size, ",");
if (put_escstr(fd, part, 2) == FAIL || put_eol(fd) == FAIL) {
goto fail;
}
@ -5149,7 +5149,7 @@ void buf_copy_options(buf_T *buf, int flags)
buf->b_p_vsts = xstrdup(p_vsts);
COPY_OPT_SCTX(buf, BV_VSTS);
if (p_vsts && p_vsts != empty_string_option) {
(void)tabstop_set(p_vsts, &buf->b_p_vsts_array);
tabstop_set(p_vsts, &buf->b_p_vsts_array);
} else {
buf->b_p_vsts_array = NULL;
}
@ -5198,7 +5198,7 @@ void buf_copy_options(buf_T *buf, int flags)
buf->b_s.b_syn_isk = empty_string_option;
buf->b_s.b_p_spc = xstrdup(p_spc);
COPY_OPT_SCTX(buf, BV_SPC);
(void)compile_cap_prog(&buf->b_s);
compile_cap_prog(&buf->b_s);
buf->b_s.b_p_spf = xstrdup(p_spf);
COPY_OPT_SCTX(buf, BV_SPF);
buf->b_s.b_p_spl = xstrdup(p_spl);
@ -5260,7 +5260,7 @@ void buf_copy_options(buf_T *buf, int flags)
if (dont_do_help) {
buf->b_p_isk = save_p_isk;
if (p_vts && p_vts != empty_string_option && !buf->b_p_vts_array) {
(void)tabstop_set(p_vts, &buf->b_p_vts_array);
tabstop_set(p_vts, &buf->b_p_vts_array);
} else {
buf->b_p_vts_array = NULL;
}
@ -5273,7 +5273,7 @@ void buf_copy_options(buf_T *buf, int flags)
buf->b_p_vts = xstrdup(p_vts);
COPY_OPT_SCTX(buf, BV_VTS);
if (p_vts && p_vts != empty_string_option && !buf->b_p_vts_array) {
(void)tabstop_set(p_vts, &buf->b_p_vts_array);
tabstop_set(p_vts, &buf->b_p_vts_array);
} else {
buf->b_p_vts_array = NULL;
}
@ -5295,7 +5295,7 @@ void buf_copy_options(buf_T *buf, int flags)
check_buf_options(buf); // make sure we don't have NULLs
if (did_isk) {
(void)buf_init_chartab(buf, false);
buf_init_chartab(buf, false);
}
}

View File

@ -148,21 +148,21 @@ static char SHM_ALL[] = { SHM_RO, SHM_MOD, SHM_LINES,
/// option values.
void didset_string_options(void)
{
(void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, true);
(void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, true);
(void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, true);
(void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, true);
(void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, true);
(void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, true);
(void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, true);
(void)opt_strings_flags(p_jop, p_jop_values, &jop_flags, true);
(void)opt_strings_flags(p_rdb, p_rdb_values, &rdb_flags, true);
(void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, false);
(void)opt_strings_flags(p_tpf, p_tpf_values, &tpf_flags, true);
(void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, true);
(void)opt_strings_flags(p_swb, p_swb_values, &swb_flags, true);
(void)opt_strings_flags(p_wop, p_wop_values, &wop_flags, true);
(void)opt_strings_flags(p_cb, p_cb_values, &cb_flags, true);
opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, true);
opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, true);
opt_strings_flags(p_bo, p_bo_values, &bo_flags, true);
opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, true);
opt_strings_flags(p_vop, p_ssop_values, &vop_flags, true);
opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, true);
opt_strings_flags(p_dy, p_dy_values, &dy_flags, true);
opt_strings_flags(p_jop, p_jop_values, &jop_flags, true);
opt_strings_flags(p_rdb, p_rdb_values, &rdb_flags, true);
opt_strings_flags(p_tc, p_tc_values, &tc_flags, false);
opt_strings_flags(p_tpf, p_tpf_values, &tpf_flags, true);
opt_strings_flags(p_ve, p_ve_values, &ve_flags, true);
opt_strings_flags(p_swb, p_swb_values, &swb_flags, true);
opt_strings_flags(p_wop, p_wop_values, &wop_flags, true);
opt_strings_flags(p_cb, p_cb_values, &cb_flags, true);
}
char *illegal_char(char *errbuf, size_t errbuflen, int c)
@ -301,7 +301,7 @@ void set_string_option_direct(OptIndex opt_idx, const char *val, int opt_flags,
assert(opt->var != &p_shada);
int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
bool both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
char *s = xstrdup(val);
char **varp = (char **)get_varp_scope(opt, both ? OPT_LOCAL : opt_flags);
@ -748,7 +748,7 @@ const char *did_set_backupcopy(optset_T *args)
+ ((*flags & BKC_YES) != 0)
+ ((*flags & BKC_NO) != 0) != 1) {
// Must have exactly one of "auto", "yes" and "no".
(void)opt_strings_flags(oldval, p_bkc_values, flags, true);
opt_strings_flags(oldval, p_bkc_values, flags, true);
return e_invarg;
}
}
@ -905,11 +905,11 @@ static const char *did_set_global_listfillchars(win_T *win, char *val, bool opt_
// here, so ignore the return value.
if (opt_lcs) {
if (*wp->w_p_lcs == NUL) {
(void)set_listchars_option(wp, wp->w_p_lcs, true);
set_listchars_option(wp, wp->w_p_lcs, true);
}
} else {
if (*wp->w_p_fcs == NUL) {
(void)set_fillchars_option(wp, wp->w_p_fcs, true);
set_fillchars_option(wp, wp->w_p_fcs, true);
}
}
}
@ -1220,7 +1220,7 @@ const char *did_set_display(optset_T *args FUNC_ATTR_UNUSED)
if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, true) != OK) {
return e_invarg;
}
(void)init_chartab();
init_chartab();
msg_grid_validate();
return NULL;
}
@ -1425,7 +1425,7 @@ int expand_set_foldcolumn(optexpand_T *args, int *numMatches, char ***matches)
const char *did_set_foldexpr(optset_T *args)
{
win_T *win = (win_T *)args->os_win;
(void)did_set_optexpr(args);
did_set_optexpr(args);
if (foldmethodIsExpr(win)) {
foldUpdateAll(win);
}
@ -1973,7 +1973,7 @@ const char *did_set_sessionoptions(optset_T *args)
if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) {
// Don't allow both "sesdir" and "curdir".
const char *oldval = args->os_oldval.string.data;
(void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, true);
opt_strings_flags(oldval, p_ssop_values, &ssop_flags, true);
return e_invarg;
}
return NULL;

View File

@ -587,7 +587,7 @@ void expand_env_esc(char *restrict srcp, char *restrict dst, int dstlen, bool es
if (src[0] == '`' && src[1] == '=') {
var = src;
src += 2;
(void)skip_expr(&src, NULL);
skip_expr(&src, NULL);
if (*src == '`') {
src++;
}
@ -1061,7 +1061,7 @@ size_t home_replace(const buf_T *const buf, const char *src, char *const dst, si
size_t usedlen = 0;
size_t flen = strlen(homedir_env_mod);
char *fbuf = NULL;
(void)modify_fname(":p", false, &usedlen, &homedir_env_mod, &fbuf, &flen);
modify_fname(":p", false, &usedlen, &homedir_env_mod, &fbuf, &flen);
flen = strlen(homedir_env_mod);
assert(homedir_env_mod != homedir_env);
if (vim_ispathsep(homedir_env_mod[flen - 1])) {

View File

@ -100,9 +100,7 @@ static char *get_mess_env(void)
/// Also do "v:lc_time"and "v:ctype".
void set_lang_var(void)
{
const char *loc;
loc = get_locale_val(LC_CTYPE);
const char *loc = get_locale_val(LC_CTYPE);
set_vim_var_string(VV_CTYPE, loc, -1);
loc = get_mess_env();
@ -143,8 +141,6 @@ void init_locale(void)
void ex_language(exarg_T *eap)
{
char *loc;
char *p;
char *name;
int what = LC_ALL;
char *whatstr = "";
#ifdef LC_MESSAGES
@ -153,12 +149,12 @@ void ex_language(exarg_T *eap)
# define VIM_LC_MESSAGES 6789
#endif
name = eap->arg;
char *name = eap->arg;
// Check for "messages {name}", "ctype {name}" or "time {name}" argument.
// Allow abbreviation, but require at least 3 characters to avoid
// confusion with a two letter language name "me" or "ct".
p = skiptowhite(eap->arg);
char *p = skiptowhite(eap->arg);
if ((*p == NUL || ascii_iswhite(*p)) && p - eap->arg >= 3) {
if (STRNICMP(eap->arg, "messages", p - eap->arg) == 0) {
what = VIM_LC_MESSAGES;
@ -249,7 +245,6 @@ static bool did_init_locales = false;
static char **find_locales(void)
{
garray_T locales_ga;
char *loc;
char *saveptr = NULL;
// Find all available locales by running command "locale -a". If this
@ -262,7 +257,7 @@ static char **find_locales(void)
// Transform locale_a string where each locale is separated by "\n"
// into an array of locale strings.
loc = os_strtok(locale_a, "\n", &saveptr);
char *loc = os_strtok(locale_a, "\n", &saveptr);
while (loc != NULL) {
loc = xstrdup(loc);

View File

@ -119,14 +119,10 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
int i;
size_t len;
char *p;
bool dir;
char *extra_shell_arg = NULL;
ShellOpts shellopts = kShellOptExpand | kShellOptSilent;
int j;
char *tempname;
char *command;
FILE *fd;
char *buffer;
#define STYLE_ECHO 0 // use "echo", the default
#define STYLE_GLOB 1 // use "glob", for csh
#define STYLE_VIMGLOB 2 // use "vimglob", for Posix sh
@ -242,7 +238,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
len += sizeof("egin;" " end") - 1;
}
command = xmalloc(len);
char *command = xmalloc(len);
// Build the shell command:
// - Set $nonomatch depending on EW_NOTFOUND (hopefully the shell
@ -390,7 +386,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
}
// read the names from the file into memory
fd = fopen(tempname, READBIN);
FILE *fd = fopen(tempname, READBIN);
if (fd == NULL) {
// Something went wrong, perhaps a file name with a special char.
if (!(flags & EW_SILENT)) {
@ -417,7 +413,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
#endif
len = (size_t)templen;
fseek(fd, 0, SEEK_SET);
buffer = xmalloc(len + 1);
char *buffer = xmalloc(len + 1);
// fread() doesn't terminate buffer with NUL;
// appropriate termination (not always NUL) is done below.
size_t readlen = fread(buffer, 1, len, fd);
@ -538,7 +534,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
}
// check if this entry should be included
dir = (os_isdir((*file)[i]));
bool dir = (os_isdir((*file)[i]));
if ((dir && !(flags & EW_DIR)) || (!dir && !(flags & EW_FILE))) {
continue;
}
@ -704,7 +700,7 @@ int os_call_shell(char *cmd, ShellOpts opts, char *extra_args)
xfree(input.data);
if (output) {
(void)write_output(output, nread, true);
write_output(output, nread, true);
xfree(output);
}
@ -1144,7 +1140,7 @@ static void out_data_append_to_screen(char *output, size_t *count, bool eof)
goto end;
}
(void)msg_outtrans_len(p, i, 0);
msg_outtrans_len(p, i, 0);
p += i;
}
}

View File

@ -717,7 +717,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in
&& *path_end == '/') {
STRCPY(s, path_end + 1);
stardepth++;
(void)do_path_expand(gap, buf, (size_t)(s - buf), flags, true);
do_path_expand(gap, buf, (size_t)(s - buf), flags, true);
stardepth--;
}
*s = NUL;
@ -746,7 +746,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in
STRCPY(buf + len, "/**"); // NOLINT
STRCPY(buf + len + 3, path_end);
stardepth++;
(void)do_path_expand(gap, buf, len + 1, flags, true);
do_path_expand(gap, buf, len + 1, flags, true);
stardepth--;
}
@ -754,7 +754,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in
if (path_has_exp_wildcard(path_end)) { // handle more wildcards
// need to expand another component of the path
// remove backslashes for the remaining components only
(void)do_path_expand(gap, buf, len + 1, flags, false);
do_path_expand(gap, buf, len + 1, flags, false);
} else {
FileInfo file_info;
@ -1965,7 +1965,7 @@ bool same_directory(char *f1, char *f2)
return false;
}
(void)vim_FullName(f1, ffname, MAXPATHL, false);
vim_FullName(f1, ffname, MAXPATHL, false);
t1 = path_tail_with_sep(ffname);
t2 = path_tail_with_sep(f2);
return t1 - ffname == t2 - f2

View File

@ -108,7 +108,7 @@ void win_linetabsize_cts(chartabsize_T *cts, colnr_T len)
}
// check for inline virtual text after the end of the line
if (len == MAXCOL && cts->cts_has_virt_text && *cts->cts_ptr == NUL) {
(void)win_lbr_chartabsize(cts, NULL);
win_lbr_chartabsize(cts, NULL);
cts->cts_vcol += cts->cts_cur_text_width_left + cts->cts_cur_text_width_right;
}
}

View File

@ -78,21 +78,20 @@ static void pum_compute_size(void)
pum_kind_width = 0;
pum_extra_width = 0;
for (int i = 0; i < pum_size; i++) {
int w;
if (pum_array[i].pum_text != NULL) {
w = vim_strsize(pum_array[i].pum_text);
int w = vim_strsize(pum_array[i].pum_text);
if (pum_base_width < w) {
pum_base_width = w;
}
}
if (pum_array[i].pum_kind != NULL) {
w = vim_strsize(pum_array[i].pum_kind) + 1;
int w = vim_strsize(pum_array[i].pum_kind) + 1;
if (pum_kind_width < w) {
pum_kind_width = w;
}
}
if (pum_array[i].pum_extra != NULL) {
w = vim_strsize(pum_array[i].pum_extra) + 1;
int w = vim_strsize(pum_array[i].pum_extra) + 1;
if (pum_extra_width < w) {
pum_extra_width = w;
}
@ -776,7 +775,7 @@ win_T *pum_set_info(int pum_idx, char *info)
} else {
// clean exist buffer
while (!buf_is_empty(wp->w_buffer)) {
ml_delete_buf(wp->w_buffer, (linenr_T)1, false);
ml_delete_buf(wp->w_buffer, 1, false);
}
}
no_u_sync--;
@ -1139,13 +1138,13 @@ void pum_set_event_info(dict_T *dict)
r = (double)pum_row;
c = (double)pum_col;
}
(void)tv_dict_add_float(dict, S_LEN("height"), h);
(void)tv_dict_add_float(dict, S_LEN("width"), w);
(void)tv_dict_add_float(dict, S_LEN("row"), r);
(void)tv_dict_add_float(dict, S_LEN("col"), c);
(void)tv_dict_add_nr(dict, S_LEN("size"), pum_size);
(void)tv_dict_add_bool(dict, S_LEN("scrollbar"),
pum_scrollbar ? kBoolVarTrue : kBoolVarFalse);
tv_dict_add_float(dict, S_LEN("height"), h);
tv_dict_add_float(dict, S_LEN("width"), w);
tv_dict_add_float(dict, S_LEN("row"), r);
tv_dict_add_float(dict, S_LEN("col"), c);
tv_dict_add_nr(dict, S_LEN("size"), pum_size);
tv_dict_add_bool(dict, S_LEN("scrollbar"),
pum_scrollbar ? kBoolVarTrue : kBoolVarFalse);
}
static void pum_position_at_mouse(int min_width)

View File

@ -254,7 +254,7 @@ void profile_reset(void)
size_t todo = functbl->ht_used;
hashitem_T *hi = functbl->ht_array;
for (; todo > (size_t)0; hi++) {
for (; todo > 0; hi++) {
if (!HASHITEM_EMPTY(hi)) {
todo--;
ufunc_T *uf = HI2UF(hi);
@ -797,7 +797,7 @@ void script_line_start(void)
if (si->sn_prof_on && SOURCING_LNUM >= 1) {
// Grow the array before starting the timer, so that the time spent
// here isn't counted.
(void)ga_grow(&si->sn_prl_ga, SOURCING_LNUM - si->sn_prl_ga.ga_len);
ga_grow(&si->sn_prl_ga, SOURCING_LNUM - si->sn_prl_ga.ga_len);
si->sn_prl_idx = SOURCING_LNUM - 1;
while (si->sn_prl_ga.ga_len <= si->sn_prl_idx
&& si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen) {

View File

@ -1603,7 +1603,7 @@ static int qf_parse_get_fields(char *linebuf, size_t linelen, efm_T *fmt_ptr, qf
// Always ignore case when looking for a matching error.
regmatch.rm_ic = true;
regmatch.regprog = fmt_ptr->prog;
int r = vim_regexec(&regmatch, linebuf, 0);
bool r = vim_regexec(&regmatch, linebuf, 0);
fmt_ptr->prog = regmatch.regprog;
int status = QF_FAIL;
if (r) {
@ -1970,7 +1970,7 @@ static qf_info_T *ll_get_or_alloc_list(win_T *wp)
/// For a location list command, returns the stack for the current window. If
/// the location list is not found, then returns NULL and prints an error
/// message if 'print_emsg' is true.
static qf_info_T *qf_cmd_get_stack(exarg_T *eap, int print_emsg)
static qf_info_T *qf_cmd_get_stack(exarg_T *eap, bool print_emsg)
{
qf_info_T *qi = &ql_info;
@ -2512,7 +2512,7 @@ static void win_set_loclist(win_T *wp, qf_info_T *qi)
/// Find a help window or open one. If 'newwin' is true, then open a new help
/// window.
static int jump_to_help_window(qf_info_T *qi, bool newwin, int *opened_window)
static int jump_to_help_window(qf_info_T *qi, bool newwin, bool *opened_window)
{
win_T *wp = NULL;
@ -2715,7 +2715,7 @@ static void qf_goto_win_with_qfl_file(int qf_fnum)
// window, jump to it. Otherwise open a new window to display the file. If
// 'newwin' is true, then always open a new window. This is called from either
// a quickfix or a location list window.
static int qf_jump_to_usable_window(int qf_fnum, bool newwin, int *opened_window)
static int qf_jump_to_usable_window(int qf_fnum, bool newwin, bool *opened_window)
{
win_T *usable_wp = NULL;
bool usable_win = false;
@ -2770,7 +2770,7 @@ static int qf_jump_to_usable_window(int qf_fnum, bool newwin, int *opened_window
/// QF_ABORT if the quickfix/location list was freed by an autocmd
/// when opening the buffer.
static int qf_jump_edit_buffer(qf_info_T *qi, qfline_T *qf_ptr, int forceit, int prev_winid,
int *opened_window)
bool *opened_window)
{
qf_list_T *qfl = qf_get_curlist(qi);
int old_changetick = qfl->qf_changedtick;
@ -2905,7 +2905,7 @@ static void qf_jump_print_msg(qf_info_T *qi, int qf_index, qfline_T *qf_ptr, buf
/// FAIL if not able to jump/open a window.
/// NOTDONE if a file is not associated with the entry.
/// QF_ABORT if the quickfix/location list was modified by an autocmd.
static int qf_jump_open_window(qf_info_T *qi, qfline_T *qf_ptr, bool newwin, int *opened_window)
static int qf_jump_open_window(qf_info_T *qi, qfline_T *qf_ptr, bool newwin, bool *opened_window)
{
qf_list_T *qfl = qf_get_curlist(qi);
int old_changetick = qfl->qf_changedtick;
@ -2964,7 +2964,7 @@ static int qf_jump_open_window(qf_info_T *qi, qfline_T *qf_ptr, bool newwin, int
/// QF_ABORT if the quickfix/location list is freed by an autocmd when opening
/// the file.
static int qf_jump_to_buffer(qf_info_T *qi, int qf_index, qfline_T *qf_ptr, int forceit,
int prev_winid, int *opened_window, int openfold, int print_message)
int prev_winid, bool *opened_window, int openfold, bool print_message)
{
// If there is a file name, read the wanted file if needed, and check
// autowrite etc.
@ -3051,7 +3051,7 @@ static void qf_jump_newwin(qf_info_T *qi, int dir, int errornr, int forceit, boo
int prev_winid = curwin->handle;
int opened_window = false;
bool opened_window = false;
int retval = qf_jump_open_window(qi, qf_ptr, newwin, &opened_window);
if (retval == FAIL) {
goto failed;
@ -3988,7 +3988,7 @@ static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
buf_inc_changedtick(buf);
if (old_last == NULL) {
(void)qf_win_pos_update(qi, 0);
qf_win_pos_update(qi, 0);
// restore curwin/curbuf and a few other things
aucmd_restbuf(&aco);
@ -4199,7 +4199,7 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int q
}
if (old_last == NULL) {
// Delete the empty line which is now at the end
(void)ml_delete(lnum + 1, false);
ml_delete(lnum + 1, false);
}
qfga_clear();
@ -4583,7 +4583,7 @@ int qf_get_cur_valid_idx(exarg_T *eap)
/// Used by :cdo, :ldo, :cfdo and :lfdo commands.
/// For :cdo and :ldo, returns the 'n'th valid error entry.
/// For :cfdo and :lfdo, returns the 'n'th valid file entry.
static size_t qf_get_nth_valid_entry(qf_list_T *qfl, size_t n, int fdo)
static size_t qf_get_nth_valid_entry(qf_list_T *qfl, size_t n, bool fdo)
FUNC_ATTR_NONNULL_ALL
{
// Check if the list has valid errors.
@ -5706,7 +5706,7 @@ static buf_T *load_dummy_buffer(char *fname, char *dirname_start, char *resultin
aucmd_prepbuf(&aco, newbuf);
// Need to set the filename for autocommands.
(void)setfname(curbuf, fname, NULL, false);
setfname(curbuf, fname, NULL, false);
// Create swap file now to avoid the ATTENTION message.
check_need_swap(true);
@ -5958,7 +5958,7 @@ static int qf_get_list_from_lines(dict_T *what, dictitem_T *di, dict_T *retdict)
if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat,
true, 0, 0, NULL, NULL) > 0) {
(void)get_errorlist(qi, NULL, 0, 0, l);
get_errorlist(qi, NULL, 0, 0, l);
qf_free(&qi->qf_lists[0]);
}
xfree(qi);
@ -7324,7 +7324,7 @@ static void get_qf_loc_list(bool is_qf, win_T *wp, typval_T *what_arg, typval_T
if (what_arg->v_type == VAR_UNKNOWN) {
tv_list_alloc_ret(rettv, kListLenMayKnow);
if (is_qf || wp != NULL) {
(void)get_errorlist(NULL, wp, -1, 0, rettv->vval.v_list);
get_errorlist(NULL, wp, -1, 0, rettv->vval.v_list);
}
} else {
tv_dict_alloc_ret(rettv);

View File

@ -213,7 +213,7 @@ int rbuffer_cmp(RBuffer *buf, const char *str, size_t count)
{
assert(count <= buf->size);
size_t rcnt;
(void)rbuffer_read_ptr(buf, &rcnt);
rbuffer_read_ptr(buf, &rcnt);
size_t n = MIN(count, rcnt);
int rv = memcmp(str, buf->read_ptr, n);
count -= n;

View File

@ -303,7 +303,7 @@ static bool source_callback_vim_lua(int num_fnames, char **fnames, bool all, voi
for (int i = 0; i < num_fnames; i++) {
if (path_with_extension(fnames[i], "vim")) {
(void)do_source(fnames[i], false, DOSO_NONE, cookie);
do_source(fnames[i], false, DOSO_NONE, cookie);
did_one = true;
if (!all) {
return true;
@ -313,7 +313,7 @@ static bool source_callback_vim_lua(int num_fnames, char **fnames, bool all, voi
for (int i = 0; i < num_fnames; i++) {
if (path_with_extension(fnames[i], "lua")) {
(void)do_source(fnames[i], false, DOSO_NONE, cookie);
do_source(fnames[i], false, DOSO_NONE, cookie);
did_one = true;
if (!all) {
return true;
@ -337,7 +337,7 @@ static bool source_callback(int num_fnames, char **fnames, bool all, void *cooki
for (int i = 0; i < num_fnames; i++) {
if (!path_with_extension(fnames[i], "vim")
&& !path_with_extension(fnames[i], "lua")) {
(void)do_source(fnames[i], false, DOSO_NONE, cookie);
do_source(fnames[i], false, DOSO_NONE, cookie);
did_one = true;
if (!all) {
return true;
@ -1804,7 +1804,7 @@ void ex_options(exarg_T *eap)
bool multi_mods = 0;
buf[0] = NUL;
(void)add_win_cmd_modifiers(buf, &cmdmod, &multi_mods);
add_win_cmd_modifiers(buf, &cmdmod, &multi_mods);
os_setenv("OPTWIN_CMD", buf, 1);
cmd_source(SYS_OPTWIN_FILE, NULL);
@ -1845,7 +1845,7 @@ static FILE *fopen_noinh_readbin(char *filename)
return NULL;
}
(void)os_set_cloexec(fd_tmp);
os_set_cloexec(fd_tmp);
return fdopen(fd_tmp, READBIN);
}
@ -2623,7 +2623,7 @@ static char *get_one_sourceline(struct source_cookie *sp)
int c;
char *buf;
#ifdef USE_CRNL
int has_cr; // CR-LF found
bool has_cr; // CR-LF found
#endif
bool have_read = false;

View File

@ -101,7 +101,7 @@ static int last_idx = 0; // index in spats[] for RE_LAST
static uint8_t lastc[2] = { NUL, NUL }; // last character searched for
static Direction lastcdir = FORWARD; // last direction of character search
static int last_t_cmd = true; // last search t_cmd
static bool last_t_cmd = true; // last search t_cmd
static char lastc_bytes[MB_MAXBYTES + 1];
static int lastc_bytelen = 1; // >1 for multi-byte char
@ -388,7 +388,7 @@ bool pat_has_uppercase(char *pat)
magic_T magic_val = MAGIC_ON;
// get the magicness of the pattern
(void)skip_regexp_ex(pat, NUL, magic_isset(), NULL, NULL, &magic_val);
skip_regexp_ex(pat, NUL, magic_isset(), NULL, NULL, &magic_val);
while (*p != NUL) {
const int l = utfc_ptr2len(p);
@ -436,7 +436,7 @@ int last_csearch_forward(void)
int last_csearch_until(void)
{
return last_t_cmd == true;
return last_t_cmd;
}
void set_last_csearch(int c, char *s, int len)
@ -474,7 +474,7 @@ void reset_search_dir(void)
// Set the last search pattern. For ":let @/ =" and ShaDa file.
// Also set the saved search pattern, so that this works in an autocommand.
void set_last_search_pat(const char *s, int idx, int magic, int setlast)
void set_last_search_pat(const char *s, int idx, int magic, bool setlast)
{
free_spat(&spats[idx]);
// An empty string means that nothing should be matched.
@ -521,7 +521,7 @@ void last_pat_prog(regmmatch_T *regmatch)
return;
}
emsg_off++; // So it doesn't beep if bad expr
(void)search_regcomp("", NULL, 0, last_idx, SEARCH_KEEP, regmatch);
search_regcomp("", NULL, 0, last_idx, SEARCH_KEEP, regmatch);
emsg_off--;
}
@ -1495,7 +1495,7 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, Direction dir, char *pat)
/// position of the character, otherwise move to just before the char.
/// Do this "cap->count1" times.
/// Return FAIL or OK.
int searchc(cmdarg_T *cap, int t_cmd)
int searchc(cmdarg_T *cap, bool t_cmd)
FUNC_ATTR_NONNULL_ALL
{
int c = cap->nchar; // char to search for
@ -2518,7 +2518,7 @@ int current_search(int count, bool forward)
/// else from position "cur".
/// "direction" is FORWARD or BACKWARD.
/// Returns true, false or -1 for failure.
static int is_zero_width(char *pattern, int move, pos_T *cur, Direction direction)
static int is_zero_width(char *pattern, bool move, pos_T *cur, Direction direction)
{
regmmatch_T regmatch;
int result = -1;
@ -2574,8 +2574,8 @@ static int is_zero_width(char *pattern, int move, pos_T *cur, Direction directio
return result;
}
/// return true if line 'lnum' is empty or has white chars only.
int linewhite(linenr_T lnum)
/// @return true if line 'lnum' is empty or has white chars only.
bool linewhite(linenr_T lnum)
{
char *p = skipwhite(ml_get(lnum));
return *p == NUL;
@ -3557,7 +3557,6 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool
char *curr_fname = curbuf->b_fname;
char *prev_fname = NULL;
int depth_displayed; // For type==CHECK_PATH
int already_searched;
char *p;
bool define_matched;
regmatch_T regmatch;
@ -3643,7 +3642,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool
FNAME_EXP|FNAME_INCL|FNAME_REL, 1, p_fname,
NULL);
}
already_searched = false;
bool already_searched = false;
if (new_fname != NULL) {
// Check whether we have already searched in this file
for (i = 0;; i++) {

View File

@ -1252,7 +1252,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
// string is close to useless: you can only use it with :& or :~ and
// thats all because s//~ is not available until the first call to
// regtilde. Vim was not calling this for some reason.
(void)regtilde(cur_entry.data.sub_string.sub, magic_isset(), false);
regtilde(cur_entry.data.sub_string.sub, magic_isset(), false);
// Do not free shada entry: its allocated memory was saved above.
break;
case kSDItemHistoryEntry:
@ -4024,7 +4024,7 @@ static bool shada_removable(const char *name)
char *new_name = home_replace_save(NULL, name);
for (char *p = p_shada; *p;) {
(void)copy_option_part(&p, part, ARRAY_SIZE(part), ", ");
copy_option_part(&p, part, ARRAY_SIZE(part), ", ");
if (part[0] == 'r') {
home_replace(NULL, part + 1, NameBuff, MAXPATHL, true);
size_t n = strlen(NameBuff);

View File

@ -719,7 +719,7 @@ static void sign_jump_cmd(buf_T *buf, linenr_T lnum, const char *name, int id, c
return;
}
(void)sign_jump(id, group, buf);
sign_jump(id, group, buf);
}
/// Parse the command line arguments for the ":sign place", ":sign unplace" and

View File

@ -176,7 +176,7 @@ typedef struct syl_item_S {
} syl_item_T;
spelltab_T spelltab;
int did_set_spelltab;
bool did_set_spelltab;
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "spell.c.generated.h"
@ -297,8 +297,8 @@ size_t spell_check(win_T *wp, char *ptr, hlf_T *attrp, int *capcol, bool docount
MB_PTR_ADV(mi.mi_fend);
}
(void)spell_casefold(wp, ptr, (int)(mi.mi_fend - ptr), mi.mi_fword,
MAXWLEN + 1);
spell_casefold(wp, ptr, (int)(mi.mi_fend - ptr), mi.mi_fword,
MAXWLEN + 1);
mi.mi_fwordlen = (int)strlen(mi.mi_fword);
if (is_camel_case && mi.mi_fwordlen > 0) {
@ -363,7 +363,7 @@ size_t spell_check(win_T *wp, char *ptr, hlf_T *attrp, int *capcol, bool docount
// Check for end of sentence.
regmatch.regprog = wp->w_s->b_cap_prog;
regmatch.rm_ic = false;
int r = vim_regexec(&regmatch, ptr, 0);
bool r = vim_regexec(&regmatch, ptr, 0);
wp->w_s->b_cap_prog = regmatch.regprog;
if (r) {
*capcol = (int)(regmatch.endp[0] - ptr);
@ -802,7 +802,7 @@ static void find_word(matchinf_T *mip, int mode)
if (slang->sl_compsylmax < MAXWLEN) {
// "fword" is only needed for checking syllables.
if (ptr == mip->mi_word) {
(void)spell_casefold(mip->mi_win, ptr, wlen, fword, MAXWLEN);
spell_casefold(mip->mi_win, ptr, wlen, fword, MAXWLEN);
} else {
xstrlcpy(fword, ptr, (size_t)endlen[endidxcnt] + 1);
}
@ -1212,9 +1212,9 @@ static int fold_more(matchinf_T *mip)
MB_PTR_ADV(mip->mi_fend);
}
(void)spell_casefold(mip->mi_win, p, (int)(mip->mi_fend - p),
mip->mi_fword + mip->mi_fwordlen,
MAXWLEN - mip->mi_fwordlen);
spell_casefold(mip->mi_win, p, (int)(mip->mi_fend - p),
mip->mi_fword + mip->mi_fwordlen,
MAXWLEN - mip->mi_fwordlen);
int flen = (int)strlen(mip->mi_fword + mip->mi_fwordlen);
mip->mi_fwordlen += flen;
return flen;
@ -1272,7 +1272,7 @@ static TriState decor_spell_nav_col(win_T *wp, linenr_T lnum, linenr_T *decor_ln
static inline bool can_syn_spell(win_T *wp, linenr_T lnum, int col)
{
bool can_spell;
(void)syn_get_id(wp, lnum, col, false, &can_spell, false);
syn_get_id(wp, lnum, col, false, &can_spell, false);
return can_spell;
}
@ -1293,7 +1293,7 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att
size_t found_len = 0;
hlf_T attr = HLF_COUNT;
size_t len;
int has_syntax = syntax_present(wp);
bool has_syntax = syntax_present(wp);
colnr_T col;
char *buf = NULL;
size_t buflen = 0;
@ -2029,7 +2029,7 @@ char *parse_spelllang(win_T *wp)
// If not found try loading the language now.
if (slang == NULL) {
if (filename) {
(void)spell_load_file(lang, lang, NULL, false);
spell_load_file(lang, lang, NULL, false);
} else {
spell_load_lang(lang);
// SpellFileMissing autocommands may do anything, including
@ -2374,7 +2374,7 @@ void spell_reload(void)
// window for this buffer in which 'spell' is set.
if (*wp->w_s->b_p_spl != NUL) {
if (wp->w_p_spell) {
(void)parse_spelllang(wp);
parse_spelllang(wp);
break;
}
}
@ -2834,7 +2834,7 @@ void spell_soundfold(slang_T *slang, char *inword, bool folded, char *res)
if (folded) {
word = inword;
} else {
(void)spell_casefold(curwin, inword, (int)strlen(inword), fword, MAXWLEN);
spell_casefold(curwin, inword, (int)strlen(inword), fword, MAXWLEN);
word = fword;
}

View File

@ -11,7 +11,7 @@ extern slang_T *first_lang;
extern char *int_wordlist;
extern spelltab_T spelltab;
extern int did_set_spelltab;
extern bool did_set_spelltab;
extern char *e_format;

View File

@ -2015,16 +2015,16 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname)
spell_message(spin, IObuff);
// Only do REP lines when not done in another .aff file already.
int do_rep = GA_EMPTY(&spin->si_rep);
bool do_rep = GA_EMPTY(&spin->si_rep);
// Only do REPSAL lines when not done in another .aff file already.
int do_repsal = GA_EMPTY(&spin->si_repsal);
bool do_repsal = GA_EMPTY(&spin->si_repsal);
// Only do SAL lines when not done in another .aff file already.
int do_sal = GA_EMPTY(&spin->si_sal);
bool do_sal = GA_EMPTY(&spin->si_sal);
// Only do MAP lines when not done in another .aff file already.
int do_mapline = GA_EMPTY(&spin->si_map);
bool do_mapline = GA_EMPTY(&spin->si_map);
// Allocate and init the afffile_T structure.
afffile_T *aff = getroom(spin, sizeof(*aff), true);
@ -2967,9 +2967,9 @@ static void add_fromto(spellinfo_T *spin, garray_T *gap, char *from, char *to)
char word[MAXWLEN];
fromto_T *ftp = GA_APPEND_VIA_PTR(fromto_T, gap);
(void)spell_casefold(curwin, from, (int)strlen(from), word, MAXWLEN);
spell_casefold(curwin, from, (int)strlen(from), word, MAXWLEN);
ftp->ft_from = getroom_save(spin, word);
(void)spell_casefold(curwin, to, (int)strlen(to), word, MAXWLEN);
spell_casefold(curwin, to, (int)strlen(to), word, MAXWLEN);
ftp->ft_to = getroom_save(spin, word);
}
@ -3614,11 +3614,9 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname)
smsg(0, _("/encoding= line after word ignored in %s line %" PRIdLINENR ": %s"),
fname, lnum, line - 1);
} else {
char *enc;
// Setup for conversion to 'encoding'.
line += 9;
enc = enc_canonize(line);
char *enc = enc_canonize(line);
if (!spin->si_ascii
&& convert_setup(&spin->si_conv, enc, p_enc) == FAIL) {
smsg(0, _("Conversion in %s not supported: from %s to %s"),
@ -3820,7 +3818,7 @@ static int store_word(spellinfo_T *spin, char *word, int flags, int region, cons
return FAIL;
}
(void)spell_casefold(curwin, word, len, foldword, MAXWLEN);
spell_casefold(curwin, word, len, foldword, MAXWLEN);
for (const char *p = pfxlist; res == OK; p++) {
if (!need_affix || (p != NULL && *p != NUL)) {
res = tree_add_word(spin, foldword, spin->si_foldroot, ct | flags,
@ -4593,7 +4591,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
spin->si_memtot += (int)(nodecount + nodecount * sizeof(int));
// Write the nodes.
(void)put_node(fd, tree, 0, regionmask, round == 3);
put_node(fd, tree, 0, regionmask, round == 3);
}
// Write another byte to check for errors (file system full).
@ -5098,7 +5096,7 @@ static void sug_write(spellinfo_T *spin, char *fname)
spin->si_memtot += (int)(nodecount + nodecount * sizeof(int));
// Write the nodes.
(void)put_node(fd, tree, 0, 0, false);
put_node(fd, tree, 0, 0, false);
// <SUGTABLE>: <sugwcount> <sugline> ...
linenr_T wcount = spin->si_spellbuf->b_ml.ml_line_count;
@ -5638,7 +5636,7 @@ static void set_spell_charflags(const char *flags_in, int cnt, const char *fol)
}
}
(void)set_spell_finish(&new_st);
set_spell_finish(&new_st);
}
static int set_spell_finish(spelltab_T *new_st)

View File

@ -442,7 +442,7 @@ void spell_suggest(int count)
char wcopy[MAXWLEN + 2];
suginfo_T sug;
suggest_T *stp;
int mouse_used;
bool mouse_used;
int limit;
int selected = count;
int badlen = 0;
@ -730,8 +730,8 @@ static void spell_find_suggest(char *badptr, int badlen, suginfo_T *su, int maxc
su->su_badlen = MAXWLEN - 1; // just in case
}
xstrlcpy(su->su_badword, su->su_badptr, (size_t)su->su_badlen + 1);
(void)spell_casefold(curwin, su->su_badptr, su->su_badlen, su->su_fbadword,
MAXWLEN);
spell_casefold(curwin, su->su_badptr, su->su_badlen, su->su_fbadword,
MAXWLEN);
// TODO(vim): make this work if the case-folded text is longer than the
// original text. Currently an illegal byte causes wrong pointer
@ -845,7 +845,7 @@ static void spell_suggest_expr(suginfo_T *su, char *expr)
// Remove bogus suggestions, sort and truncate at "maxcount".
check_suggestions(su, &su->su_ga);
(void)cleanup_suggestions(&su->su_ga, su->su_maxscore, su->su_maxcount);
cleanup_suggestions(&su->su_ga, su->su_maxscore, su->su_maxcount);
}
/// Find suggestions in file "fname". Used for "file:" in 'spellsuggest'.
@ -892,7 +892,7 @@ static void spell_suggest_file(suginfo_T *su, char *fname)
// Remove bogus suggestions, sort and truncate at "maxcount".
check_suggestions(su, &su->su_ga);
(void)cleanup_suggestions(&su->su_ga, su->su_maxscore, su->su_maxcount);
cleanup_suggestions(&su->su_ga, su->su_maxscore, su->su_maxcount);
}
/// Find suggestions for the internal method indicated by "sps_flags".
@ -956,7 +956,7 @@ static void spell_suggest_intern(suginfo_T *su, bool interactive)
// got_int when using a command, not for spellsuggest().
os_breakcheck();
if (interactive && got_int) {
(void)vgetc();
vgetc();
got_int = false;
}
@ -968,7 +968,7 @@ static void spell_suggest_intern(suginfo_T *su, bool interactive)
// Remove bogus suggestions, sort and truncate at "maxcount".
check_suggestions(su, &su->su_ga);
(void)cleanup_suggestions(&su->su_ga, su->su_maxscore, su->su_maxcount);
cleanup_suggestions(&su->su_ga, su->su_maxscore, su->su_maxcount);
}
}
@ -1064,7 +1064,7 @@ static void suggest_try_change(suginfo_T *su)
STRCPY(fword, su->su_fbadword);
int n = (int)strlen(fword);
char *p = su->su_badptr + su->su_badlen;
(void)spell_casefold(curwin, p, (int)strlen(p), fword + n, MAXWLEN - n);
spell_casefold(curwin, p, (int)strlen(p), fword + n, MAXWLEN - n);
// Make sure the resulting text is not longer than the original text.
n = (int)strlen(su->su_badptr);
@ -1272,10 +1272,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
break;
}
int fword_ends = (fword[sp->ts_fidx] == NUL
|| (soundfold
? ascii_iswhite(fword[sp->ts_fidx])
: !spell_iswordp(fword + sp->ts_fidx, curwin)));
bool fword_ends = (fword[sp->ts_fidx] == NUL
|| (soundfold
? ascii_iswhite(fword[sp->ts_fidx])
: !spell_iswordp(fword + sp->ts_fidx, curwin)));
tword[sp->ts_twordlen] = NUL;
if (sp->ts_prefixdepth <= PFD_NOTSPECIAL
@ -2538,8 +2538,8 @@ static void score_combine(suginfo_T *su)
}
if (slang == NULL) { // Using "double" without sound folding.
(void)cleanup_suggestions(&su->su_ga, su->su_maxscore,
su->su_maxcount);
cleanup_suggestions(&su->su_ga, su->su_maxscore,
su->su_maxcount);
return;
}
@ -2558,9 +2558,9 @@ static void score_combine(suginfo_T *su)
// Remove bad suggestions, sort the suggestions and truncate at "maxcount"
// for both lists.
check_suggestions(su, &su->su_ga);
(void)cleanup_suggestions(&su->su_ga, su->su_maxscore, su->su_maxcount);
cleanup_suggestions(&su->su_ga, su->su_maxscore, su->su_maxcount);
check_suggestions(su, &su->su_sga);
(void)cleanup_suggestions(&su->su_sga, su->su_maxscore, su->su_maxcount);
cleanup_suggestions(&su->su_sga, su->su_maxscore, su->su_maxcount);
ga_init(&ga, (int)sizeof(suginfo_T), 1);
ga_grow(&ga, su->su_ga.ga_len + su->su_sga.ga_len);
@ -2621,7 +2621,7 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char *ba
pbad = badsound;
} else {
// soundfold the bad word with more characters following
(void)spell_casefold(curwin, su->su_badptr, stp->st_orglen, fword, MAXWLEN);
spell_casefold(curwin, su->su_badptr, stp->st_orglen, fword, MAXWLEN);
// When joining two words the sound often changes a lot. E.g., "t he"
// sounds like "t h" while "the" sounds like "@". Avoid that by
@ -3148,7 +3148,7 @@ static void check_suggestions(suginfo_T *su, garray_T *gap)
int len = stp[i].st_wordlen;
xstrlcpy(longword + len, su->su_badptr + stp[i].st_orglen, MAXWLEN + 1 - (size_t)len);
hlf_T attr = HLF_COUNT;
(void)spell_check(curwin, longword, &attr, NULL, false);
spell_check(curwin, longword, &attr, NULL, false);
if (attr != HLF_COUNT) {
// Remove this entry.
xfree(stp[i].st_word);

View File

@ -74,7 +74,7 @@ getkey:
// Call `os_inchar` directly to block for events or user input without
// consuming anything from `input_buffer`(os/input.c) or calling the
// mapping engine.
(void)os_inchar(NULL, 0, -1, typebuf.tb_change_cnt, main_loop.events);
os_inchar(NULL, 0, -1, typebuf.tb_change_cnt, main_loop.events);
// If an event was put into the queue, we send K_EVENT directly.
if (!multiqueue_empty(main_loop.events)) {
key = K_EVENT;

View File

@ -725,8 +725,6 @@ void draw_tabline(void)
win_T *cwp;
int wincount;
int c;
int len;
char *p;
grid_line_start(&default_grid, 0);
FOR_ALL_TABS(tp) {
tabcount++;
@ -782,7 +780,7 @@ void draw_tabline(void)
if (modified || wincount > 1) {
if (wincount > 1) {
vim_snprintf(NameBuff, MAXPATHL, "%d", wincount);
len = (int)strlen(NameBuff);
int len = (int)strlen(NameBuff);
if (col + len >= Columns - 3) {
break;
}
@ -801,8 +799,8 @@ void draw_tabline(void)
// Get buffer name in NameBuff[]
get_trans_bufname(cwp->w_buffer);
shorten_dir(NameBuff);
len = vim_strsize(NameBuff);
p = NameBuff;
int len = vim_strsize(NameBuff);
char *p = NameBuff;
while (len > room) {
len -= ptr2cells(p);
MB_PTR_ADV(p);
@ -1399,7 +1397,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
case STL_VIM_EXPR: // '{'
{
char *block_start = fmt_p - 1;
int reevaluate = (*fmt_p == '%');
bool reevaluate = (*fmt_p == '%');
itemisflag = true;
if (reevaluate) {

View File

@ -183,21 +183,17 @@ char *vim_strnsave_unquoted(const char *const string, const size_t length)
char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newline)
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
{
char *d;
char *escaped_string;
size_t l;
int csh_like;
bool fish_like;
// Only csh and similar shells expand '!' within single quotes. For sh and
// the like we must not put a backslash before it, it will be taken
// literally. If do_special is set the '!' will be escaped twice.
// Csh also needs to have "\n" escaped twice when do_special is set.
csh_like = csh_like_shell();
int csh_like = csh_like_shell();
// Fish shell uses '\' as an escape character within single quotes, so '\'
// itself must be escaped to get a literal '\'.
fish_like = fish_like_shell();
bool fish_like = fish_like_shell();
// First count the number of extra bytes required.
size_t length = strlen(string) + 3; // two quotes and a trailing NUL
@ -229,8 +225,8 @@ char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newli
}
// Allocate memory for the result and fill it.
escaped_string = xmalloc(length);
d = escaped_string;
char *escaped_string = xmalloc(length);
char *d = escaped_string;
// add opening quote
#ifdef MSWIN
@ -301,9 +297,7 @@ char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newli
char *vim_strsave_up(const char *string)
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
{
char *p1;
p1 = xstrdup(string);
char *p1 = xstrdup(string);
vim_strup(p1);
return p1;
}
@ -376,9 +370,7 @@ char *strcase_save(const char *const orig, bool upper)
void del_trailing_spaces(char *ptr)
FUNC_ATTR_NONNULL_ALL
{
char *q;
q = ptr + strlen(ptr);
char *q = ptr + strlen(ptr);
while (--q > ptr && ascii_iswhite(q[0]) && q[-1] != '\\' && q[-1] != Ctrl_V) {
*q = NUL;
}
@ -1360,11 +1352,11 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st
} else {
size_t min_field_width = 0;
size_t precision = 0;
int zero_padding = 0;
int precision_specified = 0;
int justify_left = 0;
int alternate_form = 0;
int force_sign = 0;
bool zero_padding = false;
bool precision_specified = false;
bool justify_left = false;
bool alternate_form = false;
bool force_sign = false;
// if both ' ' and '+' flags appear, ' ' flag should be ignored
int space_for_positive = 1;
@ -1429,17 +1421,17 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st
while (true) {
switch (*p) {
case '0':
zero_padding = 1; p++; continue;
zero_padding = true; p++; continue;
case '-':
justify_left = 1; p++; continue;
justify_left = true; p++; continue;
// if both '0' and '-' flags appear, '0' should be ignored
case '+':
force_sign = 1; space_for_positive = 0; p++; continue;
force_sign = true; space_for_positive = 0; p++; continue;
case ' ':
force_sign = 1; p++; continue;
force_sign = true; p++; continue;
// if both ' ' and '+' flags appear, ' ' should be ignored
case '#':
alternate_form = 1; p++; continue;
alternate_form = true; p++; continue;
case '\'':
p++; continue;
default:
@ -1474,7 +1466,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st
min_field_width = (size_t)j;
} else {
min_field_width = (size_t)-j;
justify_left = 1;
justify_left = true;
}
} else if (ascii_isdigit((int)(*p))) {
// size_t could be wider than unsigned int; make sure we treat
@ -1490,7 +1482,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st
// parse precision
if (*p == '.') {
p++;
precision_specified = 1;
precision_specified = true;
if (ascii_isdigit((int)(*p))) {
// size_t could be wider than unsigned int; make sure we
@ -1525,7 +1517,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st
if (j >= 0) {
precision = (size_t)j;
} else {
precision_specified = 0;
precision_specified = false;
precision = 0;
}
}
@ -1780,7 +1772,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st
// '0' flag should be ignored. This is so with Solaris 2.6, Digital
// UNIX 4.0, HPUX 10, Linux, FreeBSD, NetBSD; but not with Perl.
if (precision_specified) {
zero_padding = 0;
zero_padding = false;
}
if (fmt_spec == 'd') {
@ -1868,8 +1860,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st
&& !(zero_padding_insertion_ind < str_arg_l
&& tmp[zero_padding_insertion_ind] == '0')) {
// assure leading zero for alternate-form octal numbers
if (!precision_specified
|| precision < num_of_digits + 1) {
if (!precision_specified || precision < num_of_digits + 1) {
// precision is increased to force the first character to be
// zero, except if a zero value is formatted with an explicit
// precision of zero
@ -1926,12 +1917,12 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st
force_sign, space_for_positive),
sizeof(tmp));
str_arg_l = strlen(tmp);
zero_padding = 0;
zero_padding = false;
} else if (xisnan(f)) {
// Not a number: nan or NAN
memmove(tmp, ASCII_ISUPPER(fmt_spec) ? "NAN" : "nan", 4);
str_arg_l = 3;
zero_padding = 0;
zero_padding = false;
} else {
// Regular float number
format[0] = '%';
@ -2017,8 +2008,8 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st
default:
// unrecognized conversion specifier, keep format string as-is
zero_padding = 0; // turn zero padding off for non-numeric conversion
justify_left = 1;
zero_padding = false; // turn zero padding off for non-numeric conversion
justify_left = true;
min_field_width = 0; // reset flags
// discard the unrecognized conversion, just keep
@ -2229,7 +2220,7 @@ char *strrep(const char *src, const char *what, const char *rep)
}
/// Implementation of "byteidx()" and "byteidxcomp()" functions
static void byteidx_common(typval_T *argvars, typval_T *rettv, int comp)
static void byteidx_common(typval_T *argvars, typval_T *rettv, bool comp)
{
rettv->vval.v_number = -1;

View File

@ -340,10 +340,10 @@ void syntax_start(win_T *wp, linenr_T lnum)
if (VALID_STATE(&current_state)
&& current_lnum < lnum
&& current_lnum < syn_buf->b_ml.ml_line_count) {
(void)syn_finish_line(false);
syn_finish_line(false);
if (!current_state_stored) {
current_lnum++;
(void)store_current_state();
store_current_state();
}
// If the current_lnum is now the same as "lnum", keep the current
@ -401,7 +401,7 @@ void syntax_start(win_T *wp, linenr_T lnum)
}
while (current_lnum < lnum) {
syn_start_line();
(void)syn_finish_line(false);
syn_finish_line(false);
current_lnum++;
// If we parsed at least "minlines" lines or started at a valid
@ -490,23 +490,16 @@ static void clear_current_state(void)
// 3. Simply start on a given number of lines above "lnum".
static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid)
{
buf_T *curbuf_save;
win_T *curwin_save;
pos_T cursor_save;
int idx;
linenr_T lnum;
linenr_T end_lnum;
linenr_T break_lnum;
bool had_sync_point;
stateitem_T *cur_si;
synpat_T *spp;
char *line;
int found_flags = 0;
int found_match_idx = 0;
linenr_T found_current_lnum = 0;
int found_current_col = 0;
lpos_T found_m_endpos;
colnr_T prev_current_col;
// Clear any current state that might be hanging around.
invalidate_current_state();
@ -543,14 +536,14 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid)
if (syn_block->b_syn_sync_flags & SF_CCOMMENT) {
// Need to make syn_buf the current buffer for a moment, to be able to
// use find_start_comment().
curwin_save = curwin;
win_T *curwin_save = curwin;
curwin = wp;
curbuf_save = curbuf;
buf_T *curbuf_save = curbuf;
curbuf = syn_buf;
// Skip lines that end in a backslash.
for (; start_lnum > 1; start_lnum--) {
line = ml_get(start_lnum - 1);
char *line = ml_get(start_lnum - 1);
if (*line == NUL || *(line + strlen(line) - 1) != '\\') {
break;
}
@ -566,7 +559,7 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid)
// defines the comment.
// Restrict the search for the end of a comment to b_syn_sync_maxlines.
if (find_start_comment((int)syn_block->b_syn_sync_maxlines) != NULL) {
for (idx = syn_block->b_syn_patterns.ga_len; --idx >= 0;) {
for (int idx = syn_block->b_syn_patterns.ga_len; --idx >= 0;) {
if (SYN_ITEMS(syn_block)[idx].sp_syn.id
== syn_block->b_syn_sync_id
&& SYN_ITEMS(syn_block)[idx].sp_type == SPTYPE_START) {
@ -593,7 +586,7 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid)
found_m_endpos.lnum = 0;
found_m_endpos.col = 0;
end_lnum = start_lnum;
linenr_T end_lnum = start_lnum;
lnum = start_lnum;
while (--lnum > break_lnum) {
// This can take a long time: break when CTRL-C pressed.
@ -621,7 +614,7 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid)
for (current_lnum = lnum; current_lnum < end_lnum; current_lnum++) {
syn_start_line();
while (true) {
had_sync_point = syn_finish_line(true);
bool had_sync_point = syn_finish_line(true);
// When a sync point has been found, remember where, and
// continue to look for another one, further on in the line.
if (had_sync_point && current_state.ga_len) {
@ -660,7 +653,7 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid)
// syn_current_attr() will have skipped the check for
// an item that ends here, need to do that now. Be
// careful not to go past the NUL.
prev_current_col = current_col;
colnr_T prev_current_col = current_col;
if (syn_getcurline()[current_col] != NUL) {
current_col++;
}
@ -697,7 +690,7 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid)
}
current_col = found_m_endpos.col;
current_lnum = found_m_endpos.lnum;
(void)syn_finish_line(false);
syn_finish_line(false);
current_lnum++;
} else {
current_lnum = start_lnum;
@ -1149,7 +1142,7 @@ static synstate_T *store_current_state(void)
// Add a new entry
// If no free items, cleanup the array first.
if (syn_block->b_sst_freecount == 0) {
(void)syn_stack_cleanup();
syn_stack_cleanup();
// "sp" may have been moved to the freelist now
sp = syn_stack_find_entry(current_lnum);
}
@ -1369,7 +1362,7 @@ bool syntax_check_changed(linenr_T lnum)
if (sp != NULL && sp->sst_lnum == lnum) {
// finish the previous line (needed when not all of the line was
// drawn)
(void)syn_finish_line(false);
syn_finish_line(false);
// Compare the current state with the previously saved state of
// the line.
@ -1379,7 +1372,7 @@ bool syntax_check_changed(linenr_T lnum)
// Store the current state in b_sst_array[] for later use.
current_lnum++;
(void)store_current_state();
store_current_state();
}
}
@ -1395,7 +1388,7 @@ bool syntax_check_changed(linenr_T lnum)
static bool syn_finish_line(const bool syncing)
{
while (!current_finished) {
(void)syn_current_attr(syncing, false, NULL, false);
syn_current_attr(syncing, false, NULL, false);
// When syncing, and found some item, need to check the item.
if (syncing && current_state.ga_len) {
@ -1518,7 +1511,7 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
// If we found a match after the last column, use it.
if (next_match_idx >= 0 && next_match_col >= (int)current_col
&& next_match_col != MAXCOL) {
(void)push_next_match();
push_next_match();
}
current_finished = true;
@ -2416,8 +2409,8 @@ static void find_endpos(int idx, lpos_T *startpos, lpos_T *m_endpos, lpos_T *hl_
regmatch.rmm_ic = spp->sp_ic;
regmatch.regprog = spp->sp_prog;
int r = syn_regexec(&regmatch, startpos->lnum, lc_col,
IF_SYN_TIME(&spp->sp_time));
bool r = syn_regexec(&regmatch, startpos->lnum, lc_col,
IF_SYN_TIME(&spp->sp_time));
spp->sp_prog = regmatch.regprog;
if (r) {
if (best_idx == -1 || regmatch.startpos[0].col
@ -2663,7 +2656,7 @@ static char *syn_getcurline(void)
// Call vim_regexec() to find a match with "rmp" in "syn_buf".
// Returns true when there is a match.
static int syn_regexec(regmmatch_T *rmp, linenr_T lnum, colnr_T col, syn_time_T *st)
static bool syn_regexec(regmmatch_T *rmp, linenr_T lnum, colnr_T col, syn_time_T *st)
{
int timed_out = 0;
proftime_T pt;
@ -3367,7 +3360,7 @@ static void syn_list_one(const int id, const bool syncing, const bool link_only)
continue;
}
(void)syn_list_header(did_header, 0, id, true);
syn_list_header(did_header, 0, id, true);
did_header = true;
last_matchgroup = 0;
if (spp->sp_type == SPTYPE_MATCH) {
@ -3420,7 +3413,7 @@ static void syn_list_one(const int id, const bool syncing, const bool link_only)
// list the link, if there is one
if (highlight_link_id(id - 1) && (did_header || link_only) && !got_int) {
(void)syn_list_header(did_header, 0, id, true);
syn_list_header(did_header, 0, id, true);
msg_puts_attr("links to", attr);
msg_putchar(' ');
msg_outtrans(highlight_group_name(highlight_link_id(id - 1) - 1), 0);
@ -3642,23 +3635,17 @@ static bool syn_list_keywords(const int id, const hashtab_T *const ht, bool did_
static void syn_clear_keyword(int id, hashtab_T *ht)
{
hashitem_T *hi;
keyentry_T *kp;
keyentry_T *kp_prev;
keyentry_T *kp_next;
int todo;
hash_lock(ht);
todo = (int)ht->ht_used;
for (hi = ht->ht_array; todo > 0; hi++) {
int todo = (int)ht->ht_used;
for (hashitem_T *hi = ht->ht_array; todo > 0; hi++) {
if (HASHITEM_EMPTY(hi)) {
continue;
}
todo--;
kp_prev = NULL;
for (kp = HI2KE(hi); kp != NULL;) {
keyentry_T *kp_prev = NULL;
for (keyentry_T *kp = HI2KE(hi); kp != NULL;) {
if (kp->k_syn.id == id) {
kp_next = kp->ke_next;
keyentry_T *kp_next = kp->ke_next;
if (kp_prev == NULL) {
if (kp_next == NULL) {
hash_remove(ht, hi);
@ -3684,16 +3671,13 @@ static void syn_clear_keyword(int id, hashtab_T *ht)
// Clear a whole keyword table.
static void clear_keywtab(hashtab_T *ht)
{
hashitem_T *hi;
int todo;
keyentry_T *kp;
keyentry_T *kp_next;
todo = (int)ht->ht_used;
for (hi = ht->ht_array; todo > 0; hi++) {
int todo = (int)ht->ht_used;
for (hashitem_T *hi = ht->ht_array; todo > 0; hi++) {
if (!HASHITEM_EMPTY(hi)) {
todo--;
for (kp = HI2KE(hi); kp != NULL; kp = kp_next) {
for (keyentry_T *kp = HI2KE(hi); kp != NULL; kp = kp_next) {
kp_next = kp->ke_next;
xfree(kp->next_list);
xfree(kp->k_syn.cont_in_list);
@ -3789,9 +3773,7 @@ static char *get_group_name(char *arg, char **name_end)
/// Return NULL for any error;
static char *get_syn_options(char *arg, syn_opt_arg_T *opt, int *conceal_char, int skip)
{
int syn_id;
int len = 0;
char *p;
int fidx;
static const struct flag {
char *name;
@ -3835,7 +3817,7 @@ static char *get_syn_options(char *arg, syn_opt_arg_T *opt, int *conceal_char, i
}
for (fidx = ARRAY_SIZE(flagtab); --fidx >= 0;) {
p = flagtab[fidx].name;
char *p = flagtab[fidx].name;
int i;
for (i = 0, len = 0; p[i] != NUL; i += 2, len++) {
if (arg[len] != p[i] && arg[len] != p[i + 1]) {
@ -3904,7 +3886,7 @@ static char *get_syn_options(char *arg, syn_opt_arg_T *opt, int *conceal_char, i
if (strcmp(gname, "NONE") == 0) {
*opt->sync_idx = NONE_IDX;
} else {
syn_id = syn_name2id(gname);
int syn_id = syn_name2id(gname);
int i;
for (i = curwin->w_s->b_syn_patterns.ga_len; --i >= 0;) {
if (SYN_ITEMS(curwin->w_s)[i].sp_syn.id == syn_id
@ -3960,10 +3942,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
char *arg = eap->arg;
int sgl_id = 1;
char *group_name_end;
char *rest;
const char *errormsg = NULL;
int prev_toplvl_grp;
int prev_syn_inc_tag;
bool source = false;
eap->nextcmd = find_nextcmd(arg);
@ -3973,7 +3952,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
if (arg[0] == '@') {
arg++;
rest = get_group_name(arg, &group_name_end);
char *rest = get_group_name(arg, &group_name_end);
if (rest == NULL) {
emsg(_("E397: Filename required"));
return;
@ -4009,9 +3988,9 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
emsg(_("E847: Too many syntax includes"));
return;
}
prev_syn_inc_tag = current_syn_inc_tag;
int prev_syn_inc_tag = current_syn_inc_tag;
current_syn_inc_tag = ++running_syn_inc_tag;
prev_toplvl_grp = curwin->w_s->b_syn_topgrp;
int prev_toplvl_grp = curwin->w_s->b_syn_topgrp;
curwin->w_s->b_syn_topgrp = sgl_id;
if (source
? do_source(eap->arg, false, DOSO_NONE, NULL) == FAIL
@ -4028,15 +4007,11 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing)
char *arg = eap->arg;
char *group_name_end;
int syn_id;
char *rest;
char *keyword_copy = NULL;
char *p;
char *kw;
syn_opt_arg_T syn_opt_arg;
int cnt;
int conceal_char = NUL;
rest = get_group_name(arg, &group_name_end);
char *rest = get_group_name(arg, &group_name_end);
if (rest != NULL) {
if (eap->skip) {
@ -4059,8 +4034,8 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing)
// The options given apply to ALL keywords, so all options must be
// found before keywords can be created.
// 1: collect the options and copy the keywords to keyword_copy.
cnt = 0;
p = keyword_copy;
int cnt = 0;
char *p = keyword_copy;
for (; rest != NULL && !ends_excmd(*rest); rest = skipwhite(rest)) {
rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip);
if (rest == NULL || ends_excmd(*rest)) {
@ -4082,7 +4057,7 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing)
syn_incl_toplevel(syn_id, &syn_opt_arg.flags);
// 2: Add an entry for each keyword.
for (kw = keyword_copy; --cnt >= 0; kw += strlen(kw) + 1) {
for (char *kw = keyword_copy; --cnt >= 0; kw += strlen(kw) + 1) {
for (p = vim_strchr(kw, '[');;) {
if (p != NULL) {
*p = NUL;
@ -4233,7 +4208,6 @@ static void syn_cmd_region(exarg_T *eap, int syncing)
char *rest; // next arg, NULL on error
char *key_end;
char *key = NULL;
char *p;
int item;
#define ITEM_START 0
#define ITEM_SKIP 1
@ -4316,7 +4290,7 @@ static void syn_cmd_region(exarg_T *eap, int syncing)
}
if (item == ITEM_MATCHGROUP) {
p = skiptowhite(rest);
char *p = skiptowhite(rest);
if ((p - rest == 4 && strncmp(rest, "NONE", 4) == 0) || eap->skip) {
matchgroup_id = 0;
} else {
@ -4643,7 +4617,6 @@ static void syn_cmd_cluster(exarg_T *eap, int syncing)
{
char *arg = eap->arg;
char *group_name_end;
char *rest;
bool got_clstr = false;
int opt_len;
int list_op;
@ -4653,7 +4626,7 @@ static void syn_cmd_cluster(exarg_T *eap, int syncing)
return;
}
rest = get_group_name(arg, &group_name_end);
char *rest = get_group_name(arg, &group_name_end);
if (rest != NULL) {
int scl_id = syn_check_cluster(arg, (int)(group_name_end - arg));
@ -4720,7 +4693,6 @@ static void init_syn_patterns(void)
/// @return a pointer to the next argument, or NULL in case of an error.
static char *get_syn_pattern(char *arg, synpat_T *ci)
{
int *p;
int idx;
// need at least three chars
@ -4757,7 +4729,7 @@ static char *get_syn_pattern(char *arg, synpat_T *ci)
}
}
if (idx >= 0) {
p = &(ci->sp_offsets[idx]);
int *p = &(ci->sp_offsets[idx]);
if (idx != SPO_LC_OFF) {
switch (end[3]) {
case 's':
@ -5123,10 +5095,8 @@ static int16_t *copy_id_list(const int16_t *const list)
static int in_id_list(stateitem_T *cur_si, int16_t *list, struct sp_syn *ssp, int contained)
{
int retval;
int16_t *scl_list;
int16_t id = ssp->id;
static int depth = 0;
int r;
// If ssp has a "containedin" list and "cur_si" is in it, return true.
if (cur_si != NULL && ssp->cont_in_list != NULL
@ -5189,12 +5159,12 @@ static int in_id_list(stateitem_T *cur_si, int16_t *list, struct sp_syn *ssp, in
return retval;
}
if (item >= SYNID_CLUSTER) {
scl_list = SYN_CLSTR(syn_block)[item - SYNID_CLUSTER].scl_list;
int16_t *scl_list = SYN_CLSTR(syn_block)[item - SYNID_CLUSTER].scl_list;
// restrict recursiveness to 30 to avoid an endless loop for a
// cluster that includes itself (indirectly)
if (scl_list != NULL && depth < 30) {
depth++;
r = in_id_list(NULL, scl_list, ssp, contained);
int r = in_id_list(NULL, scl_list, ssp, contained);
depth--;
if (r) {
return retval;
@ -5437,7 +5407,7 @@ int syn_get_id(win_T *wp, linenr_T lnum, colnr_T col, int trans, bool *spellp, i
next_match_idx = -1;
}
(void)get_syntax_attr(col, spellp, keep_state);
get_syntax_attr(col, spellp, keep_state);
return trans ? current_trans_id : current_id;
}
@ -5459,7 +5429,7 @@ int syn_get_concealed_id(win_T *wp, linenr_T lnum, colnr_T col)
{
int seqnr;
(void)syn_get_id(wp, lnum, col, false, NULL, false);
syn_get_id(wp, lnum, col, false, NULL, false);
int syntax_flags = get_syntax_info(&seqnr);
if (syntax_flags & HL_CONCEAL) {
@ -5519,7 +5489,7 @@ int syn_get_foldlevel(win_T *wp, linenr_T lnum)
int cur_level = level;
int low_level = cur_level;
while (!current_finished) {
(void)syn_current_attr(false, false, NULL, false);
syn_current_attr(false, false, NULL, false);
cur_level = syn_cur_foldlevel();
if (cur_level < low_level) {
low_level = cur_level;

View File

@ -279,7 +279,7 @@ void set_buflocal_tfu_callback(buf_T *buf)
/// @param tag tag (pattern) to jump to
/// @param forceit :ta with !
/// @param verbose print "tag not found" message
void do_tag(char *tag, int type, int count, int forceit, int verbose)
void do_tag(char *tag, int type, int count, int forceit, bool verbose)
{
taggy_T *tagstack = curwin->w_tagstack;
int tagstackidx = curwin->w_tagstackidx;
@ -546,7 +546,6 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
// Repeat searching for tags, when a file has not been found.
while (true) {
int other_name;
char *name;
// When desired match not found yet, try to find it (and others).
@ -560,7 +559,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
} else {
name = tag;
}
other_name = (tagmatchname == NULL || strcmp(tagmatchname, name) != 0);
bool other_name = (tagmatchname == NULL || strcmp(tagmatchname, name) != 0);
if (new_tag
|| (cur_match >= num_matches && max_num_matches != MAXCOL)
|| other_name) {
@ -717,7 +716,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
smsg(0, _("File \"%s\" does not exist"), nofile_fname);
}
int ic = (matches[cur_match][0] & MT_IC_OFF);
bool ic = (matches[cur_match][0] & MT_IC_OFF);
if (type != DT_TAG && type != DT_SELECT && type != DT_JUMP
&& (num_matches > 1 || ic)
&& !skip_msg) {
@ -1160,7 +1159,7 @@ static int tag_strnicmp(char *s1, char *s2, size_t len)
}
// Extract info from the tag search pattern "pats->pat".
static void prepare_pats(pat_T *pats, int has_re)
static void prepare_pats(pat_T *pats, bool has_re)
{
pats->head = pats->pat;
pats->headlen = pats->len;
@ -1275,7 +1274,7 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag
char *res_fname;
char *res_cmd;
char *res_kind;
int has_extra = 0;
bool has_extra = false;
int name_only = flags & TAG_NAMES;
if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT) {
@ -1310,7 +1309,7 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag
res_cmd = tv->vval.v_string;
continue;
}
has_extra = 1;
has_extra = true;
if (!strcmp(dict_key, "kind")) {
res_kind = tv->vval.v_string;
continue;
@ -1530,7 +1529,7 @@ static int findtags_apply_tfu(findtags_state_T *st, char *pat, char *buf_ffname)
/// reached end of a emacs included tags file)
static tags_read_status_T findtags_get_next_line(findtags_state_T *st, tagsearch_info_T *sinfo_p)
{
int eof;
bool eof;
// For binary search: compute the next offset to use.
if (st->state == TS_BINARY) {
@ -1545,7 +1544,7 @@ static tags_read_status_T findtags_get_next_line(findtags_state_T *st, tagsearch
sinfo_p->curr_offset -= st->lbuf_size * 2;
if (sinfo_p->curr_offset < 0) {
sinfo_p->curr_offset = 0;
(void)fseek(st->fp, 0, SEEK_SET);
fseek(st->fp, 0, SEEK_SET);
st->state = TS_STEP_FORWARD;
}
}
@ -2304,7 +2303,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
char *saved_pat = NULL; // copy of pat[]
int findall = (mincount == MAXCOL || mincount == TAG_MANY); // find all matching tags
int has_re = (flags & TAG_REGEXP); // regexp used
bool has_re = (flags & TAG_REGEXP); // regexp used
int noic = (flags & TAG_NOIC);
int verbose = (flags & TAG_VERBOSE);
int save_p_ic = p_ic;
@ -2564,7 +2563,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf)
// Copy next file name into buf.
buf[0] = NUL;
(void)copy_option_part(&tnp->tn_np, buf, MAXPATHL - 1, " ,");
copy_option_part(&tnp->tn_np, buf, MAXPATHL - 1, " ,");
char *r_ptr = vim_findfile_stopdir(buf);
// move the filename one char forward and truncate the
@ -2774,7 +2773,7 @@ static char *tag_full_fname(tagptrs_T *tagp)
/// @param keep_help keep help flag
///
/// @return OK for success, NOTAGFILE when file not found, FAIL otherwise.
static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help)
static int jumpto_tag(const char *lbuf_arg, int forceit, bool keep_help)
{
char *pbuf_end;
char *tofree_fname = NULL;
@ -2947,11 +2946,10 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help)
// try again, ignore case now
p_ic = true;
if (!do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, 1,
search_options, NULL)) {
if (!do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, 1, search_options, NULL)) {
// Failed to find pattern, take a guess: "^func ("
found = 2;
(void)test_for_static(&tagp);
test_for_static(&tagp);
char cc = *tagp.tagname_end;
*tagp.tagname_end = NUL;
snprintf(pbuf, LSIZE, "^%s\\s\\*(", tagp.tagname);
@ -3171,7 +3169,7 @@ static void tagstack_clear_entry(taggy_T *item)
}
/// @param tagnames expand tag names
int expand_tags(int tagnames, char *pat, int *num_file, char ***file)
int expand_tags(bool tagnames, char *pat, int *num_file, char ***file)
{
int extra_flag;
size_t name_buf_size = 100;
@ -3203,10 +3201,8 @@ int expand_tags(int tagnames, char *pat, int *num_file, char ***file)
parse_match((*file)[i], &t_p);
len = (size_t)(t_p.tagname_end - t_p.tagname);
if (len > name_buf_size - 3) {
char *buf;
name_buf_size = len + 3;
buf = xrealloc(name_buf, name_buf_size);
char *buf = xrealloc(name_buf, name_buf_size);
name_buf = buf;
}
@ -3317,12 +3313,11 @@ int get_tags(list_T *list, char *pat, char *buf_fname)
// skip "file:" (static tag)
p += 4;
} else if (!ascii_iswhite(*p)) {
char *n;
int len;
// Add extra field as a dict entry. Fields are
// separated by Tabs.
n = p;
char *n = p;
while (*p != NUL && *p >= ' ' && *p < 127 && *p != ':') {
p++;
}

View File

@ -77,7 +77,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
bool first_line = true;
colnr_T leader_len;
bool no_leader = false;
int do_comments = (flags & INSCHAR_DO_COM);
bool do_comments = (flags & INSCHAR_DO_COM);
int has_lbr = curwin->w_p_lbr;
// make sure win_lbr_chartabsize() counts correctly
@ -100,15 +100,12 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
int wantcol; // column at textwidth border
int foundcol; // column for start of spaces
int end_foundcol = 0; // column for start of word
colnr_T virtcol;
int orig_col = 0;
char *saved_text = NULL;
colnr_T col;
colnr_T end_col;
bool did_do_comment = false;
virtcol = get_nolist_virtcol()
+ char2cells(c != NUL ? c : gchar_cursor());
colnr_T virtcol = get_nolist_virtcol() + char2cells(c != NUL ? c : gchar_cursor());
if (virtcol <= (colnr_T)textwidth) {
break;
}
@ -175,7 +172,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
}
if (WHITECHAR(cc)) {
// remember position of blank just before text
end_col = curwin->w_cursor.col;
colnr_T end_col = curwin->w_cursor.col;
// find start of sequence of blanks
int wcc = 0; // counter for whitespace chars
@ -419,7 +416,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
ins_str(" ");
}
} else {
(void)set_indent(second_indent, SIN_CHANGED);
set_indent(second_indent, SIN_CHANGED);
}
}
}
@ -472,9 +469,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
static int fmt_check_par(linenr_T lnum, int *leader_len, char **leader_flags, bool do_comments)
{
char *flags = NULL; // init for GCC
char *ptr;
ptr = ml_get(lnum);
char *ptr = ml_get(lnum);
if (do_comments) {
*leader_len = get_leader_len(ptr, leader_flags, false, true);
} else {
@ -624,8 +619,6 @@ static bool paragraph_start(linenr_T lnum)
/// @param prev_line may start in previous line
void auto_format(bool trailblank, bool prev_line)
{
char *linep;
if (!has_format_option(FO_AUTO)) {
return;
}
@ -694,7 +687,7 @@ void auto_format(bool trailblank, bool prev_line)
// need to add a space when 'w' is in 'formatoptions' to keep a paragraph
// formatted.
if (!wasatend && has_format_option(FO_WHITE_PAR)) {
linep = get_cursor_line_ptr();
char *linep = get_cursor_line_ptr();
colnr_T len = (colnr_T)strlen(linep);
if (curwin->w_cursor.col == len) {
char *plinep = xstrnsave(linep, (size_t)len + 2);
@ -1052,7 +1045,7 @@ void format_lines(linenr_T line_count, bool avoid_fex)
indent = get_indent();
}
}
(void)set_indent(indent, SIN_CHANGED);
set_indent(indent, SIN_CHANGED);
}
// put cursor on last non-space
@ -1096,13 +1089,13 @@ void format_lines(linenr_T line_count, bool avoid_fex)
break;
}
if (next_leader_len > 0) {
(void)del_bytes(next_leader_len, false, false);
del_bytes(next_leader_len, false, false);
mark_col_adjust(curwin->w_cursor.lnum, 0, 0, -next_leader_len, 0);
} else if (second_indent > 0) { // the "leader" for FO_Q_SECOND
int indent = (int)getwhitecols_curline();
if (indent > 0) {
(void)del_bytes(indent, false, false);
del_bytes(indent, false, false);
mark_col_adjust(curwin->w_cursor.lnum, 0, 0, -indent, 0);
}
}

View File

@ -169,14 +169,13 @@ found:
/// @return true if the next paragraph or section was found.
bool findpar(bool *pincl, int dir, int count, int what, bool both)
{
linenr_T curr;
bool first; // true on first line
linenr_T fold_first; // first line of a closed fold
linenr_T fold_last; // last line of a closed fold
bool fold_skipped; // true if a closed fold was skipped this
// iteration
curr = curwin->w_cursor.lnum;
linenr_T curr = curwin->w_cursor.lnum;
while (count--) {
bool did_skip = false; // true after separating lines have been skipped
@ -259,9 +258,7 @@ static bool inmacro(char *opt, const char *s)
/// If 'both' is true also stop at '}'
bool startPS(linenr_T lnum, int para, bool both)
{
char *s;
s = ml_get(lnum);
char *s = ml_get(lnum);
if ((uint8_t)(*s) == para || *s == '\f' || (both && *s == '}')) {
return true;
}
@ -293,9 +290,7 @@ static bool cls_bigword; ///< true for "W", "B" or "E"
/// boundaries are of interest.
static int cls(void)
{
int c;
c = gchar_cursor();
int c = gchar_cursor();
if (c == ' ' || c == '\t' || c == NUL) {
return 0;
}
@ -534,9 +529,7 @@ static bool skip_chars(int cclass, int dir)
/// Go back to the start of the word or the start of white space
static void back_in_line(void)
{
int sclass; // starting class
sclass = cls();
int sclass = cls(); // starting class
while (true) {
if (curwin->w_cursor.col == 0) { // stop at start of line
break;
@ -723,15 +716,13 @@ int current_word(oparg_T *oap, int count, bool include, bool bigword)
/// When Visual active, extend it by one or more sentences.
int current_sent(oparg_T *oap, int count, bool include)
{
pos_T start_pos;
pos_T pos;
bool start_blank;
int c;
bool at_start_sent;
int ncount;
start_pos = curwin->w_cursor;
pos = start_pos;
pos_T start_pos = curwin->w_cursor;
pos_T pos = start_pos;
findsent(FORWARD, 1); // Find start of next sentence.
// When the Visual area is bigger than one character: Extend it.
@ -1314,7 +1305,7 @@ extend:
}
// First move back to the start_lnum of the paragraph or white lines
int white_in_front = linewhite(start_lnum);
bool white_in_front = linewhite(start_lnum);
while (start_lnum > 1) {
if (white_in_front) { // stop at first white line
if (!linewhite(start_lnum - 1)) {

View File

@ -344,7 +344,7 @@ static inline void zero_fmark_additional_data(fmark_T *fmarks)
/// "reload" is true when saving for a buffer reload.
/// Careful: may trigger autocommands that reload the buffer.
/// Returns FAIL when lines could not be saved, OK otherwise.
int u_savecommon(buf_T *buf, linenr_T top, linenr_T bot, linenr_T newbot, int reload)
int u_savecommon(buf_T *buf, linenr_T top, linenr_T bot, linenr_T newbot, bool reload)
{
if (!reload) {
// When making changes is not allowed return FAIL. It's a crude way
@ -934,7 +934,7 @@ static u_header_T *unserialize_uhp(bufinfo_T *bi, const char *file_name)
default:
// Field not supported, skip it.
while (--len >= 0) {
(void)undo_read_byte(bi);
undo_read_byte(bi);
}
}
}
@ -1255,7 +1255,7 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf,
semsg(_(e_not_open), file_name);
goto theend;
}
(void)os_setperm(file_name, perm);
os_setperm(file_name, perm);
if (p_verbose > 0) {
verbose_enter();
smsg(0, _("Writing undo file: %s"), file_name);
@ -1500,7 +1500,7 @@ void u_read_undo(char *name, const uint8_t *hash, const char *orig_name FUNC_ATT
default:
// field not supported, skip
while (--len >= 0) {
(void)undo_read_byte(&bi);
undo_read_byte(&bi);
}
}
}
@ -2250,7 +2250,7 @@ target_zero:
///
/// @param undo If `true`, go up the tree. Down if `false`.
/// @param do_buf_event If `true`, send buffer updates.
static void u_undoredo(int undo, bool do_buf_event)
static void u_undoredo(bool undo, bool do_buf_event)
{
char **newarray = NULL;
linenr_T newlnum = MAXLNUM;

View File

@ -1708,8 +1708,8 @@ int do_ucmd(exarg_T *eap, bool preview)
save_current_sctx = current_sctx;
current_sctx.sc_sid = cmd->uc_script_ctx.sc_sid;
}
(void)do_cmdline(buf, eap->getline, eap->cookie,
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED);
do_cmdline(buf, eap->getline, eap->cookie,
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED);
// Careful: Do not use "cmd" here, it may have become invalid if a user
// command was added.

View File

@ -2580,7 +2580,7 @@ void ex_version(exarg_T *eap)
/// When "wrap" is true wrap the string in [].
/// @param s
/// @param wrap
static void version_msg_wrap(char *s, int wrap)
static void version_msg_wrap(char *s, bool wrap)
{
int len = vim_strsize(s) + (wrap ? 2 : 0);
@ -2647,7 +2647,7 @@ void list_in_columns(char **items, int size, int current)
for (int i = 0; !got_int && i < nrow * ncol; i++) {
int idx = (i / ncol) + (i % ncol) * nrow;
if (idx < item_count) {
int last_col = (i + 1) % ncol == 0;
bool last_col = (i + 1) % ncol == 0;
if (idx == current) {
msg_putchar('[');
}

View File

@ -190,7 +190,7 @@ void do_window(int nchar, int Prenum, int xchar)
if (bt_quickfix(curbuf)) {
goto newwindow;
}
(void)win_split(Prenum, 0);
win_split(Prenum, 0);
break;
// split current window in two parts, vertically
@ -203,7 +203,7 @@ void do_window(int nchar, int Prenum, int xchar)
if (bt_quickfix(curbuf)) {
goto newwindow;
}
(void)win_split(Prenum, WSP_VERT);
win_split(Prenum, WSP_VERT);
break;
// split current window and edit alternate file
@ -222,8 +222,8 @@ void do_window(int nchar, int Prenum, int xchar)
}
if (!curbuf_locked() && win_split(0, 0) == OK) {
(void)buflist_getfile(Prenum == 0 ? curwin->w_alt_fnum : Prenum,
0, GETF_ALT, false);
buflist_getfile(Prenum == 0 ? curwin->w_alt_fnum : Prenum,
0, GETF_ALT, false);
}
break;
@ -610,7 +610,7 @@ wingotofile:
LANGMAP_ADJUST(xchar, true);
no_mapping--;
allow_keys--;
(void)add_to_showcmd(xchar);
add_to_showcmd(xchar);
switch (xchar) {
case '}':
@ -1206,7 +1206,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
CLEAR_FIELD(wp->w_border_adj);
}
int before;
bool before;
frame_T *curfrp;
// Reorganise the tree of frames to insert the new window.
@ -1398,7 +1398,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
}
if (flags & (WSP_TOP | WSP_BOT)) {
(void)win_comp_pos();
win_comp_pos();
}
// Both windows need redrawing. Update all status lines, in case they
@ -1746,7 +1746,7 @@ static void win_exchange(int Prenum)
frame_fix_width(curwin);
frame_fix_width(wp);
(void)win_comp_pos(); // recompute window positions
win_comp_pos(); // recompute window positions
if (wp->w_buffer != curbuf) {
reset_VIsual_and_resel();
@ -1833,7 +1833,7 @@ static void win_rotate(bool upwards, int count)
frame_fix_width(wp2);
// recompute w_winrow and w_wincol for all windows
(void)win_comp_pos();
win_comp_pos();
}
wp1->w_pos_changed = true;
@ -1870,14 +1870,14 @@ static void win_totop(int size, int flags)
}
} else {
// Remove the window and frame from the tree of frames.
(void)winframe_remove(curwin, &dir, NULL);
winframe_remove(curwin, &dir, NULL);
}
win_remove(curwin, NULL);
last_status(false); // may need to remove last status line
(void)win_comp_pos(); // recompute window positions
win_comp_pos(); // recompute window positions
// Split a window on the desired side and put the window there.
(void)win_split_ins(size, flags, curwin, dir);
win_split_ins(size, flags, curwin, dir);
if (!(flags & WSP_VERT)) {
win_setheight(height);
if (p_ea) {
@ -1944,7 +1944,7 @@ void win_move_after(win_T *win1, win_T *win2)
win_append(win2, win1);
frame_append(win2->w_frame, win1->w_frame);
(void)win_comp_pos(); // recompute w_winrow for all windows
win_comp_pos(); // recompute w_winrow for all windows
redraw_later(curwin, UPD_NOT_VALID);
}
win_enter(win1, false);
@ -2023,7 +2023,7 @@ static void win_equal_rec(win_T *next_curwin, bool current, frame_T *topfr, int
int totwincount = 0;
int next_curwin_size = 0;
int room = 0;
int has_next_curwin = 0;
bool has_next_curwin = false;
if (topfr->fr_layout == FR_LEAF) {
// Set the width/height of this frame.
@ -2814,7 +2814,7 @@ int win_close(win_T *win, bool free_buf, bool force)
// only resize that frame. Otherwise resize all windows.
win_equal(curwin, curwin->w_frame->fr_parent == win_frame, dir);
} else {
(void)win_comp_pos();
win_comp_pos();
win_fix_scroll(false);
}
}
@ -3031,7 +3031,7 @@ void win_free_all(void)
win_T *wp = lastwin;
win_remove(lastwin, NULL);
int dummy;
(void)win_free_mem(wp, &dummy, NULL);
win_free_mem(wp, &dummy, NULL);
for (int i = 0; i < AUCMD_WIN_COUNT; i++) {
if (aucmd_win[i].auc_win == wp) {
aucmd_win[i].auc_win = NULL;
@ -3042,7 +3042,7 @@ void win_free_all(void)
for (int i = 0; i < AUCMD_WIN_COUNT; i++) {
if (aucmd_win[i].auc_win != NULL) {
int dummy;
(void)win_free_mem(aucmd_win[i].auc_win, &dummy, NULL);
win_free_mem(aucmd_win[i].auc_win, &dummy, NULL);
aucmd_win[i].auc_win = NULL;
}
}
@ -3051,7 +3051,7 @@ void win_free_all(void)
while (firstwin != NULL) {
int dummy;
(void)win_free_mem(firstwin, &dummy, NULL);
win_free_mem(firstwin, &dummy, NULL);
}
// No window should be used after this. Set curwin to NULL to crash
@ -5221,7 +5221,7 @@ void win_new_screen_rows(void)
frame_new_height(topframe, h, false, false);
}
(void)win_comp_pos(); // recompute w_winrow and w_wincol
win_comp_pos(); // recompute w_winrow and w_wincol
win_reconfig_floats(); // The size of floats might change
compute_cmdrow();
curtab->tp_ch_used = p_ch;
@ -5245,7 +5245,7 @@ void win_new_screen_cols(void)
frame_new_width(topframe, Columns, false, false);
}
(void)win_comp_pos(); // recompute w_winrow and w_wincol
win_comp_pos(); // recompute w_winrow and w_wincol
win_reconfig_floats(); // The size of floats might change
}
@ -5469,8 +5469,8 @@ void may_trigger_win_scrolled_resized(void)
int cwsr = check_window_scroll_resize(&size_count,
&first_scroll_win, &first_size_win,
NULL, NULL);
int trigger_resize = do_resize && size_count > 0;
int trigger_scroll = do_scroll && cwsr != 0;
bool trigger_resize = do_resize && size_count > 0;
bool trigger_scroll = do_scroll && cwsr != 0;
if (!trigger_resize && !trigger_scroll) {
return; // no relevant changes
}
@ -5480,7 +5480,7 @@ void may_trigger_win_scrolled_resized(void)
// Create the list for v:event.windows before making the snapshot.
// windows_list = tv_list_alloc_with_items(size_count);
windows_list = tv_list_alloc(size_count);
(void)check_window_scroll_resize(NULL, NULL, NULL, windows_list, NULL);
check_window_scroll_resize(NULL, NULL, NULL, windows_list, NULL);
}
dict_T *scroll_dict = NULL;
@ -5488,7 +5488,7 @@ void may_trigger_win_scrolled_resized(void)
// Create the dict with entries for v:event before making the snapshot.
scroll_dict = tv_dict_alloc();
scroll_dict->dv_refcount = 1;
(void)check_window_scroll_resize(NULL, NULL, NULL, NULL, scroll_dict);
check_window_scroll_resize(NULL, NULL, NULL, NULL, scroll_dict);
}
// WinScrolled/WinResized are triggered only once, even when multiple
@ -5572,7 +5572,7 @@ void win_size_restore(garray_T *gap)
}
}
// recompute the window positions
(void)win_comp_pos();
win_comp_pos();
}
}
@ -5865,7 +5865,7 @@ void win_setwidth_win(int width, win_T *wp)
frame_setwidth(wp->w_frame, width + wp->w_vsep_width);
// recompute the window positions
(void)win_comp_pos();
win_comp_pos();
redraw_all_later(UPD_NOT_VALID);
}
}
@ -6250,7 +6250,7 @@ void win_drag_vsep_line(win_T *dragwin, int offset)
fr = fr->fr_next;
}
}
(void)win_comp_pos();
win_comp_pos();
redraw_all_later(UPD_NOT_VALID);
}
@ -6275,7 +6275,7 @@ void set_fraction(win_T *wp)
/// TODO(vim): Ensure this also works with wrapped lines.
/// Requires a not fully visible cursor line to be allowed at the bottom of
/// a window("zb"), probably only when 'smoothscroll' is also set.
void win_fix_scroll(int resize)
void win_fix_scroll(bool resize)
{
if (*p_spk == 'c') {
return; // 'splitkeep' is "cursor"
@ -6446,7 +6446,7 @@ void scroll_to_fraction(win_T *wp, int prev_height)
}
} else if (sline > 0) {
while (sline > 0 && lnum > 1) {
(void)hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
if (lnum == 1) {
// first line in buffer is folded
line_size = 1;
@ -6466,7 +6466,7 @@ void scroll_to_fraction(win_T *wp, int prev_height)
if (sline < 0) {
// Line we want at top would go off top of screen. Use next
// line instead.
(void)hasFoldingWin(wp, lnum, NULL, &lnum, true, NULL);
hasFoldingWin(wp, lnum, NULL, &lnum, true, NULL);
lnum++;
wp->w_wrow -= line_size + sline;
} else if (sline > 0) {
@ -6632,7 +6632,7 @@ void command_height(void)
}
// Recompute window positions.
(void)win_comp_pos();
win_comp_pos();
// clear the lines added to cmdline
if (full_screen) {
@ -6652,7 +6652,7 @@ void command_height(void)
// Recompute window positions.
if (frp != lastwin->w_frame) {
(void)win_comp_pos();
win_comp_pos();
}
}
@ -6868,7 +6868,7 @@ static bool resize_frame_for_status(frame_T *fr)
} else if (fp != fr) {
frame_new_height(fp, fp->fr_height - 1, false, false);
frame_fix_height(wp);
(void)win_comp_pos();
win_comp_pos();
} else {
win_new_height(wp, wp->w_height - 1);
}
@ -6890,7 +6890,7 @@ static bool resize_frame_for_winbar(frame_T *fr)
frame_new_height(fp, fp->fr_height - 1, false, false);
win_new_height(wp, wp->w_height + 1);
frame_fix_height(wp);
(void)win_comp_pos();
win_comp_pos();
return true;
}
@ -7226,7 +7226,7 @@ void restore_snapshot(int idx, int close_curwin)
&& curtab->tp_snapshot[idx]->fr_height == topframe->fr_height
&& check_snapshot_rec(curtab->tp_snapshot[idx], topframe) == OK) {
win_T *wp = restore_snapshot_rec(curtab->tp_snapshot[idx], topframe);
(void)win_comp_pos();
win_comp_pos();
if (wp != NULL && close_curwin) {
win_goto(wp);
}

View File

@ -57,7 +57,7 @@ win_T *win_new_float(win_T *wp, bool last, FloatConfig fconfig, Error *err)
int dir;
winframe_remove(wp, &dir, NULL);
XFREE_CLEAR(wp->w_frame);
(void)win_comp_pos(); // recompute window positions
win_comp_pos(); // recompute window positions
win_remove(wp, NULL);
win_append(lastwin_nofloating(), wp);
}