diff options
author | dundargoc <gocdundar@gmail.com> | 2023-12-16 22:14:28 +0100 |
---|---|---|
committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2023-12-19 11:43:21 +0100 |
commit | 7f6b775b45de5011ff1c44e63e57551566d80704 (patch) | |
tree | 54eab8482051d2d1a958fcf9f6c9bcbb02827717 | |
parent | 693aea0e9e1032aee85d56c1a3f33e0811dbdc18 (diff) | |
download | rneovim-7f6b775b45de5011ff1c44e63e57551566d80704.tar.gz rneovim-7f6b775b45de5011ff1c44e63e57551566d80704.tar.bz2 rneovim-7f6b775b45de5011ff1c44e63e57551566d80704.zip |
refactor: use `bool` to represent boolean values
49 files changed, 175 insertions, 186 deletions
diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c index f575bf30b8..665e61c277 100644 --- a/src/nvim/arabic.c +++ b/src/nvim/arabic.c @@ -270,22 +270,22 @@ bool arabic_combine(int one, int two) return false; } -/// A_is_iso returns true if 'c' is an Arabic ISO-8859-6 character +/// @return true if 'c' is an Arabic ISO-8859-6 character /// (alphabet/number/punctuation) -static int A_is_iso(int c) +static bool A_is_iso(int c) { return find_achar(c) != NULL; } -/// A_is_ok returns true if 'c' is an Arabic 10646 (8859-6 or Form-B) -static int A_is_ok(int c) +/// @return true if 'c' is an Arabic 10646 (8859-6 or Form-B) +static bool A_is_ok(int c) { return (A_is_iso(c) || c == a_BYTE_ORDER_MARK); } -/// A_is_valid returns true if 'c' is an Arabic 10646 (8859-6 or Form-B) -/// with some exceptions/exclusions -static int A_is_valid(int c) +/// @return true if 'c' is an Arabic 10646 (8859-6 or Form-B) +/// with some exceptions/exclusions +static bool A_is_valid(int c) { return (A_is_ok(c) && c != a_HAMZA); } @@ -304,8 +304,8 @@ int arabic_shape(int c, int *c1p, int prev_c, int prev_c1, int next_c) } int curr_c; - int curr_laa = arabic_combine(c, *c1p); - int prev_laa = arabic_combine(prev_c, prev_c1); + bool curr_laa = arabic_combine(c, *c1p); + bool prev_laa = arabic_combine(prev_c, prev_c1); if (curr_laa) { if (A_is_valid(prev_c) && can_join(prev_c, a_LAM) && !prev_laa) { diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index 8bc8edb572..a2f3aa11ca 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -280,7 +280,7 @@ static char *do_one_arg(char *str) /// Separate the arguments in "str" and return a list of pointers in the /// growarray "gap". -static void get_arglist(garray_T *gap, char *str, int escaped) +static void get_arglist(garray_T *gap, char *str, bool escaped) { ga_init(gap, (int)sizeof(char *), 20); while (*str != NUL) { @@ -426,7 +426,7 @@ static int do_arglist(char *str, int what, int after, bool will_edit) garray_T new_ga; int exp_count; char **exp_files; - int arg_escaped = true; + bool arg_escaped = true; if (check_arglist_locked() == FAIL) { return FAIL; diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index bfcf566fe3..9605e3b4db 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -913,7 +913,7 @@ int do_autocmd_event(event_T event, const char *pat, bool once, int nested, char int patlen = (int)aucmd_pattern_length(pat); while (patlen) { // detect special <buffer[=X]> buffer-local patterns - int is_buflocal = aupat_is_buflocal(pat, patlen); + bool is_buflocal = aupat_is_buflocal(pat, patlen); if (is_buflocal) { const int buflocal_nr = aupat_get_buflocal_nr(pat, patlen); @@ -977,7 +977,7 @@ int autocmd_register(int64_t id, event_T event, const char *pat, int patlen, int const int findgroup = group == AUGROUP_ALL ? current_augroup : group; // detect special <buffer[=X]> buffer-local patterns - const int is_buflocal = aupat_is_buflocal(pat, patlen); + const bool is_buflocal = aupat_is_buflocal(pat, patlen); int buflocal_nr = 0; char buflocal_pat[BUFLOCAL_PAT_LEN]; // for "<buffer=X>" @@ -1568,7 +1568,7 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force static int nesting = 0; char *save_cmdarg; varnumber_T save_cmdbang; - static int filechangeshell_busy = false; + static bool filechangeshell_busy = false; proftime_T wait_time; bool did_save_redobuff = false; save_redo_T save_redo; diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 75c6545c1d..7660093fc2 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -201,13 +201,13 @@ bool buf_ensure_loaded(buf_T *buf) /// @param flags_arg extra flags for readfile() /// /// @return FAIL for failure, OK otherwise. -int open_buffer(int read_stdin, exarg_T *eap, int flags_arg) +int open_buffer(bool read_stdin, exarg_T *eap, int flags_arg) { int flags = flags_arg; int retval = OK; bufref_T old_curbuf; OptInt old_tw = curbuf->b_p_tw; - int read_fifo = false; + bool read_fifo = false; bool silent = shortmess(SHM_FILEINFO); // The 'readonly' flag is only set when BF_NEVERLOADED is being reset. diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index f8df273375..67e5fb3b6f 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -799,7 +799,7 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o char *backup_ext = *p_bex == NUL ? ".bak" : p_bex; if (*backup_copyp) { - int some_error = false; + bool some_error = false; // Try to make the backup in each directory in the 'bdir' option. // @@ -1059,14 +1059,14 @@ nobackup: /// /// @return FAIL for failure, OK otherwise int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T end, exarg_T *eap, - int append, int forceit, int reset_changed, int filtering) + bool append, bool forceit, bool reset_changed, bool filtering) { int retval = OK; int msg_save = msg_scroll; - int prev_got_int = got_int; + bool prev_got_int = got_int; // writing everything - int whole = (start == 1 && end == buf->b_ml.ml_line_count); - int write_undo_file = false; + bool whole = (start == 1 && end == buf->b_ml.ml_line_count); + bool write_undo_file = false; context_sha256_T sha_ctx; unsigned bkc = get_bkc_value(buf); @@ -1245,7 +1245,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en } #if defined(UNIX) - int made_writable = false; // 'w' bit has been set + bool made_writable = false; // 'w' bit has been set // When using ":w!" and the file was read-only: make it writable if (forceit && perm >= 0 && !(perm & 0200) @@ -1352,7 +1352,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en } } - int notconverted = false; + bool notconverted = false; if (converted && wb_flags == 0 && write_info.bw_iconv_fd == (iconv_t)-1 @@ -1364,7 +1364,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en notconverted = true; } - int no_eol = false; // no end-of-line written + bool no_eol = false; // no end-of-line written int nchars; linenr_T lnum; int fileformat; diff --git a/src/nvim/change.c b/src/nvim/change.c index 622eb3b9a5..99698f2e5d 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -1322,7 +1322,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) char *comment_end = NULL; // where lead_end has been found int extra_space = false; // append extra space int current_flag; - int require_blank = false; // requires blank after middle + bool require_blank = false; // requires blank after middle char *p2; // If the comment leader has the start, middle or end flag, it may not @@ -1979,7 +1979,7 @@ void del_lines(linenr_T nlines, bool undo) int get_leader_len(char *line, char **flags, bool backward, bool include_space) { int j; - int got_com = false; + bool got_com = false; char part_buf[COM_MAX_LEN]; // buffer for one option part char *string; // pointer to comment string int middle_match_len = 0; @@ -1994,7 +1994,7 @@ int get_leader_len(char *line, char **flags, bool backward, bool include_space) // Repeat to match several nested comment strings. while (line[i] != NUL) { // scan through the 'comments' option for a match - int found_one = false; + bool found_one = false; for (char *list = curbuf->b_p_com; *list;) { // Get one option part into part_buf[]. Advance "list" to next // one. Put "string" at start of string. @@ -2129,7 +2129,7 @@ int get_last_leader_offset(char *line, char **flags) int i = (int)strlen(line); while (--i >= lower_check_bound) { // scan through the 'comments' option for a match - int found_one = false; + bool found_one = false; for (char *list = curbuf->b_p_com; *list;) { char *flags_save = list; diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 523145af1b..31b385c466 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -841,7 +841,7 @@ static char *find_longest_match(expand_T *xp, int options) char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode) { char *ss = NULL; - int orig_saved = false; + bool orig_saved = false; // first handle the case of using an old match if (mode == WILD_NEXT || mode == WILD_PREV @@ -3311,7 +3311,7 @@ static int wildmenu_process_key_menunames(CmdlineInfo *cclp, int key, expand_T * } else if (key == K_UP) { // Hitting <Up>: Remove one submenu name in front of the // cursor - int found = false; + bool found = false; int j = (int)(xp->xp_pattern - cclp->cmdbuff); int i = 0; @@ -3367,7 +3367,7 @@ static int wildmenu_process_key_filenames(CmdlineInfo *cclp, int key, expand_T * KeyTyped = true; // in case the key was mapped } else if (strncmp(xp->xp_pattern, upseg + 1, 3) == 0 && key == K_DOWN) { // If in a direct ancestor, strip off one ../ to go down - int found = false; + bool found = false; int j = cclp->cmdpos; int i = (int)(xp->xp_pattern - cclp->cmdbuff); @@ -3388,7 +3388,7 @@ static int wildmenu_process_key_filenames(CmdlineInfo *cclp, int key, expand_T * } } else if (key == K_UP) { // go up a directory - int found = false; + bool found = false; int j = cclp->cmdpos - 1; int i = (int)(xp->xp_pattern - cclp->cmdbuff); diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index 9396fdac7f..51a73dec10 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -374,7 +374,7 @@ static int calc_hist_idx(int histype, int num) histentry_T *hist = history[histype]; if (num > 0) { - int wrapped = false; + bool wrapped = false; while (hist[i].hisnum > num) { if (--i < 0) { if (wrapped) { diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index fe07c33df5..64cf1ea263 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -110,7 +110,7 @@ const char *parse_shape_opt(int what) int all_idx; int len; int i; - int found_ve = false; // found "ve" flag + bool found_ve = false; // found "ve" flag // First round: check for errors; second round: do it for real. for (int round = 1; round <= 2; round++) { diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 483182dc25..765cbdadd2 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -59,7 +59,7 @@ #include "nvim/window.h" #include "xdiff/xdiff.h" -static int diff_busy = false; // using diff structs, don't change them +static bool diff_busy = false; // using diff structs, don't change them static bool diff_need_update = false; // ex_diffupdate needs to be called // Flags obtained from the 'diffopt' option @@ -384,7 +384,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T } dp->df_lnum[idx] += amount_after; } else { - int check_unchanged = false; + bool check_unchanged = false; // 2. 3. 4. 5.: inserted/deleted lines touching this diff. if (deleted > 0) { @@ -1003,7 +1003,7 @@ theend: static int check_external_diff(diffio_T *diffio) { // May try twice, first with "-a" and then without. - int io_error = false; + bool io_error = false; TriState ok = kFalse; while (true) { ok = kFalse; @@ -1472,7 +1472,7 @@ void diff_win_options(win_T *wp, int addbuf) /// @param eap void ex_diffoff(exarg_T *eap) { - int diffwin = false; + bool diffwin = false; FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { if (eap->forceit ? wp->w_p_diff : (wp == curwin)) { @@ -2155,12 +2155,12 @@ int diff_check_with_linestatus(win_T *wp, linenr_T lnum, int *linestatus) } if (lnum < dp->df_lnum[idx] + dp->df_count[idx]) { - int zero = false; + bool zero = false; // Changed or inserted line. If the other buffers have a count of // zero, the lines were inserted. If the other buffers have the same // count, check if the lines are identical. - int cmp = false; + bool cmp = false; for (int i = 0; i < DB_COUNT; i++) { if ((i != idx) && (curtab->tp_diffbuf[i] != NULL)) { @@ -2195,7 +2195,7 @@ int diff_check_with_linestatus(win_T *wp, linenr_T lnum, int *linestatus) // the difference. Can't remove the entry here, we might be halfway // through updating the window. Just report the text as unchanged. // Other windows might still show the change though. - if (zero == false) { + if (!zero) { return 0; } return -2; @@ -2845,7 +2845,7 @@ void ex_diffgetput(exarg_T *eap) } if (*eap->arg == NUL) { - int found_not_ma = false; + bool found_not_ma = false; // No argument: Find the other buffer in the list of diff buffers. for (idx_other = 0; idx_other < DB_COUNT; idx_other++) { if ((curtab->tp_diffbuf[idx_other] != curbuf) diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 77bd05eb55..ee1cd0a3ce 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -1076,7 +1076,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl int prev_syntax_id = 0; int conceal_attr = win_hl_attr(wp, HLF_CONCEAL); bool is_concealing = false; - int did_wcol = false; + bool did_wcol = false; int old_boguscols = 0; #define VCOL_HLC (wlv.vcol - wlv.vcol_off) #define FIX_FOR_BOGUSCOLS \ diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 7d869881e8..21bb325e37 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -564,7 +564,7 @@ static char *redir_varname = NULL; /// @param append append to an existing variable /// /// @return OK if successfully completed the setup. FAIL otherwise. -int var_redir_start(char *name, int append) +int var_redir_start(char *name, bool append) { // Catch a bad name early. if (!eval_isnamec1(*name)) { @@ -765,7 +765,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. -int eval_to_bool(char *arg, bool *error, exarg_T *eap, int skip) +bool eval_to_bool(char *arg, bool *error, exarg_T *eap, int skip) { typval_T tv; bool retval = false; diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 81ae208560..f13235c3e9 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -305,7 +305,7 @@ int call_internal_method(const char *const fname, const int argcount, typval_T * } /// @return true for a non-zero Number and a non-empty String. -static int non_zero_arg(typval_T *argvars) +static bool non_zero_arg(typval_T *argvars) { return ((argvars[0].v_type == VAR_NUMBER && argvars[0].vval.v_number != 0) @@ -2443,7 +2443,7 @@ static void getpos_both(typval_T *argvars, typval_T *rettv, bool getcurpos, bool : (varnumber_T)0)); tv_list_append_number(l, (fp != NULL) ? (varnumber_T)fp->coladd : (varnumber_T)0); if (getcurpos) { - const int save_set_curswant = curwin->w_set_curswant; + const bool save_set_curswant = curwin->w_set_curswant; const colnr_T save_curswant = curwin->w_curswant; const colnr_T save_virtcol = curwin->w_virtcol; diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index cce02e6daf..5e943711d1 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -928,7 +928,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett int tv_to_free_len = 0; proftime_T wait_start; proftime_T call_start; - int started_profiling = false; + bool started_profiling = false; bool did_save_redo = false; save_redo_T save_redo; @@ -3035,7 +3035,7 @@ static inline bool fc_referenced(const funccall_T *const fc) /// @return true if items in "fc" do not have "copyID". That means they are not /// referenced from anywhere that is in use. -static int can_free_funccal(funccall_T *fc, int copyID) +static bool can_free_funccal(funccall_T *fc, int copyID) { return fc->fc_l_varlist.lv_copyID != copyID && fc->fc_l_vars.dv_copyID != copyID @@ -3048,7 +3048,7 @@ void ex_return(exarg_T *eap) { char *arg = eap->arg; typval_T rettv; - int returning = false; + bool returning = false; if (current_funccal == NULL) { emsg(_("E133: :return not inside a function")); @@ -3395,7 +3395,7 @@ end: /// /// @return true when the return can be carried out, /// false when the return gets pending. -int do_return(exarg_T *eap, int reanimate, int is_cmd, void *rettv) +bool do_return(exarg_T *eap, bool reanimate, bool is_cmd, void *rettv) { cstack_T *const cstack = eap->cstack; diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index 9897ca77f1..de2fddb083 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -616,7 +616,7 @@ static void list_tab_vars(int *first) /// List variables in "arg". static const char *list_arg_vars(exarg_T *eap, const char *arg, int *first) { - int error = false; + bool error = false; int len; const char *name; const char *name_start; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index d8e2c54efa..c268f47323 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6212,7 +6212,7 @@ static void ex_redir(exarg_T *eap) semsg(_(e_invarg2), eap->arg); } } else if (*arg == '=' && arg[1] == '>') { - int append; + bool append; // redirect to a variable close_redir(); diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index bc4cb634e8..c239e8a9ea 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -92,7 +92,7 @@ static void discard_pending_return(typval_T *p) // expression evaluation is done without producing any error messages, but all // error messages on parsing errors during the expression evaluation are given // (even if a try conditional is active). -static int cause_abort = false; +static bool cause_abort = false; /// @return true when immediately aborting on error, or when an interrupt /// occurred or an exception was thrown but not caught. @@ -844,7 +844,7 @@ void ex_if(exarg_T *eap) int skip = CHECK_SKIP; bool error; - int result = eval_to_bool(eap->arg, &error, eap, skip); + bool result = eval_to_bool(eap->arg, &error, eap, skip); if (!skip && !error) { if (result) { @@ -971,7 +971,7 @@ void ex_while(exarg_T *eap) if (cstack->cs_idx == CSTACK_LEN - 1) { eap->errmsg = _("E585: :while/:for nesting too deep"); } else { - int result; + bool result; // The loop flag is set when we have jumped back from the matching // ":endwhile" or ":endfor". When not set, need to initialise this // cstack entry. @@ -1183,7 +1183,7 @@ void ex_throw(exarg_T *eap) /// used for rethrowing an uncaught exception. void do_throw(cstack_T *cstack) { - int inactivate_try = false; + bool inactivate_try = false; // Cleanup and deactivate up to the next surrounding try conditional that // is not in its finally clause. Normally, do not deactivate the try @@ -1861,7 +1861,7 @@ void leave_cleanup(cleanup_T *csp) int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive) { int idx; - int stop = false; + bool stop = false; for (idx = cstack->cs_idx; idx >= 0; idx--) { if (cstack->cs_flags[idx] & CSF_TRY) { @@ -1998,7 +1998,7 @@ void ex_endfunction(exarg_T *eap) } /// @return true if the string "p" looks like a ":while" or ":for" command. -int has_loop_cmd(char *p) +bool has_loop_cmd(char *p) { // skip modifiers, white space and ':' while (true) { diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index afaf0a6e2b..974115d803 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -109,7 +109,7 @@ typedef struct command_line_state { int count; int indent; int c; - int gotesc; // true when <ESC> just typed + bool gotesc; // true when <ESC> just typed int do_abbr; // when true check for abbr. char *lookfor; // string to match int hiscnt; // current history line in use @@ -584,7 +584,8 @@ static int may_add_char_to_search(int firstc, int *c, incsearch_state_T *s) return OK; } -static void finish_incsearch_highlighting(int gotesc, incsearch_state_T *s, bool call_update_screen) +static void finish_incsearch_highlighting(bool gotesc, incsearch_state_T *s, + bool call_update_screen) { if (!s->did_incsearch) { return; @@ -840,7 +841,7 @@ static uint8_t *command_line_enter(int firstc, int count, int indent, bool clear // error printed below, to avoid redraw issues tl_ret = try_leave(&tstate, &err); if (tv_dict_get_number(dict, "abort") != 0) { - s->gotesc = 1; + s->gotesc = true; } restore_v_event(dict, &save_v_event); } @@ -4206,7 +4207,7 @@ int get_cmdline_firstc(void) int get_list_range(char **str, int *num1, int *num2) { int len; - int first = false; + bool first = false; varnumber_T num; *str = skipwhite((*str)); @@ -4280,7 +4281,7 @@ static int open_cmdwin(void) int save_restart_edit = restart_edit; int save_State = State; bool save_exmode = exmode_active; - int save_cmdmsg_rl = cmdmsg_rl; + bool save_cmdmsg_rl = cmdmsg_rl; // Can't do this when text or buffer is locked. // Can't do this recursively. Can't do it when typing a password. diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 45f05e10f2..6ae401a58c 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -59,7 +59,7 @@ static int put_view_curpos(FILE *fd, const win_T *wp, char *spaces) return r >= 0; } -static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin) +static int ses_winsizes(FILE *fd, bool restore_size, win_T *tab_firstwin) { if (restore_size && (ssop_flags & SSOP_WINSIZE)) { int n = 0; @@ -314,7 +314,7 @@ static int ses_put_fname(FILE *fd, char *name, unsigned *flagp) static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int current_arg_idx) { int f; - int did_next = false; + bool did_next = false; // Always restore cursor position for ":mksession". For ":mkview" only // when 'viewoptions' contains "cursor". @@ -528,8 +528,8 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr /// @return FAIL on error, OK otherwise. static int makeopens(FILE *fd, char *dirnow) { - int only_save_windows = true; - int restore_size = true; + bool only_save_windows = true; + bool restore_size = true; win_T *edited_win = NULL; win_T *tab_firstwin; frame_T *tab_topframe; @@ -627,7 +627,7 @@ static int makeopens(FILE *fd, char *dirnow) } } - int restore_stal = false; + bool restore_stal = false; // When there are two or more tabpages and 'showtabline' is 1 the tabline // will be displayed when creating the next tab. That resizes the windows // in the first tab, which may cause problems. Set 'showtabline' to 2 @@ -886,7 +886,7 @@ void ex_loadview(exarg_T *eap) /// - SSOP_SLASH: filenames are written with "/" slash void ex_mkrc(exarg_T *eap) { - int view_session = false; // :mkview, :mksession + bool view_session = false; // :mkview, :mksession int using_vdir = false; // using 'viewdir'? char *viewFile = NULL; diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 460cd48fc5..acbcaa16c2 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -882,7 +882,7 @@ char *vim_findfile(void *search_ctx_arg) // is the last starting directory in the stop list? if (ff_path_in_stoplist(search_ctx->ffsc_start_dir, (int)(path_end - search_ctx->ffsc_start_dir), - search_ctx->ffsc_stopdirs_v) == true) { + search_ctx->ffsc_stopdirs_v)) { break; } @@ -1221,7 +1221,7 @@ static void ff_clear(ff_search_ctx_T *search_ctx) /// check if the given path is in the stopdirs /// /// @return true if yes else false -static int ff_path_in_stoplist(char *path, int path_len, char **stopdirs_v) +static bool ff_path_in_stoplist(char *path, int path_len, char **stopdirs_v) { int i = 0; @@ -1338,11 +1338,9 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch { ff_search_ctx_T **search_ctx = (ff_search_ctx_T **)search_ctx_arg; static char *dir; - static int did_findfile_init = false; - char save_char; + static bool did_findfile_init = false; char *file_name = NULL; char *buf = NULL; - int rel_to_curdir; if (rel_fname != NULL && path_with_url(rel_fname)) { // Do not attempt to search "relative" to a URL. #6009 @@ -1355,7 +1353,7 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch } // copy file name into NameBuff, expanding environment variables - save_char = ptr[len]; + char save_char = ptr[len]; ptr[len] = NUL; expand_env_esc(ptr, NameBuff, MAXPATHL, false, true, NULL); ptr[len] = save_char; @@ -1372,12 +1370,12 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch } } - rel_to_curdir = ((*file_to_find)[0] == '.' - && ((*file_to_find)[1] == NUL - || vim_ispathsep((*file_to_find)[1]) - || ((*file_to_find)[1] == '.' - && ((*file_to_find)[2] == NUL - || vim_ispathsep((*file_to_find)[2]))))); + bool rel_to_curdir = ((*file_to_find)[0] == '.' + && ((*file_to_find)[1] == NUL + || vim_ispathsep((*file_to_find)[1]) + || ((*file_to_find)[1] == '.' + && ((*file_to_find)[2] == NUL + || vim_ispathsep((*file_to_find)[2]))))); if (vim_isAbsName(*file_to_find) // "..", "../path", "." and "./path": don't use the path_option || rel_to_curdir diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 0e2959835b..066a150f5a 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -180,7 +180,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, off_T filesize = 0; bool skip_read = false; context_sha256_T sha_ctx; - int read_undo_file = false; + bool read_undo_file = false; int split = 0; // number of split lines linenr_T linecnt; bool error = false; // errors encountered @@ -2754,7 +2754,7 @@ int vim_rename(const char *from, const char *to) return 0; } -static int already_warned = false; +static bool already_warned = false; /// Check if any not hidden buffer has been changed. /// Postpone the check if there are characters in the stuff buffer, a global diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 9e90ab9439..a268070dec 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -319,42 +319,42 @@ foldinfo_T fold_info(win_T *win, linenr_T lnum) // foldmethodIsManual() {{{2 /// @return true if 'foldmethod' is "manual" -int foldmethodIsManual(win_T *wp) +bool foldmethodIsManual(win_T *wp) { return wp->w_p_fdm[3] == 'u'; } // foldmethodIsIndent() {{{2 /// @return true if 'foldmethod' is "indent" -int foldmethodIsIndent(win_T *wp) +bool foldmethodIsIndent(win_T *wp) { return wp->w_p_fdm[0] == 'i'; } // foldmethodIsExpr() {{{2 /// @return true if 'foldmethod' is "expr" -int foldmethodIsExpr(win_T *wp) +bool foldmethodIsExpr(win_T *wp) { return wp->w_p_fdm[1] == 'x'; } // foldmethodIsMarker() {{{2 /// @return true if 'foldmethod' is "marker" -int foldmethodIsMarker(win_T *wp) +bool foldmethodIsMarker(win_T *wp) { return wp->w_p_fdm[2] == 'r'; } // foldmethodIsSyntax() {{{2 /// @return true if 'foldmethod' is "syntax" -int foldmethodIsSyntax(win_T *wp) +bool foldmethodIsSyntax(win_T *wp) { return wp->w_p_fdm[0] == 's'; } // foldmethodIsDiff() {{{2 /// @return true if 'foldmethod' is "diff" -int foldmethodIsDiff(win_T *wp) +bool foldmethodIsDiff(win_T *wp) { return wp->w_p_fdm[0] == 'd'; } @@ -536,8 +536,8 @@ int foldManualAllowed(bool create) /// window. void foldCreate(win_T *wp, pos_T start, pos_T end) { - int use_level = false; - int closed = false; + bool use_level = false; + bool closed = false; int level = 0; pos_T start_rel = start; pos_T end_rel = end; diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 0ccf1823f8..305b18fc28 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -91,7 +91,7 @@ static int typeahead_char = 0; ///< typeahead char that's not flushed /// When block_redo is true the redo buffer will not be changed. /// Used by edit() to repeat insertions. -static int block_redo = false; +static bool block_redo = false; static int KeyNoremap = 0; ///< remapping flags @@ -375,16 +375,16 @@ static void start_stuff(void) } } -/// Return true if the stuff buffer is empty. -int stuff_empty(void) +/// @return true if the stuff buffer is empty. +bool stuff_empty(void) FUNC_ATTR_PURE { return (readbuf1.bh_first.b_next == NULL && readbuf2.bh_first.b_next == NULL); } -/// Return true if readbuf1 is empty. There may still be redo characters in -/// redbuf2. -int readbuf1_empty(void) +/// @return true if readbuf1 is empty. There may still be redo characters in +/// redbuf2. +bool readbuf1_empty(void) FUNC_ATTR_PURE { return (readbuf1.bh_first.b_next == NULL); diff --git a/src/nvim/grid.c b/src/nvim/grid.c index 9830f25dcb..37e538ea16 100644 --- a/src/nvim/grid.c +++ b/src/nvim/grid.c @@ -919,7 +919,7 @@ void win_grid_alloc(win_T *wp) wp->w_lines = xcalloc((size_t)rows + 1, sizeof(wline_T)); } - int was_resized = false; + bool was_resized = false; if (want_allocation && (!has_allocation || grid_allocated->rows != total_rows || grid_allocated->cols != total_cols)) { diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index 7c64571c11..683ad0c8a3 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -670,7 +670,7 @@ void syn_init_cmdline_highlight(bool reset, bool init) /// @param reset clear groups first void init_highlight(bool both, bool reset) { - static int had_both = false; + static bool had_both = false; // Try finding the color scheme file. Used when a color file was loaded // and 'background' or 't_Co' is changed. diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 61422561e0..adb609358d 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -434,7 +434,7 @@ int get_indent_str_vtab(const char *ptr, OptInt ts, colnr_T *vts, bool list) /// @param size measured in spaces /// /// @return true if the line was changed. -int set_indent(int size, int flags) +bool set_indent(int size, int flags) { char *newline; char *oldline; @@ -442,7 +442,7 @@ int set_indent(int size, int flags) int doit = false; int ind_done = 0; // Measured in spaces. int tab_pad; - int retval = false; + bool retval = false; // Number of initial whitespace chars when 'et' and 'pi' are both set. int orig_char_len = -1; @@ -1094,14 +1094,14 @@ void ex_retab(exarg_T *eap) /// Get indent level from 'indentexpr'. int get_expr_indent(void) { - int use_sandbox = was_set_insecurely(curwin, kOptIndentexpr, OPT_LOCAL); + bool use_sandbox = was_set_insecurely(curwin, kOptIndentexpr, OPT_LOCAL); const sctx_T save_sctx = current_sctx; // Save and restore cursor position and curswant, in case it was changed // * via :normal commands. pos_T save_pos = curwin->w_cursor; colnr_T save_curswant = curwin->w_curswant; - int save_set_curswant = curwin->w_set_curswant; + bool save_set_curswant = curwin->w_set_curswant; set_vim_var_nr(VV_LNUM, (varnumber_T)curwin->w_cursor.lnum); if (use_sandbox) { diff --git a/src/nvim/main.c b/src/nvim/main.c index 521d67a638..bf0b8d33b2 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1680,7 +1680,7 @@ static void create_windows(mparm_T *parmp) // Don't execute Win/Buf Enter/Leave autocommands here autocmd_no_enter++; autocmd_no_leave++; - int dorewind = true; + bool dorewind = true; while (done++ < 1000) { if (dorewind) { if (parmp->window_layout == WIN_TABS) { diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 345ec45152..cb50050344 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -1121,7 +1121,7 @@ bool map_to_exists(const char *const str, const char *const modechars, const boo MAPMODE(mode, modechars, 'c', MODE_CMDLINE); #undef MAPMODE - int retval = map_to_exists_mode(rhs, mode, abbr); + bool retval = map_to_exists_mode(rhs, mode, abbr); xfree(buf); return retval; @@ -1137,7 +1137,7 @@ bool map_to_exists(const char *const str, const char *const modechars, const boo /// @param[in] abbr true if checking abbreviations in place of mappings. /// /// @return true if there is at least one mapping with given parameters. -int map_to_exists_mode(const char *const rhs, const int mode, const bool abbr) +bool map_to_exists_mode(const char *const rhs, const int mode, const bool abbr) { bool exp_buffer = false; diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 38ac3b7bcf..25c2de89e0 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -3347,7 +3347,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_ if (!recoverymode && buf_fname != NULL && !buf->b_help && !(buf->b_flags & BF_DUMMY)) { int fd; ZeroBlock b0; - int differ = false; + bool differ = false; // Try to read block 0 from the swapfile to get the original file name (and inode number). fd = os_open(fname, O_RDONLY, 0); @@ -3386,7 +3386,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_ // Show the ATTENTION message when: // - there is an old swapfile for the current file // - the buffer was not recovered - if (differ == false && !(curbuf->b_flags & BF_RECOVERED) + if (!differ && !(curbuf->b_flags & BF_RECOVERED) && vim_strchr(p_shm, SHM_ATTENTION) == NULL) { sea_choice_T choice = SEA_CHOICE_NONE; diff --git a/src/nvim/menu.c b/src/nvim/menu.c index bc850d8961..68a8c9f873 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -968,7 +968,7 @@ char *get_menu_name(expand_T *xp, int idx) { static vimmenu_T *menu = NULL; char *str; - static int should_advance = false; + static bool should_advance = false; if (idx == 0) { // first call: start at first item menu = expand_menu; @@ -1334,9 +1334,9 @@ bool menu_is_toolbar(const char *const name) return strncmp(name, "ToolBar", 7) == 0; } -/// Return true if the name is a menu separator identifier: Starts and ends -/// with '-' -int menu_is_separator(char *name) +/// @return true if the name is a menu separator identifier: Starts and ends +/// with '-' +bool menu_is_separator(char *name) { return name[0] == '-' && name[strlen(name) - 1] == '-'; } @@ -1344,7 +1344,7 @@ int menu_is_separator(char *name) /// True if a popup menu or starts with \ref MNU_HIDDEN_CHAR /// /// @return true if the menu is hidden -static int menu_is_hidden(char *name) +static bool menu_is_hidden(char *name) { return (name[0] == MNU_HIDDEN_CHAR) || (menu_is_popup(name) && name[5] != NUL); diff --git a/src/nvim/message.c b/src/nvim/message.c index 6aaa00cee9..38952d2cf6 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -88,7 +88,7 @@ MessageHistoryEntry *last_msg_hist = NULL; static int msg_hist_len = 0; static FILE *verbose_fd = NULL; -static int verbose_did_open = false; +static bool verbose_did_open = false; bool keep_msg_more = false; // keep_msg was set by msgmore() @@ -2549,11 +2549,9 @@ void clear_sb_text(int all) /// "g<" command. void show_sb_text(void) { - msgchunk_T *mp; - // Only show something if there is more than one line, otherwise it looks // weird, typing a command without output results in one line. - mp = msg_sb_start(last_msgchunk); + msgchunk_T *mp = msg_sb_start(last_msgchunk); if (mp == NULL || mp->sb_prev == NULL) { vim_beep(BO_MESS); } else { @@ -2663,13 +2661,13 @@ static void msg_puts_printf(const char *str, const ptrdiff_t maxlen) /// otherwise it's NUL. /// /// @return true when jumping ahead to "confirm_msg_tail". -static int do_more_prompt(int typed_char) +static bool do_more_prompt(int typed_char) { static bool entered = false; int used_typed_char = typed_char; int oldState = State; int c; - int retval = false; + bool retval = false; bool to_redraw = false; msgchunk_T *mp_last = NULL; msgchunk_T *mp; @@ -3395,7 +3393,6 @@ int do_dialog(int type, const char *title, const char *message, const char *butt const char *textfield, int ex_cmd) { int retval = 0; - char *hotkeys; int i; if (silent_mode // No dialogs in silent mode ("ex -s") @@ -3414,7 +3411,7 @@ int do_dialog(int type, const char *title, const char *message, const char *butt // Since we wait for a keypress, don't make the // user press RETURN as well afterwards. no_wait_return++; - hotkeys = msg_show_console_dialog(message, buttons, dfltbutton); + char *hotkeys = msg_show_console_dialog(message, buttons, dfltbutton); while (true) { // Get a typed character directly from the user. diff --git a/src/nvim/move.c b/src/nvim/move.c index 891aa8f5ce..c4f8eca493 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -2703,7 +2703,7 @@ void do_check_cursorbind(void) colnr_T col = curwin->w_cursor.col; colnr_T coladd = curwin->w_cursor.coladd; colnr_T curswant = curwin->w_curswant; - int set_curswant = curwin->w_set_curswant; + bool set_curswant = curwin->w_set_curswant; win_T *old_curwin = curwin; buf_T *old_curbuf = curbuf; int old_VIsual_select = VIsual_select; diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 8083bb00f5..d9988cb94b 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4721,7 +4721,7 @@ static void nv_vreplace(cmdarg_T *cap) /// Swap case for "~" command, when it does not work like an operator. static void n_swapchar(cmdarg_T *cap) { - int did_change = 0; + bool did_change = false; if (checkclearopq(cap->oap)) { return; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 71c2c7930e..6f5f209a71 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1496,7 +1496,7 @@ int op_delete(oparg_T *oap) // register. For the black hole register '_' don't yank anything. if (oap->regname != '_') { yankreg_T *reg = NULL; - int did_yank = false; + bool did_yank = false; if (oap->regname != 0) { // check for read-only register if (!valid_yank_reg(oap->regname, true)) { @@ -1794,7 +1794,7 @@ static int op_replace(oparg_T *oap, int c) int n; struct block_def bd; char *after_p = NULL; - int had_ctrl_v_cr = false; + bool had_ctrl_v_cr = false; if ((curbuf->b_ml.ml_flags & ML_EMPTY) || oap->empty) { return OK; // nothing to do @@ -2638,7 +2638,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) case kMTCharWise: { colnr_T startcol = 0; colnr_T endcol = MAXCOL; - int is_oneChar = false; + bool is_oneChar = false; colnr_T cs, ce; char *p = ml_get(lnum); bd.startspaces = 0; @@ -3696,7 +3696,7 @@ void adjust_cursor_eol(void) } /// @return true if lines starting with '#' should be left aligned. -int preprocs_left(void) +bool preprocs_left(void) { return ((curbuf->b_p_si && !curbuf->b_p_cin) || (curbuf->b_p_cin && in_cinkeys('#', ' ', true) @@ -3956,7 +3956,7 @@ char *skip_comment(char *line, bool process, bool include_space, bool *is_commen /// to set those marks. /// /// @return FAIL for failure, OK otherwise -int do_join(size_t count, int insert_space, int save_undo, int use_formatoptions, bool setmark) +int do_join(size_t count, bool insert_space, bool save_undo, bool use_formatoptions, bool setmark) { char *curr = NULL; char *curr_start = NULL; @@ -3967,8 +3967,7 @@ int do_join(size_t count, int insert_space, int save_undo, int use_formatoptions int sumsize = 0; // size of the long new line int ret = OK; int *comments = NULL; - int remove_comments = (use_formatoptions == true) - && has_format_option(FO_REMOVE_COMS); + bool remove_comments = use_formatoptions && has_format_option(FO_REMOVE_COMS); bool prev_was_comment = false; assert(count >= 1); diff --git a/src/nvim/option.c b/src/nvim/option.c index ce4ca92ae8..b1bc34744c 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -4054,7 +4054,7 @@ int makeset(FILE *fd, int opt_flags, int local_only) return FAIL; } } else { // string - int do_endif = false; + bool do_endif = false; // Don't set 'syntax' and 'filetype' again if the value is // already right, avoids reloading the syntax file. @@ -4779,9 +4779,9 @@ static void init_buf_opt_idx(void) /// BCO_NOHELP Don't copy the values to a help buffer. void buf_copy_options(buf_T *buf, int flags) { - int should_copy = true; + bool should_copy = true; char *save_p_isk = NULL; // init for GCC - int did_isk = false; + bool did_isk = false; // Skip this when the option defaults have not been set yet. Happens when // main() allocates the first buffer. @@ -5120,7 +5120,7 @@ void set_context_in_set_cmd(expand_T *xp, char *arg, int opt_flags) char nextchar; uint32_t flags = 0; OptIndex opt_idx = 0; - int is_term_option = false; + bool is_term_option = false; if (*arg == '<') { while (*p != '>') { diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c index 5db7a19411..b9657beb7a 100644 --- a/src/nvim/os/users.c +++ b/src/nvim/os/users.c @@ -190,7 +190,7 @@ void free_users(void) /// Done only once and then cached. static void init_users(void) { - static int lazy_init_done = false; + static bool lazy_init_done = false; if (lazy_init_done) { return; diff --git a/src/nvim/path.c b/src/nvim/path.c index 0fc461ae0f..1d34f5400e 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -236,9 +236,9 @@ char *get_past_head(const char *path) return (char *)retval; } -/// Return true if 'c' is a path separator. +/// @return true if 'c' is a path separator. /// Note that for MS-Windows this includes the colon. -int vim_ispathsep(int c) +bool vim_ispathsep(int c) { #ifdef UNIX return c == '/'; // Unix has ':' inside file names @@ -252,7 +252,7 @@ int vim_ispathsep(int c) } // Like vim_ispathsep(c), but exclude the colon for MS-Windows. -int vim_ispathsep_nocolon(int c) +bool vim_ispathsep_nocolon(int c) { return vim_ispathsep(c) #ifdef BACKSLASH_IN_FILENAME @@ -261,8 +261,8 @@ int vim_ispathsep_nocolon(int c) ; } -/// return true if 'c' is a path list separator. -int vim_ispathlistsep(int c) +/// @return true if 'c' is a path list separator. +bool vim_ispathlistsep(int c) { #ifdef UNIX return c == ':'; @@ -970,20 +970,17 @@ static void uniquefy_paths(garray_T *gap, char *pattern) for (int i = 0; i < gap->ga_len && !got_int; i++) { char *path = fnames[i]; - int is_in_curdir; const char *dir_end = gettail_dir(path); - char *pathsep_p; - char *path_cutoff; len = strlen(path); - is_in_curdir = path_fnamencmp(curdir, path, (size_t)(dir_end - path)) == 0 - && curdir[dir_end - path] == NUL; + bool is_in_curdir = path_fnamencmp(curdir, path, (size_t)(dir_end - path)) == 0 + && curdir[dir_end - path] == NUL; if (is_in_curdir) { in_curdir[i] = xstrdup(path); } // Shorten the filename while maintaining its uniqueness - path_cutoff = get_path_cutoff(path, &path_ga); + char *path_cutoff = get_path_cutoff(path, &path_ga); // Don't assume all files can be reached without path when search // pattern starts with **/, so only remove path_cutoff @@ -998,7 +995,7 @@ static void uniquefy_paths(garray_T *gap, char *pattern) } else { // Here all files can be reached without path, so get shortest // unique path. We start at the end of the path. */ - pathsep_p = path + len - 1; + char *pathsep_p = path + len - 1; while (find_previous_pathsep(path, &pathsep_p)) { if (vim_regexec(®match, pathsep_p + 1, 0) && is_unique(pathsep_p + 1, gap, i) @@ -1353,7 +1350,7 @@ void FreeWild(int count, char **files) } /// @return true if we can expand this backtick thing here. -static int vim_backtick(char *p) +static bool vim_backtick(char *p) { return *p == '`' && *(p + 1) != NUL && *(p + strlen(p) - 1) == '`'; } @@ -2237,7 +2234,7 @@ int expand_wildcards(int num_pat, char **pat, int *num_files, char ***files, int } /// @return true if "fname" matches with an entry in 'suffixes'. -int match_suffix(char *fname) +bool match_suffix(char *fname) { #define MAXSUFLEN 30 // maximum length of a file suffix char suf_buf[MAXSUFLEN]; @@ -2392,7 +2389,7 @@ static int path_to_absolute(const char *fname, char *buf, size_t len, int force) /// Check if file `fname` is a full (absolute) path. /// /// @return `true` if "fname" is absolute. -int path_is_absolute(const char *fname) +bool path_is_absolute(const char *fname) { #ifdef MSWIN if (*fname == NUL) { diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index a3e92fb595..c1f13c1115 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -810,7 +810,7 @@ win_T *pum_set_info(int pum_idx, char *info) /// menu must be recomputed. static bool pum_set_selected(int n, int repeat) { - int resized = false; + bool resized = false; int context = pum_height / 2; int prev_selected = pum_selected; diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 976b7e837d..e25f6b9b5e 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -5689,7 +5689,7 @@ static buf_T *load_dummy_buffer(char *fname, char *dirname_start, char *resultin return NULL; } - int failed = true; + bool failed = true; bufref_T newbufref; set_bufref(&newbufref, newbuf); @@ -7318,7 +7318,7 @@ void free_quickfix(void) } #endif -static void get_qf_loc_list(int is_qf, win_T *wp, typval_T *what_arg, typval_T *rettv) +static void get_qf_loc_list(bool is_qf, win_T *wp, typval_T *what_arg, typval_T *rettv) { if (what_arg->v_type == VAR_UNKNOWN) { tv_list_alloc_ret(rettv, kListLenMayKnow); diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index d0305a1082..7dfbdd888a 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -2757,7 +2757,7 @@ void ex_finish(exarg_T *eap) /// Mark a sourced file as finished. Possibly makes the ":finish" pending. /// Also called for a pending finish at the ":endtry" or after returning from /// an extra do_cmdline(). "reanimate" is used in the latter case. -void do_finish(exarg_T *eap, int reanimate) +void do_finish(exarg_T *eap, bool reanimate) { if (reanimate) { ((struct source_cookie *)getline_cookie(eap->getline, diff --git a/src/nvim/sign.c b/src/nvim/sign.c index f901f371ce..2bf328bf75 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -721,7 +721,7 @@ static int parse_sign_cmd_args(int cmd, char *arg, char **name, int *id, char ** { char *arg1 = arg; char *filename = NULL; - int lnum_arg = false; + bool lnum_arg = false; // first arg could be placed sign id if (ascii_isdigit(*arg)) { diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index f4ffa2a6b8..7fda93834d 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -696,7 +696,7 @@ void draw_tabline(void) win_T *wp; int attr_nosel = HL_ATTR(HLF_TP); int attr_fill = HL_ATTR(HLF_TPF); - int use_sep_chars = (t_colors < 8); + bool use_sep_chars = (t_colors < 8); if (default_grid.chars == NULL) { return; @@ -772,7 +772,7 @@ void draw_tabline(void) grid_line_put_schar(col++, schar_from_ascii(' '), attr); - int modified = false; + bool modified = false; for (wincount = 0; wp != NULL; wp = wp->w_next, wincount++) { if (bufIsChanged(wp->w_buffer)) { @@ -959,8 +959,8 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op // If "fmt" was set insecurely it needs to be evaluated in the sandbox. // "opt_idx" will be kOptInvalid when caller is nvim_eval_statusline(). - const int use_sandbox = (opt_idx != kOptInvalid) ? was_set_insecurely(wp, opt_idx, opt_scope) - : false; + const bool use_sandbox = (opt_idx != kOptInvalid) ? was_set_insecurely(wp, opt_idx, opt_scope) + : false; // When the format starts with "%!" then evaluate it as an expression and // use the result as the actual format string. diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 2a5777a774..9bddc01f02 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -1900,7 +1900,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st case 'G': { // floating point char format[40]; - int remove_trailing_zeroes = false; + bool remove_trailing_zeroes = false; double f = (tvs ? tv_float(tvs, &arg_idx) diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index f6f0fca74a..d5ee93914a 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -4811,12 +4811,9 @@ static char *get_syn_pattern(char *arg, synpat_T *ci) static void syn_cmd_sync(exarg_T *eap, int syncing) { char *arg_start = eap->arg; - char *arg_end; char *key = NULL; - char *next_arg; - int illegal = false; - int finished = false; - char *cpo_save; + bool illegal = false; + bool finished = false; if (ends_excmd(*arg_start)) { syn_cmd_list(eap, true); @@ -4824,8 +4821,8 @@ static void syn_cmd_sync(exarg_T *eap, int syncing) } while (!ends_excmd(*arg_start)) { - arg_end = skiptowhite(arg_start); - next_arg = skipwhite(arg_end); + char *arg_end = skiptowhite(arg_start); + char *next_arg = skipwhite(arg_end); xfree(key); key = vim_strnsave_up(arg_start, (size_t)(arg_end - arg_start)); if (strcmp(key, "CCOMMENT") == 0) { @@ -4895,7 +4892,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing) curwin->w_s->b_syn_linecont_ic = curwin->w_s->b_syn_ic; // Make 'cpoptions' empty, to avoid the 'l' flag - cpo_save = p_cpo; + char *cpo_save = p_cpo; p_cpo = empty_string_option; curwin->w_s->b_syn_linecont_prog = vim_regcomp(curwin->w_s->b_syn_linecont_pat, RE_MAGIC); diff --git a/src/nvim/tag.c b/src/nvim/tag.c index e67fa337b3..fb798a06fd 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -207,8 +207,8 @@ static char *tagmatchname = NULL; // name of last used tag // normal tagstack. static taggy_T ptag_entry = { NULL, INIT_FMARK, 0, 0, NULL }; -static int tfu_in_use = false; // disallow recursive call of tagfunc -static Callback tfu_cb; // 'tagfunc' callback function +static bool tfu_in_use = false; // disallow recursive call of tagfunc +static Callback tfu_cb; // 'tagfunc' callback function // Used instead of NUL to separate tag fields in the growarrays. #define TAG_SEP 0x02 @@ -287,17 +287,17 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) int cur_fnum = curbuf->b_fnum; int oldtagstackidx = tagstackidx; int prevtagstackidx = tagstackidx; - int new_tag = false; - int no_regexp = false; + bool new_tag = false; + bool no_regexp = false; int error_cur_match = 0; - int save_pos = false; + bool save_pos = false; fmark_T saved_fmark; int new_num_matches; char **new_matches; - int use_tagstack; - int skip_msg = false; + bool use_tagstack; + bool skip_msg = false; char *buf_ffname = curbuf->b_ffname; // name for priority computation - int use_tfu = 1; + bool use_tfu = true; char *tofree = NULL; // remember the matches for the last used tag @@ -323,7 +323,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) if (type == DT_HELP) { type = DT_TAG; no_regexp = true; - use_tfu = 0; + use_tfu = false; } int prev_num_matches = num_matches; @@ -792,7 +792,7 @@ end_do_tag: } // List all the matching tags. -static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char **matches) +static void print_tag_list(bool new_tag, bool use_tagstack, int num_matches, char **matches) { taggy_T *tagstack = curwin->w_tagstack; int tagstackidx = curwin->w_tagstackidx; diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c index 3484d104fd..1b9732c5b2 100644 --- a/src/nvim/textformat.c +++ b/src/nvim/textformat.c @@ -870,7 +870,7 @@ void op_formatexpr(oparg_T *oap) /// @param c character to be inserted int fex_format(linenr_T lnum, long count, int c) { - int use_sandbox = was_set_insecurely(curwin, kOptFormatexpr, OPT_LOCAL); + bool use_sandbox = was_set_insecurely(curwin, kOptFormatexpr, OPT_LOCAL); const sctx_T save_sctx = current_sctx; // Set v:lnum to the first line number and v:count to the number of lines. diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 6e61e9be61..3a7cc2a633 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -586,7 +586,7 @@ int current_word(oparg_T *oap, int count, bool include, bool bigword) { pos_T start_pos; bool inclusive = true; - int include_white = false; + bool include_white = false; cls_bigword = bigword; clearpos(&start_pos); @@ -1079,7 +1079,7 @@ int current_tagblock(oparg_T *oap, int count_arg, bool include) bool do_include = include; bool save_p_ws = p_ws; int retval = FAIL; - int is_inclusive = true; + bool is_inclusive = true; p_ws = false; diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua index 8e20c0a883..e635fc9667 100644 --- a/test/unit/os/fs_spec.lua +++ b/test/unit/os/fs_spec.lua @@ -197,7 +197,7 @@ describe('fs.c', function() itp('returns the absolute path when given an executable inside $PATH', function() local fullpath = exe('ls') - eq(1, fs.path_is_absolute(to_cstr(fullpath))) + eq(true, fs.path_is_absolute(to_cstr(fullpath))) end) itp('returns the absolute path when given an executable relative to the current dir', function() diff --git a/test/unit/path_spec.lua b/test/unit/path_spec.lua index 7614b4dd9c..3ed25b0ba7 100644 --- a/test/unit/path_spec.lua +++ b/test/unit/path_spec.lua @@ -617,15 +617,15 @@ describe('path.c', function() end itp('returns true if filename starts with a slash', function() - eq(OK, path_is_absolute('/some/directory/')) + eq(true, path_is_absolute('/some/directory/')) end) itp('returns true if filename starts with a tilde', function() - eq(OK, path_is_absolute('~/in/my/home~/directory')) + eq(true, path_is_absolute('~/in/my/home~/directory')) end) itp('returns false if filename starts not with slash nor tilde', function() - eq(FAIL, path_is_absolute('not/in/my/home~/directory')) + eq(false, path_is_absolute('not/in/my/home~/directory')) end) end) |