refactor: replace TRUE/FALSE with true/false #15425

This commit is contained in:
dundargoc
2021-08-22 16:10:57 +02:00
committed by GitHub
parent 783140c670
commit db1b0ee3b3
15 changed files with 411 additions and 423 deletions

View File

@@ -1837,7 +1837,7 @@ void truncate_line(int fixpos)
/// Delete "nlines" lines at the cursor. /// Delete "nlines" lines at the cursor.
/// Saves the lines for undo first if "undo" is true. /// 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; long n;
linenr_T first = curwin->w_cursor.lnum; linenr_T first = curwin->w_cursor.lnum;

View File

@@ -1652,8 +1652,8 @@ static void init_prompt(int cmdchar_todo)
check_cursor(); check_cursor();
} }
// Return TRUE if the cursor is in the editable position of the prompt line. /// @return true if the cursor is in the editable position of the prompt line.
int prompt_curpos_editable(void) bool prompt_curpos_editable(void)
{ {
return curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count return curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count
&& curwin->w_cursor.col >= (int)STRLEN(prompt_text()); && 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. // again when auto-formatting.
if (has_format_option(FO_AUTO) if (has_format_option(FO_AUTO)
&& has_format_option(FO_WHITE_PAR)) { && has_format_option(FO_WHITE_PAR)) {
char_u *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, char_u *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, true);
TRUE);
int len; int len;
len = (int)STRLEN(ptr); len = (int)STRLEN(ptr);

View File

@@ -715,7 +715,7 @@ sortend:
void ex_retab(exarg_T *eap) void ex_retab(exarg_T *eap)
{ {
linenr_T lnum; linenr_T lnum;
int got_tab = FALSE; bool got_tab = false;
long num_spaces = 0; long num_spaces = 0;
long num_tabs; long num_tabs;
long len; long len;
@@ -766,10 +766,11 @@ void ex_retab(exarg_T *eap)
start_vcol = vcol; start_vcol = vcol;
start_col = col; start_col = col;
} }
if (ptr[col] == ' ') if (ptr[col] == ' ') {
num_spaces++; num_spaces++;
else } else {
got_tab = TRUE; got_tab = true;
}
} else { } else {
if (got_tab || (eap->forceit && num_spaces > 1)) { if (got_tab || (eap->forceit && num_spaces > 1)) {
/* Retabulate this string of white-space */ /* Retabulate this string of white-space */
@@ -824,7 +825,7 @@ void ex_retab(exarg_T *eap)
col = start_col + len; col = start_col + len;
} }
} }
got_tab = FALSE; got_tab = false;
num_spaces = 0; num_spaces = 0;
} }
if (ptr[col] == NUL) if (ptr[col] == NUL)
@@ -1386,11 +1387,11 @@ static void do_filter(
* Adjust '[ and '] (set by buf_write()). * Adjust '[ and '] (set by buf_write()).
*/ */
curwin->w_cursor.lnum = line1; curwin->w_cursor.lnum = line1;
del_lines(linecount, TRUE); del_lines(linecount, true);
curbuf->b_op_start.lnum -= linecount; /* adjust '[ */ curbuf->b_op_start.lnum -= linecount; // adjust '[
curbuf->b_op_end.lnum -= linecount; /* adjust '] */ curbuf->b_op_end.lnum -= linecount; // adjust ']
write_lnum_adjust(-linecount); /* adjust last line write_lnum_adjust(-linecount); // adjust last line
for next write */ // for next write
foldUpdate(curwin, curbuf->b_op_start.lnum, curbuf->b_op_end.lnum); foldUpdate(curwin, curbuf->b_op_start.lnum, curbuf->b_op_end.lnum);
} else { } 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); _("replace with %s (y/n/a/q/l/^E/^Y)?"), sub);
msg_no_more = FALSE; msg_no_more = FALSE;
msg_scroll = i; msg_scroll = i;
showruler(TRUE); showruler(true);
ui_cursor_goto(msg_row, msg_col); ui_cursor_goto(msg_row, msg_col);
RedrawingDisabled = temp; RedrawingDisabled = temp;
@@ -5171,21 +5172,21 @@ void fix_help_buffer(void)
if (in_example && len > 0 && !ascii_iswhite(line[0])) { if (in_example && len > 0 && !ascii_iswhite(line[0])) {
/* End of example: non-white or '<' in first column. */ /* End of example: non-white or '<' in first column. */
if (line[0] == '<') { if (line[0] == '<') {
/* blank-out a '<' in the first column */ // blank-out a '<' in the first column
line = ml_get_buf(curbuf, lnum, TRUE); line = ml_get_buf(curbuf, lnum, true);
line[0] = ' '; line[0] = ' ';
} }
in_example = false; in_example = false;
} }
if (!in_example && len > 0) { if (!in_example && len > 0) {
if (line[len - 1] == '>' && (len == 1 || line[len - 2] == ' ')) { if (line[len - 1] == '>' && (len == 1 || line[len - 2] == ' ')) {
/* blank-out a '>' in the last column (start of example) */ // blank-out a '>' in the last column (start of example)
line = ml_get_buf(curbuf, lnum, TRUE); line = ml_get_buf(curbuf, lnum, true);
line[len - 1] = ' '; line[len - 1] = ' ';
in_example = true; in_example = true;
} else if (line[len - 1] == '~') { } else if (line[len - 1] == '~') {
/* blank-out a '~' at the end of line (header marker) */ // blank-out a '~' at the end of line (header marker)
line = ml_get_buf(curbuf, lnum, TRUE); line = ml_get_buf(curbuf, lnum, true);
line[len - 1] = ' '; line[len - 1] = ' ';
} }
} }
@@ -5204,10 +5205,11 @@ void fix_help_buffer(void)
&& TOLOWER_ASC(fname[7]) == 'x' && TOLOWER_ASC(fname[7]) == 'x'
&& fname[8] == NUL) && fname[8] == NUL)
) { ) {
for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; ++lnum) { for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; lnum++) {
line = ml_get_buf(curbuf, lnum, FALSE); line = ml_get_buf(curbuf, lnum, false);
if (strstr((char *)line, "*local-additions*") == NULL) if (strstr((char *)line, "*local-additions*") == NULL) {
continue; continue;
}
/* Go through all directories in 'runtimepath', skipping /* Go through all directories in 'runtimepath', skipping
* $VIMRUNTIME. */ * $VIMRUNTIME. */

View File

@@ -5734,18 +5734,13 @@ HistoryType get_histtype(const char *const name, const size_t len,
static int last_maptick = -1; /* last seen maptick */ static int last_maptick = -1; /* last seen maptick */
/* /// Add the given string to the given history. If the string is already in the
* 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_
* history then it is moved to the front. "histype" may be one of he HIST_ /// values.
* values. ///
*/ /// @parma in_map consider maptick when inside a mapping
void /// @param sep separator character used (search hist)
add_to_history ( void add_to_history(int histype, char_u *new_entry, int in_map, int sep)
int histype,
char_u *new_entry,
int in_map, /* consider maptick when inside a mapping */
int sep /* separator character used (search hist) */
)
{ {
histentry_T *hisptr; histentry_T *hisptr;

View File

@@ -2961,7 +2961,7 @@ static void foldlevelIndent(fline_T *flp)
linenr_T lnum = flp->lnum + flp->off; linenr_T lnum = flp->lnum + flp->off;
buf = flp->wp->w_buffer; 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 /* empty line or lines starting with a character in 'foldignore': level
* depends on surrounding lines */ * depends on surrounding lines */
@@ -3123,7 +3123,7 @@ static void foldlevelMarker(fline_T *flp)
flp->start = 0; flp->start = 0;
flp->lvl_next = flp->lvl; 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) { while (*s) {
if (*s == cstart if (*s == cstart
&& STRNCMP(s + 1, startmarker, foldstartmarkerlen - 1) == 0) { && STRNCMP(s + 1, startmarker, foldstartmarkerlen - 1) == 0) {

View File

@@ -382,7 +382,7 @@ error:
*/ */
void ml_setname(buf_T *buf) void ml_setname(buf_T *buf)
{ {
int success = FALSE; bool success = false;
memfile_T *mfp; memfile_T *mfp;
char_u *fname; char_u *fname;
char_u *dirp; 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 the file name is the same we don't have to do anything */
if (fnamecmp(fname, mfp->mf_fname) == 0) { if (fnamecmp(fname, mfp->mf_fname) == 0) {
xfree(fname); xfree(fname);
success = TRUE; success = true;
break; break;
} }
/* need to close the swap file before renaming */ /* need to close the swap file before renaming */
@@ -429,7 +429,7 @@ void ml_setname(buf_T *buf)
/* try to rename the swap file */ /* try to rename the swap file */
if (vim_rename(mfp->mf_fname, fname) == 0) { if (vim_rename(mfp->mf_fname, fname) == 0) {
success = TRUE; success = true;
mf_free_fnames(mfp); mf_free_fnames(mfp);
mf_set_fnames(mfp, fname); mf_set_fnames(mfp, fname);
ml_upd_block0(buf, UB_SAME_DIR); ml_upd_block0(buf, UB_SAME_DIR);
@@ -758,12 +758,12 @@ void ml_recover(bool checkext)
blocknr_T bnum; blocknr_T bnum;
int page_count; int page_count;
int len; int len;
int directly; bool directly;
linenr_T lnum; linenr_T lnum;
char_u *p; char_u *p;
int i; int i;
long error; long error;
int cannot_open; bool cannot_open;
linenr_T line_count; linenr_T line_count;
bool has_error; bool has_error;
int idx; int idx;
@@ -771,7 +771,7 @@ void ml_recover(bool checkext)
int txt_start; int txt_start;
off_T size; off_T size;
int called_from_main; int called_from_main;
int serious_error = TRUE; bool serious_error = true;
long mtime; long mtime;
int attr; int attr;
int orig_file_status = NOTDONE; int orig_file_status = NOTDONE;
@@ -791,10 +791,10 @@ void ml_recover(bool checkext)
&& vim_strchr((char_u *)"abcdefghijklmnopqrstuvw", && vim_strchr((char_u *)"abcdefghijklmnopqrstuvw",
TOLOWER_ASC(fname[len - 2])) != NULL TOLOWER_ASC(fname[len - 2])) != NULL
&& ASCII_ISALPHA(fname[len - 1])) { && ASCII_ISALPHA(fname[len - 1])) {
directly = TRUE; directly = true;
fname_used = vim_strsave(fname); /* make a copy for mf_open() */ fname_used = vim_strsave(fname); // make a copy for mf_open()
} else { } else {
directly = FALSE; directly = false;
/* count the number of matching swap files */ /* count the number of matching swap files */
len = recover_names(fname, FALSE, 0, NULL); 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 = NULL;
buf->b_ml.ml_stack_size = 0; /* no stack yet */ buf->b_ml.ml_stack_size = 0; /* no stack yet */
if (curbuf->b_ffname == NULL) if (curbuf->b_ffname == NULL) {
cannot_open = TRUE; cannot_open = true;
else } else {
cannot_open = FALSE; cannot_open = false;
}
serious_error = FALSE; serious_error = false;
for (; !got_int; line_breakcheck()) { for (; !got_int; line_breakcheck()) {
if (hp != NULL) if (hp != NULL)
mf_put(mfp, hp, false, false); /* release previous block */ mf_put(mfp, hp, false, false); /* release previous block */
@@ -1796,7 +1797,7 @@ theend:
*/ */
char_u *ml_get(linenr_T lnum) 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 */ int total_moved = 0; /* init to shut up gcc */
DATA_BL *dp_right, *dp_left; DATA_BL *dp_right, *dp_left;
int stack_idx; int stack_idx;
int in_left; bool in_left;
int lineadd; int lineadd;
blocknr_T bnum_left, bnum_right; blocknr_T bnum_left, bnum_right;
linenr_T lnum_left, lnum_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 */ if (db_idx < 0) { /* left block is new, right block is existing */
lines_moved = 0; lines_moved = 0;
in_left = TRUE; in_left = true;
/* space_needed does not change */ // space_needed does not change
} else { /* left block is existing, right block is new */ } else { // left block is existing, right block is new
lines_moved = line_count - db_idx - 1; lines_moved = line_count - db_idx - 1;
if (lines_moved == 0) if (lines_moved == 0) {
in_left = FALSE; /* put new line in right block */ in_left = false; // put new line in right block
/* space_needed does not change */ // space_needed does not change
else { } else {
data_moved = ((dp->db_index[db_idx]) & DB_INDEX_MASK) - data_moved = ((dp->db_index[db_idx]) & DB_INDEX_MASK) -
dp->db_txt_start; dp->db_txt_start;
total_moved = data_moved + lines_moved * INDEX_SIZE; total_moved = data_moved + lines_moved * INDEX_SIZE;
if ((int)dp->db_free + total_moved >= space_needed) { 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; space_needed = total_moved;
} else { } else {
in_left = FALSE; /* put new line in right block */ in_left = false; // put new line in right block
space_needed += total_moved; space_needed += total_moved;
} }
} }
@@ -2761,7 +2762,7 @@ static void ml_flush_line(buf_T *buf)
int start; int start;
int count; int count;
int i; int i;
static int entered = FALSE; static bool entered = false;
if (buf->b_ml.ml_line_lnum == 0 || buf->b_ml.ml_mfp == NULL) if (buf->b_ml.ml_line_lnum == 0 || buf->b_ml.ml_mfp == NULL)
return; /* nothing to do */ return; /* nothing to do */
@@ -2770,7 +2771,7 @@ static void ml_flush_line(buf_T *buf)
/* This code doesn't work recursively. */ /* This code doesn't work recursively. */
if (entered) if (entered)
return; return;
entered = TRUE; entered = true;
buf->flush_count++; buf->flush_count++;
@@ -2833,7 +2834,7 @@ static void ml_flush_line(buf_T *buf)
} }
xfree(new_line); xfree(new_line);
entered = FALSE; entered = false;
} }
buf->b_ml.ml_line_lnum = 0; buf->b_ml.ml_line_lnum = 0;

View File

@@ -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
* Insert register contents "s" into the typeahead buffer, so that it will be /// executed again.
* executed again. ///
* When "esc" is TRUE it is to be taken literally: Escape CSI characters and /// @param esc when true then it is to be taken literally: Escape CSI
* no remapping. /// characters and no remapping.
*/ /// @param colon add ':' before the line
static int put_in_typebuf( static int put_in_typebuf(char_u *s, bool esc, bool colon, int silent)
char_u *s,
bool esc,
bool colon, // add ':' before the line
int silent
)
{ {
int retval = OK; int retval = OK;
@@ -1567,8 +1562,8 @@ int op_delete(oparg_T *oap)
if (oap->line_count > 1) { if (oap->line_count > 1) {
lnum = curwin->w_cursor.lnum; lnum = curwin->w_cursor.lnum;
++curwin->w_cursor.lnum; curwin->w_cursor.lnum++;
del_lines(oap->line_count - 1, TRUE); del_lines(oap->line_count - 1, true);
curwin->w_cursor.lnum = lnum; curwin->w_cursor.lnum = lnum;
} }
if (u_save_cursor() == FAIL) if (u_save_cursor() == FAIL)
@@ -1593,7 +1588,7 @@ int op_delete(oparg_T *oap)
u_clearline(); // "U" command not possible after "2cc" u_clearline(); // "U" command not possible after "2cc"
} }
} else { } else {
del_lines(oap->line_count, TRUE); del_lines(oap->line_count, true);
beginline(BL_WHITE | BL_FIX); beginline(BL_WHITE | BL_FIX);
u_clearline(); /* "U" command not possible after "dd" */ u_clearline(); /* "U" command not possible after "dd" */
} }

View File

@@ -324,8 +324,7 @@ void update_curbuf(int type)
/// @param type set to a NOT_VALID to force redraw of entire screen /// @param type set to a NOT_VALID to force redraw of entire screen
int update_screen(int type) int update_screen(int type)
{ {
static int did_intro = FALSE; static bool did_intro = false;
int did_one;
// Don't do anything if the screen structures are (not yet) valid. // Don't do anything if the screen structures are (not yet) valid.
// A VimResized autocmd can invoke redrawing in the middle of a resize, // 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 * Go from top to bottom through the windows, redrawing the ones that need
* it. * it.
*/ */
did_one = FALSE; bool did_one = false;
search_hl.rm.regprog = NULL; search_hl.rm.regprog = NULL;
@@ -597,7 +596,7 @@ int update_screen(int type)
if (wp->w_redr_type != 0) { if (wp->w_redr_type != 0) {
if (!did_one) { if (!did_one) {
did_one = TRUE; did_one = true;
start_search_hl(); start_search_hl();
} }
win_update(wp, &providers); win_update(wp, &providers);
@@ -635,7 +634,7 @@ int update_screen(int type)
/* May put up an introductory message when not editing a file */ /* May put up an introductory message when not editing a file */
if (!did_intro) if (!did_intro)
maybe_intro_message(); maybe_intro_message();
did_intro = TRUE; did_intro = true;
for (size_t i = 0; i < kv_size(providers); i++) { for (size_t i = 0; i < kv_size(providers); i++) {
DecorProvider *p = kv_A(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. */ updating. 0 when no mid area updating. */
int bot_start = 999; /* first row of the bot area that needs int bot_start = 999; /* first row of the bot area that needs
updating. 999 when no bot area updating */ updating. 999 when no bot area updating */
int scrolled_down = FALSE; /* TRUE when scrolled down when bool scrolled_down = false; // true when scrolled down when w_topline got smaller a bit
w_topline got smaller a bit */
bool top_to_mod = false; // redraw above mod_top bool top_to_mod = false; // redraw above mod_top
int row; /* current window row to display */ 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 idx; /* current index in w_lines[] */
int srow; /* starting row of the current line */ int srow; /* starting row of the current line */
int eof = FALSE; /* if TRUE, we hit the end of the file */ bool eof = false; // if true, we hit the end of the file
int didline = FALSE; /* if TRUE, we finished the last line */ bool didline = false; // if true, we finished the last line
int i; int i;
long j; long j;
static bool recursive = false; // being called recursively 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 */ /* stop updating when hit the end of the file */
if (lnum > buf->b_ml.ml_line_count) { if (lnum > buf->b_ml.ml_line_count) {
eof = TRUE; eof = true;
break; break;
} }
@@ -1596,7 +1594,7 @@ static void win_update(win_T *wp, Providers *providers)
} }
if (lnum > buf->b_ml.ml_line_count) { if (lnum > buf->b_ml.ml_line_count) {
eof = TRUE; eof = true;
break; 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
* Advance **color_cols and return TRUE when there are columns to draw. ///
*/ /// @return true when there are columns to draw.
static int advance_color_col(int vcol, int **color_cols) static bool advance_color_col(int vcol, int **color_cols)
{ {
while (**color_cols >= 0 && vcol > **color_cols) while (**color_cols >= 0 && vcol > **color_cols)
++*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 has_syntax = FALSE; /* this buffer has syntax highl. */
int save_did_emsg; int save_did_emsg;
int eol_hl_off = 0; // 1 if highlighted char after EOL 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 int *color_cols = NULL; // pointer to according columns array
bool has_spell = false; // this buffer has spell checking bool has_spell = false; // this buffer has spell checking
# define SPWORDLEN 150 # 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 syntax_seqnr = 0;
int prev_syntax_id = 0; int prev_syntax_id = 0;
int conceal_attr = win_hl_attr(wp, HLF_CONCEAL); int conceal_attr = win_hl_attr(wp, HLF_CONCEAL);
int is_concealing = false; bool is_concealing = false;
int boguscols = 0; ///< nonexistent columns added to int boguscols = 0; ///< nonexistent columns added to
///< force wrapping ///< force wrapping
int vcol_off = 0; ///< offset for concealed characters 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_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; ptr = line;
if (has_spell && !number_only) { 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; wp->w_cursor.col = linecol;
len = spell_move_to(wp, FORWARD, TRUE, TRUE, &spell_hlf); len = spell_move_to(wp, FORWARD, TRUE, TRUE, &spell_hlf);
/* spell_move_to() may call ml_get() and make "line" invalid */ // spell_move_to() may call ml_get() and make "line" invalid
line = ml_get_buf(wp->w_buffer, lnum, FALSE); line = ml_get_buf(wp->w_buffer, lnum, false);
ptr = line + linecol; ptr = line + linecol;
if (len == 0 || (int)wp->w_cursor.col > ptr - line) { 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); shl == &search_hl ? NULL : cur);
pos_inprogress = !(cur == NULL || cur->pos.cur == 0); pos_inprogress = !(cur == NULL || cur->pos.cur == 0);
/* Need to get the line again, a multi-line regexp // Need to get the line again, a multi-line regexp
* may have made it invalid. */ // may have made it invalid.
line = ml_get_buf(wp->w_buffer, lnum, FALSE); line = ml_get_buf(wp->w_buffer, lnum, false);
ptr = line + v; ptr = line + v;
if (shl->lnum == lnum) { if (shl->lnum == lnum) {
@@ -3408,9 +3406,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
} else } else
did_emsg = save_did_emsg; did_emsg = save_did_emsg;
/* Need to get the line again, a multi-line regexp may // Need to get the line again, a multi-line regexp may
* have made it invalid. */ // have made it invalid.
line = ml_get_buf(wp->w_buffer, lnum, FALSE); line = ml_get_buf(wp->w_buffer, lnum, false);
ptr = line + v; ptr = line + v;
if (!attr_pri) { 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_extra = 0;
n_attr = 0; n_attr = 0;
} else if (n_skip == 0) { } else if (n_skip == 0) {
is_concealing = TRUE; is_concealing = true;
n_skip = 1; n_skip = 1;
} }
mb_c = c; mb_c = c;
@@ -3847,7 +3845,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
} }
} else { } else {
prev_syntax_id = 0; prev_syntax_id = 0;
is_concealing = FALSE; is_concealing = false;
} }
if (n_skip > 0 && did_decrement_ptr) { if (n_skip > 0 && did_decrement_ptr) {
@@ -4953,12 +4951,12 @@ win_redr_status_matches (
int fillchar; int fillchar;
int attr; int attr;
int i; int i;
int highlight = TRUE; bool highlight = true;
char_u *selstart = NULL; char_u *selstart = NULL;
int selstart_col = 0; int selstart_col = 0;
char_u *selend = NULL; char_u *selend = NULL;
static int first_match = 0; static int first_match = 0;
int add_left = FALSE; bool add_left = false;
char_u *s; char_u *s;
int emenu; int emenu;
int l; int l;
@@ -4970,7 +4968,7 @@ win_redr_status_matches (
if (match == -1) { /* don't show match but original text */ if (match == -1) { /* don't show match but original text */
match = 0; match = 0;
highlight = FALSE; highlight = false;
} }
/* count 1 for the ending ">" */ /* count 1 for the ending ">" */
clen = status_match_len(xp, L_MATCH(match)) + 3; clen = status_match_len(xp, L_MATCH(match)) + 3;
@@ -4979,7 +4977,7 @@ win_redr_status_matches (
else if (match < first_match) { else if (match < first_match) {
/* jumping left, as far as we can go */ /* jumping left, as far as we can go */
first_match = match; first_match = match;
add_left = TRUE; add_left = true;
} else { } else {
/* check if match fits on the screen */ /* check if match fits on the screen */
for (i = first_match; i < match; ++i) for (i = first_match; i < match; ++i)
@@ -4997,8 +4995,9 @@ win_redr_status_matches (
break; break;
} }
} }
if (i == num_matches) if (i == num_matches) {
add_left = TRUE; add_left = true;
}
} }
} }
if (add_left) if (add_left)
@@ -5215,7 +5214,7 @@ static void win_redr_status(win_T *wp)
grid_puts(&default_grid, NameBuff, row, grid_puts(&default_grid, NameBuff, row,
(int)(this_ru_col - STRLEN(NameBuff) - 1), attr); (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 void redraw_custom_statusline(win_T *wp)
{ {
static int entered = false; static bool entered = false;
int saved_did_emsg = did_emsg; int saved_did_emsg = did_emsg;
/* When called recursively return. This can happen when the statusline /* When called recursively return. This can happen when the statusline
* contains an expression that triggers a redraw. */ * contains an expression that triggers a redraw. */
if (entered) if (entered)
return; return;
entered = TRUE; entered = true;
did_emsg = false; did_emsg = false;
win_redr_custom(wp, false); win_redr_custom(wp, false);
@@ -5261,12 +5260,11 @@ static void redraw_custom_statusline(win_T *wp)
entered = false; entered = false;
} }
/* /// 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. /// @return true if the status line of window "wp" is connected to the status
* Only call if (wp->w_vsep_width != 0). /// line of the window right of it. If not, then it's a vertical separator.
*/ bool stl_connected(win_T *wp)
int stl_connected(win_T *wp)
{ {
frame_T *fr; frame_T *fr;
@@ -5276,30 +5274,28 @@ int stl_connected(win_T *wp)
if (fr->fr_next != NULL) if (fr->fr_next != NULL)
break; break;
} else { } else {
if (fr->fr_next != NULL) if (fr->fr_next != NULL) {
return TRUE; return true;
}
} }
fr = fr->fr_parent; fr = fr->fr_parent;
} }
return FALSE; return false;
} }
/* /// Get the value to show for the language mappings, active 'keymap'.
* Get the value to show for the language mappings, active 'keymap'. ///
*/ /// @param fmt format string containing one %s item
int /// @param buf buffer for the result
get_keymap_str ( /// @param len length of buffer
win_T *wp, bool get_keymap_str(win_T *wp, char_u *fmt, char_u *buf, int len)
char_u *fmt, // format string containing one %s item
char_u *buf, // buffer for the result
int len // length of buffer
)
{ {
char_u *p; char_u *p;
if (wp->w_buffer->b_p_iminsert != B_IMODE_LMAP) if (wp->w_buffer->b_p_iminsert != B_IMODE_LMAP) {
return FALSE; return false;
}
{ {
buf_T *old_curbuf = curbuf; buf_T *old_curbuf = curbuf;
@@ -5339,7 +5335,7 @@ win_redr_custom (
bool draw_ruler bool draw_ruler
) )
{ {
static int entered = FALSE; static bool entered = false;
int attr; int attr;
int curattr; int curattr;
int row; int row;
@@ -5365,7 +5361,7 @@ win_redr_custom (
* Avoid trouble by not allowing recursion. */ * Avoid trouble by not allowing recursion. */
if (entered) if (entered)
return; return;
entered = TRUE; entered = true;
/* setup environment for the task at hand */ /* setup environment for the task at hand */
if (wp == NULL) { if (wp == NULL) {
@@ -5500,7 +5496,7 @@ win_redr_custom (
} }
theend: theend:
entered = FALSE; entered = false;
} }
static void win_redr_border(win_T *wp) static void win_redr_border(win_T *wp)
@@ -6065,7 +6061,7 @@ next_search_hl (
char_u *ml; char_u *ml;
matchcol = shl->rm.startpos[0].col; 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) { if (*ml == NUL) {
++matchcol; ++matchcol;
shl->lnum = 0; shl->lnum = 0;
@@ -7333,11 +7329,10 @@ int messaging(void)
return !(p_lz && char_avail() && !KeyTyped); return !(p_lz && char_avail() && !KeyTyped);
} }
/* /// Show current status info in ruler and various other places
* Show current status info in ruler and various other places ///
* If always is FALSE, only show ruler if position has changed. /// @param always if false, only show ruler if position has changed.
*/ void showruler(bool always)
void showruler(int always)
{ {
if (!always && !redrawing()) if (!always && !redrawing())
return; return;
@@ -7357,7 +7352,7 @@ void showruler(int always)
draw_tabline(); 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; 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". /// Set dimensions of the Nvim application "shell".
void screen_resize(int width, int height) 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 // Avoid recursiveness, can happen when setting the window size causes
// another window-changed signal. // another window-changed signal.
if (updating_screen || busy) { if (updating_screen || recursive) {
return; return;
} }
@@ -7643,7 +7638,7 @@ void screen_resize(int width, int height)
if (curwin->w_buffer == NULL) if (curwin->w_buffer == NULL)
return; return;
++busy; recursive = true;
Rows = height; Rows = height;
Columns = width; 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 /* The window layout used to be adjusted here, but it now happens in
* screenalloc() (also invoked from screenclear()). That is because the * 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) { if (State != ASKMORE && State != EXTERNCMD && State != CONFIRM) {
screenclear(); screenclear();
@@ -7694,8 +7689,9 @@ void screen_resize(int width, int height)
ui_comp_set_screen_valid(true); ui_comp_set_screen_valid(true);
repeat_message(); repeat_message();
} else { } else {
if (curwin->w_p_scb) if (curwin->w_p_scb) {
do_check_scrollbind(TRUE); do_check_scrollbind(true);
}
if (State & CMDLINE) { if (State & CMDLINE) {
redraw_popupmenu = false; redraw_popupmenu = false;
update_screen(NOT_VALID); update_screen(NOT_VALID);
@@ -7720,7 +7716,7 @@ void screen_resize(int width, int height)
} }
ui_flush(); ui_flush();
} }
busy--; recursive = false;
} }
/// Check if the new Nvim application "shell" dimensions are valid. /// 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; return NULL;
} }

View File

@@ -98,7 +98,7 @@ static int saved_spats_last_idx = 0;
static bool saved_spats_no_hlsearch = false; static bool saved_spats_no_hlsearch = false;
static char_u *mr_pattern = NULL; // pattern used by search_regcomp() 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 * Type used by find_pattern_in_path() to remember which included files have
@@ -159,19 +159,21 @@ search_regcomp(
pat = spats[i].pat; pat = spats[i].pat;
magic = spats[i].magic; magic = spats[i].magic;
no_smartcase = spats[i].no_scs; no_smartcase = spats[i].no_scs;
} else if (options & SEARCH_HIS) /* put new pattern in history */ } else if (options & SEARCH_HIS) { // put new pattern in history
add_to_history(HIST_SEARCH, pat, TRUE, NUL); add_to_history(HIST_SEARCH, pat, true, NUL);
}
if (mr_pattern_alloced) { if (mr_pattern_alloced) {
xfree(mr_pattern); xfree(mr_pattern);
mr_pattern_alloced = FALSE; mr_pattern_alloced = false;
} }
if (curwin->w_p_rl && *curwin->w_p_rlc == 's') { if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {
mr_pattern = reverse_text(pat); mr_pattern = reverse_text(pat);
mr_pattern_alloced = TRUE; mr_pattern_alloced = true;
} else } else {
mr_pattern = pat; mr_pattern = pat;
}
/* /*
* Save the currently used pattern in the appropriate place, * Save the currently used pattern in the appropriate place,
@@ -293,7 +295,7 @@ void free_search_patterns(void)
if (mr_pattern_alloced) { if (mr_pattern_alloced) {
xfree(mr_pattern); xfree(mr_pattern);
mr_pattern_alloced = FALSE; mr_pattern_alloced = false;
mr_pattern = NULL; mr_pattern = NULL;
} }
} }
@@ -556,12 +558,12 @@ int searchit(
int at_first_line; int at_first_line;
int extra_col; int extra_col;
int start_char_len; int start_char_len;
int match_ok; bool match_ok;
long nmatched; long nmatched;
int submatch = 0; int submatch = 0;
bool first_match = true; bool first_match = true;
int save_called_emsg = called_emsg; 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 linenr_T stop_lnum = 0; // stop after this line number when != 0
proftime_T *tm = NULL; // timeout limit or NULL proftime_T *tm = NULL; // timeout limit or NULL
int *timed_out = NULL; // set when timed out or NULL int *timed_out = NULL; // set when timed out or NULL
@@ -659,11 +661,12 @@ int searchit(
matchpos = regmatch.startpos[0]; matchpos = regmatch.startpos[0];
endpos = regmatch.endpos[0]; endpos = regmatch.endpos[0];
submatch = first_submatch(&regmatch); submatch = first_submatch(&regmatch);
/* "lnum" may be past end of buffer for "\n\zs". */ // "lnum" may be past end of buffer for "\n\zs".
if (lnum + matchpos.lnum > buf->b_ml.ml_line_count) if (lnum + matchpos.lnum > buf->b_ml.ml_line_count) {
ptr = (char_u *)""; ptr = (char_u *)"";
else } else {
ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE); ptr = ml_get_buf(buf, lnum + matchpos.lnum, false);
}
/* /*
* Forward search in the first line: match should be after * Forward search in the first line: match should be after
@@ -671,14 +674,12 @@ int searchit(
* match (this is vi compatible) or on the next char. * match (this is vi compatible) or on the next char.
*/ */
if (dir == FORWARD && at_first_line) { if (dir == FORWARD && at_first_line) {
match_ok = TRUE; match_ok = true;
/* // When the match starts in a next line it's certainly
* When the match starts in a next line it's certainly // past the start position.
* past the start position. // When match lands on a NUL the cursor will be put
* When match lands on a NUL the cursor will be put // one back afterwards, compare with that position,
* one back afterwards, compare with that position, // otherwise "/$" will get stuck on end of line.
* otherwise "/$" will get stuck on end of line.
*/
while (matchpos.lnum == 0 while (matchpos.lnum == 0
&& (((options & SEARCH_END) && first_match) && (((options & SEARCH_END) && first_match)
? (nmatched == 1 ? (nmatched == 1
@@ -696,7 +697,7 @@ int searchit(
if (nmatched > 1) { if (nmatched > 1) {
/* end is in next line, thus no match in /* end is in next line, thus no match in
* this line */ * this line */
match_ok = FALSE; match_ok = false;
break; break;
} }
matchcol = endpos.col; matchcol = endpos.col;
@@ -750,7 +751,7 @@ int searchit(
* When putting the new cursor at the end, compare * When putting the new cursor at the end, compare
* relative to the end of the match. * relative to the end of the match.
*/ */
match_ok = FALSE; match_ok = false;
for (;; ) { for (;; ) {
/* Remember a position that is before the start /* Remember a position that is before the start
* position, we use it if it's the last match in * position, we use it if it's the last match in
@@ -842,10 +843,9 @@ int searchit(
pos->lnum = lnum + endpos.lnum; pos->lnum = lnum + endpos.lnum;
pos->col = endpos.col; pos->col = endpos.col;
if (endpos.col == 0) { if (endpos.col == 0) {
if (pos->lnum > 1) { /* just in case */ if (pos->lnum > 1) { // just in case
--pos->lnum; pos->lnum--;
pos->col = (colnr_T)STRLEN(ml_get_buf(buf, pos->col = (colnr_T)STRLEN(ml_get_buf(buf, pos->lnum, false));
pos->lnum, FALSE));
} }
} else { } else {
pos->col--; pos->col--;
@@ -888,7 +888,7 @@ int searchit(
if ((options & SEARCH_PEEK) if ((options & SEARCH_PEEK)
&& ((lnum - pos->lnum) & 0x3f) == 0 && ((lnum - pos->lnum) & 0x3f) == 0
&& char_avail()) { && char_avail()) {
break_loop = TRUE; break_loop = true;
break; break;
} }
@@ -962,9 +962,10 @@ int searchit(
/* A pattern like "\n\zs" may go past the last line. */ /* A pattern like "\n\zs" may go past the last line. */
if (pos->lnum > buf->b_ml.ml_line_count) { if (pos->lnum > buf->b_ml.ml_line_count) {
pos->lnum = buf->b_ml.ml_line_count; pos->lnum = buf->b_ml.ml_line_count;
pos->col = (int)STRLEN(ml_get_buf(buf, pos->lnum, FALSE)); pos->col = (int)STRLEN(ml_get_buf(buf, pos->lnum, false));
if (pos->col > 0) if (pos->col > 0) {
--pos->col; pos->col--;
}
} }
return submatch + 1; return submatch + 1;
@@ -1465,7 +1466,7 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, Direction dir, char_u *pat)
break; break;
if (start == 0) if (start == 0)
start = pos->lnum; start = pos->lnum;
ptr = ml_get_buf(buf, pos->lnum, FALSE); ptr = ml_get_buf(buf, pos->lnum, false);
p = skipwhite(ptr); p = skipwhite(ptr);
pos->col = (colnr_T) (p - ptr); pos->col = (colnr_T) (p - ptr);
@@ -1506,7 +1507,7 @@ int searchc(cmdarg_T *cap, int t_cmd)
int col; int col;
char_u *p; char_u *p;
int len; int len;
int stop = TRUE; bool stop = true;
if (c != NUL) { /* normal search: remember args for repeat */ if (c != NUL) { /* normal search: remember args for repeat */
if (!KeyStuffed) { /* don't remember when redoing */ if (!KeyStuffed) { /* don't remember when redoing */
@@ -1539,8 +1540,9 @@ int searchc(cmdarg_T *cap, int t_cmd)
/* Force a move of at least one char, so ";" and "," will move the /* Force a move of at least one char, so ";" and "," will move the
* cursor, even if the cursor is right in front of char we are looking * cursor, even if the cursor is right in front of char we are looking
* at. */ * at. */
if (vim_strchr(p_cpo, CPO_SCOLON) == NULL && count == 1 && t_cmd) if (vim_strchr(p_cpo, CPO_SCOLON) == NULL && count == 1 && t_cmd) {
stop = FALSE; stop = false;
}
} }
if (dir == BACKWARD) if (dir == BACKWARD)
@@ -2257,22 +2259,25 @@ static int check_linecomment(const char_u *line)
const char_u *p = line; // scan from start const char_u *p = line; // scan from start
// skip Lispish one-line comments // skip Lispish one-line comments
if (curbuf->b_p_lisp) { if (curbuf->b_p_lisp) {
if (vim_strchr(p, ';') != NULL) { /* there may be comments */ if (vim_strchr(p, ';') != NULL) { // there may be comments
int in_str = FALSE; /* inside of string */ bool in_str = false; // inside of string
while ((p = vim_strpbrk(p, (char_u *)"\";")) != NULL) { while ((p = vim_strpbrk(p, (char_u *)"\";")) != NULL) {
if (*p == '"') { if (*p == '"') {
if (in_str) { if (in_str) {
if (*(p - 1) != '\\') /* skip escaped quote */ if (*(p - 1) != '\\') { // skip escaped quote
in_str = FALSE; in_str = false;
}
} else if (p == line || ((p - line) >= 2 } else if (p == line || ((p - line) >= 2
/* skip #\" form */ // skip #\" form
&& *(p - 1) != '\\' && *(p - 2) != '#')) && *(p - 1) != '\\' && *(p - 2) != '#')) {
in_str = TRUE; in_str = true;
}
} else if (!in_str && ((p - line) < 2 } else if (!in_str && ((p - line) < 2
|| (*(p - 1) != '\\' && *(p - 2) != '#'))) || (*(p - 1) != '\\' && *(p - 2) != '#'))) {
break; /* found! */ break; // found!
++p; }
p++;
} }
} else } else
p = NULL; p = NULL;
@@ -2855,17 +2860,13 @@ finished:
return OK; return OK;
} }
/* /// Move back to the end of the word.
* Move back to the end of the word. ///
* /// @param bigword TRUE for "B"
* Returns FAIL if start of the file was reached. /// @param eol if true, then stop at end of line.
*/ ///
int /// @return FAIL if start of the file was reached.
bckend_word( int bckend_word(long count, int bigword, bool eol)
long count,
int bigword, /* TRUE for "B" */
int eol /* TRUE: stop at end of line. */
)
{ {
int sclass; /* starting class */ int sclass; /* starting class */
int i; int i;
@@ -2903,16 +2904,17 @@ bckend_word(
return OK; return OK;
} }
/* /// Skip a row of characters of the same class.
* Skip a row of characters of the same class. ///
* Return TRUE when end-of-file reached, FALSE otherwise. /// @return true when end-of-file reached, false otherwise.
*/ static bool skip_chars(int cclass, int dir)
static int skip_chars(int cclass, int dir)
{ {
while (cls() == cclass) while (cls() == cclass) {
if ((dir == FORWARD ? inc_cursor() : dec_cursor()) == -1) if ((dir == FORWARD ? inc_cursor() : dec_cursor()) == -1) {
return TRUE; return true;
return FALSE; }
}
return false;
} }
/* /*
@@ -2947,14 +2949,10 @@ static void find_first_blank(pos_T *posp)
} }
} }
/* /// Skip count/2 sentences and count/2 separating white spaces.
* Skip count/2 sentences and count/2 separating white spaces. ///
*/ /// @param at_start_sent cursor is at start of sentence
static void static void findsent_forward(long count, bool at_start_sent)
findsent_forward(
long count,
int at_start_sent /* cursor is at start of sentence */
)
{ {
while (count--) { while (count--) {
findsent(FORWARD, 1L); findsent(FORWARD, 1L);
@@ -3053,8 +3051,9 @@ current_word(
if (bck_word(1L, bigword, TRUE) == FAIL) if (bck_word(1L, bigword, TRUE) == FAIL)
return FAIL; return FAIL;
} else { } else {
if (bckend_word(1L, bigword, TRUE) == FAIL) if (bckend_word(1L, bigword, true) == FAIL) {
return FAIL; return FAIL;
}
(void)incl(&curwin->w_cursor); (void)incl(&curwin->w_cursor);
} }
} else { } else {
@@ -3126,9 +3125,9 @@ int current_sent(oparg_T *oap, long count, int include)
{ {
pos_T start_pos; pos_T start_pos;
pos_T pos; pos_T pos;
int start_blank; bool start_blank;
int c; int c;
int at_start_sent; bool at_start_sent;
long ncount; long ncount;
start_pos = curwin->w_cursor; start_pos = curwin->w_cursor;
@@ -3148,24 +3147,25 @@ extend:
* - in a sentence or just after it * - in a sentence or just after it
* - at the start of a sentence * - at the start of a sentence
*/ */
at_start_sent = TRUE; at_start_sent = true;
decl(&pos); decl(&pos);
while (lt(pos, curwin->w_cursor)) { while (lt(pos, curwin->w_cursor)) {
c = gchar_pos(&pos); c = gchar_pos(&pos);
if (!ascii_iswhite(c)) { if (!ascii_iswhite(c)) {
at_start_sent = FALSE; at_start_sent = false;
break; break;
} }
incl(&pos); incl(&pos);
} }
if (!at_start_sent) { if (!at_start_sent) {
findsent(BACKWARD, 1L); findsent(BACKWARD, 1L);
if (equalpos(curwin->w_cursor, start_pos)) if (equalpos(curwin->w_cursor, start_pos)) {
at_start_sent = TRUE; /* exactly at start of sentence */ at_start_sent = true; // exactly at start of sentence
else } else {
/* inside a sentence, go to its end (start of next) */ // inside a sentence, go to its end (start of next)
findsent(FORWARD, 1L); findsent(FORWARD, 1L);
} }
}
if (include) /* "as" gets twice as much as "is" */ if (include) /* "as" gets twice as much as "is" */
count *= 2; count *= 2;
while (count--) { while (count--) {
@@ -3185,13 +3185,13 @@ extend:
* - in a sentence * - in a sentence
*/ */
incl(&pos); incl(&pos);
at_start_sent = TRUE; at_start_sent = true;
if (!equalpos(pos, curwin->w_cursor)) { /* not just before a sentence */ if (!equalpos(pos, curwin->w_cursor)) { // not just before a sentence
at_start_sent = FALSE; at_start_sent = false;
while (lt(pos, curwin->w_cursor)) { while (lt(pos, curwin->w_cursor)) {
c = gchar_pos(&pos); c = gchar_pos(&pos);
if (!ascii_iswhite(c)) { if (!ascii_iswhite(c)) {
at_start_sent = TRUE; at_start_sent = true;
break; break;
} }
incl(&pos); incl(&pos);
@@ -3218,10 +3218,10 @@ extend:
while (c = gchar_pos(&pos), ascii_iswhite(c)) while (c = gchar_pos(&pos), ascii_iswhite(c))
incl(&pos); incl(&pos);
if (equalpos(pos, curwin->w_cursor)) { if (equalpos(pos, curwin->w_cursor)) {
start_blank = TRUE; start_blank = true;
find_first_blank(&start_pos); /* go back to first blank */ find_first_blank(&start_pos); // go back to first blank
} else { } else {
start_blank = FALSE; start_blank = false;
findsent(BACKWARD, 1L); findsent(BACKWARD, 1L);
start_pos = curwin->w_cursor; start_pos = curwin->w_cursor;
} }
@@ -3232,10 +3232,11 @@ extend:
if (start_blank) if (start_blank)
--ncount; --ncount;
} }
if (ncount > 0) if (ncount > 0) {
findsent_forward(ncount, TRUE); findsent_forward(ncount, true);
else } else {
decl(&curwin->w_cursor); decl(&curwin->w_cursor);
}
if (include) { if (include) {
/* /*
@@ -3293,7 +3294,7 @@ current_block(
pos_T *end_pos; pos_T *end_pos;
pos_T old_start, old_end; pos_T old_start, old_end;
char_u *save_cpo; char_u *save_cpo;
int sol = FALSE; /* '{' at start of line */ bool sol = false; // '{' at start of line
old_pos = curwin->w_cursor; old_pos = curwin->w_cursor;
old_end = curwin->w_cursor; /* remember where we started */ old_end = curwin->w_cursor; /* remember where we started */
@@ -3351,7 +3352,7 @@ current_block(
sol = (curwin->w_cursor.col == 0); sol = (curwin->w_cursor.col == 0);
decl(&curwin->w_cursor); decl(&curwin->w_cursor);
while (inindent(1)) { while (inindent(1)) {
sol = TRUE; sol = true;
if (decl(&curwin->w_cursor) != 0) { if (decl(&curwin->w_cursor) != 0) {
break; break;
} }
@@ -3410,11 +3411,10 @@ current_block(
} }
/* /// @param end_tag when true, return true if the cursor is on "</aaa>".
* Return TRUE if the cursor is on a "<aaa>" tag. Ignore "<aaa/>". ///
* When "end_tag" is TRUE return TRUE if the cursor is on "</aaa>". /// @return true if the cursor is on a "<aaa>" tag. Ignore "<aaa/>".
*/ static bool in_html_tag(bool end_tag)
static int in_html_tag(int end_tag)
{ {
char_u *line = get_cursor_line_ptr(); char_u *line = get_cursor_line_ptr();
char_u *p; char_u *p;
@@ -3444,14 +3444,16 @@ static int in_html_tag(int end_tag)
return *p == '/'; return *p == '/';
} }
/* check that there is no '/' after the '<' */ // check that there is no '/' after the '<'
if (*p == '/') if (*p == '/') {
return FALSE; return false;
}
/* check that the matching '>' is not preceded by '/' */ /* check that the matching '>' is not preceded by '/' */
for (;; ) { for (;; ) {
if (inc(&pos) < 0) if (inc(&pos) < 0) {
return FALSE; return false;
}
c = *ml_get_pos(&pos); c = *ml_get_pos(&pos);
if (c == '>') if (c == '>')
break; break;
@@ -3502,16 +3504,20 @@ current_tagblock(
if (inc_cursor() != 0) if (inc_cursor() != 0)
break; break;
if (in_html_tag(FALSE)) { if (in_html_tag(false)) {
/* cursor on start tag, move to its '>' */ // cursor on start tag, move to its '>'
while (*get_cursor_pos_ptr() != '>') while (*get_cursor_pos_ptr() != '>') {
if (inc_cursor() < 0) if (inc_cursor() < 0) {
break; break;
} else if (in_html_tag(TRUE)) { }
/* cursor on end tag, move to just before it */ }
while (*get_cursor_pos_ptr() != '<') } else if (in_html_tag(true)) {
if (dec_cursor() < 0) // cursor on end tag, move to just before it
while (*get_cursor_pos_ptr() != '<') {
if (dec_cursor() < 0) {
break; break;
}
}
dec_cursor(); dec_cursor();
old_end = curwin->w_cursor; old_end = curwin->w_cursor;
} }
@@ -4667,7 +4673,7 @@ find_pattern_in_path(
char_u *line; char_u *line;
char_u *p; char_u *p;
char_u save_char; char_u save_char;
int define_matched; bool define_matched;
regmatch_T regmatch; regmatch_T regmatch;
regmatch_T incl_regmatch; regmatch_T incl_regmatch;
regmatch_T def_regmatch; regmatch_T def_regmatch;
@@ -4904,7 +4910,7 @@ find_pattern_in_path(
*/ */
p = line; p = line;
search_line: search_line:
define_matched = FALSE; define_matched = false;
if (def_regmatch.regprog != NULL if (def_regmatch.regprog != NULL
&& vim_regexec(&def_regmatch, line, (colnr_T)0)) { && vim_regexec(&def_regmatch, line, (colnr_T)0)) {
/* /*
@@ -4915,7 +4921,7 @@ search_line:
p = def_regmatch.endp[0]; p = def_regmatch.endp[0];
while (*p && !vim_iswordc(*p)) while (*p && !vim_iswordc(*p))
p++; p++;
define_matched = TRUE; define_matched = true;
} }
/* /*

View File

@@ -1399,7 +1399,7 @@ spell_move_to (
clearpos(&found_pos); clearpos(&found_pos);
while (!got_int) { while (!got_int) {
line = ml_get_buf(wp->w_buffer, lnum, FALSE); line = ml_get_buf(wp->w_buffer, lnum, false);
len = STRLEN(line); len = STRLEN(line);
if (buflen < len + MAXWLEN + 2) { if (buflen < len + MAXWLEN + 2) {
@@ -1425,7 +1425,7 @@ spell_move_to (
// Need to get the line again, may have looked at the previous // Need to get the line again, may have looked at the previous
// one. // one.
line = ml_get_buf(wp->w_buffer, lnum, FALSE); line = ml_get_buf(wp->w_buffer, lnum, false);
} }
// Copy the line into "buf" and append the start of the next line if // Copy the line into "buf" and append the start of the next line if
@@ -1433,7 +1433,7 @@ spell_move_to (
STRCPY(buf, line); STRCPY(buf, line);
if (lnum < wp->w_buffer->b_ml.ml_line_count) if (lnum < wp->w_buffer->b_ml.ml_line_count)
spell_cat_line(buf + STRLEN(buf), spell_cat_line(buf + STRLEN(buf),
ml_get_buf(wp->w_buffer, lnum + 1, FALSE), ml_get_buf(wp->w_buffer, lnum + 1, false),
MAXWLEN); MAXWLEN);
p = buf + skip; p = buf + skip;
endp = buf + len; endp = buf + len;

View File

@@ -5035,7 +5035,7 @@ static void sug_write(spellinfo_T *spin, char_u *fname)
for (linenr_T lnum = 1; lnum <= wcount; ++lnum) { for (linenr_T lnum = 1; lnum <= wcount; ++lnum) {
// <sugline>: <sugnr> ... NUL // <sugline>: <sugnr> ... NUL
char_u *line = ml_get_buf(spin->si_spellbuf, lnum, FALSE); char_u *line = ml_get_buf(spin->si_spellbuf, lnum, false);
size_t len = STRLEN(line) + 1; size_t len = STRLEN(line) + 1;
if (fwrite(line, len, 1, fd) == 0) { if (fwrite(line, len, 1, fd) == 0) {
EMSG(_(e_write)); EMSG(_(e_write));

View File

@@ -371,9 +371,9 @@ static synblock_T *syn_block; // current buffer for highlighting
static proftime_T *syn_tm; // timeout limit static proftime_T *syn_tm; // timeout limit
static linenr_T current_lnum = 0; // lnum of current state static linenr_T current_lnum = 0; // lnum of current state
static colnr_T current_col = 0; // column of current state static colnr_T current_col = 0; // column of current state
static int current_state_stored = 0; // TRUE if stored current state static bool current_state_stored = false; // true if stored current state
// after setting current_finished // after setting current_finished
static int current_finished = 0; // current line has been finished static bool current_finished = false; // current line has been finished
static garray_T current_state // current stack of state_items static garray_T current_state // current stack of state_items
= GA_EMPTY_INIT_VALUE; = GA_EMPTY_INIT_VALUE;
static int16_t *current_next_list = NULL; // when non-zero, nextgroup list static int16_t *current_next_list = NULL; // when non-zero, nextgroup list
@@ -382,7 +382,7 @@ static int current_line_id = 0; // unique number for current line
#define CUR_STATE(idx) ((stateitem_T *)(current_state.ga_data))[idx] #define CUR_STATE(idx) ((stateitem_T *)(current_state.ga_data))[idx]
static int syn_time_on = FALSE; static bool syn_time_on = false;
# define IF_SYN_TIME(p) (p) # define IF_SYN_TIME(p) (p)
// Set the timeout used for syntax highlighting. // Set the timeout used for syntax highlighting.
@@ -810,7 +810,7 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid)
cur_si = &CUR_STATE(current_state.ga_len - 1); cur_si = &CUR_STATE(current_state.ga_len - 1);
cur_si->si_h_startpos.lnum = found_current_lnum; cur_si->si_h_startpos.lnum = found_current_lnum;
cur_si->si_h_startpos.col = found_current_col; cur_si->si_h_startpos.col = found_current_col;
update_si_end(cur_si, (int)current_col, TRUE); update_si_end(cur_si, (int)current_col, true);
check_keepend(); check_keepend();
} }
current_col = found_m_endpos.col; current_col = found_m_endpos.col;
@@ -881,7 +881,7 @@ static int syn_match_linecont(linenr_T lnum)
*/ */
static void syn_start_line(void) static void syn_start_line(void)
{ {
current_finished = FALSE; current_finished = false;
current_col = 0; current_col = 0;
/* /*
@@ -889,7 +889,7 @@ static void syn_start_line(void)
* previous line and regions that have "keepend". * previous line and regions that have "keepend".
*/ */
if (!GA_EMPTY(&current_state)) { if (!GA_EMPTY(&current_state)) {
syn_update_ends(TRUE); syn_update_ends(true);
check_state_ends(); check_state_ends();
} }
@@ -898,15 +898,13 @@ static void syn_start_line(void)
next_seqnr = 1; next_seqnr = 1;
} }
/* /// Check for items in the stack that need their end updated.
* Check for items in the stack that need their end updated. ///
* When "startofline" is TRUE the last item is always updated. /// @param startofline if true the last item is always updated.
* When "startofline" is FALSE the item with "keepend" is forcefully updated. /// if false the item with "keepend" is forcefully updated.
*/ static void syn_update_ends(bool startofline)
static void syn_update_ends(int startofline)
{ {
stateitem_T *cur_si; stateitem_T *cur_si;
int seen_keepend;
if (startofline) { if (startofline) {
/* Check for a match carried over from a previous line with a /* Check for a match carried over from a previous line with a
@@ -941,8 +939,8 @@ static void syn_update_ends(int startofline)
if (CUR_STATE(i).si_flags & HL_EXTEND) if (CUR_STATE(i).si_flags & HL_EXTEND)
break; break;
seen_keepend = FALSE; bool seen_keepend = false;
for (; i < current_state.ga_len; ++i) { for (; i < current_state.ga_len; i++) {
cur_si = &CUR_STATE(i); cur_si = &CUR_STATE(i);
if ((cur_si->si_flags & HL_KEEPEND) if ((cur_si->si_flags & HL_KEEPEND)
|| (seen_keepend && !startofline) || (seen_keepend && !startofline)
@@ -953,8 +951,9 @@ static void syn_update_ends(int startofline)
if (!(cur_si->si_flags & HL_MATCHCONT)) if (!(cur_si->si_flags & HL_MATCHCONT))
update_si_end(cur_si, (int)current_col, !startofline); update_si_end(cur_si, (int)current_col, !startofline);
if (!startofline && (cur_si->si_flags & HL_KEEPEND)) if (!startofline && (cur_si->si_flags & HL_KEEPEND)) {
seen_keepend = TRUE; seen_keepend = true;
}
} }
} }
check_keepend(); check_keepend();
@@ -1152,17 +1151,15 @@ static void syn_stack_apply_changes_block(synblock_T *block, buf_T *buf)
} }
} }
/* /// Reduce the number of entries in the state stack for syn_buf.
* Reduce the number of entries in the state stack for syn_buf. ///
* Returns TRUE if at least one entry was freed. /// @return true if at least one entry was freed.
*/ static bool syn_stack_cleanup(void)
static int syn_stack_cleanup(void)
{ {
synstate_T *p, *prev; synstate_T *p, *prev;
disptick_T tick; disptick_T tick;
int above;
int dist; int dist;
int retval = FALSE; bool retval = false;
if (syn_block->b_sst_first == NULL) { if (syn_block->b_sst_first == NULL) {
return retval; return retval;
@@ -1180,18 +1177,19 @@ static int syn_stack_cleanup(void)
* "b_sst_lasttick" (the display tick wraps around). * "b_sst_lasttick" (the display tick wraps around).
*/ */
tick = syn_block->b_sst_lasttick; tick = syn_block->b_sst_lasttick;
above = FALSE; bool above = false;
prev = syn_block->b_sst_first; prev = syn_block->b_sst_first;
for (p = prev->sst_next; p != NULL; prev = p, p = p->sst_next) { for (p = prev->sst_next; p != NULL; prev = p, p = p->sst_next) {
if (prev->sst_lnum + dist > p->sst_lnum) { if (prev->sst_lnum + dist > p->sst_lnum) {
if (p->sst_tick > syn_block->b_sst_lasttick) { if (p->sst_tick > syn_block->b_sst_lasttick) {
if (!above || p->sst_tick < tick) if (!above || p->sst_tick < tick)
tick = p->sst_tick; tick = p->sst_tick;
above = TRUE; above = true;
} else if (!above && p->sst_tick < tick) } else if (!above && p->sst_tick < tick) {
tick = p->sst_tick; tick = p->sst_tick;
} }
} }
}
/* /*
* Go through the list to make the entries for the oldest tick at an * Go through the list to make the entries for the oldest tick at an
@@ -1204,7 +1202,7 @@ static int syn_stack_cleanup(void)
prev->sst_next = p->sst_next; prev->sst_next = p->sst_next;
syn_stack_free_entry(syn_block, p); syn_stack_free_entry(syn_block, p);
p = prev; p = prev;
retval = TRUE; retval = true;
} }
} }
return retval; return retval;
@@ -1340,7 +1338,7 @@ static synstate_T *store_current_state(void)
sp->sst_tick = display_tick; sp->sst_tick = display_tick;
sp->sst_change_lnum = 0; sp->sst_change_lnum = 0;
} }
current_state_stored = TRUE; current_state_stored = true;
return sp; return sp;
} }
@@ -1385,11 +1383,10 @@ static void load_current_state(synstate_T *from)
current_lnum = from->sst_lnum; current_lnum = from->sst_lnum;
} }
/* /// Compare saved state stack "*sp" with the current state.
* Compare saved state stack "*sp" with the current state. ///
* Return TRUE when they are equal. /// @return true when they are equal.
*/ static bool syn_stack_equal(synstate_T *sp)
static int syn_stack_equal(synstate_T *sp)
{ {
bufstate_T *bp; bufstate_T *bp;
reg_extmatch_T *six, *bsx; reg_extmatch_T *six, *bsx;
@@ -1397,7 +1394,7 @@ static int syn_stack_equal(synstate_T *sp)
/* First a quick check if the stacks have the same size end nextlist. */ /* First a quick check if the stacks have the same size end nextlist. */
if (sp->sst_stacksize != current_state.ga_len if (sp->sst_stacksize != current_state.ga_len
|| sp->sst_next_list != current_next_list) { || sp->sst_next_list != current_next_list) {
return FALSE; return false;
} }
/* Need to compare all states on both stacks. */ /* Need to compare all states on both stacks. */
@@ -1444,10 +1441,11 @@ static int syn_stack_equal(synstate_T *sp)
if (j != NSUBEXP) if (j != NSUBEXP)
break; break;
} }
if (i < 0) if (i < 0) {
return TRUE; return true;
}
return FALSE; return false;
} }
/* /*
@@ -1490,14 +1488,13 @@ static void validate_current_state(void)
ga_set_growsize(&current_state, 3); ga_set_growsize(&current_state, 3);
} }
/* /// This will only be called just after get_syntax_attr() for the previous
* Return TRUE if the syntax at start of lnum changed since last time. /// line, to check if the next line needs to be redrawn too.
* This will only be called just after get_syntax_attr() for the previous ///
* line, to check if the next line needs to be redrawn too. /// @return true if the syntax at start of lnum changed since last time.
*/ bool syntax_check_changed(linenr_T lnum)
int syntax_check_changed(linenr_T lnum)
{ {
int retval = TRUE; bool retval = true;
synstate_T *sp; synstate_T *sp;
/* /*
@@ -1520,8 +1517,9 @@ int syntax_check_changed(linenr_T lnum)
* Compare the current state with the previously saved state of * Compare the current state with the previously saved state of
* the line. * the line.
*/ */
if (syn_stack_equal(sp)) if (syn_stack_equal(sp)) {
retval = FALSE; retval = false;
}
/* /*
* Store the current state in b_sst_array[] for later use. * Store the current state in b_sst_array[] for later use.
@@ -1678,15 +1676,15 @@ static int syn_current_attr(
(void)push_next_match(); (void)push_next_match();
} }
current_finished = TRUE; current_finished = true;
current_state_stored = FALSE; current_state_stored = false;
return 0; return 0;
} }
/* if the current or next character is NUL, we will finish the line now */ /* if the current or next character is NUL, we will finish the line now */
if (line[current_col] == NUL || line[current_col + 1] == NUL) { if (line[current_col] == NUL || line[current_col + 1] == NUL) {
current_finished = TRUE; current_finished = true;
current_state_stored = FALSE; current_state_stored = false;
} }
/* /*
@@ -2152,16 +2150,14 @@ static int syn_current_attr(
} }
/* /// @return true if we already matched pattern "idx" at the current column.
* Check if we already matched pattern "idx" at the current column. static bool did_match_already(int idx, garray_T *gap)
*/
static int did_match_already(int idx, garray_T *gap)
{ {
for (int i = current_state.ga_len; --i >= 0; ) { for (int i = current_state.ga_len; --i >= 0; ) {
if (CUR_STATE(i).si_m_startcol == (int)current_col if (CUR_STATE(i).si_m_startcol == (int)current_col
&& CUR_STATE(i).si_m_lnum == (int)current_lnum && CUR_STATE(i).si_m_lnum == (int)current_lnum
&& CUR_STATE(i).si_idx == idx) { && CUR_STATE(i).si_idx == idx) {
return TRUE; return true;
} }
} }
@@ -2169,11 +2165,11 @@ static int did_match_already(int idx, garray_T *gap)
* stack, and can only be matched once anyway. */ * stack, and can only be matched once anyway. */
for (int i = gap->ga_len; --i >= 0; ) { for (int i = gap->ga_len; --i >= 0; ) {
if (((int *)(gap->ga_data))[i] == idx) { if (((int *)(gap->ga_data))[i] == idx) {
return TRUE; return true;
} }
} }
return FALSE; return false;
} }
/* /*
@@ -2209,8 +2205,8 @@ static stateitem_T *push_next_match(void)
cur_si->si_next_list = spp->sp_next_list; cur_si->si_next_list = spp->sp_next_list;
cur_si->si_extmatch = ref_extmatch(next_match_extmatch); cur_si->si_extmatch = ref_extmatch(next_match_extmatch);
if (spp->sp_type == SPTYPE_START && !(spp->sp_flags & HL_ONELINE)) { if (spp->sp_type == SPTYPE_START && !(spp->sp_flags & HL_ONELINE)) {
/* Try to find the end pattern in the current line */ // Try to find the end pattern in the current line
update_si_end(cur_si, (int)(next_match_m_endpos.col), TRUE); update_si_end(cur_si, (int)(next_match_m_endpos.col), true);
check_keepend(); check_keepend();
} else { } else {
cur_si->si_m_endpos = next_match_m_endpos; cur_si->si_m_endpos = next_match_m_endpos;
@@ -2316,10 +2312,11 @@ static void check_state_ends(void)
break; break;
if (had_extend && keepend_level >= 0) { if (had_extend && keepend_level >= 0) {
syn_update_ends(FALSE); syn_update_ends(false);
if (GA_EMPTY(&current_state)) if (GA_EMPTY(&current_state)) {
break; break;
} }
}
cur_si = &CUR_STATE(current_state.ga_len - 1); cur_si = &CUR_STATE(current_state.ga_len - 1);
@@ -2336,7 +2333,7 @@ static void check_state_ends(void)
&& SYN_ITEMS(syn_block)[cur_si->si_idx].sp_type && SYN_ITEMS(syn_block)[cur_si->si_idx].sp_type
== SPTYPE_START == SPTYPE_START
&& !(cur_si->si_flags & (HL_MATCH | HL_KEEPEND))) { && !(cur_si->si_flags & (HL_MATCH | HL_KEEPEND))) {
update_si_end(cur_si, (int)current_col, TRUE); update_si_end(cur_si, (int)current_col, true);
check_keepend(); check_keepend();
if ((current_next_flags & HL_HAS_EOL) if ((current_next_flags & HL_HAS_EOL)
&& keepend_level < 0 && keepend_level < 0
@@ -2452,18 +2449,14 @@ static void check_keepend(void)
} }
} }
/* /// Update an entry in the current_state stack for a start-skip-end pattern.
* Update an entry in the current_state stack for a start-skip-end pattern. /// This finds the end of the current item, if it's in the current line.
* This finds the end of the current item, if it's in the current line. ///
* /// @param startcol where to start searching for the end
* Return the flags for the matched END. /// @param force when true overrule a previous end
*/ ///
static void /// @return the flags for the matched END.
update_si_end( static void update_si_end(stateitem_T *sip, int startcol, bool force)
stateitem_T *sip,
int startcol, /* where to start searching for the end */
int force /* when TRUE overrule a previous end */
)
{ {
lpos_T hl_endpos; lpos_T hl_endpos;
lpos_T end_endpos; lpos_T end_endpos;
@@ -2571,7 +2564,7 @@ find_endpos(
regmmatch_T best_regmatch; /* startpos/endpos of best match */ regmmatch_T best_regmatch; /* startpos/endpos of best match */
lpos_T pos; lpos_T pos;
char_u *line; char_u *line;
int had_match = false; bool had_match = false;
char_u buf_chartab[32]; // chartab array for syn option iskeyword char_u buf_chartab[32]; // chartab array for syn option iskeyword
/* just in case we are invoked for a keyword */ /* just in case we are invoked for a keyword */
@@ -2753,7 +2746,7 @@ find_endpos(
*flagsp = spp->sp_flags; *flagsp = spp->sp_flags;
had_match = TRUE; had_match = true;
break; break;
} }
@@ -2816,12 +2809,12 @@ syn_add_end_off(
col = regmatch->endpos[0].col; col = regmatch->endpos[0].col;
off = spp->sp_offsets[idx]; off = spp->sp_offsets[idx];
} }
/* Don't go past the end of the line. Matters for "rs=e+2" when there // Don't go past the end of the line. Matters for "rs=e+2" when there
* is a matchgroup. Watch out for match with last NL in the buffer. */ // is a matchgroup. Watch out for match with last NL in the buffer.
if (result->lnum > syn_buf->b_ml.ml_line_count) if (result->lnum > syn_buf->b_ml.ml_line_count) {
col = 0; col = 0;
else if (off != 0) { } else if (off != 0) {
base = ml_get_buf(syn_buf, result->lnum, FALSE); base = ml_get_buf(syn_buf, result->lnum, false);
p = base + col; p = base + col;
if (off > 0) { if (off > 0) {
while (off-- > 0 && *p != NUL) { while (off-- > 0 && *p != NUL) {
@@ -2867,10 +2860,10 @@ syn_add_start_off(
if (result->lnum > syn_buf->b_ml.ml_line_count) { if (result->lnum > syn_buf->b_ml.ml_line_count) {
/* a "\n" at the end of the pattern may take us below the last line */ /* a "\n" at the end of the pattern may take us below the last line */
result->lnum = syn_buf->b_ml.ml_line_count; result->lnum = syn_buf->b_ml.ml_line_count;
col = (int)STRLEN(ml_get_buf(syn_buf, result->lnum, FALSE)); col = (int)STRLEN(ml_get_buf(syn_buf, result->lnum, false));
} }
if (off != 0) { if (off != 0) {
base = ml_get_buf(syn_buf, result->lnum, FALSE); base = ml_get_buf(syn_buf, result->lnum, false);
p = base + col; p = base + col;
if (off > 0) { if (off > 0) {
while (off-- && *p != NUL) { while (off-- && *p != NUL) {
@@ -2891,7 +2884,7 @@ syn_add_start_off(
*/ */
static char_u *syn_getcurline(void) static char_u *syn_getcurline(void)
{ {
return ml_get_buf(syn_buf, current_lnum, FALSE); return ml_get_buf(syn_buf, current_lnum, false);
} }
/* /*
@@ -2903,7 +2896,7 @@ static int syn_regexec(regmmatch_T *rmp, linenr_T lnum, colnr_T col, syn_time_T
int r; int r;
int timed_out = 0; int timed_out = 0;
proftime_T pt; proftime_T pt;
const int l_syn_time_on = syn_time_on; const bool l_syn_time_on = syn_time_on;
if (l_syn_time_on) { if (l_syn_time_on) {
pt = profile_start(); pt = profile_start();
@@ -4242,7 +4235,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
char_u *errormsg = NULL; char_u *errormsg = NULL;
int prev_toplvl_grp; int prev_toplvl_grp;
int prev_syn_inc_tag; int prev_syn_inc_tag;
int source = FALSE; bool source = false;
eap->nextcmd = find_nextcmd(arg); eap->nextcmd = find_nextcmd(arg);
if (eap->skip) if (eap->skip)
@@ -4542,9 +4535,9 @@ syn_cmd_region(
int pat_count = 0; /* nr of syn_patterns found */ int pat_count = 0; /* nr of syn_patterns found */
int syn_id; int syn_id;
int matchgroup_id = 0; int matchgroup_id = 0;
int not_enough = FALSE; /* not enough arguments */ bool not_enough = false; // not enough arguments
int illegal = FALSE; /* illegal arguments */ bool illegal = false; // illegal arguments
int success = FALSE; bool success = false;
syn_opt_arg_T syn_opt_arg; syn_opt_arg_T syn_opt_arg;
int conceal_char = NUL; int conceal_char = NUL;
@@ -4602,7 +4595,7 @@ syn_cmd_region(
} }
rest = skipwhite(rest + 1); rest = skipwhite(rest + 1);
if (*rest == NUL) { if (*rest == NUL) {
not_enough = TRUE; not_enough = true;
break; break;
} }
@@ -4613,7 +4606,7 @@ syn_cmd_region(
else { else {
matchgroup_id = syn_check_group(rest, (int)(p - rest)); matchgroup_id = syn_check_group(rest, (int)(p - rest));
if (matchgroup_id == 0) { if (matchgroup_id == 0) {
illegal = TRUE; illegal = true;
break; break;
} }
} }
@@ -4707,8 +4700,8 @@ syn_cmd_region(
} }
redraw_curbuf_later(SOME_VALID); redraw_curbuf_later(SOME_VALID);
syn_stack_free_all(curwin->w_s); /* Need to recompute all syntax. */ syn_stack_free_all(curwin->w_s); // Need to recompute all syntax.
success = TRUE; /* don't free the progs and patterns now */ success = true; // don't free the progs and patterns now
} }
} }
} }
@@ -5860,16 +5853,17 @@ int syn_get_foldlevel(win_T *wp, long lnum)
*/ */
void ex_syntime(exarg_T *eap) void ex_syntime(exarg_T *eap)
{ {
if (STRCMP(eap->arg, "on") == 0) if (STRCMP(eap->arg, "on") == 0) {
syn_time_on = TRUE; syn_time_on = true;
else if (STRCMP(eap->arg, "off") == 0) } else if (STRCMP(eap->arg, "off") == 0) {
syn_time_on = FALSE; syn_time_on = false;
else if (STRCMP(eap->arg, "clear") == 0) } else if (STRCMP(eap->arg, "clear") == 0) {
syntime_clear(); syntime_clear();
else if (STRCMP(eap->arg, "report") == 0) } else if (STRCMP(eap->arg, "report") == 0) {
syntime_report(); syntime_report();
else } else {
EMSG2(_(e_invarg2), eap->arg); EMSG2(_(e_invarg2), eap->arg);
}
} }
static void syn_clear_time(syn_time_T *st) static void syn_clear_time(syn_time_T *st)
@@ -6421,7 +6415,7 @@ void init_highlight(bool both, bool reset)
do_highlight(pp[i], reset, true); do_highlight(pp[i], reset, true);
} }
} else if (!had_both) { } else if (!had_both) {
// Don't do anything before the call with both == TRUE from main(). // Don't do anything before the call with both == true from main().
// Not everything has been setup then, and that call will overrule // Not everything has been setup then, and that call will overrule
// everything anyway. // everything anyway.
return; return;
@@ -6462,7 +6456,7 @@ int load_colors(char_u *name)
{ {
char_u *buf; char_u *buf;
int retval = FAIL; int retval = FAIL;
static int recursive = false; static bool recursive = false;
// When being called recursively, this is probably because setting // When being called recursively, this is probably because setting
// 'background' caused the highlighting to be reloaded. This means it is // 'background' caused the highlighting to be reloaded. This means it is
@@ -7132,11 +7126,10 @@ void restore_cterm_colors(void)
cterm_normal_bg_color = 0; cterm_normal_bg_color = 0;
} }
/* /// @param check_link if true also check for an existing link.
* Return TRUE if highlight group "idx" has any settings. ///
* When "check_link" is TRUE also check for an existing link. /// @return TRUE if highlight group "idx" has any settings.
*/ static int hl_has_settings(int idx, bool check_link)
static int hl_has_settings(int idx, int check_link)
{ {
return HL_TABLE()[idx].sg_cleared == 0 return HL_TABLE()[idx].sg_cleared == 0
&& (HL_TABLE()[idx].sg_attr != 0 && (HL_TABLE()[idx].sg_attr != 0
@@ -7878,8 +7871,9 @@ const char *get_highlight_name(expand_T *const xp, int idx)
/// Obtain a highlight group name. /// Obtain a highlight group name.
/// When "skip_cleared" is TRUE don't return a cleared entry. ///
const char *get_highlight_name_ext(expand_T *xp, int idx, int skip_cleared) /// @param skip_cleared if true don't return a cleared entry.
const char *get_highlight_name_ext(expand_T *xp, int idx, bool skip_cleared)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_WARN_UNUSED_RESULT
{ {
if (idx < 0) { if (idx < 0) {

View File

@@ -1371,12 +1371,12 @@ find_tags(
tagname_T tn; /* info for get_tagfname() */ tagname_T tn; /* info for get_tagfname() */
int first_file; /* trying first tag file */ int first_file; /* trying first tag file */
tagptrs_T tagp; tagptrs_T tagp;
int did_open = FALSE; /* did open a tag file */ bool did_open = false; // did open a tag file
int stop_searching = FALSE; /* stop when match found or error */ bool stop_searching = false; // stop when match found or error
int retval = FAIL; /* return value */ int retval = FAIL; // return value
int is_static; /* current tag line is static */ int is_static; // current tag line is static
int is_current; /* file name matches */ int is_current; // file name matches
int eof = FALSE; /* found end-of-file */ bool eof = false; // found end-of-file
char_u *p; char_u *p;
char_u *s; char_u *s;
int i; int i;
@@ -1429,12 +1429,12 @@ find_tags(
vimconv_T vimconv; vimconv_T vimconv;
int findall = (mincount == MAXCOL || mincount == TAG_MANY); int findall = (mincount == MAXCOL || mincount == TAG_MANY);
/* find all matching tags */ // find all matching tags
int sort_error = FALSE; /* tags file not sorted */ bool sort_error = false; // tags file not sorted
int linear; /* do a linear search */ int linear; // do a linear search
int sortic = FALSE; /* tag file sorted in nocase */ bool sortic = false; // tag file sorted in nocase
int line_error = FALSE; /* syntax error */ bool line_error = false; // syntax error
int has_re = (flags & TAG_REGEXP); /* regexp used */ int has_re = (flags & TAG_REGEXP); // regexp used
int help_only = (flags & TAG_HELP); int help_only = (flags & TAG_HELP);
int name_only = (flags & TAG_NAMES); int name_only = (flags & TAG_NAMES);
int noic = (flags & TAG_NOIC); int noic = (flags & TAG_NOIC);
@@ -1621,7 +1621,7 @@ find_tags(
verbose_leave(); verbose_leave();
} }
} }
did_open = TRUE; /* remember that we found at least one file */ did_open = true; // remember that we found at least one file
state = TS_START; /* we're at the start of the file */ state = TS_START; /* we're at the start of the file */
@@ -1638,13 +1638,13 @@ find_tags(
if ((flags & TAG_INS_COMP)) /* Double brackets for gcc */ if ((flags & TAG_INS_COMP)) /* Double brackets for gcc */
ins_compl_check_keys(30, false); ins_compl_check_keys(30, false);
if (got_int || compl_interrupted) { if (got_int || compl_interrupted) {
stop_searching = TRUE; stop_searching = true;
break; break;
} }
/* When mincount is TAG_MANY, stop when enough matches have been /* When mincount is TAG_MANY, stop when enough matches have been
* found (for completion). */ * found (for completion). */
if (mincount == TAG_MANY && match_count >= TAG_MANY) { if (mincount == TAG_MANY && match_count >= TAG_MANY) {
stop_searching = TRUE; stop_searching = true;
retval = OK; retval = OK;
break; break;
} }
@@ -1795,7 +1795,7 @@ line_read_in:
state = TS_BINARY; state = TS_BINARY;
else if (tag_file_sorted == '2') { else if (tag_file_sorted == '2') {
state = TS_BINARY; state = TS_BINARY;
sortic = TRUE; sortic = true;
orgpat.regmatch.rm_ic = (p_ic || !noic); orgpat.regmatch.rm_ic = (p_ic || !noic);
} else } else
state = TS_LINEAR; state = TS_LINEAR;
@@ -1878,8 +1878,9 @@ parse_line:
i = (int)tagp.tagname[0]; i = (int)tagp.tagname[0];
if (sortic) if (sortic)
i = TOUPPER_ASC(tagp.tagname[0]); i = TOUPPER_ASC(tagp.tagname[0]);
if (i < search_info.low_char || i > search_info.high_char) if (i < search_info.low_char || i > search_info.high_char) {
sort_error = TRUE; sort_error = true;
}
/* /*
* Compare the current tag with the searched tag. * Compare the current tag with the searched tag.
@@ -1970,7 +1971,7 @@ parse_line:
i = parse_tag_line(lbuf, i = parse_tag_line(lbuf,
&tagp); &tagp);
if (i == FAIL) { if (i == FAIL) {
line_error = TRUE; line_error = true;
break; break;
} }
@@ -2175,7 +2176,7 @@ parse_line:
tag_file_sorted = NUL; tag_file_sorted = NUL;
if (sort_error) { if (sort_error) {
EMSG2(_("E432: Tags file not sorted: %s"), tag_fname); EMSG2(_("E432: Tags file not sorted: %s"), tag_fname);
sort_error = FALSE; sort_error = false;
} }
/* /*
@@ -2183,7 +2184,7 @@ parse_line:
*/ */
if (match_count >= mincount) { if (match_count >= mincount) {
retval = OK; retval = OK;
stop_searching = TRUE; stop_searching = true;
} }
if (stop_searching || use_cscope) if (stop_searching || use_cscope)

View File

@@ -2762,13 +2762,13 @@ void u_find_first_changed(void)
return; return;
for (lnum = 1; lnum < curbuf->b_ml.ml_line_count for (lnum = 1; lnum < curbuf->b_ml.ml_line_count
&& lnum <= uep->ue_size; ++lnum) && lnum <= uep->ue_size; lnum++) {
if (STRCMP(ml_get_buf(curbuf, lnum, FALSE), if (STRCMP(ml_get_buf(curbuf, lnum, false), uep->ue_array[lnum - 1]) != 0) {
uep->ue_array[lnum - 1]) != 0) {
clearpos(&(uhp->uh_cursor)); clearpos(&(uhp->uh_cursor));
uhp->uh_cursor.lnum = lnum; uhp->uh_cursor.lnum = lnum;
return; return;
} }
}
if (curbuf->b_ml.ml_line_count != uep->ue_size) { if (curbuf->b_ml.ml_line_count != uep->ue_size) {
/* lines added or deleted at the end, put the cursor there */ /* lines added or deleted at the end, put the cursor there */
clearpos(&(uhp->uh_cursor)); clearpos(&(uhp->uh_cursor));

View File

@@ -2604,7 +2604,7 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp)
{ {
int dir; int dir;
tabpage_T *ptp = NULL; tabpage_T *ptp = NULL;
int free_tp = FALSE; bool free_tp = false;
// Get here with win->w_buffer == NULL when win_close() detects the tab page // Get here with win->w_buffer == NULL when win_close() detects the tab page
// changed. // changed.