diff options
-rw-r--r-- | src/nvim/edit.c | 2 | ||||
-rw-r--r-- | src/nvim/indent_c.c | 34 | ||||
-rw-r--r-- | src/nvim/search.c | 78 |
3 files changed, 55 insertions, 59 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index ceedcb5a99..b3222b0781 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -6589,7 +6589,7 @@ void fixthisline(IndentGetter get_the_indent) if (amount >= 0) { change_indent(INDENT_SET, amount, false, 0, true); if (linewhite(curwin->w_cursor.lnum)) { - did_ai = TRUE; // delete the indent if the line stays empty + did_ai = true; // delete the indent if the line stays empty } } } diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 59845552e1..340287499e 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -78,8 +78,8 @@ find_start_comment ( /* XXX */ */ static pos_T *ind_find_start_CORS(void) { /* XXX */ - pos_T *comment_pos = find_start_comment(curbuf->b_ind_maxcomment); - pos_T *rs_pos = find_start_rawstring(curbuf->b_ind_maxcomment); + pos_T *comment_pos = find_start_comment(curbuf->b_ind_maxcomment); + pos_T *rs_pos = find_start_rawstring(curbuf->b_ind_maxcomment); /* If comment_pos is before rs_pos the raw string is inside the comment. * If rs_pos is before comment_pos the comment is inside the raw string. */ @@ -95,9 +95,9 @@ static pos_T *ind_find_start_CORS(void) */ static pos_T *find_start_rawstring(int ind_maxcomment) { /* XXX */ - pos_T *pos; - char_u *line; - char_u *p; + pos_T *pos; + char_u *line; + char_u *p; long cur_maxcomment = ind_maxcomment; for (;;) @@ -159,9 +159,7 @@ static char_u *skip_string(char_u *p) } if (p[0] == '"') continue; /* continue for another string */ - } - else if (p[0] == 'R' && p[1] == '"') - { + } else if (p[0] == 'R' && p[1] == '"') { /* Raw string: R"[delim](...)[delim]" */ char_u *delim = p + 2; char_u *paren = vim_strchr(delim, '('); @@ -1748,7 +1746,7 @@ int get_c_indent(void) /* * #defines and so on always go at the left when included in 'cinkeys'. */ - if (*theline == '#' && (*linecopy == '#' || in_cinkeys('#', ' ', TRUE))) { + if (*theline == '#' && (*linecopy == '#' || in_cinkeys('#', ' ', true))) { amount = curbuf->b_ind_hash_comment; goto theend; } @@ -1842,12 +1840,12 @@ int get_c_indent(void) lead_middle_len) == 0) { amount = get_indent_lnum(curwin->w_cursor.lnum - 1); break; - } - /* If the start comment string doesn't match with the - * start of the comment, skip this entry. XXX */ - else if (STRNCMP(ml_get(comment_pos->lnum) + comment_pos->col, - lead_start, lead_start_len) != 0) + } else if (STRNCMP(ml_get(comment_pos->lnum) + comment_pos->col, + lead_start, lead_start_len) != 0) { + /* If the start comment string doesn't match with the + * start of the comment, skip this entry. XXX */ continue; + } } if (start_off != 0) amount += start_off; @@ -3201,11 +3199,11 @@ term_again: // basically just match where the previous line is, except // for the lines immediately following a function declaration, // which are K&R-style parameters and need to be indented. - + // if our line starts with an open brace, forget about any // prevailing indent and make sure it looks like the start // of a function - + if (theline[0] == '{') { amount = curbuf->b_ind_first_open; goto theend; @@ -3225,7 +3223,7 @@ term_again: && !cin_ends_in(theline, (char_u *)",", NULL) && cin_isfuncdecl(NULL, cur_curpos.lnum + 1, cur_curpos.lnum + 1) - && !cin_isterminated(theline, FALSE, TRUE)) { + && !cin_isterminated(theline, false, true)) { amount = curbuf->b_ind_func_type; goto theend; } @@ -3253,7 +3251,7 @@ term_again: * Are we at the start of a cpp base class declaration or * constructor initialization? */ /* XXX */ - n = FALSE; + n = false; if (curbuf->b_ind_cpp_baseclass != 0 && theline[0] != '{') { n = cin_is_cpp_baseclass(&cache_cpp_baseclass); l = get_cursor_line_ptr(); diff --git a/src/nvim/search.c b/src/nvim/search.c index 7dd3a5d219..18a72524cb 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -1448,39 +1448,39 @@ static int check_prevcol(char_u *linep, int col, int ch, int *prevcol) */ static int find_rawstring_end(char_u *linep, pos_T *startpos, pos_T *endpos) { - char_u *p; - char_u *delim_copy; - size_t delim_len; - linenr_T lnum; - int found = FALSE; - - for (p = linep + startpos->col + 1; *p && *p != '('; ++p) - ; - delim_len = (p - linep) - startpos->col - 1; - delim_copy = vim_strnsave(linep + startpos->col + 1, delim_len); - if (delim_copy == NULL) - return FALSE; - for (lnum = startpos->lnum; lnum <= endpos->lnum; ++lnum) + char_u *p; + char_u *delim_copy; + size_t delim_len; + linenr_T lnum; + int found = false; + + for (p = linep + startpos->col + 1; *p && *p != '('; ++p) {} + + delim_len = (p - linep) - startpos->col - 1; + delim_copy = vim_strnsave(linep + startpos->col + 1, delim_len); + if (delim_copy == NULL) + return false; + for (lnum = startpos->lnum; lnum <= endpos->lnum; ++lnum) + { + char_u *line = ml_get(lnum); + + for (p = line + (lnum == startpos->lnum + ? startpos->col + 1 : 0); *p; ++p) { - char_u *line = ml_get(lnum); - - for (p = line + (lnum == startpos->lnum - ? startpos->col + 1 : 0); *p; ++p) - { - if (lnum == endpos->lnum && (colnr_T)(p - line) >= endpos->col) - break; - if (*p == ')' && p[delim_len + 1] == '"' - && STRNCMP(delim_copy, p + 1, delim_len) == 0) - { - found = TRUE; - break; - } - } - if (found) - break; + if (lnum == endpos->lnum && (colnr_T)(p - line) >= endpos->col) + break; + if (*p == ')' && p[delim_len + 1] == '"' + && STRNCMP(delim_copy, p + 1, delim_len) == 0) + { + found = true; + break; + } } - xfree(delim_copy); - return found; + if (found) + break; + } + xfree(delim_copy); + return found; } /* @@ -1510,9 +1510,9 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) int findc = 0; /* matching brace */ int c; int count = 0; /* cumulative number of braces */ - int backwards = FALSE; /* init for gcc */ - int raw_string = FALSE; /* search for raw string */ - int inquote = FALSE; /* TRUE when inside quotes */ + int backwards = false; /* init for gcc */ + int raw_string = false; /* search for raw string */ + int inquote = false; /* true when inside quotes */ char_u *linep; /* pointer to current line */ char_u *ptr; int do_quotes; /* check for quotes in current line */ @@ -1555,16 +1555,15 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) if (initc == '/' || initc == '*' || initc == 'R') { comment_dir = dir; if (initc == '/') - ignore_cend = TRUE; - backwards = (dir == FORWARD) ? FALSE : TRUE; + ignore_cend = true; + backwards = (dir == FORWARD) ? false : true; raw_string = (initc == 'R'); initc = NUL; } else if (initc != '#' && initc != NUL) { find_mps_values(&initc, &findc, &backwards, TRUE); if (findc == NUL) return NULL; - } - else { + } else { /* * Either initc is '#', or no initc was given and we need to look * under the cursor. @@ -1832,8 +1831,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) } linep = ml_get(pos.lnum); /* may have been released */ } - } - else if ( linep[pos.col - 1] == '/' + } else if ( linep[pos.col - 1] == '/' && linep[pos.col] == '*' && (int)pos.col < comment_col) { count++; |