diff options
Diffstat (limited to 'src/nvim/indent_c.c')
-rw-r--r-- | src/nvim/indent_c.c | 440 |
1 files changed, 220 insertions, 220 deletions
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 64844a510f..ccf4448e93 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -56,7 +56,7 @@ pos_T *find_start_comment(int ind_maxcomment) // XXX // Check if the comment start we found is inside a string. // If it is then restrict the search to below this line and try again. - if (!is_pos_in_string((char_u *)ml_get(pos->lnum), pos->col)) { + if (!is_pos_in_string(ml_get(pos->lnum), pos->col)) { break; } cur_maxcomment = curwin->w_cursor.lnum - pos->lnum - 1; @@ -117,7 +117,7 @@ static pos_T *find_start_rawstring(int ind_maxcomment) // XXX // Check if the raw string start we found is inside a string. // If it is then restrict the search to below this line and try again. - if (!is_pos_in_string((char_u *)ml_get(pos->lnum), pos->col)) { + if (!is_pos_in_string(ml_get(pos->lnum), pos->col)) { break; } cur_maxcomment = curwin->w_cursor.lnum - pos->lnum - 1; @@ -165,8 +165,8 @@ static const char *skip_string(const char *p) } } else if (p[0] == 'R' && p[1] == '"') { // Raw string: R"[delim](...)[delim]" - const char *delim = (char *)p + 2; - const char *paren = vim_strchr((char *)delim, '('); + const char *delim = p + 2; + const char *paren = vim_strchr(delim, '('); if (paren != NULL) { const ptrdiff_t delim_len = paren - delim; @@ -192,12 +192,12 @@ static const char *skip_string(const char *p) } /// @returns true if "line[col]" is inside a C string. -int is_pos_in_string(const char_u *line, colnr_T col) +int is_pos_in_string(const char *line, colnr_T col) { - const char_u *p; + const char *p; for (p = line; *p && (colnr_T)(p - line) < col; p++) { - p = (char_u *)skip_string((char *)p); + p = skip_string(p); } return !((colnr_T)(p - line) <= col); } @@ -214,7 +214,7 @@ bool cin_is_cinword(const char *line) size_t cinw_len = strlen(curbuf->b_p_cinw) + 1; char *cinw_buf = xmalloc(cinw_len); - line = skipwhite((char *)line); + line = skipwhite(line); for (char *cinw = curbuf->b_p_cinw; *cinw;) { size_t len = copy_option_part(&cinw, cinw_buf, cinw_len, ","); @@ -232,17 +232,17 @@ bool cin_is_cinword(const char *line) // Skip over white space and C comments within the line. // Also skip over Perl/shell comments if desired. -static const char_u *cin_skipcomment(const char_u *s) +static const char *cin_skipcomment(const char *s) { while (*s) { - const char_u *prev_s = s; + const char *prev_s = s; - s = (char_u *)skipwhite((char *)s); + s = skipwhite(s); // Perl/shell # comment comment continues until eol. Require a space // before # to avoid recognizing $#array. if (curbuf->b_ind_hash_comment != 0 && s != prev_s && *s == '#') { - s += strlen((char *)s); + s += strlen(s); break; } if (*s != '/') { @@ -250,7 +250,7 @@ static const char_u *cin_skipcomment(const char_u *s) } s++; if (*s == '/') { // slash-slash comment continues till eol - s += strlen((char *)s); + s += strlen(s); break; } if (*s != '*') { @@ -268,7 +268,7 @@ static const char_u *cin_skipcomment(const char_u *s) /// Return true if there is no code at *s. White space and comments are /// not considered code. -static int cin_nocode(const char_u *s) +static int cin_nocode(const char *s) { return *cin_skipcomment(s) == NUL; } @@ -277,13 +277,13 @@ static int cin_nocode(const char_u *s) static pos_T *find_line_comment(void) // XXX { static pos_T pos; - char_u *line; - char_u *p; + char *line; + char *p; pos = curwin->w_cursor; while (--pos.lnum > 0) { - line = (char_u *)ml_get(pos.lnum); - p = (char_u *)skipwhite((char *)line); + line = ml_get(pos.lnum); + p = skipwhite(line); if (cin_islinecomment(p)) { pos.col = (int)(p - line); return &pos; @@ -296,9 +296,9 @@ static pos_T *find_line_comment(void) // XXX } /// Checks if `text` starts with "key:". -static bool cin_has_js_key(const char_u *text) +static bool cin_has_js_key(const char *text) { - const char *s = skipwhite((char *)text); + const char *s = skipwhite(text); char quote = 0; if (*s == '\'' || *s == '"') { @@ -317,7 +317,7 @@ static bool cin_has_js_key(const char_u *text) s++; } - s = (char *)cin_skipcomment((char_u *)s); + s = cin_skipcomment(s); // "::" is not a label, it's C++ return (*s == ':' && s[1] != ':'); @@ -336,7 +336,7 @@ static bool cin_islabel_skip(const char **s) (*s)++; } - *s = (char *)cin_skipcomment((char_u *)(*s)); + *s = cin_skipcomment(*s); // "::" is not a label, it's C++ return **s == ':' && *++*s != ':'; @@ -346,14 +346,14 @@ static bool cin_islabel_skip(const char **s) // Note: curwin->w_cursor must be where we are looking for the label. bool cin_islabel(void) // XXX { - const char *s = (char *)cin_skipcomment((char_u *)get_cursor_line_ptr()); + const char *s = cin_skipcomment(get_cursor_line_ptr()); // Exclude "default" from labels, since it should be indented // like a switch label. Same for C++ scope declarations. - if (cin_isdefault((char *)s)) { + if (cin_isdefault(s)) { return false; } - if (cin_isscopedecl((char_u *)s)) { + if (cin_isscopedecl(s)) { return false; } @@ -379,18 +379,18 @@ bool cin_islabel(void) // XXX } line = get_cursor_line_ptr(); - if (cin_ispreproc((char_u *)line)) { // ignore #defines, #if, etc. + if (cin_ispreproc(line)) { // ignore #defines, #if, etc. continue; } - if (*(line = (char *)cin_skipcomment((char_u *)line)) == NUL) { + if (*(line = cin_skipcomment(line)) == NUL) { continue; } curwin->w_cursor = cursor_save; - if (cin_isterminated((char_u *)line, true, false) - || cin_isscopedecl((char_u *)line) - || cin_iscase((char_u *)line, true) - || (cin_islabel_skip(&line) && cin_nocode((char_u *)line))) { + if (cin_isterminated(line, true, false) + || cin_isscopedecl(line) + || cin_iscase(line, true) + || (cin_islabel_skip(&line) && cin_nocode(line))) { return true; } return false; @@ -404,12 +404,12 @@ bool cin_islabel(void) // XXX // "[typedef] [static|public|protected|private] = {" static int cin_isinit(void) { - const char_u *s; + const char *s; static char *skip[] = { "static", "public", "protected", "private" }; - s = cin_skipcomment((char_u *)get_cursor_line_ptr()); + s = cin_skipcomment(get_cursor_line_ptr()); - if (cin_starts_with((char *)s, "typedef")) { + if (cin_starts_with(s, "typedef")) { s = cin_skipcomment(s + 7); } @@ -418,7 +418,7 @@ static int cin_isinit(void) for (i = 0; i < (int)ARRAY_SIZE(skip); i++) { l = (int)strlen(skip[i]); - if (cin_starts_with((char *)s, skip[i])) { + if (cin_starts_with(s, skip[i])) { s = cin_skipcomment(s + l); l = 0; break; @@ -429,11 +429,11 @@ static int cin_isinit(void) } } - if (cin_starts_with((char *)s, "enum")) { + if (cin_starts_with(s, "enum")) { return true; } - if (cin_ends_in((char *)s, "=", "{")) { + if (cin_ends_in(s, "=", "{")) { return true; } @@ -443,10 +443,10 @@ static int cin_isinit(void) /// Recognize a switch label: "case .*:" or "default:". /// /// @param strict Allow relaxed check of case statement for JS -bool cin_iscase(const char_u *s, bool strict) +bool cin_iscase(const char *s, bool strict) { s = cin_skipcomment(s); - if (cin_starts_with((char *)s, "case")) { + if (cin_starts_with(s, "case")) { for (s += 4; *s; s++) { s = cin_skipcomment(s); if (*s == NUL) { @@ -474,7 +474,7 @@ bool cin_iscase(const char_u *s, bool strict) return false; } - if (cin_isdefault((char *)s)) { + if (cin_isdefault(s)) { return true; } return false; @@ -484,14 +484,14 @@ bool cin_iscase(const char_u *s, bool strict) static int cin_isdefault(const char *s) { return strncmp(s, "default", 7) == 0 - && *(s = (char *)cin_skipcomment((char_u *)s + 7)) == ':' + && *(s = cin_skipcomment(s + 7)) == ':' && s[1] != ':'; } /// Recognize a scope declaration label set in 'cinscopedecls'. -bool cin_isscopedecl(const char_u *p) +bool cin_isscopedecl(const char *p) { - const char *s = (char *)cin_skipcomment(p); + const char *s = cin_skipcomment(p); const size_t cinsd_len = strlen(curbuf->b_p_cinsd) + 1; char *cinsd_buf = xmalloc(cinsd_len); @@ -501,7 +501,7 @@ bool cin_isscopedecl(const char_u *p) for (char *cinsd = curbuf->b_p_cinsd; *cinsd;) { const size_t len = copy_option_part(&cinsd, cinsd_buf, cinsd_len, ","); if (strncmp(s, cinsd_buf, len) == 0) { - const char_u *skip = cin_skipcomment((char_u *)s + len); + const char *skip = cin_skipcomment(s + len); if (*skip == ':' && skip[1] != ':') { found = true; break; @@ -524,18 +524,18 @@ static bool cin_is_cpp_namespace(const char *s) bool has_name = false; bool has_name_start = false; - s = (char *)cin_skipcomment((char_u *)s); + s = cin_skipcomment(s); if (strncmp(s, "inline", 6) == 0 && (s[6] == NUL || !vim_iswordc((uint8_t)s[6]))) { - s = (char *)cin_skipcomment((char_u *)skipwhite((char *)s + 6)); + s = cin_skipcomment(skipwhite(s + 6)); } if (strncmp(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc((uint8_t)s[9]))) { - p = (char *)cin_skipcomment((char_u *)skipwhite((char *)s + 9)); + p = cin_skipcomment(skipwhite(s + 9)); while (*p != NUL) { if (ascii_iswhite(*p)) { has_name = true; // found end of a name - p = (char *)cin_skipcomment((char_u *)skipwhite((char *)p)); + p = cin_skipcomment(skipwhite(p)); } else if (*p == '{') { break; } else if (vim_iswordc((uint8_t)(*p))) { @@ -563,7 +563,7 @@ static bool cin_is_cpp_namespace(const char *s) // Return NULL if not found. // case 234: a = b; // ^ -static const char_u *after_label(const char_u *l) +static const char *after_label(const char *l) { for (; *l; l++) { if (*l == ':') { @@ -590,12 +590,12 @@ static const char_u *after_label(const char_u *l) // Return 0 if there is nothing after the label. static int get_indent_nolabel(linenr_T lnum) // XXX { - const char_u *l; + const char *l; pos_T fp; colnr_T col; - const char_u *p; + const char *p; - l = (char_u *)ml_get(lnum); + l = ml_get(lnum); p = after_label(l); if (p == NULL) { return 0; @@ -621,9 +621,9 @@ static int skip_label(linenr_T lnum, const char **pp) curwin->w_cursor.lnum = lnum; l = get_cursor_line_ptr(); // XXX - if (cin_iscase((char_u *)l, false) || cin_isscopedecl((char_u *)l) || cin_islabel()) { + if (cin_iscase(l, false) || cin_isscopedecl(l) || cin_islabel()) { amount = get_indent_nolabel(lnum); - l = (char *)after_label((char_u *)get_cursor_line_ptr()); + l = after_label(get_cursor_line_ptr()); if (l == NULL) { // just in case l = get_cursor_line_ptr(); } @@ -671,7 +671,7 @@ static int cin_first_id_amount(void) } } for (len = 0; vim_isIDc((uint8_t)p[len]); len++) {} - if (len == 0 || !ascii_iswhite(p[len]) || cin_nocode((char_u *)p)) { + if (len == 0 || !ascii_iswhite(p[len]) || cin_nocode(p)) { return 0; } @@ -691,19 +691,19 @@ static int cin_first_id_amount(void) // here"; static int cin_get_equal_amount(linenr_T lnum) { - const char_u *line; - const char_u *s; + const char *line; + const char *s; colnr_T col; pos_T fp; if (lnum > 1) { - line = (char_u *)ml_get(lnum - 1); - if (*line != NUL && line[strlen((char *)line) - 1] == '\\') { + line = ml_get(lnum - 1); + if (*line != NUL && line[strlen(line) - 1] == '\\') { return -1; } } - s = (char_u *)ml_get(lnum); + s = ml_get(lnum); line = s; while (*s != NUL && vim_strchr("=;{}\"'", *s) == NULL) { if (cin_iscomment(s)) { // ignore comments @@ -716,7 +716,7 @@ static int cin_get_equal_amount(linenr_T lnum) return 0; } - s = (char_u *)skipwhite((char *)s + 1); + s = skipwhite(s + 1); if (cin_nocode(s)) { return 0; } @@ -732,9 +732,9 @@ static int cin_get_equal_amount(linenr_T lnum) } // Recognize a preprocessor statement: Any line that starts with '#'. -static int cin_ispreproc(const char_u *s) +static int cin_ispreproc(const char *s) { - if (*skipwhite((char *)s) == '#') { + if (*skipwhite(s) == '#') { return true; } return false; @@ -746,12 +746,12 @@ static int cin_ispreproc(const char_u *s) /// Put the amount of indent in "*amount". static int cin_ispreproc_cont(const char **pp, linenr_T *lnump, int *amount) { - const char_u *line = (char_u *)(*pp); + const char *line = *pp; linenr_T lnum = *lnump; int retval = false; int candidate_amount = *amount; - if (*line != NUL && line[strlen((char *)line) - 1] == '\\') { + if (*line != NUL && line[strlen(line) - 1] == '\\') { candidate_amount = get_indent_lnum(lnum); } @@ -764,8 +764,8 @@ static int cin_ispreproc_cont(const char **pp, linenr_T *lnump, int *amount) if (lnum == 1) { break; } - line = (char_u *)ml_get(--lnum); - if (*line == NUL || line[strlen((char *)line) - 1] != '\\') { + line = ml_get(--lnum); + if (*line == NUL || line[strlen(line) - 1] != '\\') { break; } } @@ -780,13 +780,13 @@ static int cin_ispreproc_cont(const char **pp, linenr_T *lnump, int *amount) } // Recognize the start of a C or C++ comment. -static int cin_iscomment(const char_u *p) +static int cin_iscomment(const char *p) { return p[0] == '/' && (p[1] == '*' || p[1] == '/'); } // Recognize the start of a "//" comment. -static int cin_islinecomment(const char_u *p) +static int cin_islinecomment(const char *p) { return p[0] == '/' && p[1] == '/'; } @@ -802,25 +802,25 @@ static int cin_islinecomment(const char_u *p) /// /// @return the character terminating the line (ending char's have precedence if /// both apply in order to determine initializations). -static char_u cin_isterminated(const char_u *s, int incl_open, int incl_comma) +static char cin_isterminated(const char *s, int incl_open, int incl_comma) { - char_u found_start = 0; + char found_start = 0; unsigned n_open = 0; int is_else = false; s = cin_skipcomment(s); - if (*s == '{' || (*s == '}' && !cin_iselse((char *)s))) { + if (*s == '{' || (*s == '}' && !cin_iselse(s))) { found_start = *s; } if (!found_start) { - is_else = cin_iselse((char *)s); + is_else = cin_iselse(s); } while (*s) { // skip over comments, "" strings and 'c'haracters - s = (char_u *)skip_string((char *)cin_skipcomment(s)); + s = skip_string(cin_skipcomment(s)); if (*s == '}' && n_open > 0) { n_open--; } @@ -855,7 +855,7 @@ static char_u cin_isterminated(const char_u *s, int incl_open, int incl_comma) /// @param[in] min_lnum The line before which we will not be looking. static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnum) { - const char_u *s; + const char *s; linenr_T lnum = first_lnum; linenr_T save_lnum = curwin->w_cursor.lnum; int retval = false; @@ -863,9 +863,9 @@ static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnu int just_started = true; if (sp == NULL) { - s = (char_u *)ml_get(lnum); + s = ml_get(lnum); } else { - s = (char_u *)(*sp); + s = *sp; } curwin->w_cursor.lnum = lnum; @@ -876,7 +876,7 @@ static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnu curwin->w_cursor.lnum = save_lnum; return false; } - s = (char_u *)ml_get(lnum); + s = ml_get(lnum); } curwin->w_cursor.lnum = save_lnum; @@ -915,8 +915,8 @@ static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnu // #if defined(x) && {backslash} // defined(y) lnum = first_lnum - 1; - s = (char_u *)ml_get(lnum); - if (*s == NUL || s[strlen((char *)s) - 1] != '\\') { + s = ml_get(lnum); + if (*s == NUL || s[strlen(s) - 1] != '\\') { retval = true; } goto done; @@ -932,7 +932,7 @@ static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnu if (lnum >= curbuf->b_ml.ml_line_count) { break; } - s = (char_u *)ml_get(++lnum); + s = ml_get(++lnum); if (!cin_ispreproc(s)) { break; } @@ -942,7 +942,7 @@ static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnu } // Require a comma at end of the line or a comma or ')' at the // start of next line. - s = (char_u *)skipwhite((char *)s); + s = skipwhite(s); if (!just_started && (!comma && *s != ',' && *s != ')')) { break; } @@ -971,7 +971,7 @@ static int cin_isif(const char *p) static int cin_iselse(const char *p) { if (*p == '}') { // accept "} else" - p = (char *)cin_skipcomment((char_u *)p + 1); + p = cin_skipcomment(p + 1); } return strncmp(p, "else", 4) == 0 && !vim_isIDc((uint8_t)p[4]); } @@ -984,7 +984,7 @@ static int cin_isdo(const char *p) // Check if this is a "while" that should have a matching "do". // We only accept a "while (condition) ;", with only white space between the // ')' and ';'. The condition may be spread over several lines. -static int cin_iswhileofdo(const char_u *p, linenr_T lnum) // XXX +static int cin_iswhileofdo(const char *p, linenr_T lnum) // XXX { pos_T cursor_save; pos_T *trypos; @@ -994,17 +994,17 @@ static int cin_iswhileofdo(const char_u *p, linenr_T lnum) // XXX if (*p == '}') { // accept "} while (cond);" p = cin_skipcomment(p + 1); } - if (cin_starts_with((char *)p, "while")) { + if (cin_starts_with(p, "while")) { cursor_save = curwin->w_cursor; curwin->w_cursor.lnum = lnum; curwin->w_cursor.col = 0; - p = (char_u *)get_cursor_line_ptr(); + p = get_cursor_line_ptr(); while (*p && *p != 'w') { // skip any '}', until the 'w' of the "while" p++; curwin->w_cursor.col++; } if ((trypos = findmatchlimit(NULL, 0, 0, curbuf->b_ind_maxparen)) != NULL - && *cin_skipcomment((char_u *)ml_get_pos(trypos) + 1) == ';') { + && *cin_skipcomment(ml_get_pos(trypos) + 1) == ';') { retval = true; } curwin->w_cursor = cursor_save; @@ -1063,9 +1063,9 @@ probablyFound: /// Adjust the cursor to the line with "while". static int cin_iswhileofdo_end(int terminated) { - const char_u *line; - const char_u *p; - const char_u *s; + const char *line; + const char *p; + const char *s; pos_T *trypos; int i; @@ -1073,11 +1073,11 @@ static int cin_iswhileofdo_end(int terminated) return false; } - p = line = (char_u *)get_cursor_line_ptr(); + p = line = get_cursor_line_ptr(); while (*p != NUL) { p = cin_skipcomment(p); if (*p == ')') { - s = (char_u *)skipwhite((char *)p + 1); + s = skipwhite(p + 1); if (*s == ';' && cin_nocode(s + 1)) { // Found ");" at end of the line, now check there is "while" // before the matching '('. XXX @@ -1085,18 +1085,18 @@ static int cin_iswhileofdo_end(int terminated) curwin->w_cursor.col = i; trypos = find_match_paren(curbuf->b_ind_maxparen); if (trypos != NULL) { - s = cin_skipcomment((char_u *)ml_get(trypos->lnum)); + s = cin_skipcomment(ml_get(trypos->lnum)); if (*s == '}') { // accept "} while (cond);" s = cin_skipcomment(s + 1); } - if (cin_starts_with((char *)s, "while")) { + if (cin_starts_with(s, "while")) { curwin->w_cursor.lnum = trypos->lnum; return true; } } // Searching may have made "line" invalid, get it again. - line = (char_u *)get_cursor_line_ptr(); + line = get_cursor_line_ptr(); p = line + i; } } @@ -1141,7 +1141,7 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached) if (*s == '#') { // skip #define FOO x ? (x) : x return false; } - s = (char *)cin_skipcomment((char_u *)s); + s = cin_skipcomment(s); if (*s == NUL) { return false; } @@ -1167,9 +1167,9 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached) break; } while (*s != NUL) { - s = (char *)cin_skipcomment((char_u *)s); + s = cin_skipcomment(s); if (*s == '{' || *s == '}' - || (*s == ';' && cin_nocode((char_u *)s + 1))) { + || (*s == ';' && cin_nocode(s + 1))) { break; } if (*s != NUL) { @@ -1196,32 +1196,32 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached) } if (s == line) { // don't recognize "case (foo):" as a baseclass */ - if (cin_iscase((char_u *)s, false)) { + if (cin_iscase(s, false)) { break; } - s = (char *)cin_skipcomment((char_u *)line); + s = cin_skipcomment(line); if (*s == NUL) { continue; } } if (s[0] == '"' || (s[0] == 'R' && s[1] == '"')) { - s = (char *)skip_string(s) + 1; + s = skip_string(s) + 1; } else if (s[0] == ':') { if (s[1] == ':') { // skip double colon. It can't be a constructor // initialization any more lookfor_ctor_init = false; - s = (char *)cin_skipcomment((char_u *)s + 2); + s = cin_skipcomment(s + 2); } else if (lookfor_ctor_init || class_or_struct) { // we have something found, that looks like the start of // cpp-base-class-declaration or constructor-initialization cpp_base_class = true; lookfor_ctor_init = class_or_struct = false; pos->col = 0; - s = (char *)cin_skipcomment((char_u *)s + 1); + s = cin_skipcomment(s + 1); } else { - s = (char *)cin_skipcomment((char_u *)s + 1); + s = cin_skipcomment(s + 1); } } else if ((strncmp(s, "class", 5) == 0 && !vim_isIDc((uint8_t)s[5])) || (strncmp(s, "struct", 6) == 0 && !vim_isIDc((uint8_t)s[6]))) { @@ -1229,9 +1229,9 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached) lookfor_ctor_init = false; if (*s == 'c') { - s = (char *)cin_skipcomment((char_u *)s + 5); + s = cin_skipcomment(s + 5); } else { - s = (char *)cin_skipcomment((char_u *)s + 6); + s = cin_skipcomment(s + 6); } } else { if (s[0] == '{' || s[0] == '}' || s[0] == ';') { @@ -1259,11 +1259,11 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached) } // When the line ends in a comma don't align with it. - if (lnum == curwin->w_cursor.lnum && *s == ',' && cin_nocode((char_u *)s + 1)) { + if (lnum == curwin->w_cursor.lnum && *s == ',' && cin_nocode(s + 1)) { pos->col = 0; } - s = (char *)cin_skipcomment((char_u *)s + 1); + s = cin_skipcomment(s + 1); } } @@ -1282,7 +1282,7 @@ static int get_baseclass_amount(int col) if (col == 0) { amount = get_indent(); - if (find_last_paren((char_u *)get_cursor_line_ptr(), '(', ')') + if (find_last_paren(get_cursor_line_ptr(), '(', ')') && (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) { amount = get_indent_lnum(trypos->lnum); // XXX } @@ -1305,18 +1305,18 @@ static int get_baseclass_amount(int col) /// Ignore "ignore" after "find" if it's not NULL. static int cin_ends_in(const char *s, const char *find, const char *ignore) { - const char *p = (char *)s; + const char *p = s; const char *r; - int len = (int)strlen((char *)find); + int len = (int)strlen(find); while (*p != NUL) { - p = (char *)cin_skipcomment((char_u *)p); + p = cin_skipcomment(p); if (strncmp(p, find, (size_t)len) == 0) { - r = skipwhite((char *)p + len); - if (ignore != NULL && strncmp(r, ignore, strlen((char *)ignore)) == 0) { - r = skipwhite((char *)r + strlen((char *)ignore)); + r = skipwhite(p + len); + if (ignore != NULL && strncmp(r, ignore, strlen(ignore)) == 0) { + r = skipwhite(r + strlen(ignore)); } - if (cin_nocode((char_u *)r)) { + if (cin_nocode(r)) { return true; } } @@ -1338,15 +1338,15 @@ static int cin_starts_with(const char *s, const char *word) /// Recognize a `extern "C"` or `extern "C++"` linkage specifications. static int cin_is_cpp_extern_c(const char *s) { - const char_u *p; + const char *p; int has_string_literal = false; - s = (char *)cin_skipcomment((char_u *)s); + s = cin_skipcomment(s); if (strncmp(s, "extern", 6) == 0 && (s[6] == NUL || !vim_iswordc((uint8_t)s[6]))) { - p = cin_skipcomment((char_u *)skipwhite((char *)s + 6)); + p = cin_skipcomment(skipwhite(s + 6)); while (*p != NUL) { if (ascii_iswhite(*p)) { - p = cin_skipcomment((char_u *)skipwhite((char *)p)); + p = cin_skipcomment(skipwhite(p)); } else if (*p == '{') { break; } else if (p[0] == '"' && p[1] == 'C' && p[2] == '"') { @@ -1375,17 +1375,17 @@ static int cin_is_cpp_extern_c(const char *s) // Return the column found. static int cin_skip2pos(pos_T *trypos) { - const char_u *line; - const char_u *p; - const char_u *new_p; + const char *line; + const char *p; + const char *new_p; - line = (char_u *)ml_get(trypos->lnum); + line = ml_get(trypos->lnum); p = line; while (*p && (colnr_T)(p - line) < trypos->col) { if (cin_iscomment(p)) { p = cin_skipcomment(p); } else { - new_p = (char_u *)skip_string((char *)p); + new_p = skip_string(p); if (new_p == p) { p++; } else { @@ -1437,7 +1437,7 @@ static pos_T *find_match_paren(int ind_maxparen) return find_match_char('(', ind_maxparen); } -static pos_T *find_match_char(char_u c, int ind_maxparen) +static pos_T *find_match_char(char c, int ind_maxparen) { pos_T cursor_save; pos_T *trypos; @@ -1447,7 +1447,7 @@ static pos_T *find_match_char(char_u c, int ind_maxparen) cursor_save = curwin->w_cursor; ind_maxp_wk = ind_maxparen; retry: - if ((trypos = findmatchlimit(NULL, c, 0, ind_maxp_wk)) != NULL) { + if ((trypos = findmatchlimit(NULL, (uint8_t)c, 0, ind_maxp_wk)) != NULL) { // check if the ( is in a // comment if ((colnr_T)cin_skip2pos(trypos) > trypos->col) { ind_maxp_wk = ind_maxparen - (cursor_save.lnum - trypos->lnum); @@ -1515,7 +1515,7 @@ static int corr_ind_maxparen(pos_T *startpos) // Set w_cursor.col to the column number of the last unmatched ')' or '{' in // line "l". "l" must point to the start of the line. -static int find_last_paren(const char_u *l, int start, int end) +static int find_last_paren(const char *l, char start, char end) { int i; int retval = false; @@ -1525,7 +1525,7 @@ static int find_last_paren(const char_u *l, int start, int end) for (i = 0; l[i] != NUL; i++) { i = (int)(cin_skipcomment(l + i) - l); // ignore parens in comments - i = (int)(skip_string((char *)l + i) - (char *)l); // ignore parens in quotes + i = (int)(skip_string(l + i) - l); // ignore parens in quotes if (l[i] == start) { open_count++; } else if (l[i] == end) { @@ -1852,7 +1852,7 @@ int get_c_indent(void) pos_T *tryposBrace = NULL; pos_T tryposCopy; pos_T our_paren_pos; - char_u *start; + char *start; int start_brace; #define BRACE_IN_COL0 1 // '{' is in column 0 #define BRACE_AT_START 2 // '{' is at start of line @@ -1860,7 +1860,7 @@ int get_c_indent(void) linenr_T ourscope; const char *l; const char *look; - char_u terminated; + char terminated; int lookfor; #define LOOKFOR_INITIAL 0 #define LOOKFOR_IF 1 @@ -1955,7 +1955,7 @@ int get_c_indent(void) } // If we're inside a "//" comment and there is a "//" comment in a // previous line, lineup with that one. - if (cin_islinecomment((char_u *)theline)) { + if (cin_islinecomment(theline)) { pos_T linecomment_pos; trypos = find_line_comment(); // XXX @@ -1977,7 +1977,7 @@ int get_c_indent(void) } // If we're inside a comment and not looking at the start of the // comment, try using the 'comments' option. - if (!cin_iscomment((char_u *)theline) && comment_pos != NULL) { // XXX + if (!cin_iscomment(theline) && comment_pos != NULL) { // XXX int lead_start_len = 2; int lead_middle_len = 1; char lead_start[COM_MAX_LEN]; // start-comment string @@ -2096,10 +2096,10 @@ int get_c_indent(void) } if (amount == -1) { // use the comment opener if (!curbuf->b_ind_in_comment2) { - start = (char_u *)ml_get(comment_pos->lnum); - look = (char *)start + comment_pos->col + 2; // skip / and * + start = ml_get(comment_pos->lnum); + look = start + comment_pos->col + 2; // skip / and * if (*look != NUL) { // if something after it - comment_pos->col = (colnr_T)((char_u *)skipwhite((char *)look) - start); + comment_pos->col = (colnr_T)(skipwhite(look) - start); } } getvcol(curwin, comment_pos, &col, NULL, NULL); @@ -2147,7 +2147,7 @@ int get_c_indent(void) amount = -1; for (lnum = cur_curpos.lnum - 1; lnum > our_paren_pos.lnum; lnum--) { l = skipwhite(ml_get(lnum)); - if (cin_nocode((char_u *)l)) { // skip comment lines + if (cin_nocode(l)) { // skip comment lines continue; } if (cin_ispreproc_cont(&l, &lnum, &amount)) { @@ -2192,7 +2192,7 @@ int get_c_indent(void) pos_T cursor_save = curwin->w_cursor; pos_T outermost; - char_u *line; + char *line; trypos = &our_paren_pos; do { @@ -2205,24 +2205,24 @@ int get_c_indent(void) curwin->w_cursor = cursor_save; - line = (char_u *)ml_get(outermost.lnum); + line = ml_get(outermost.lnum); is_if_for_while = - cin_is_if_for_while_before_offset((char *)line, &outermost.col); + cin_is_if_for_while_before_offset(line, &outermost.col); } amount = skip_label(our_paren_pos.lnum, &look); - look = skipwhite((char *)look); + look = skipwhite(look); if (*look == '(') { linenr_T save_lnum = curwin->w_cursor.lnum; - char_u *line; + char *line; int look_col; // Ignore a '(' in front of the line that has a match before // our matching '('. curwin->w_cursor.lnum = our_paren_pos.lnum; - line = (char_u *)get_cursor_line_ptr(); - look_col = (int)(look - (char *)line); + line = get_cursor_line_ptr(); + look_col = (int)(look - line); curwin->w_cursor.col = look_col + 1; if ((trypos = findmatchlimit(NULL, ')', 0, curbuf->b_ind_maxparen)) @@ -2353,7 +2353,7 @@ int get_c_indent(void) } // add extra indent for a comment - if (cin_iscomment((char_u *)theline)) { + if (cin_iscomment(theline)) { amount += curbuf->b_ind_comment; } } else { @@ -2365,13 +2365,13 @@ int get_c_indent(void) tryposBrace = &tryposCopy; trypos = tryposBrace; ourscope = trypos->lnum; - start = (char_u *)ml_get(ourscope); + start = ml_get(ourscope); // Now figure out how indented the line is in general. // If the brace was at the start of the line, we use that; // otherwise, check out the indentation of the line as // a whole and then add the "imaginary indent" to that. - look = skipwhite((char *)start); + look = skipwhite(start); if (*look == '{') { getvcol(curwin, trypos, &col, NULL, NULL); amount = col; @@ -2398,7 +2398,7 @@ int get_c_indent(void) // ldfd) { // } if ((curbuf->b_ind_js || curbuf->b_ind_keep_case_label) - && cin_iscase((char_u *)skipwhite(get_cursor_line_ptr()), false)) { + && cin_iscase(skipwhite(get_cursor_line_ptr()), false)) { amount = get_indent(); } else if (curbuf->b_ind_js) { amount = get_indent_lnum(lnum); @@ -2410,7 +2410,7 @@ int get_c_indent(void) } // For Javascript check if the line starts with "key:". - bool js_cur_has_key = curbuf->b_ind_js ? cin_has_js_key((char_u *)theline) : false; + bool js_cur_has_key = curbuf->b_ind_js ? cin_has_js_key(theline) : false; // If we're looking at a closing brace, that's where // we want to be. Otherwise, add the amount of room @@ -2427,7 +2427,7 @@ int get_c_indent(void) lookfor = LOOKFOR_INITIAL; if (cin_iselse(theline)) { lookfor = LOOKFOR_IF; - } else if (cin_iswhileofdo((char_u *)theline, cur_curpos.lnum)) { // XXX + } else if (cin_iswhileofdo(theline, cur_curpos.lnum)) { // XXX lookfor = LOOKFOR_DO; } if (lookfor != LOOKFOR_INITIAL) { @@ -2458,7 +2458,7 @@ int get_c_indent(void) amount += curbuf->b_ind_open_imag; l = skipwhite(get_cursor_line_ptr()); - if (cin_is_cpp_namespace((char *)l)) { + if (cin_is_cpp_namespace(l)) { amount += curbuf->b_ind_cpp_namespace; } else if (cin_is_cpp_extern_c(l)) { amount += curbuf->b_ind_cpp_extern_c; @@ -2474,10 +2474,10 @@ int get_c_indent(void) lookfor_break = false; - if (cin_iscase((char_u *)theline, false)) { // it's a switch() label + if (cin_iscase(theline, false)) { // it's a switch() label lookfor = LOOKFOR_CASE; // find a previous switch() label amount += curbuf->b_ind_case; - } else if (cin_isscopedecl((char_u *)theline)) { // private:, ... + } else if (cin_isscopedecl(theline)) { // private:, ... lookfor = LOOKFOR_SCOPEDECL; // class decl is this block amount += curbuf->b_ind_scopedecl; } else { @@ -2548,11 +2548,11 @@ int get_c_indent(void) continue; } - if (cin_nocode((char_u *)l)) { + if (cin_nocode(l)) { continue; } - terminated = cin_isterminated((char_u *)l, false, true); + terminated = cin_isterminated(l, false, true); // If we are at top level and the line looks like a // function declaration, we are done @@ -2587,11 +2587,11 @@ int get_c_indent(void) // will take us back to the start of the line. // XXX trypos = NULL; - if (find_last_paren((char_u *)l, '(', ')')) { + if (find_last_paren(l, '(', ')')) { trypos = find_match_paren(curbuf->b_ind_maxparen); } - if (trypos == NULL && find_last_paren((char_u *)l, '{', '}')) { + if (trypos == NULL && find_last_paren(l, '{', '}')) { trypos = find_start_brace(); } @@ -2658,7 +2658,7 @@ int get_c_indent(void) } // Finally the actual check for "namespace". - if (cin_is_cpp_namespace((char *)l)) { + if (cin_is_cpp_namespace(l)) { amount += curbuf->b_ind_cpp_namespace - added_to_amount; break; @@ -2667,7 +2667,7 @@ int get_c_indent(void) break; } - if (cin_nocode((char_u *)l)) { + if (cin_nocode(l)) { continue; } } @@ -2688,8 +2688,8 @@ int get_c_indent(void) // If this is a switch() label, may line up relative to that. // If this is a C++ scope declaration, do the same. - bool iscase = cin_iscase((char_u *)l, false); - if (iscase || cin_isscopedecl((char_u *)l)) { + bool iscase = cin_iscase(l, false); + if (iscase || cin_isscopedecl(l)) { // we are only looking for cpp base class // declaration/initialization any longer if (lookfor == LOOKFOR_CPP_BASECLASS) { @@ -2758,8 +2758,8 @@ int get_c_indent(void) // -> y = y + 1; if (n) { amount = n; - l = (char *)after_label((char_u *)get_cursor_line_ptr()); - if (l != NULL && cin_is_cinword((char *)l)) { + l = after_label(get_cursor_line_ptr()); + if (l != NULL && cin_is_cinword(l)) { if (theline[0] == '{') { amount += curbuf->b_ind_open_extra; } else { @@ -2787,7 +2787,7 @@ int get_c_indent(void) // Looking for a switch() label or C++ scope declaration, // ignore other lines, skip {}-blocks. if (lookfor == LOOKFOR_CASE || lookfor == LOOKFOR_SCOPEDECL) { - if (find_last_paren((char_u *)l, '{', '}') + if (find_last_paren(l, '{', '}') && (trypos = find_start_brace()) != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.col = 0; @@ -2797,8 +2797,8 @@ int get_c_indent(void) // Ignore jump labels with nothing after them. if (!curbuf->b_ind_js && cin_islabel()) { - l = (char *)after_label((char_u *)get_cursor_line_ptr()); - if (l == NULL || cin_nocode((char_u *)l)) { + l = after_label(get_cursor_line_ptr()); + if (l == NULL || cin_nocode(l)) { continue; } } @@ -2809,7 +2809,7 @@ int get_c_indent(void) // unlocked it) l = get_cursor_line_ptr(); if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount) - || cin_nocode((char_u *)l)) { + || cin_nocode(l)) { continue; } @@ -2841,7 +2841,7 @@ int get_c_indent(void) } else if (lookfor == LOOKFOR_CPP_BASECLASS) { // only look, whether there is a cpp base class // declaration or initialization before the opening brace. - if (cin_isterminated((char_u *)l, true, false)) { + if (cin_isterminated(l, true, false)) { break; } else { continue; @@ -2857,7 +2857,7 @@ int get_c_indent(void) // Otherwise check whether it is an enumeration or structure // initialisation (not indented) or a variable declaration // (indented). - terminated = cin_isterminated((char_u *)l, false, true); + terminated = cin_isterminated(l, false, true); if (js_cur_has_key) { js_cur_has_key = false; // only check the first line @@ -2872,7 +2872,7 @@ int get_c_indent(void) lookfor = LOOKFOR_JS_KEY; } } - if (lookfor == LOOKFOR_JS_KEY && cin_has_js_key((char_u *)l)) { + if (lookfor == LOOKFOR_JS_KEY && cin_has_js_key(l)) { amount = get_indent(); break; } @@ -2898,7 +2898,7 @@ int get_c_indent(void) if (terminated == 0 || (lookfor != LOOKFOR_UNTERM && terminated == ',')) { if (lookfor != LOOKFOR_ENUM_OR_INIT - && (*skipwhite((char *)l) == '[' || l[strlen((char *)l) - 1] == '[')) { + && (*skipwhite(l) == '[' || l[strlen(l) - 1] == '[')) { amount += ind_continuation; } // If we're in the middle of a paren thing, Go back to the line @@ -2909,7 +2909,7 @@ int get_c_indent(void) // Position the cursor over the rightmost paren, so that // matching it will take us back to the start of the line. // Ignore a match before the start of the block. - (void)find_last_paren((char_u *)l, '(', ')'); + (void)find_last_paren(l, '(', ')'); trypos = find_match_paren(corr_ind_maxparen(&cur_curpos)); if (trypos != NULL && (trypos->lnum < tryposBrace->lnum || (trypos->lnum == tryposBrace->lnum @@ -2920,7 +2920,7 @@ int get_c_indent(void) // If we are looking for ',', we also look for matching // braces. if (trypos == NULL && terminated == ',' - && find_last_paren((char_u *)l, '{', '}')) { + && find_last_paren(l, '{', '}')) { trypos = find_start_brace(); } @@ -2931,7 +2931,7 @@ int get_c_indent(void) // asdf) curwin->w_cursor = *trypos; l = get_cursor_line_ptr(); - if (cin_iscase((char_u *)l, false) || cin_isscopedecl((char_u *)l)) { + if (cin_iscase(l, false) || cin_isscopedecl(l)) { curwin->w_cursor.lnum++; curwin->w_cursor.col = 0; continue; @@ -2946,7 +2946,7 @@ int get_c_indent(void) if (terminated == ',') { while (curwin->w_cursor.lnum > 1) { l = ml_get(curwin->w_cursor.lnum - 1); - if (*l == NUL || l[strlen((char *)l) - 1] != '\\') { + if (*l == NUL || l[strlen(l) - 1] != '\\') { break; } curwin->w_cursor.lnum--; @@ -2974,7 +2974,7 @@ int get_c_indent(void) // in the same line (scope is the same). Probably: // { 1, 2 }, // -> { 3, 4 } - if (*skipwhite((char *)l) != '{') { + if (*skipwhite(l) != '{') { amount += curbuf->b_ind_open_extra; } @@ -2989,7 +2989,7 @@ int get_c_indent(void) // Check if we are after an "if", "while", etc. // Also allow " } else". - if (cin_is_cinword((char *)l) || cin_iselse(skipwhite((char *)l))) { + if (cin_is_cinword(l) || cin_iselse(skipwhite(l))) { // Found an unterminated line after an if (), line up // with the last one. // if (cond) @@ -3032,7 +3032,7 @@ int get_c_indent(void) // x = 1; // -> here l = skipwhite(get_cursor_line_ptr()); - if (cin_isdo((char *)l)) { + if (cin_isdo(l)) { if (whilelevel == 0) { break; } @@ -3043,7 +3043,7 @@ int get_c_indent(void) // one between the "if" and the matching "else". // Need to use the scope of this "else". XXX // If whilelevel != 0 continue looking for a "do {". - if (cin_iselse((char *)l) && whilelevel == 0) { + if (cin_iselse(l) && whilelevel == 0) { // If we're looking at "} else", let's make sure we // find the opening brace of the enclosing scope, // not the one from "if () {". @@ -3105,9 +3105,9 @@ int get_c_indent(void) l = get_cursor_line_ptr(); amount = cur_amount; - n = (int)strlen((char *)l); + n = (int)strlen(l); if (terminated == ',' - && (*skipwhite((char *)l) == ']' + && (*skipwhite(l) == ']' || (n >= 2 && l[n - 2] == ']'))) { break; } @@ -3134,7 +3134,7 @@ int get_c_indent(void) // 4 * // 5, // 6, - if (cin_iscomment((char_u *)skipwhite((char *)l))) { + if (cin_iscomment(skipwhite(l))) { break; } lookfor = LOOKFOR_COMMA; @@ -3154,7 +3154,7 @@ int get_c_indent(void) } else { if (lookfor == LOOKFOR_INITIAL && *l != NUL - && l[strlen((char *)l) - 1] == '\\') { + && l[strlen(l) - 1] == '\\') { // XXX cont_amount = cin_get_equal_amount(curwin->w_cursor.lnum); } @@ -3169,7 +3169,7 @@ int get_c_indent(void) } // Check if we are after a while (cond); // If so: Ignore until the matching "do". - } else if (cin_iswhileofdo_end(terminated)) { // XXX + } else if (cin_iswhileofdo_end((uint8_t)terminated)) { // XXX // Found an unterminated line after a while ();, line up // with the last one. // while (cond); @@ -3210,8 +3210,8 @@ int get_c_indent(void) // Handle "do {" line. if (whilelevel > 0) { - l = (char *)cin_skipcomment((char_u *)get_cursor_line_ptr()); - if (cin_isdo((char *)l)) { + l = cin_skipcomment(get_cursor_line_ptr()); + if (cin_isdo(l)) { amount = get_indent(); // XXX whilelevel--; continue; @@ -3261,7 +3261,7 @@ int get_c_indent(void) // here; term_again: l = get_cursor_line_ptr(); - if (find_last_paren((char_u *)l, '(', ')') + if (find_last_paren(l, '(', ')') && (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) { // Check if we are on a case label now. This is // handled above. @@ -3269,7 +3269,7 @@ term_again: // asdf) curwin->w_cursor = *trypos; l = get_cursor_line_ptr(); - if (cin_iscase((char_u *)l, false) || cin_isscopedecl((char_u *)l)) { + if (cin_iscase(l, false) || cin_isscopedecl(l)) { curwin->w_cursor.lnum++; curwin->w_cursor.col = 0; continue; @@ -3284,7 +3284,7 @@ term_again: // case 2: // stat; // } - iscase = curbuf->b_ind_keep_case_label && cin_iscase((char_u *)l, false); + iscase = curbuf->b_ind_keep_case_label && cin_iscase(l, false); // Get indent and pointer to text for current line, // ignoring any jump label. @@ -3294,7 +3294,7 @@ term_again: amount += curbuf->b_ind_open_extra; } // See remark above: "Only add b_ind_open_extra.." - l = skipwhite((char *)l); + l = skipwhite(l); if (*l == '{') { amount -= curbuf->b_ind_open_extra; } @@ -3308,7 +3308,7 @@ term_again: // If whilelevel != 0 continue looking for a "do {". if (lookfor == LOOKFOR_TERM && *l != '}' - && cin_iselse((char *)l) + && cin_iselse(l) && whilelevel == 0) { if ((trypos = find_start_brace()) == NULL || find_match(LOOKFOR_IF, trypos->lnum) @@ -3321,13 +3321,13 @@ term_again: // If we're at the end of a block, skip to the start of // that block. l = get_cursor_line_ptr(); - if (find_last_paren((char_u *)l, '{', '}') // XXX + if (find_last_paren(l, '{', '}') // XXX && (trypos = find_start_brace()) != NULL) { curwin->w_cursor = *trypos; // if not "else {" check for terminated again // but skip block for "} else {" - l = (char *)cin_skipcomment((char_u *)get_cursor_line_ptr()); - if (*l == '}' || !cin_iselse((char *)l)) { + l = cin_skipcomment(get_cursor_line_ptr()); + if (*l == '}' || !cin_iselse(l)) { goto term_again; } curwin->w_cursor.lnum++; @@ -3340,7 +3340,7 @@ term_again: } // add extra indent for a comment - if (cin_iscomment((char_u *)theline)) { + if (cin_iscomment(theline)) { amount += curbuf->b_ind_comment; } // subtract extra left-shift for jump labels @@ -3372,13 +3372,13 @@ term_again: // current line is terminated, ie. ends in ';', or if the current line // contains { or }: "void f() {\n if (1)" if (cur_curpos.lnum < curbuf->b_ml.ml_line_count - && !cin_nocode((char_u *)theline) + && !cin_nocode(theline) && vim_strchr(theline, '{') == NULL && vim_strchr(theline, '}') == NULL && !cin_ends_in(theline, ":", NULL) && !cin_ends_in(theline, ",", NULL) && cin_isfuncdecl(NULL, cur_curpos.lnum + 1, cur_curpos.lnum + 1) - && !cin_isterminated((char_u *)theline, false, true)) { + && !cin_isterminated(theline, false, true)) { amount = curbuf->b_ind_func_type; goto theend; } @@ -3421,7 +3421,7 @@ term_again: continue; } - if (cin_nocode((char_u *)l)) { + if (cin_nocode(l)) { continue; } @@ -3436,9 +3436,9 @@ term_again: // } foo, // bar; if (cin_ends_in(l, ",", NULL) - || (*l != NUL && (n = (uint8_t)l[strlen((char *)l) - 1]) == '\\')) { + || (*l != NUL && (n = (uint8_t)l[strlen(l) - 1]) == '\\')) { // take us back to opening paren - if (find_last_paren((char_u *)l, '(', ')') + if (find_last_paren(l, '(', ')') && (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) { curwin->w_cursor = *trypos; } @@ -3450,7 +3450,7 @@ term_again: // here; while (n == 0 && curwin->w_cursor.lnum > 1) { l = ml_get(curwin->w_cursor.lnum - 1); - if (*l == NUL || l[strlen((char *)l) - 1] != '\\') { + if (*l == NUL || l[strlen(l) - 1] != '\\') { break; } curwin->w_cursor.lnum--; @@ -3477,7 +3477,7 @@ term_again: // Finding the closing '}' of a previous function. Put // current line at the left margin. For when 'cino' has "fs". - if (*skipwhite((char *)l) == '}') { + if (*skipwhite(l) == '}') { break; } @@ -3502,12 +3502,12 @@ term_again: // Find a line only has a semicolon that belongs to a previous // line ending in '}', e.g. before an #endif. Don't increase // indent then. - if (*(look = skipwhite((char *)l)) == ';' && cin_nocode((char_u *)look + 1)) { + if (*(look = skipwhite(l)) == ';' && cin_nocode(look + 1)) { pos_T curpos_save = curwin->w_cursor; while (curwin->w_cursor.lnum > 1) { look = ml_get(--curwin->w_cursor.lnum); - if (!(cin_nocode((char_u *)look) + if (!(cin_nocode(look) || cin_ispreproc_cont(&look, &curwin->w_cursor.lnum, &amount))) { break; } @@ -3536,7 +3536,7 @@ term_again: if (cin_ends_in(l, ";", NULL)) { l = ml_get(curwin->w_cursor.lnum - 1); if (cin_ends_in(l, ",", NULL) - || (*l != NUL && l[strlen((char *)l) - 1] == '\\')) { + || (*l != NUL && l[strlen(l) - 1] == '\\')) { break; } l = get_cursor_line_ptr(); @@ -3547,7 +3547,7 @@ term_again: // // Position the cursor over the rightmost paren, so that // matching it will take us back to the start of the line. - (void)find_last_paren((char_u *)l, '(', ')'); + (void)find_last_paren(l, '(', ')'); if ((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) { curwin->w_cursor = *trypos; @@ -3557,7 +3557,7 @@ term_again: } // add extra indent for a comment - if (cin_iscomment((char_u *)theline)) { + if (cin_iscomment(theline)) { amount += curbuf->b_ind_comment; } @@ -3568,7 +3568,7 @@ term_again: // here"; if (cur_curpos.lnum > 1) { l = ml_get(cur_curpos.lnum - 1); - if (*l != NUL && l[strlen((char *)l) - 1] == '\\') { + if (*l != NUL && l[strlen(l) - 1] == '\\') { cur_amount = cin_get_equal_amount(cur_curpos.lnum - 1); if (cur_amount > 0) { amount = cur_amount; @@ -3594,9 +3594,9 @@ laterend: static int find_match(int lookfor, linenr_T ourscope) { - const char_u *look; + const char *look; pos_T *theirscope; - const char_u *mightbeif; + const char *mightbeif; int elselevel; int whilelevel; @@ -3614,10 +3614,10 @@ static int find_match(int lookfor, linenr_T ourscope) curwin->w_cursor.lnum--; curwin->w_cursor.col = 0; - look = cin_skipcomment((char_u *)get_cursor_line_ptr()); - if (!cin_iselse((char *)look) - && !cin_isif((char *)look) - && !cin_isdo((char *)look) // XXX + look = cin_skipcomment(get_cursor_line_ptr()); + if (!cin_iselse(look) + && !cin_isif(look) + && !cin_isdo(look) // XXX && !cin_iswhileofdo(look, curwin->w_cursor.lnum)) { continue; } @@ -3646,10 +3646,10 @@ static int find_match(int lookfor, linenr_T ourscope) // if it was an "else" (that's not an "else if") // then we need to go back to another if, so // increment elselevel - look = cin_skipcomment((char_u *)get_cursor_line_ptr()); - if (cin_iselse((char *)look)) { + look = cin_skipcomment(get_cursor_line_ptr()); + if (cin_iselse(look)) { mightbeif = cin_skipcomment(look + 4); - if (!cin_isif((char *)mightbeif)) { + if (!cin_isif(mightbeif)) { elselevel++; // NOLINT(readability/braces) } continue; @@ -3663,8 +3663,8 @@ static int find_match(int lookfor, linenr_T ourscope) } // If it's an "if" decrement elselevel - look = cin_skipcomment((char_u *)get_cursor_line_ptr()); - if (cin_isif((char *)look)) { + look = cin_skipcomment(get_cursor_line_ptr()); + if (cin_isif(look)) { elselevel--; // NOLINT(readability/braces) // When looking for an "if" ignore "while"s that // get in the way. @@ -3674,7 +3674,7 @@ static int find_match(int lookfor, linenr_T ourscope) } // If it's a "do" decrement whilelevel - if (cin_isdo((char *)look)) { + if (cin_isdo(look)) { whilelevel--; } |