diff options
| author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2021-08-22 16:10:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-22 07:10:57 -0700 |
| commit | db1b0ee3b30fd4cd323907c7f24bd575c22e68f0 (patch) | |
| tree | f018c725dfbafc2d128db9ed5a4b3662cce14429 /src | |
| parent | 783140c670115541f3eb68be6e148f2eeb1696e1 (diff) | |
| download | rneovim-db1b0ee3b30fd4cd323907c7f24bd575c22e68f0.tar.gz rneovim-db1b0ee3b30fd4cd323907c7f24bd575c22e68f0.tar.bz2 rneovim-db1b0ee3b30fd4cd323907c7f24bd575c22e68f0.zip | |
refactor: replace TRUE/FALSE with true/false #15425
Diffstat (limited to 'src')
| -rw-r--r-- | src/nvim/change.c | 2 | ||||
| -rw-r--r-- | src/nvim/edit.c | 7 | ||||
| -rw-r--r-- | src/nvim/ex_cmds.c | 42 | ||||
| -rw-r--r-- | src/nvim/ex_getln.c | 19 | ||||
| -rw-r--r-- | src/nvim/fold.c | 4 | ||||
| -rw-r--r-- | src/nvim/memline.c | 57 | ||||
| -rw-r--r-- | src/nvim/ops.c | 25 | ||||
| -rw-r--r-- | src/nvim/screen.c | 147 | ||||
| -rw-r--r-- | src/nvim/search.c | 236 | ||||
| -rw-r--r-- | src/nvim/spell.c | 6 | ||||
| -rw-r--r-- | src/nvim/spellfile.c | 2 | ||||
| -rw-r--r-- | src/nvim/syntax.c | 236 | ||||
| -rw-r--r-- | src/nvim/tag.c | 43 | ||||
| -rw-r--r-- | src/nvim/undo.c | 6 | ||||
| -rw-r--r-- | src/nvim/window.c | 2 |
15 files changed, 411 insertions, 423 deletions
diff --git a/src/nvim/change.c b/src/nvim/change.c index 41e1e3911b..13b86e9244 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -1837,7 +1837,7 @@ void truncate_line(int fixpos) /// Delete "nlines" lines at the cursor. /// Saves the lines for undo first if "undo" is true. -void del_lines(long nlines, int undo) +void del_lines(long nlines, bool undo) { long n; linenr_T first = curwin->w_cursor.lnum; diff --git a/src/nvim/edit.c b/src/nvim/edit.c index fec8da2c3c..ffe60ab043 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1652,8 +1652,8 @@ static void init_prompt(int cmdchar_todo) check_cursor(); } -// Return TRUE if the cursor is in the editable position of the prompt line. -int prompt_curpos_editable(void) +/// @return true if the cursor is in the editable position of the prompt line. +bool prompt_curpos_editable(void) { return curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count && curwin->w_cursor.col >= (int)STRLEN(prompt_text()); @@ -8124,8 +8124,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p) // again when auto-formatting. if (has_format_option(FO_AUTO) && has_format_option(FO_WHITE_PAR)) { - char_u *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, - TRUE); + char_u *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, true); int len; len = (int)STRLEN(ptr); diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 0c099085a0..f7a1327c87 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -715,7 +715,7 @@ sortend: void ex_retab(exarg_T *eap) { linenr_T lnum; - int got_tab = FALSE; + bool got_tab = false; long num_spaces = 0; long num_tabs; long len; @@ -766,10 +766,11 @@ void ex_retab(exarg_T *eap) start_vcol = vcol; start_col = col; } - if (ptr[col] == ' ') + if (ptr[col] == ' ') { num_spaces++; - else - got_tab = TRUE; + } else { + got_tab = true; + } } else { if (got_tab || (eap->forceit && num_spaces > 1)) { /* Retabulate this string of white-space */ @@ -824,7 +825,7 @@ void ex_retab(exarg_T *eap) col = start_col + len; } } - got_tab = FALSE; + got_tab = false; num_spaces = 0; } if (ptr[col] == NUL) @@ -1386,11 +1387,11 @@ static void do_filter( * Adjust '[ and '] (set by buf_write()). */ curwin->w_cursor.lnum = line1; - del_lines(linecount, TRUE); - curbuf->b_op_start.lnum -= linecount; /* adjust '[ */ - curbuf->b_op_end.lnum -= linecount; /* adjust '] */ - write_lnum_adjust(-linecount); /* adjust last line - for next write */ + del_lines(linecount, true); + curbuf->b_op_start.lnum -= linecount; // adjust '[ + curbuf->b_op_end.lnum -= linecount; // adjust '] + write_lnum_adjust(-linecount); // adjust last line + // for next write foldUpdate(curwin, curbuf->b_op_start.lnum, curbuf->b_op_end.lnum); } else { /* @@ -3835,7 +3836,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, _("replace with %s (y/n/a/q/l/^E/^Y)?"), sub); msg_no_more = FALSE; msg_scroll = i; - showruler(TRUE); + showruler(true); ui_cursor_goto(msg_row, msg_col); RedrawingDisabled = temp; @@ -5171,21 +5172,21 @@ void fix_help_buffer(void) if (in_example && len > 0 && !ascii_iswhite(line[0])) { /* End of example: non-white or '<' in first column. */ if (line[0] == '<') { - /* blank-out a '<' in the first column */ - line = ml_get_buf(curbuf, lnum, TRUE); + // blank-out a '<' in the first column + line = ml_get_buf(curbuf, lnum, true); line[0] = ' '; } in_example = false; } if (!in_example && len > 0) { if (line[len - 1] == '>' && (len == 1 || line[len - 2] == ' ')) { - /* blank-out a '>' in the last column (start of example) */ - line = ml_get_buf(curbuf, lnum, TRUE); + // blank-out a '>' in the last column (start of example) + line = ml_get_buf(curbuf, lnum, true); line[len - 1] = ' '; in_example = true; } else if (line[len - 1] == '~') { - /* blank-out a '~' at the end of line (header marker) */ - line = ml_get_buf(curbuf, lnum, TRUE); + // blank-out a '~' at the end of line (header marker) + line = ml_get_buf(curbuf, lnum, true); line[len - 1] = ' '; } } @@ -5204,10 +5205,11 @@ void fix_help_buffer(void) && TOLOWER_ASC(fname[7]) == 'x' && fname[8] == NUL) ) { - for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; ++lnum) { - line = ml_get_buf(curbuf, lnum, FALSE); - if (strstr((char *)line, "*local-additions*") == NULL) + for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; lnum++) { + line = ml_get_buf(curbuf, lnum, false); + if (strstr((char *)line, "*local-additions*") == NULL) { continue; + } /* Go through all directories in 'runtimepath', skipping * $VIMRUNTIME. */ diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 7cab3eb650..0f98c9cd34 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -5734,18 +5734,13 @@ HistoryType get_histtype(const char *const name, const size_t len, static int last_maptick = -1; /* last seen maptick */ -/* - * Add the given string to the given history. If the string is already in the - * history then it is moved to the front. "histype" may be one of he HIST_ - * values. - */ -void -add_to_history ( - int histype, - char_u *new_entry, - int in_map, /* consider maptick when inside a mapping */ - int sep /* separator character used (search hist) */ -) +/// Add the given string to the given history. If the string is already in the +/// history then it is moved to the front. "histype" may be one of he HIST_ +/// values. +/// +/// @parma in_map consider maptick when inside a mapping +/// @param sep separator character used (search hist) +void add_to_history(int histype, char_u *new_entry, int in_map, int sep) { histentry_T *hisptr; diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 6989c29d57..51a8a85aa0 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -2961,7 +2961,7 @@ static void foldlevelIndent(fline_T *flp) linenr_T lnum = flp->lnum + flp->off; buf = flp->wp->w_buffer; - s = skipwhite(ml_get_buf(buf, lnum, FALSE)); + s = skipwhite(ml_get_buf(buf, lnum, false)); /* empty line or lines starting with a character in 'foldignore': level * depends on surrounding lines */ @@ -3123,7 +3123,7 @@ static void foldlevelMarker(fline_T *flp) flp->start = 0; flp->lvl_next = flp->lvl; - s = ml_get_buf(flp->wp->w_buffer, flp->lnum + flp->off, FALSE); + s = ml_get_buf(flp->wp->w_buffer, flp->lnum + flp->off, false); while (*s) { if (*s == cstart && STRNCMP(s + 1, startmarker, foldstartmarkerlen - 1) == 0) { diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 8229b8f6bc..4d435bc99f 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -382,7 +382,7 @@ error: */ void ml_setname(buf_T *buf) { - int success = FALSE; + bool success = false; memfile_T *mfp; char_u *fname; char_u *dirp; @@ -418,7 +418,7 @@ void ml_setname(buf_T *buf) /* if the file name is the same we don't have to do anything */ if (fnamecmp(fname, mfp->mf_fname) == 0) { xfree(fname); - success = TRUE; + success = true; break; } /* need to close the swap file before renaming */ @@ -429,7 +429,7 @@ void ml_setname(buf_T *buf) /* try to rename the swap file */ if (vim_rename(mfp->mf_fname, fname) == 0) { - success = TRUE; + success = true; mf_free_fnames(mfp); mf_set_fnames(mfp, fname); ml_upd_block0(buf, UB_SAME_DIR); @@ -758,12 +758,12 @@ void ml_recover(bool checkext) blocknr_T bnum; int page_count; int len; - int directly; + bool directly; linenr_T lnum; char_u *p; int i; long error; - int cannot_open; + bool cannot_open; linenr_T line_count; bool has_error; int idx; @@ -771,7 +771,7 @@ void ml_recover(bool checkext) int txt_start; off_T size; int called_from_main; - int serious_error = TRUE; + bool serious_error = true; long mtime; int attr; int orig_file_status = NOTDONE; @@ -791,10 +791,10 @@ void ml_recover(bool checkext) && vim_strchr((char_u *)"abcdefghijklmnopqrstuvw", TOLOWER_ASC(fname[len - 2])) != NULL && ASCII_ISALPHA(fname[len - 1])) { - directly = TRUE; - fname_used = vim_strsave(fname); /* make a copy for mf_open() */ + directly = true; + fname_used = vim_strsave(fname); // make a copy for mf_open() } else { - directly = FALSE; + directly = false; /* count the number of matching swap files */ len = recover_names(fname, FALSE, 0, NULL); @@ -1018,12 +1018,13 @@ void ml_recover(bool checkext) buf->b_ml.ml_stack = NULL; buf->b_ml.ml_stack_size = 0; /* no stack yet */ - if (curbuf->b_ffname == NULL) - cannot_open = TRUE; - else - cannot_open = FALSE; + if (curbuf->b_ffname == NULL) { + cannot_open = true; + } else { + cannot_open = false; + } - serious_error = FALSE; + serious_error = false; for (; !got_int; line_breakcheck()) { if (hp != NULL) mf_put(mfp, hp, false, false); /* release previous block */ @@ -1796,7 +1797,7 @@ theend: */ char_u *ml_get(linenr_T lnum) { - return ml_get_buf(curbuf, lnum, FALSE); + return ml_get_buf(curbuf, lnum, false); } /* @@ -2096,7 +2097,7 @@ static int ml_append_int( int total_moved = 0; /* init to shut up gcc */ DATA_BL *dp_right, *dp_left; int stack_idx; - int in_left; + bool in_left; int lineadd; blocknr_T bnum_left, bnum_right; linenr_T lnum_left, lnum_right; @@ -2113,22 +2114,22 @@ static int ml_append_int( */ if (db_idx < 0) { /* left block is new, right block is existing */ lines_moved = 0; - in_left = TRUE; - /* space_needed does not change */ - } else { /* left block is existing, right block is new */ + in_left = true; + // space_needed does not change + } else { // left block is existing, right block is new lines_moved = line_count - db_idx - 1; - if (lines_moved == 0) - in_left = FALSE; /* put new line in right block */ - /* space_needed does not change */ - else { + if (lines_moved == 0) { + in_left = false; // put new line in right block + // space_needed does not change + } else { data_moved = ((dp->db_index[db_idx]) & DB_INDEX_MASK) - dp->db_txt_start; total_moved = data_moved + lines_moved * INDEX_SIZE; if ((int)dp->db_free + total_moved >= space_needed) { - in_left = TRUE; /* put new line in left block */ + in_left = true; // put new line in left block space_needed = total_moved; } else { - in_left = FALSE; /* put new line in right block */ + in_left = false; // put new line in right block space_needed += total_moved; } } @@ -2761,7 +2762,7 @@ static void ml_flush_line(buf_T *buf) int start; int count; int i; - static int entered = FALSE; + static bool entered = false; if (buf->b_ml.ml_line_lnum == 0 || buf->b_ml.ml_mfp == NULL) return; /* nothing to do */ @@ -2770,7 +2771,7 @@ static void ml_flush_line(buf_T *buf) /* This code doesn't work recursively. */ if (entered) return; - entered = TRUE; + entered = true; buf->flush_count++; @@ -2833,7 +2834,7 @@ static void ml_flush_line(buf_T *buf) } xfree(new_line); - entered = FALSE; + entered = false; } buf->b_ml.ml_line_lnum = 0; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index a6eda26d75..178b454e4e 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1121,18 +1121,13 @@ static void put_reedit_in_typebuf(int silent) } } -/* - * Insert register contents "s" into the typeahead buffer, so that it will be - * executed again. - * When "esc" is TRUE it is to be taken literally: Escape CSI characters and - * no remapping. - */ -static int put_in_typebuf( - char_u *s, - bool esc, - bool colon, // add ':' before the line - int silent -) +/// Insert register contents "s" into the typeahead buffer, so that it will be +/// executed again. +/// +/// @param esc when true then it is to be taken literally: Escape CSI +/// characters and no remapping. +/// @param colon add ':' before the line +static int put_in_typebuf(char_u *s, bool esc, bool colon, int silent) { int retval = OK; @@ -1567,8 +1562,8 @@ int op_delete(oparg_T *oap) if (oap->line_count > 1) { lnum = curwin->w_cursor.lnum; - ++curwin->w_cursor.lnum; - del_lines(oap->line_count - 1, TRUE); + curwin->w_cursor.lnum++; + del_lines(oap->line_count - 1, true); curwin->w_cursor.lnum = lnum; } if (u_save_cursor() == FAIL) @@ -1593,7 +1588,7 @@ int op_delete(oparg_T *oap) u_clearline(); // "U" command not possible after "2cc" } } else { - del_lines(oap->line_count, TRUE); + del_lines(oap->line_count, true); beginline(BL_WHITE | BL_FIX); u_clearline(); /* "U" command not possible after "dd" */ } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index e4030b76a3..208ae3488f 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -324,8 +324,7 @@ void update_curbuf(int type) /// @param type set to a NOT_VALID to force redraw of entire screen int update_screen(int type) { - static int did_intro = FALSE; - int did_one; + static bool did_intro = false; // Don't do anything if the screen structures are (not yet) valid. // A VimResized autocmd can invoke redrawing in the middle of a resize, @@ -578,7 +577,7 @@ int update_screen(int type) * Go from top to bottom through the windows, redrawing the ones that need * it. */ - did_one = FALSE; + bool did_one = false; search_hl.rm.regprog = NULL; @@ -597,7 +596,7 @@ int update_screen(int type) if (wp->w_redr_type != 0) { if (!did_one) { - did_one = TRUE; + did_one = true; start_search_hl(); } win_update(wp, &providers); @@ -635,7 +634,7 @@ int update_screen(int type) /* May put up an introductory message when not editing a file */ if (!did_intro) maybe_intro_message(); - did_intro = TRUE; + did_intro = true; for (size_t i = 0; i < kv_size(providers); i++) { DecorProvider *p = kv_A(providers, i); @@ -747,8 +746,7 @@ static void win_update(win_T *wp, Providers *providers) updating. 0 when no mid area updating. */ int bot_start = 999; /* first row of the bot area that needs updating. 999 when no bot area updating */ - int scrolled_down = FALSE; /* TRUE when scrolled down when - w_topline got smaller a bit */ + bool scrolled_down = false; // true when scrolled down when w_topline got smaller a bit bool top_to_mod = false; // redraw above mod_top int row; /* current window row to display */ @@ -756,8 +754,8 @@ static void win_update(win_T *wp, Providers *providers) int idx; /* current index in w_lines[] */ int srow; /* starting row of the current line */ - int eof = FALSE; /* if TRUE, we hit the end of the file */ - int didline = FALSE; /* if TRUE, we finished the last line */ + bool eof = false; // if true, we hit the end of the file + bool didline = false; // if true, we finished the last line int i; long j; static bool recursive = false; // being called recursively @@ -1339,7 +1337,7 @@ static void win_update(win_T *wp, Providers *providers) /* stop updating when hit the end of the file */ if (lnum > buf->b_ml.ml_line_count) { - eof = TRUE; + eof = true; break; } @@ -1596,7 +1594,7 @@ static void win_update(win_T *wp, Providers *providers) } if (lnum > buf->b_ml.ml_line_count) { - eof = TRUE; + eof = true; break; } } @@ -1841,10 +1839,10 @@ static void win_draw_end(win_T *wp, int c1, int c2, bool draw_margin, int row, } -/* - * Advance **color_cols and return TRUE when there are columns to draw. - */ -static int advance_color_col(int vcol, int **color_cols) +/// Advance **color_cols +/// +/// @return true when there are columns to draw. +static bool advance_color_col(int vcol, int **color_cols) { while (**color_cols >= 0 && vcol > **color_cols) ++*color_cols; @@ -2062,7 +2060,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int has_syntax = FALSE; /* this buffer has syntax highl. */ int save_did_emsg; int eol_hl_off = 0; // 1 if highlighted char after EOL - int draw_color_col = false; // highlight colorcolumn + bool draw_color_col = false; // highlight colorcolumn int *color_cols = NULL; // pointer to according columns array bool has_spell = false; // this buffer has spell checking # define SPWORDLEN 150 @@ -2139,7 +2137,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int syntax_seqnr = 0; int prev_syntax_id = 0; int conceal_attr = win_hl_attr(wp, HLF_CONCEAL); - int is_concealing = false; + bool is_concealing = false; int boguscols = 0; ///< nonexistent columns added to ///< force wrapping int vcol_off = 0; ///< offset for concealed characters @@ -2430,7 +2428,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, line_attr_lowprio_save = line_attr_lowprio; } - line = ml_get_buf(wp->w_buffer, lnum, FALSE); + line = ml_get_buf(wp->w_buffer, lnum, false); ptr = line; if (has_spell && !number_only) { @@ -2562,8 +2560,8 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, wp->w_cursor.col = linecol; len = spell_move_to(wp, FORWARD, TRUE, TRUE, &spell_hlf); - /* spell_move_to() may call ml_get() and make "line" invalid */ - line = ml_get_buf(wp->w_buffer, lnum, FALSE); + // spell_move_to() may call ml_get() and make "line" invalid + line = ml_get_buf(wp->w_buffer, lnum, false); ptr = line + linecol; if (len == 0 || (int)wp->w_cursor.col > ptr - line) { @@ -3095,9 +3093,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, shl == &search_hl ? NULL : cur); pos_inprogress = !(cur == NULL || cur->pos.cur == 0); - /* Need to get the line again, a multi-line regexp - * may have made it invalid. */ - line = ml_get_buf(wp->w_buffer, lnum, FALSE); + // Need to get the line again, a multi-line regexp + // may have made it invalid. + line = ml_get_buf(wp->w_buffer, lnum, false); ptr = line + v; if (shl->lnum == lnum) { @@ -3408,9 +3406,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, } else did_emsg = save_did_emsg; - /* Need to get the line again, a multi-line regexp may - * have made it invalid. */ - line = ml_get_buf(wp->w_buffer, lnum, FALSE); + // Need to get the line again, a multi-line regexp may + // have made it invalid. + line = ml_get_buf(wp->w_buffer, lnum, false); ptr = line + v; if (!attr_pri) { @@ -3834,7 +3832,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, n_extra = 0; n_attr = 0; } else if (n_skip == 0) { - is_concealing = TRUE; + is_concealing = true; n_skip = 1; } mb_c = c; @@ -3847,7 +3845,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, } } else { prev_syntax_id = 0; - is_concealing = FALSE; + is_concealing = false; } if (n_skip > 0 && did_decrement_ptr) { @@ -4953,12 +4951,12 @@ win_redr_status_matches ( int fillchar; int attr; int i; - int highlight = TRUE; + bool highlight = true; char_u *selstart = NULL; int selstart_col = 0; char_u *selend = NULL; static int first_match = 0; - int add_left = FALSE; + bool add_left = false; char_u *s; int emenu; int l; @@ -4970,7 +4968,7 @@ win_redr_status_matches ( if (match == -1) { /* don't show match but original text */ match = 0; - highlight = FALSE; + highlight = false; } /* count 1 for the ending ">" */ clen = status_match_len(xp, L_MATCH(match)) + 3; @@ -4979,7 +4977,7 @@ win_redr_status_matches ( else if (match < first_match) { /* jumping left, as far as we can go */ first_match = match; - add_left = TRUE; + add_left = true; } else { /* check if match fits on the screen */ for (i = first_match; i < match; ++i) @@ -4997,8 +4995,9 @@ win_redr_status_matches ( break; } } - if (i == num_matches) - add_left = TRUE; + if (i == num_matches) { + add_left = true; + } } } if (add_left) @@ -5215,7 +5214,7 @@ static void win_redr_status(win_T *wp) grid_puts(&default_grid, NameBuff, row, (int)(this_ru_col - STRLEN(NameBuff) - 1), attr); - win_redr_ruler(wp, TRUE); + win_redr_ruler(wp, true); } /* @@ -5238,14 +5237,14 @@ static void win_redr_status(win_T *wp) */ static void redraw_custom_statusline(win_T *wp) { - static int entered = false; + static bool entered = false; int saved_did_emsg = did_emsg; /* When called recursively return. This can happen when the statusline * contains an expression that triggers a redraw. */ if (entered) return; - entered = TRUE; + entered = true; did_emsg = false; win_redr_custom(wp, false); @@ -5261,12 +5260,11 @@ static void redraw_custom_statusline(win_T *wp) entered = false; } -/* - * Return TRUE if the status line of window "wp" is connected to the status - * line of the window right of it. If not, then it's a vertical separator. - * Only call if (wp->w_vsep_width != 0). - */ -int stl_connected(win_T *wp) +/// Only call if (wp->w_vsep_width != 0). +/// +/// @return true if the status line of window "wp" is connected to the status +/// line of the window right of it. If not, then it's a vertical separator. +bool stl_connected(win_T *wp) { frame_T *fr; @@ -5276,30 +5274,28 @@ int stl_connected(win_T *wp) if (fr->fr_next != NULL) break; } else { - if (fr->fr_next != NULL) - return TRUE; + if (fr->fr_next != NULL) { + return true; + } } fr = fr->fr_parent; } - return FALSE; + return false; } -/* - * Get the value to show for the language mappings, active 'keymap'. - */ -int -get_keymap_str ( - win_T *wp, - char_u *fmt, // format string containing one %s item - char_u *buf, // buffer for the result - int len // length of buffer -) +/// Get the value to show for the language mappings, active 'keymap'. +/// +/// @param fmt format string containing one %s item +/// @param buf buffer for the result +/// @param len length of buffer +bool get_keymap_str(win_T *wp, char_u *fmt, char_u *buf, int len) { char_u *p; - if (wp->w_buffer->b_p_iminsert != B_IMODE_LMAP) - return FALSE; + if (wp->w_buffer->b_p_iminsert != B_IMODE_LMAP) { + return false; + } { buf_T *old_curbuf = curbuf; @@ -5339,7 +5335,7 @@ win_redr_custom ( bool draw_ruler ) { - static int entered = FALSE; + static bool entered = false; int attr; int curattr; int row; @@ -5365,7 +5361,7 @@ win_redr_custom ( * Avoid trouble by not allowing recursion. */ if (entered) return; - entered = TRUE; + entered = true; /* setup environment for the task at hand */ if (wp == NULL) { @@ -5500,7 +5496,7 @@ win_redr_custom ( } theend: - entered = FALSE; + entered = false; } static void win_redr_border(win_T *wp) @@ -6065,7 +6061,7 @@ next_search_hl ( char_u *ml; matchcol = shl->rm.startpos[0].col; - ml = ml_get_buf(shl->buf, lnum, FALSE) + matchcol; + ml = ml_get_buf(shl->buf, lnum, false) + matchcol; if (*ml == NUL) { ++matchcol; shl->lnum = 0; @@ -7333,11 +7329,10 @@ int messaging(void) return !(p_lz && char_avail() && !KeyTyped); } -/* - * Show current status info in ruler and various other places - * If always is FALSE, only show ruler if position has changed. - */ -void showruler(int always) +/// Show current status info in ruler and various other places +/// +/// @param always if false, only show ruler if position has changed. +void showruler(bool always) { if (!always && !redrawing()) return; @@ -7357,7 +7352,7 @@ void showruler(int always) draw_tabline(); } -static void win_redr_ruler(win_T *wp, int always) +static void win_redr_ruler(win_T *wp, bool always) { static bool did_show_ext_ruler = false; @@ -7619,11 +7614,11 @@ static void margin_columns_win(win_T *wp, int *left_col, int *right_col) /// Set dimensions of the Nvim application "shell". void screen_resize(int width, int height) { - static int busy = FALSE; + static bool recursive = false; // Avoid recursiveness, can happen when setting the window size causes // another window-changed signal. - if (updating_screen || busy) { + if (updating_screen || recursive) { return; } @@ -7643,7 +7638,7 @@ void screen_resize(int width, int height) if (curwin->w_buffer == NULL) return; - ++busy; + recursive = true; Rows = height; Columns = width; @@ -7662,7 +7657,7 @@ void screen_resize(int width, int height) /* The window layout used to be adjusted here, but it now happens in * screenalloc() (also invoked from screenclear()). That is because the - * "busy" check above may skip this, but not screenalloc(). */ + * "recursive" check above may skip this, but not screenalloc(). */ if (State != ASKMORE && State != EXTERNCMD && State != CONFIRM) { screenclear(); @@ -7694,8 +7689,9 @@ void screen_resize(int width, int height) ui_comp_set_screen_valid(true); repeat_message(); } else { - if (curwin->w_p_scb) - do_check_scrollbind(TRUE); + if (curwin->w_p_scb) { + do_check_scrollbind(true); + } if (State & CMDLINE) { redraw_popupmenu = false; update_screen(NOT_VALID); @@ -7720,7 +7716,7 @@ void screen_resize(int width, int height) } ui_flush(); } - busy--; + recursive = false; } /// Check if the new Nvim application "shell" dimensions are valid. @@ -7778,4 +7774,3 @@ win_T *get_win_by_grid_handle(handle_T handle) return NULL; } - diff --git a/src/nvim/search.c b/src/nvim/search.c index b712e09861..b0ee41b245 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -98,7 +98,7 @@ static int saved_spats_last_idx = 0; static bool saved_spats_no_hlsearch = false; static char_u *mr_pattern = NULL; // pattern used by search_regcomp() -static int mr_pattern_alloced = false; // mr_pattern was allocated +static bool mr_pattern_alloced = false; // mr_pattern was allocated /* * Type used by find_pattern_in_path() to remember which included files have @@ -159,19 +159,21 @@ search_regcomp( pat = spats[i].pat; magic = spats[i].magic; no_smartcase = spats[i].no_scs; - } else if (options & SEARCH_HIS) /* put new pattern in history */ - add_to_history(HIST_SEARCH, pat, TRUE, NUL); + } else if (options & SEARCH_HIS) { // put new pattern in history + add_to_history(HIST_SEARCH, pat, true, NUL); + } if (mr_pattern_alloced) { xfree(mr_pattern); - mr_pattern_alloced = FALSE; + mr_pattern_alloced = false; } if (curwin->w_p_rl && *curwin->w_p_rlc == 's') { mr_pattern = reverse_text(pat); - mr_pattern_alloced = TRUE; - } else + mr_pattern_alloced = true; + } else { mr_pattern = pat; + } /* * Save the currently used pattern in the appropriate place, @@ -293,7 +295,7 @@ void free_search_patterns(void) if (mr_pattern_alloced) { xfree(mr_pattern); - mr_pattern_alloced = FALSE; + mr_pattern_alloced = false; mr_pattern = NULL; } } @@ -556,12 +558,12 @@ int searchit( int at_first_line; int extra_col; int start_char_len; - int match_ok; + bool match_ok; long nmatched; int submatch = 0; bool first_match = true; int save_called_emsg = called_emsg; - int break_loop = false; + bool break_loop = false; linenr_T stop_lnum = 0; // stop after this line number when != 0 proftime_T *tm = NULL; // timeout limit or NULL int *timed_out = NULL; // set when timed out or NULL @@ -659,11 +661,12 @@ int searchit( matchpos = regmatch.startpos[0]; endpos = regmatch.endpos[0]; submatch = first_submatch(®match); - /* "lnum" may be past end of buffer for "\n\zs". */ - if (lnum + matchpos.lnum > buf->b_ml.ml_line_count) + // "lnum" may be past end of buffer for "\n\zs". |