diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2023-01-17 14:17:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-17 21:17:40 +0800 |
commit | 0344bfad0fc87d2e256ea2b80de7abd069ba1dd2 (patch) | |
tree | e42d0318ed1e684bbb468661d8a1fbfe82e819ee | |
parent | 99186508d9a1b7536441112f9bbe48690592b5d7 (diff) | |
download | rneovim-0344bfad0fc87d2e256ea2b80de7abd069ba1dd2.tar.gz rneovim-0344bfad0fc87d2e256ea2b80de7abd069ba1dd2.tar.bz2 rneovim-0344bfad0fc87d2e256ea2b80de7abd069ba1dd2.zip |
refactor: replace char_u with char 22 (#21786)
Work on https://github.com/neovim/neovim/issues/459
54 files changed, 532 insertions, 535 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 3f93d85624..bc0bd9e004 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3829,7 +3829,7 @@ static int chk_modeline(linenr_T lnum, int flags) && (s[0] != 'V' || strncmp(skipwhite(e + 1), "set", 3) == 0) && (s[3] == ':' - || (VIM_VERSION_100 >= vers && isdigit(s[3])) + || (VIM_VERSION_100 >= vers && isdigit((uint8_t)s[3])) || (VIM_VERSION_100 < vers && s[3] == '<') || (VIM_VERSION_100 > vers && s[3] == '>') || (VIM_VERSION_100 == vers && s[3] == '='))) { diff --git a/src/nvim/charset.c b/src/nvim/charset.c index aa2d845728..fa9aa27774 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -146,19 +146,19 @@ int buf_init_chartab(buf_T *buf, int global) // options Each option is a list of characters, character numbers or // ranges, separated by commas, e.g.: "200-210,x,#-178,-" for (i = global ? 0 : 3; i <= 3; i++) { - const char_u *p; + const char *p; if (i == 0) { // first round: 'isident' - p = (char_u *)p_isi; + p = p_isi; } else if (i == 1) { // second round: 'isprint' - p = (char_u *)p_isp; + p = p_isp; } else if (i == 2) { // third round: 'isfname' - p = (char_u *)p_isf; + p = p_isf; } else { // i == 3 // fourth round: 'iskeyword' - p = (char_u *)buf->b_p_isk; + p = buf->b_p_isk; } while (*p) { @@ -254,8 +254,8 @@ int buf_init_chartab(buf_T *buf, int global) c++; } - c = *p; - p = (char_u *)skip_to_option_part((char *)p); + c = (uint8_t)(*p); + p = skip_to_option_part(p); if ((c == ',') && (*p == NUL)) { // Trailing comma is not allowed. diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index b5956d75ab..59891e9899 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -1174,7 +1174,7 @@ static bool expand_showtail(expand_T *xp) // separator, on DOS the '*' "path\*\file" must not be skipped. if (rem_backslash(s)) { s++; - } else if (vim_strchr("*?[", *s) != NULL) { + } else if (vim_strchr("*?[", (uint8_t)(*s)) != NULL) { return false; } } @@ -1405,7 +1405,7 @@ static const char *set_cmd_index(const char *cmd, exarg_T *eap, expand_T *xp, in } } // check for non-alpha command - if (p == cmd && vim_strchr("@*!=><&~#", *p) != NULL) { + if (p == cmd && vim_strchr("@*!=><&~#", (uint8_t)(*p)) != NULL) { p++; } len = (size_t)(p - cmd); @@ -1435,7 +1435,7 @@ static const char *set_cmd_index(const char *cmd, exarg_T *eap, expand_T *xp, in } if (eap->cmdidx == CMD_SIZE) { - if (*cmd == 's' && vim_strchr("cgriI", cmd[1]) != NULL) { + if (*cmd == 's' && vim_strchr("cgriI", (uint8_t)cmd[1]) != NULL) { eap->cmdidx = CMD_substitute; p = cmd + 1; } else if (cmd[0] >= 'A' && cmd[0] <= 'Z') { @@ -2171,7 +2171,7 @@ static const char *set_one_cmd_context(expand_T *xp, const char *buff) // 1. skip comment lines and leading space, colons or bars const char *cmd; - for (cmd = buff; vim_strchr(" \t:|", *cmd) != NULL; cmd++) {} + for (cmd = buff; vim_strchr(" \t:|", (uint8_t)(*cmd)) != NULL; cmd++) {} xp->xp_pattern = (char *)cmd; if (*cmd == NUL) { @@ -2967,7 +2967,7 @@ static void expand_shellcmd(char *filepat, char ***matches, int *numMatches, int path = "."; } else { // For an absolute name we don't use $PATH. - if (!path_is_absolute((char_u *)pat)) { + if (!path_is_absolute(pat)) { path = vim_getenv("PATH"); } if (path == NULL) { diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index d12ac87bbb..2df82d9355 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -280,7 +280,7 @@ static HistoryType get_histtype(const char *const name, const size_t len, const } } - if (vim_strchr(":=@>?/", name[0]) != NULL && len == 1) { + if (vim_strchr(":=@>?/", (uint8_t)name[0]) != NULL && len == 1) { return hist_char2type(name[0]); } @@ -437,7 +437,7 @@ int clr_history(const int histype) /// Remove all entries matching {str} from a history. /// /// @param histype may be one of the HIST_ values. -static int del_history_entry(int histype, char_u *str) +static int del_history_entry(int histype, char *str) { if (hislen == 0 || histype < 0 || histype >= HIST_COUNT || *str == NUL || hisidx[histype] < 0) { @@ -446,7 +446,7 @@ static int del_history_entry(int histype, char_u *str) const int idx = hisidx[histype]; regmatch_T regmatch; - regmatch.regprog = vim_regcomp((char *)str, RE_MAGIC + RE_STRING); + regmatch.regprog = vim_regcomp(str, RE_MAGIC + RE_STRING); if (regmatch.regprog == NULL) { return false; } @@ -560,7 +560,7 @@ void f_histdel(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) // string given: remove all matching entries char buf[NUMBUFLEN]; n = del_history_entry(get_histtype(str, strlen(str), false), - (char_u *)tv_get_string_buf(&argvars[1], buf)); + (char *)tv_get_string_buf(&argvars[1], buf)); } rettv->vval.v_number = n; } @@ -611,7 +611,7 @@ void ex_history(exarg_T *eap) int idx; int i, j, k; char *end; - char_u *arg = (char_u *)eap->arg; + char *arg = eap->arg; if (hislen == 0) { msg(_("'history' option is zero")); @@ -619,12 +619,12 @@ void ex_history(exarg_T *eap) } if (!(ascii_isdigit(*arg) || *arg == '-' || *arg == ',')) { - end = (char *)arg; + end = arg; while (ASCII_ISALPHA(*end) - || vim_strchr(":=@>/?", *end) != NULL) { + || vim_strchr(":=@>/?", (uint8_t)(*end)) != NULL) { end++; } - histype1 = get_histtype((const char *)arg, (size_t)(end - (char *)arg), false); + histype1 = get_histtype(arg, (size_t)(end - arg), false); if (histype1 == HIST_INVALID) { if (STRNICMP(arg, "all", end - (char *)arg) == 0) { histype1 = 0; @@ -637,7 +637,7 @@ void ex_history(exarg_T *eap) histype2 = histype1; } } else { - end = (char *)arg; + end = arg; } if (!get_list_range(&end, &hisidx1, &hisidx2) || *end != NUL) { semsg(_(e_trailing_arg), end); diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 45f00cb41e..40be6b1abc 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1575,7 +1575,7 @@ static bool extract_hunk(FILE *fd, diffhunk_T *hunk, diffstyle_T *diffstyle) // --- file1 2018-03-20 13:23:35.783153140 +0100 // +++ file2 2018-03-20 13:23:41.183156066 +0100 // @@ -1,3 +1,5 @@ - if (isdigit(*line)) { + if (isdigit((uint8_t)(*line))) { *diffstyle = DIFF_ED; } else if ((strncmp(line, "@@ ", 3) == 0)) { *diffstyle = DIFF_UNIFIED; @@ -1593,7 +1593,7 @@ static bool extract_hunk(FILE *fd, diffhunk_T *hunk, diffstyle_T *diffstyle) } if (*diffstyle == DIFF_ED) { - if (!isdigit(*line)) { + if (!isdigit((uint8_t)(*line))) { continue; // not the start of a diff block } if (parse_diff_ed(line, hunk) == FAIL) { diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 33038dfb9f..144817fe2b 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1885,7 +1885,7 @@ static int get_digraph_chars(const typval_T *arg, int *char1, int *char2) { char buf_chars[NUMBUFLEN]; const char *chars = tv_get_string_buf_chk(arg, buf_chars); - const char_u *p = (const char_u *)chars; + const char *p = chars; if (p != NULL) { if (*p != NUL) { @@ -1917,7 +1917,7 @@ static bool digraph_set_common(const typval_T *argchars, const typval_T *argdigr if (digraph == NULL) { return false; } - const char_u *p = (const char_u *)digraph; + const char *p = digraph; int n = mb_cptr2char_adv(&p); if (*p != NUL) { semsg(_(e_digraph_argument_must_be_one_character_str), digraph); diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index ae3e5698b2..9287fdb460 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -513,7 +513,7 @@ static bool use_cursor_line_nr(win_T *wp, linenr_T lnum, int row, int startrow, && (wp->w_p_culopt_flags & CULOPT_LINE))); } -static inline void get_line_number_str(win_T *wp, linenr_T lnum, char_u *buf, size_t buf_len) +static inline void get_line_number_str(win_T *wp, linenr_T lnum, char *buf, size_t buf_len) { long num; char *fmt = "%*ld "; @@ -531,7 +531,7 @@ static inline void get_line_number_str(win_T *wp, linenr_T lnum, char_u *buf, si } } - snprintf((char *)buf, buf_len, fmt, number_width(wp), num); + snprintf(buf, buf_len, fmt, number_width(wp), num); } static int get_line_number_attr(win_T *wp, linenr_T lnum, int row, int startrow, int filler_lines) @@ -612,7 +612,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, int row; // row in the window, excl w_winrow ScreenGrid *grid = &wp->w_grid; // grid specific to the window - char_u extra[57]; // sign, line number and 'fdc' must + char extra[57]; // sign, line number and 'fdc' must // fit in here int n_extra = 0; // number of extra chars char *p_extra = NULL; // string of extra chars, plus NUL @@ -806,7 +806,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, nextline[SPWORDLEN] = NUL; if (lnum < wp->w_buffer->b_ml.ml_line_count) { line = ml_get_buf(wp->w_buffer, lnum + 1, false); - spell_cat_line(nextline + SPWORDLEN, (char_u *)line, SPWORDLEN); + spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN); } // When a word wrapped from the previous line the start of the current @@ -1132,7 +1132,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, // no bad word found at line start, don't check until end of a // word spell_hlf = HLF_COUNT; - word_end = (int)(spell_to_word_end((char_u *)ptr, wp) - (char_u *)line + 1); + word_end = (int)(spell_to_word_end(ptr, wp) - line + 1); } else { // bad word found, use attributes until end of word assert(len <= INT_MAX); @@ -1278,7 +1278,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, if (wp->w_scwidth > 0) { get_sign_display_info(false, wp, lnum, sattrs, row, startrow, filler_lines, filler_todo, - &c_extra, &c_final, (char *)extra, sizeof(extra), + &c_extra, &c_final, extra, sizeof(extra), &p_extra, &n_extra, &char_attr, sign_idx, sign_cul_attr); sign_idx++; @@ -1303,29 +1303,29 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, if (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u' && num_signs > 0) { get_sign_display_info(true, wp, lnum, sattrs, row, startrow, filler_lines, filler_todo, - &c_extra, &c_final, (char *)extra, sizeof(extra), + &c_extra, &c_final, extra, sizeof(extra), &p_extra, &n_extra, &char_attr, sign_idx, sign_cul_attr); } else { // Draw the line number (empty space after wrapping). if (row == startrow + filler_lines) { - get_line_number_str(wp, lnum, (char_u *)extra, sizeof(extra)); + get_line_number_str(wp, lnum, extra, sizeof(extra)); if (wp->w_skipcol > 0) { - for (p_extra = (char *)extra; *p_extra == ' '; p_extra++) { + for (p_extra = extra; *p_extra == ' '; p_extra++) { *p_extra = '-'; } } if (wp->w_p_rl) { // reverse line numbers // like rl_mirror(), but keep the space at the end - char *p2 = skipwhite((char *)extra); + char *p2 = skipwhite(extra); p2 = skiptowhite(p2) - 1; - for (char *p1 = skipwhite((char *)extra); p1 < p2; p1++, p2--) { + for (char *p1 = skipwhite(extra); p1 < p2; p1++, p2--) { const char t = *p1; *p1 = *p2; *p2 = t; } } - p_extra = (char *)extra; + p_extra = extra; c_extra = NUL; } else { c_extra = ' '; @@ -1729,14 +1729,14 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, || (mb_l > 1 && (!vim_isprintc(mb_c)))) { // Illegal UTF-8 byte: display as <xx>. // Non-BMP character : display as ? or fullwidth ?. - transchar_hex((char *)extra, mb_c); + transchar_hex(extra, mb_c); if (wp->w_p_rl) { // reverse - rl_mirror((char *)extra); + rl_mirror(extra); } - p_extra = (char *)extra; + p_extra = extra; c = (uint8_t)(*p_extra); - mb_c = mb_ptr2char_adv((const char_u **)&p_extra); + mb_c = mb_ptr2char_adv((const char **)&p_extra); mb_utf8 = (c >= 0x80); n_extra = (int)strlen(p_extra); c_extra = NUL; @@ -1909,7 +1909,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, p = prev_ptr; } cap_col -= (int)(prev_ptr - line); - size_t tmplen = spell_check(wp, (char_u *)p, &spell_hlf, &cap_col, nochange); + size_t tmplen = spell_check(wp, p, &spell_hlf, &cap_col, nochange); assert(tmplen <= INT_MAX); len = (int)tmplen; word_end = (int)v + len; @@ -2075,12 +2075,12 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, if (c == TAB && (!wp->w_p_list || wp->w_p_lcs_chars.tab1)) { int tab_len = 0; long vcol_adjusted = vcol; // removed showbreak length - char_u *const sbr = get_showbreak_value(wp); + char *const sbr = (char *)get_showbreak_value(wp); // Only adjust the tab_len, when at the first column after the // showbreak value was drawn. if (*sbr != NUL && vcol == vcol_sbr && wp->w_p_wrap) { - vcol_adjusted = vcol - mb_charlen((char *)sbr); + vcol_adjusted = vcol - mb_charlen(sbr); } // tab amount depends on current column tab_len = tabstop_padding((colnr_T)vcol_adjusted, diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 6102f05abd..9b82d50012 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3127,7 +3127,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) // make up some named keys <o>, <O>, <e>, <0>, <>>, <<>, <*>, // <:> and <!> so that people can re-indent on o, O, e, 0, <, // >, *, : and ! keys if they really really want to. - if (vim_strchr("<>!*oOe0:", look[1]) != NULL + if (vim_strchr("<>!*oOe0:", (uint8_t)look[1]) != NULL && keytyped == look[1]) { return true; } @@ -3182,7 +3182,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) // TODO(@brammool): multi-byte if (keytyped == (int)(uint8_t)p[-1] || (icase && keytyped < 256 - && TOLOWER_LOC(keytyped) == TOLOWER_LOC((int)p[-1]))) { + && TOLOWER_LOC(keytyped) == TOLOWER_LOC((uint8_t)p[-1]))) { line = get_cursor_pos_ptr(); assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX); if ((curwin->w_cursor.col == (colnr_T)(p - look) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 6d32b71016..b0805aecff 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2185,7 +2185,7 @@ int pattern_match(const char *pat, const char *text, bool ic) regmatch.regprog = vim_regcomp((char *)pat, RE_MAGIC + RE_STRING); if (regmatch.regprog != NULL) { regmatch.rm_ic = ic; - matches = vim_regexec_nl(®match, (char_u *)text, (colnr_T)0); + matches = vim_regexec_nl(®match, (char *)text, (colnr_T)0); vim_regfree(regmatch.regprog); } p_cpo = save_cpo; @@ -2543,7 +2543,7 @@ static int eval4(char **arg, typval_T *rettv, int evaluate) if (p[2] == 'n' && p[3] == 'o' && p[4] == 't') { len = 5; } - if (!isalnum(p[len]) && p[len] != '_') { + if (!isalnum((uint8_t)p[len]) && p[len] != '_') { type = len == 2 ? EXPR_IS : EXPR_ISNOT; } } @@ -3777,7 +3777,7 @@ static int get_string_tv(char **arg, typval_T *rettv, int evaluate) case 'U': if (ascii_isxdigit(p[1])) { int n, nr; - int c = toupper(*p); + int c = toupper((uint8_t)(*p)); if (c == 'X') { n = 2; @@ -6302,7 +6302,7 @@ int get_id_len(const char **const arg) // slice "[n:]". Also "xx:" is not a namespace. len = (int)(p - *arg); if (len > 1 - || (len == 1 && vim_strchr(namespace_char, **arg) == NULL)) { + || (len == 1 && vim_strchr(namespace_char, (uint8_t)(**arg)) == NULL)) { break; } } @@ -6430,7 +6430,7 @@ const char *find_name_end(const char *arg, const char **expr_start, const char * // slice "[n:]". Also "xx:" is not a namespace. But {ns}: is. len = (int)(p - arg); if ((len > 1 && p[-1] != '}') - || (len == 1 && vim_strchr(namespace_char, *arg) == NULL)) { + || (len == 1 && vim_strchr(namespace_char, (uint8_t)(*arg)) == NULL)) { break; } } @@ -8081,7 +8081,7 @@ char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, const char if (regmatch.regprog != NULL) { char *tail = str; char *end = str + strlen(str); - while (vim_regexec_nl(®match, (char_u *)str, (colnr_T)(tail - str))) { + while (vim_regexec_nl(®match, str, (colnr_T)(tail - str))) { // Skip empty match except for first match. if (regmatch.startp[0] == regmatch.endp[0]) { if (zero_width == regmatch.startp[0]) { diff --git a/src/nvim/eval/executor.c b/src/nvim/eval/executor.c index 86d6063b01..831c468288 100644 --- a/src/nvim/eval/executor.c +++ b/src/nvim/eval/executor.c @@ -69,7 +69,7 @@ int eexe_mod_op(typval_T *const tv1, const typval_T *const tv2, const char *cons if (tv2->v_type == VAR_LIST) { break; } - if (vim_strchr("+-*/%", *op) != NULL) { + if (vim_strchr("+-*/%", (uint8_t)(*op)) != NULL) { // nr += nr or nr -= nr, nr *= nr, nr /= nr, nr %= nr varnumber_T n = tv_get_number(tv1); if (tv2->v_type == VAR_FLOAT) { diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index d6b9ca20fc..25e026706c 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -1770,7 +1770,7 @@ static void f_expand(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } size_t len; char *errormsg = NULL; - char *result = (char *)eval_vars((char_u *)s, (char_u *)s, &len, NULL, &errormsg, NULL, false); + char *result = (char *)eval_vars((char *)s, (char_u *)s, &len, NULL, &errormsg, NULL, false); if (p_verbose == 0) { emsg_off--; } else if (errormsg != NULL) { @@ -4488,7 +4488,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, } } - match = vim_regexec_nl(®match, (char_u *)str, startcol); + match = vim_regexec_nl(®match, str, startcol); if (match && --nth <= 0) { break; @@ -5885,7 +5885,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) q[-1] = NUL; q = path_tail(p); } - if (q > p && !path_is_absolute((const char_u *)buf)) { + if (q > p && !path_is_absolute(buf)) { // Symlink is relative to directory of argument. Replace the // symlink with the resolved name in the same directory. const size_t p_len = strlen(p); @@ -6228,7 +6228,7 @@ static int search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp) // Repeat until {skip} returns false. for (;;) { subpatnum - = searchit(curwin, curbuf, &pos, NULL, dir, (char_u *)pat, 1, options, RE_SEARCH, &sia); + = searchit(curwin, curbuf, &pos, NULL, dir, (char *)pat, 1, options, RE_SEARCH, &sia); // finding the first match again means there is no match where {skip} // evaluates to zero. if (firstpos.lnum != 0 && equalpos(pos, firstpos)) { @@ -6810,7 +6810,7 @@ long do_searchpair(const char *spat, const char *mpat, const char *epat, int dir .sa_tm = &tm, }; - int n = searchit(curwin, curbuf, &pos, NULL, dir, (char_u *)pat, 1L, + int n = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L, options, RE_SEARCH, &sia); if (n == FAIL || (firstpos.lnum != 0 && equalpos(pos, firstpos))) { // didn't find it or found the first match again: FAIL @@ -7073,7 +7073,7 @@ static void f_setcharsearch(typval_T *argvars, typval_T *rettv, EvalFuncData fpt if (csearch != NULL) { int pcc[MAX_MCO]; const int c = utfc_ptr2char((char *)csearch, pcc); - set_last_csearch(c, csearch, utfc_ptr2len((char *)csearch)); + set_last_csearch(c, (char *)csearch, utfc_ptr2len((char *)csearch)); } dictitem_T *di = tv_dict_find(d, S_LEN("forward")); @@ -7553,7 +7553,7 @@ static void f_spellbadword(typval_T *argvars, typval_T *rettv, EvalFuncData fptr if (str != NULL) { // Check the argument for spelling. while (*str != NUL) { - len = spell_check(curwin, (char_u *)str, &attr, &capcol, false); + len = spell_check(curwin, (char *)str, &attr, &capcol, false); if (attr != HLF_COUNT) { word = str; break; @@ -7668,7 +7668,7 @@ static void f_split(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) if (*str == NUL) { match = false; // Empty item at the end. } else { - match = vim_regexec_nl(®match, (char_u *)str, col); + match = vim_regexec_nl(®match, (char *)str, col); } const char *end; if (match) { @@ -7930,11 +7930,11 @@ static void strchar_common(typval_T *argvars, typval_T *rettv, bool skipcc) { const char *s = tv_get_string(&argvars[0]); varnumber_T len = 0; - int (*func_mb_ptr2char_adv)(const char_u **pp); + int (*func_mb_ptr2char_adv)(const char **pp); func_mb_ptr2char_adv = skipcc ? mb_ptr2char_adv : mb_cptr2char_adv; while (*s != NUL) { - func_mb_ptr2char_adv((const char_u **)&s); + func_mb_ptr2char_adv(&s); len++; } rettv->vval.v_number = len; diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 1a3fd13fe3..5d3b70b414 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -118,7 +118,7 @@ static int get_function_args(char **argp, char_u endchar, garray_T *newargs, int while (ASCII_ISALNUM(*p) || *p == '_') { p++; } - if (arg == p || isdigit(*arg) + if (arg == p || isdigit((uint8_t)(*arg)) || (p - arg == 9 && strncmp(arg, "firstline", 9) == 0) || (p - arg == 8 && strncmp(arg, "lastline", 8) == 0)) { if (!skip) { @@ -1228,7 +1228,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett /// looked up by name. static bool func_name_refcount(const char_u *name) { - return isdigit(*name) || *name == '<'; + return isdigit((uint8_t)(*name)) || *name == '<'; } /// Call a user function after checking the arguments. @@ -2002,7 +2002,7 @@ static void list_functions(regmatch_T *regmatch) && (regmatch == NULL ? (!message_filtered((char *)fp->uf_name) && !func_name_refcount((char_u *)fp->uf_name)) - : (!isdigit(*fp->uf_name) + : (!isdigit((uint8_t)(*fp->uf_name)) && vim_regexec(regmatch, (char *)fp->uf_name, 0)))) { list_func_head(fp, false, false); if (changed != func_hashtab.ht_changed) { @@ -2792,7 +2792,7 @@ void ex_delfunction(exarg_T *eap) *p = NUL; } - if (isdigit(*name) && fudi.fd_dict == NULL) { + if (isdigit((uint8_t)(*name)) && fudi.fd_dict == NULL) { if (!eap->skip) { semsg(_(e_invarg2), eap->arg); } @@ -2858,7 +2858,7 @@ void func_unref(char_u *name) } fp = find_func(name); - if (fp == NULL && isdigit(*name)) { + if (fp == NULL && isdigit((uint8_t)(*name))) { #ifdef EXITFREE if (!entered_free_all_mem) { internal_error("func_unref()"); @@ -2901,7 +2901,7 @@ void func_ref(char_u *name) fp = find_func(name); if (fp != NULL) { (fp->uf_refcount)++; - } else if (isdigit(*name)) { + } else if (isdigit((uint8_t)(*name))) { // Only give an error for a numbered function. // Fail silently, when named or lambda function isn't found. internal_error("func_ref()"); diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index 206df03381..75af99fbd5 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -106,7 +106,7 @@ static list_T *heredoc_get(exarg_T *eap, char *cmd) return NULL; } *p = NUL; - if (islower(*marker)) { + if (islower((uint8_t)(*marker))) { emsg(_("E221: Marker cannot start with lower case letter")); return NULL; } @@ -208,7 +208,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const) argend--; } expr = skipwhite(argend); - if (*expr != '=' && !((vim_strchr("+-*/%.", *expr) != NULL + if (*expr != '=' && !((vim_strchr("+-*/%.", (uint8_t)(*expr)) != NULL && expr[1] == '=') || strncmp(expr, "..=", 3) == 0)) { // ":let" without "=": list variables if (*arg == '[') { @@ -244,7 +244,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const) op[0] = '='; op[1] = NUL; if (*expr != '=') { - if (vim_strchr("+-*/%.", *expr) != NULL) { + if (vim_strchr("+-*/%.", (uint8_t)(*expr)) != NULL) { op[0] = *expr; // +=, -=, *=, /=, %= or .= if (expr[0] == '.' && expr[1] == '.') { // ..= expr++; @@ -590,10 +590,10 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo if (len == 0) { semsg(_(e_invarg2), name - 1); } else { - if (op != NULL && vim_strchr("+-*/%", *op) != NULL) { + if (op != NULL && vim_strchr("+-*/%", (uint8_t)(*op)) != NULL) { semsg(_(e_letwrong), op); } else if (endchars != NULL - && vim_strchr(endchars, *skipwhite(arg)) == NULL) { + && vim_strchr(endchars, (uint8_t)(*skipwhite(arg))) == NULL) { emsg(_(e_letunexp)); } else if (!check_secure()) { char *tofree = NULL; @@ -629,7 +629,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo char *const p = (char *)find_option_end((const char **)&arg, &scope); if (p == NULL || (endchars != NULL - && vim_strchr(endchars, *skipwhite(p)) == NULL)) { + && vim_strchr(endchars, (uint8_t)(*skipwhite(p))) == NULL)) { emsg(_(e_letunexp)); } else { varnumber_T n = 0; @@ -716,10 +716,10 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo return NULL; } arg++; - if (op != NULL && vim_strchr("+-*/%", *op) != NULL) { + if (op != NULL && vim_strchr("+-*/%", (uint8_t)(*op)) != NULL) { semsg(_(e_letwrong), op); } else if (endchars != NULL - && vim_strchr(endchars, *skipwhite(arg + 1)) == NULL) { + && vim_strchr(endchars, (uint8_t)(*skipwhite(arg + 1))) == NULL) { emsg(_(e_letunexp)); } else { char *s; @@ -747,7 +747,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo char *const p = get_lval(arg, tv, &lv, false, false, 0, FNE_CHECK_START); if (p != NULL && lv.ll_name != NULL) { - if (endchars != NULL && vim_strchr(endchars, *skipwhite(p)) == NULL) { + if (endchars != NULL && vim_strchr(endchars, (uint8_t)(*skipwhite(p))) == NULL) { emsg(_(e_letunexp)); } else { set_var_lval(&lv, p, tv, copy, is_const, op); @@ -1464,7 +1464,7 @@ bool var_wrong_func_name(const char *const name, const bool new_var) { // Allow for w: b: s: and t:. // Allow autoload variable. - if (!(vim_strchr("wbst", name[0]) != NULL && name[1] == ':') + if (!(vim_strchr("wbst", (uint8_t)name[0]) != NULL && name[1] == ':') && !ASCII_ISUPPER((name[0] != NUL && name[1] == ':') ? name[2] : name[0]) && vim_strchr(name, '#') == NULL) { semsg(_("E704: Funcref variable name must start with a capital: %s"), name); diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index c2af0e6986..4ea11dd32a 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -528,7 +528,7 @@ void ex_sort(exarg_T *eap) emsg(_(e_noprevre)); goto sortend; } - regmatch.regprog = vim_regcomp((char *)last_search_pat(), RE_MAGIC); + regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC); } else { regmatch.regprog = vim_regcomp(p + 1, RE_MAGIC); } @@ -3332,7 +3332,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T } // new pattern and substitution if (eap->cmd[0] == 's' && *cmd != NUL && !ascii_iswhite(*cmd) - && vim_strchr("0123456789cegriIp|\"", *cmd) == NULL) { + && vim_strchr("0123456789cegriIp|\"", (uint8_t)(*cmd)) == NULL) { // don't accept alphanumeric for separator if (check_regexp_delim(*cmd) == FAIL) { return 0; @@ -3343,7 +3343,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T // //sub/r). "\&sub&" use last substitute pattern (like //sub/). if (*cmd == '\\') { cmd++; - if (vim_strchr("/?&", *cmd) == NULL) { + if (vim_strchr("/?&", (uint8_t)(*cmd)) == NULL) { emsg(_(e_backslash)); return 0; } @@ -3443,7 +3443,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T return 0; } - if (search_regcomp((char_u *)pat, NULL, RE_SUBST, which_pat, + if (search_regcomp(pat, NULL, RE_SUBST, which_pat, (cmdpreview ? 0 : SEARCH_HIS), ®match) == FAIL) { if (subflags.do_error) { emsg(_(e_invcmd)); @@ -4372,7 +4372,7 @@ void ex_global(exarg_T *eap) // "\&": use previous substitute pattern. if (*cmd == '\\') { cmd++; - if (vim_strchr("/?&", *cmd) == NULL) { + if (vim_strchr("/?&", (uint8_t)(*cmd)) == NULL) { emsg(_(e_backslash)); return; } @@ -4398,8 +4398,8 @@ void ex_global(exarg_T *eap) } } - char_u *used_pat; - if (search_regcomp((char_u *)pat, &used_pat, RE_BOTH, which_pat, + char *used_pat; + if (search_regcomp(pat, &used_pat, RE_BOTH, which_pat, SEARCH_HIS, ®match) == FAIL) { emsg(_(e_invcmd)); return; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 511251f0b5..896130debf 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2852,7 +2852,7 @@ bool checkforcmd(char **pp, const char *cmd, int len) break; } } - if (i >= len && !isalpha((*pp)[i])) { + if (i >= len && !isalpha((uint8_t)(*pp)[i])) { *pp = skipwhite(*pp + i); return true; } @@ -2877,7 +2877,7 @@ static void append_command(char *cmd) STRCAT(IObuff, ": "); d = IObuff + strlen(IObuff); while (*s != NUL && d - IObuff + 5 < IOSIZE) { - if ((char_u)s[0] == 0xc2 && (char_u)s[1] == 0xa0) { + if ((uint8_t)s[0] == 0xc2 && (uint8_t)s[1] == 0xa0) { s += 2; STRCPY(d, "<a0>"); d += 4; @@ -2942,7 +2942,7 @@ char *find_ex_command(exarg_T *eap, int *full) } // check for non-alpha command - if (p == eap->cmd && vim_strchr("@!=><&~#", *p) != NULL) { + if (p == eap->cmd && vim_strchr("@!=><&~#", (uint8_t)(*p)) != NULL) { p++; } int len = (int)(p - eap->cmd); @@ -2967,7 +2967,7 @@ char *find_ex_command(exarg_T *eap, int *full) } if (ASCII_ISLOWER(eap->cmd[0])) { - const int c1 = (char_u)eap->cmd[0]; + const int c1 = (uint8_t)eap->cmd[0]; const int c2 = len == 1 ? NUL : eap->cmd[1]; if (command_count != CMD_SIZE) { @@ -3172,7 +3172,7 @@ uint32_t excmd_get_argt(cmdidx_T idx) /// @return the "cmd" pointer advanced to beyond the range. char *skip_range(const char *cmd, int *ctx) { - while (vim_strchr(" \t0123456789.$%'/?-+,;\\", *cmd) != NULL) { + while (vim_strchr(" \t0123456789.$%'/?-+,;\\", (uint8_t)(*cmd)) != NULL) { if (*cmd == '\\') { if (cmd[1] == '?' || cmd[1] == '/' || cmd[1] == '&') { cmd++; @@ -3361,7 +3361,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int case '/': case '?': // '/' or '?' - search - c = (char_u)(*cmd++); + c = (uint8_t)(*cmd++); if (addr_type != ADDR_LINES) { addr_error(addr_type); cmd = NULL; @@ -3434,7 +3434,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int pos.coladd = 0; if (searchit(curwin, curbuf, &pos, NULL, *cmd == '?' ? BACKWARD : FORWARD, - (char_u *)"", 1L, SEARCH_MSG, i, NULL) != FAIL) { + "", 1L, SEARCH_MSG, i, NULL) != FAIL) { lnum = pos.lnum; } else { cmd = NULL; @@ -3495,7 +3495,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int if (ascii_isdigit(*cmd)) { i = '+'; // "number" is same as "+number" } else { - i = (char_u)(*cmd++); + i = (uint8_t)(*cmd++); } if (!ascii_isdigit(*cmd)) { // '+' is '+1' n = 1; @@ -3542,7 +3542,7 @@ error: /// Get flags from an Ex command argument. static void get_flags(exarg_T *eap) { - while (vim_strchr("lp#", *eap->arg) != NULL) { + while (vim_strchr("lp#", (uint8_t)(*eap->arg)) != NULL) { if (*eap->arg == 'l') { eap->flags |= EXFLAG_LIST; } else if (*eap->arg == 'p') { @@ -3759,7 +3759,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, char **errormsgp) } // Quick check if this cannot be the start of a special string. // Also removes backslash before '%', '#' and '<'. - if (vim_strchr("%#<", *p) == NULL) { + if (vim_strchr("%#<", (uint8_t)(*p)) == NULL) { p++; continue; } @@ -3767,7 +3767,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, char **errormsgp) // Try to find a match at this position. size_t srclen; int escaped; - char *repl = (char *)eval_vars((char_u *)p, (char_u *)eap->arg, &srclen, &(eap->do_ecmd_lnum), + char *repl = (char *)eval_vars(p, (char_u *)eap->arg, &srclen, &(eap->do_ecmd_lnum), errormsgp, &escaped, true); if (*errormsgp != NULL) { // error detected return FAIL; @@ -3812,7 +3812,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, char **errormsgp) #endif for (l = repl; *l; l++) { - if (vim_strchr((char *)ESCAPE_CHARS, *l) != NULL) { + if (vim_strchr((char *)ESCAPE_CHARS, (uint8_t)(*l)) != NULL) { l = vim_strsave_escaped(repl, (char *)ESCAPE_CHARS); xfree(repl); repl = l; @@ -4044,15 +4044,15 @@ char *skip_cmd_arg(char *p, int rembs) return p; } -int get_bad_opt(const char_u *p, exarg_T *eap) +int get_bad_opt(const char *p, exarg_T *eap) FUNC_ATTR_NONNULL_ALL { if (STRICMP(p, "keep") == 0) { eap->bad_char = BAD_KEEP; } else if (STRICMP(p, "drop") == 0) { eap->bad_char = BAD_DROP; - } else if (MB_BYTE2LEN(*p) == 1 && p[1] == NUL) { - eap->bad_char = *p; + } else if (MB_BYTE2LEN((uint8_t)(*p)) == 1 && p[1] == NUL) { + eap->bad_char = (uint8_t)(*p); } else { return FAIL; } @@ -4129,7 +4129,7 @@ static int getargopt(exarg_T *eap) if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) { return FAIL; } - eap->force_ff = (char_u)eap->cmd[eap->force_ff]; + eap->force_ff = (uint8_t)eap->cmd[eap->force_ff]; } else if (pp == &eap->force_enc) { // Make 'fileencoding' lower case. for (char *p = eap->cmd + eap->force_enc; *p != NUL; p++) { @@ -4138,7 +4138,7 @@ static int getargopt(exarg_T *eap) } else { // Check ++bad= argument. Must be a single-byte character, "keep" or // "drop". - if (get_bad_opt((char_u *)eap->cmd + bad_char_idx, eap) == FAIL) { + if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) { return FAIL; } } @@ -6002,7 +6002,7 @@ static void ex_later(exarg_T *eap) if (*p == NUL) { count = 1; - } else if (isdigit(*p)) { + } else if (isdigit((uint8_t)(*p))) { count = getdigits_long(&p, false, 0); switch (*p) { case 's': @@ -6060,7 +6060,7 @@ static void ex_redir(exarg_T *eap) close_redir(); arg++; if (valid_yank_reg(*arg, true) && *arg != '_') { - redir_reg = (char_u)(*arg++); + redir_reg = (uint8_t)(*arg++); if (*arg == '>' && arg[1] == '>') { // append arg += 2; } else { @@ -6725,7 +6725,7 @@ ssize_t find_cmdline_var(const char *src, size_t *usedlen) /// @return an allocated string if a valid match was found. /// Returns NULL if no match was found. "usedlen" then still contains the /// number of characters to skip. -char_u *eval_vars(char_u *src, const char_u *srcstart, size_t *usedlen, linenr_T *lnump, +char_u *eval_vars(char *src, const char_u *srcstart, size_t *usedlen, linenr_T *lnump, char **errormsg, int *escaped, bool empty_is_error) { char *result; @@ -6742,7 +6742,7 @@ char_u *eval_vars(char_u *src, const char_u *srcstart, size_t *usedlen, linenr_T } // Check if there is something to do. - ssize_t spec_idx = find_cmdline_var((char *)src, usedlen); + ssize_t spec_idx = find_cmdline_var(src, usedlen); if (spec_idx < 0) { // no match *usedlen = 1; return NULL; @@ -6750,7 +6750,7 @@ char_u *eval_vars(char_u *src, const char_u *srcstart, size_t *usedlen, linenr_T // Skip when preceded with a backslash "\%" and "\#". // Note: In "\\%" the % is also not recognized! - if (src > srcstart && src[-1] == '\\') { + if ((char_u *)src > srcstart && src[-1] == '\\') { *usedlen = 0; STRMOVE(src - 1, (char *)src); // remove backslash return NULL; @@ -6800,16 +6800,16 @@ char_u *eval_vars(char_u *src, const char_u *srcstart, size_t *usedlen, linenr_T skip_mod = true; break; } - char *s = (char *)src + 1; + char *s = src + 1; if (*s == '<') { // "#<99" uses v:oldfiles. s++; } int i = getdigits_int(&s, false, 0); - if ((char_u *)s == src + 2 && src[1] == '-') { + if (s == src + 2 && src[1] == '-') { // just a minus sign, don't skip over it s--; } - *usedlen = (size_t)((char_u *)s - src); // length of what we expand + *usedlen = (size_t)(s - src); // length of what we expand if (src[1] == '<' && i != 0) { if (*usedlen < 2) { @@ -6855,7 +6855,7 @@ char_u *eval_vars(char_u *src, const char_u *srcstart, size_t *usedlen, linenr_T case SPEC_AFILE: // file name for autocommand if (autocmd_fname != NULL - && !path_is_absolute((char_u *)autocmd_fname) + && !path_is_absolute(autocmd_fname) // For CmdlineEnter and related events, <afile> is not a path! #9348 && !strequal("/", autocmd_fname)) { // Still need to turn the fname into a full path. It was @@ -6962,7 +6962,7 @@ char_u *eval_vars(char_u *src, const char_u *srcstart, size_t *usedlen, linenr_T resultlen = (size_t)(s - result); } } else if (!skip_mod) { - valid |= modify_fname((char *)src, tilde_file, usedlen, &result, + valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf, &resultlen); if (result == NULL) { *errormsg = ""; @@ -7002,7 +7002,7 @@ char *expand_sfile(char *arg) // replace "<sfile>" with the sourced file name, and do ":" stuff size_t srclen; char *errormsg; - char *repl = (char *)eval_vars((char_u *)p, (char_u *)result, &srclen, NULL, &errormsg, NULL, + char *repl = (char *)eval_vars(p, (char_u *)result, &srclen, NULL, &errormsg, NULL, true); if (errormsg != NULL) { if (*errormsg) { diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 6450892e39..bfbb6f89b5 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -449,8 +449,8 @@ static int throw_exception(void *value, except_type_T type, char *cmdname) // when no active try block is found, see do_cmdline(). if (type == ET_USER) { if (strncmp(value, "Vim", 3) == 0 - && (((char_u *)value)[3] == NUL || ((char_u *)value)[3] == ':' - || ((char_u *)value)[3] == '(')) { + && (((char *)value)[3] == NUL || ((char *)value)[3] == ':' + || ((char *)value)[3] == '(')) { emsg(_("E608: Cannot :throw exceptions with 'Vim' prefix")); goto fail; } @@ -1372,8 +1372,7 @@ void ex_catch(exarg_T *eap) // prev_got_int = got_int; got_int = false; - caught = vim_regexec_nl(®match, (char_u *)current_exception->value, - (colnr_T)0); + caught = vim_regexec_nl(®match, current_exception->value, (colnr_T)0); got_int |= prev_got_int; vim_regfree(regmatch.regprog); } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 47ee1c00ce..0a1d6b2857 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -274,7 +274,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s parse_command_modifiers(&ea, &dummy, &dummy_cmdmod, true); cmd = skip_range(ea.cmd, NULL); - if (vim_strchr("sgvl", *cmd) == NULL) { + if (vim_strchr("sgvl", (uint8_t)(*cmd)) == NULL) { goto theend; } @@ -558,7 +558,7 @@ static int may_add_char_to_search(int firstc, int *c, incsearch_state_T *s) // command line has no uppercase characters, convert // the character to lowercase if (p_ic && p_scs - && !pat_has_uppercase((char_u *)ccline.cmdbuff + skiplen)) { + && !pat_has_uppercase(ccline.cmdbuff + skiplen)) { *c = mb_tolower(*c); } if (*c == search_delim @@ -1379,7 +1379,7 @@ static int may_do_command_line_next_incsearch(int firstc, long count, incsearch_ char save; if (search_delim == ccline.cmdbuff[skiplen]) { - pat = (char *)last_search_pattern(); + pat = last_search_pattern(); if (pat == NULL) { restore_last_search_pattern(); return FAIL; @@ -1409,7 +1409,7 @@ static int may_do_command_line_next_incsearch(int firstc, long count, incsearch_ pat[patlen] = NUL; int found = searchit(curwin, curbuf, &t, NULL, next_match ? FORWARD : BACKWARD, - (char_u *)pat, count, search_flags, + pat, count, search_flags, RE_SEARCH, NULL); emsg_off--; pat[patlen] = save; @@ -2165,7 +2165,7 @@ static bool empty_pattern_magic(char *p, size_t len, magic_T magic_val) { // remove trailing \v and the like while (len >= 2 && p[len - 2] == '\\' - && vim_strchr("mMvVcCZ", p[len - 1]) != NULL) { + && vim_strchr("mMvVcCZ", (uint8_t)p[len - 1]) != NULL) { len -= 2; } @@ -3733,7 +3733,7 @@ static bool cmdline_paste(int regname, bool literally, bool remcr) } } - cmdline_paste_str(p, literally); + cmdline_paste_str((char *)p, literally); if (allocated) { xfree(arg); } @@ -3747,19 +3747,19 @@ static bool cmdline_paste(int regname, bool literally, bool remcr) // When "literally" is true, insert literally. // When "literally" is false, insert as typed, but don't leave the command // line. -void cmdline_paste_str(char_u *s, int literally) +void cmdline_paste_str(char *s, int literally) { int c, cv; if (literally) { - put_on_cmdline((char *)s, -1, true); + put_on_cmdline(s, -1, true); } else { while (*s != NUL) { - cv = *s; + cv = (uint8_t)(*s); if (cv == Ctrl_V && s[1]) { s++; } - c = mb_cptr2char_adv((const char_u **)&s); + c = mb_cptr2char_adv((const char **)&s); if (cv == Ctrl_V || c == ESC || c == Ctrl_C || c == CAR || c == NL || c == Ctrl_L || (c == Ctrl_BSL && *s == Ctrl_N)) { diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 0ee547d124..3a7db22d2f 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -278,7 +278,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, && fname != NULL && vim_strchr(p_cpo, CPO_FNAMER) != NULL && !(flags & READ_DUMMY)) { - if (set_rw_fname((char_u *)fname, (char_u *)sfname) == FAIL) { + if (set_rw_fname(fname, sfname) == FAIL) { return FAIL; } } @@ -860,7 +860,7 @@ retry: // Skip conversion when it's already done (retry for wrong // "fileformat"). if (tmpname == NULL) { - tmpname = (char *)readfile_charconvert((char_u *)fname, (char_u *)fenc, &fd); + tmpname = readfile_charconvert(fname, fenc, &fd); if (tmpname == NULL) { // Conversion failed. Try another one. advance_fenc = true; @@ -1175,7 +1175,7 @@ retry: goto rewind_retry; } if (conv_error == 0) { - conv_error = readfile_linenr(linecnt, (char_u *)ptr, (char_u *)top); + conv_error = readfile_linenr(linecnt, ptr, top); } // Deal with a bad byte and continue with the next. @@ -1287,7 +1287,7 @@ retry: goto rewind_retry; } if (conv_error == 0) { - conv_error = readfile_linenr(linecnt, (char_u *)ptr, p); + conv_error = readfile_linenr(linecnt, ptr, (char *)p); } if (bad_char_behavior == BAD_DROP) { continue; @@ -1315,7 +1315,7 @@ retry: goto rewind_retry; } if (conv_error == 0) { - conv_error = readfile_linenr(linecnt, (char_u *)ptr, p); + conv_error = readfile_linenr(linecnt, ptr, (char *)p); } if (bad_char_behavior == BAD_DROP) { continue; @@ -1356,7 +1356,7 @@ retry: goto rewind_retry; } if (conv_error == 0) { - conv_error = readfile_linenr(linecnt, (char_u *)ptr, p); + conv_error = readfile_linenr(linecnt, ptr, (char *)p); } if (bad_char_behavior == BAD_DROP) { continue; @@ -1423,12 +1423,12 @@ retry: #ifdef HAVE_ICONV // When we did a conversion report an error. if (iconv_fd != (iconv_t)-1 && conv_error == 0) { - conv_error = readfile_linenr(linecnt, (char_u *)ptr, p); + conv_error = readfile_linenr(linecnt, ptr, (char *)p); } #endif // Remember the first linenr with an illegal byte if (conv_error == 0 && illegal_byte == 0) { - illegal_byte = readfile_linenr(linecnt, (char_u *)ptr, p); + illegal_byte = readfile_linenr(linecnt, ptr, (char *)p); } // Drop, keep or replace the bad byte. @@ -1887,7 +1887,7 @@ failed: char_u hash[UNDO_HASH_SIZE]; sha256_finish(&sha_ctx, hash); - u_read_undo(NULL, hash, (char_u *)fname); + u_read_undo(NULL, hash, fname); } if (!read_stdin && !read_fifo && (!read_buffer || sfname != NULL)) { @@ -1958,9 +1958,9 @@ bool is_dev_fd_file(char *fname) /// @param linecnt line count before reading more bytes /// @param p start of more bytes read /// @param endp end of more bytes read -static linenr_T readfile_linenr(linenr_T linecnt, char_u *p, const char_u *endp) +static linenr_T readfile_linenr(linenr_T linecnt, char *p, const char *endp) { - char_u *s; + char *s; linenr_T lnum; lnum = curbuf->b_ml.ml_line_count - linecnt + 1; @@ -2040,7 +2040,7 @@ static char *next_fenc(char **pp, bool *alloced) *pp = NULL; return ""; } - p = vim_strchr((*pp), ','); + p = vim_strchr(*pp, ','); if (p == NULL) { r = enc_canonize(*pp); *pp += strlen(*pp); @@ -2065,22 +2065,22 @@ static char *next_fenc(char **pp, bool *alloced) /// /// @return name of the resulting converted file (the caller should delete it after reading it). /// Returns NULL if the conversion failed ("*fdp" is not set) . -static char_u *readfile_charconvert(char_u *fname, char_u *fenc, int *fdp) +static char *readfile_charconvert(char *fname, char *fenc, int *fdp) { - char_u *tmpname; + char *tmpname; char *errmsg = NULL; - tmpname = (char_u *)vim_tempname(); + tmpname = vim_tempname(); if (tmpname == NULL) { errmsg = _("Can't find temp file for conversion"); } else { close(*fdp); // close the input file, ignore errors *fdp = -1; - if (eval_charconvert((char *)fenc, "utf-8", - (char *)fname, (char *)tmpname) == FAIL) { + if (eval_charconvert(fenc, "utf-8", + fname, tmpname) == FAIL) { errmsg = _("Conversion with 'charconvert' failed"); } - if (errmsg == NULL && (*fdp = os_open((char *)tmpname, O_RDONLY, 0)) < 0) { + if (errmsg == NULL && (*fdp = os_open(tmpname, O_RDONLY, 0)) < 0) { errmsg = _("can't read output of 'charconvert'"); } } @@ -2090,14 +2090,14 @@ static char_u *readfile_charconvert(char_u *fname, char_u *fenc, int *fdp) // another type of conversion might still work. msg(errmsg); if (tmpname != NULL) { - os_remove((char *)tmpname); // delete converted file + os_remove(tmpname); // delete converted file XFREE_CLEAR(tmpname); } } // If the input file is closed, open it (caller should check for error). if (*fdp < 0) { - *fdp = os_open((char *)fname, O_RDONLY, 0); + *fdp = os_open(fname, O_RDONLY, 0); } return tmpname; @@ -2254,7 +2254,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en && !filtering && (!append || vim_strchr(p_cpo, CPO_FNAMEAPP) != NULL) && vim_strchr(p_cpo, CPO_FNAMEW) != NULL) { - if (set_rw_fname((char_u *)fname, (char_u *)sfname) == FAIL) { + if (set_rw_fname(fname, sfname) == FAIL) { return FAIL; } buf = curbuf; // just in case autocmds made "buf" invalid @@ -2572,7 +2572,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en // If 'backupskip' is not empty, don't make a backup for some files. dobackup = (p_wb || p_bk || *p_pm != NUL); - if (dobackup && *p_bsk != NUL && match_file_list(p_bsk, (char_u *)sfname, (char_u *)ffname)) { + if (dobackup && *p_bsk != NUL && match_file_list((char *)p_bsk, sfname, ffname)) { dobackup = false; } @@ -3652,7 +3652,7 @@ nofail: /// Set the name of the current buffer. Use when the buffer doesn't have a /// name and a ":r" or ":w" command with a file name is used. -static int set_rw_fname(char_u *fname, char_u *sfname) +static int set_rw_fname(char *fname, char *sfname) { buf_T *buf = curbuf; @@ -3670,7 +3670,7 @@ static int set_rw_fname(char_u *fname, char_u *sfname) return FAIL; } - if (setfname(curbuf, (char *)fname, (char *)sfname, false) == OK) { + if (setfname(curbuf, fname, sfname, false) == OK) { curbuf->b_flags |= BF_NOTEDITED; } @@ -4205,7 +4205,7 @@ static int make_bom(char_u *buf, char_u *name) /// /// For buffers that have buftype "nofile" or "scratch": never change the file /// name. -void shorten_buf_fname(buf_T *buf, char_u *dirname, int force) +void shorten_buf_fname(buf_T *buf, char *dirname, int force) { char *p; @@ -4214,11 +4214,11 @@ void shorten_buf_fname(buf_T *buf, char_u *dirname, int force) && !path_with_url(buf->b_fname) && (force || buf->b_sfname == NULL - || path_is_absolute((char_u *)buf->b_sfname))) { + || path_is_absolute(buf->b_sfname))) { if (buf->b_sfname != buf->b_ffname) { XFREE_CLEAR(buf->b_sfname); } - p = path_shorten_fname(buf->b_ffname, (char *)dirname); + p = path_shorten_fname(buf->b_ffname, dirname); if (p != NULL) { buf->b_sfname = xstrdup(p); buf->b_fname = buf->b_sfname; @@ -4236,7 +4236,7 @@ void shorten_fnames(int force) os_dirname((char *)dirname, MAXPATHL); FOR_ALL_BUFFERS(buf) { - shorten_buf_fname(buf, dirname, force); + shorten_buf_fname(buf, (char *)dirname, force); // Always make the swap file name a full path, a "nofile" buffer may // also have a swap file. @@ -4552,7 +4552,7 @@ int vim_rename(const char *from, const char *to) } if (use_tmp_file) { - char_u tempname[MAXPATHL + 1]; + char tempname[MAXPATHL + 1]; // Find a name that doesn't exist and is in the same directory. // Rename "from" to "tempname" and then rename "tempname" to "to". @@ -4561,17 +4561,17 @@ int vim_rename(const char *from, const char *to) } STRCPY(tempname, from); for (n = 123; n < 99999; n++) { - char *tail = path_tail((char *)tempname); - snprintf(tail, (size_t)((MAXPATHL + 1) - (tail - (char *)tempname - 1)), "%d", n); + char *tail = path_tail(tempname); + snprintf(tail, (size_t)((MAXPATHL + 1) - (tail - tempname - 1)), "%d", n); - if (!os_path_exists((char *)tempname)) { - if (os_rename((char_u *)from, tempname) == OK) { - if (os_rename(tempname, (char_u *)to) == OK) { + if (!os_path_exists(tempname)) { + if (os_rename(from, tempname) == OK) { + if (os_rename(tempname, to) == OK) { return 0; } // Strange, the second step failed. Try moving the // file back and return failure. - (void)os_rename(tempname, (char_u *)from); + (void)os_rename(tempname, from); return -1; } // If it fails for one temp name it will most likely fail @@ -4589,7 +4589,7 @@ int vim_rename(const char *from, const char *to) os_remove((char *)to); // First try a normal rename, return if it works. - if (os_rename((char_u *)from, (char_u *)to) == OK) { + if (os_rename(from, to) == OK) { return 0; } @@ -5317,7 +5317,7 @@ int delete_recursive(const char *name) garray_T ga; if (readdir_core(&ga, exp, NULL, NULL) == OK) { for (int i = 0; i < ga.ga_len; i++) { - vim_snprintf(NameBuff, MAXPATHL, "%s/%s", exp, ((char_u **)ga.ga_data)[i]); + vim_snprintf(NameBuff, MAXPATHL, "%s/%s", exp, ((char **)ga.ga_data)[i]); if (delete_recursive((const char *)NameBuff) != 0) { // Remember the failure but continue deleting any further // entries. @@ -5505,28 +5505,27 @@ bool match_file_pat(char *pattern, regprog_T **prog, char *fname, char *sfname, /// @param ffname full file name /// /// @return true if there was a match -bool match_file_list(char_u *list, char_u *sfname, char_u *ffname) +bool match_file_list(char *list, char *sfname, char *ffname) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1, 3) { - char_u buf[100]; - char_u *tail; - char_u *regpat; + char buf[100]; + char *tail; + char *regpat; char allow_dirs; bool match; char *p; - tail = (char_u *)path_tail((char *)sfname); + tail = path_tail(sfname); // try all patterns in 'wildignore' - p = (char *)list; + p = list; while (*p) { - copy_option_part(&p, (char *)buf, ARRAY_SIZE(buf), ","); - regpat = (char_u *)file_pat_to_reg_pat((char *)buf, NULL, &allow_dirs, false); + copy_option_part(&p, buf, ARRAY_SIZE(buf), ","); + regpat = file_pat_to_reg_pat(buf, NULL, &allow_dirs, false); if (regpat == NULL) { break; } - match = match_file_pat((char *)regpat, NULL, (char *)ffname, (char *)sfname, (char *)tail, - (int)allow_dirs); + match = match_file_pat(regpat, NULL, ffname, sfname, tail, (int)allow_dirs); xfree(regpat); if (match) { return true; diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 6cb9e5c38d..7306131574 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -2873,7 +2873,7 @@ static void foldlevelIndent(fline_T *flp) // empty line or lines starting with a character in 'foldignore': level // depends on surrounding lines - if (*s == NUL || vim_strchr(flp->wp->w_p_fdi, *s) != NULL) { + if (*s == NUL || vim_strchr(flp->wp->w_p_fdi, (uint8_t)(*s)) != NULL) { // first and last line can't be undefined, use level 0 if (lnum == 1 || lnum == buf->b_ml.ml_line_count) { flp->lvl = 0; diff --git a/src/nvim/garray.c b/src/nvim/garray.c index 0f11868031..f75210bacb 100644 --- a/src/nvim/garray.c +++ b/src/nvim/garray.c @@ -173,9 +173,9 @@ char *ga_concat_strings_sep(const garray_T *gap, const char *sep) /// @param gap /// /// @returns the concatenated strings -char_u *ga_concat_strings(const garray_T *gap) FUNC_ATTR_NONNULL_RET +char *ga_concat_strings(const garray_T *gap) FUNC_ATTR_NONNULL_RET { - return (char_u *)ga_concat_strings_sep(gap, ","); + return ga_concat_strings_sep(gap, ","); } /// Concatenate a string to a growarray which contains characters. diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index b9e3b6b902..842b0b10b6 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -538,7 +538,7 @@ void AppendToRedobuffLit(const char *str, int len) // Handle a special or multibyte character. // Composing chars separately are handled separately. - const int c = mb_cptr2char_adv((const char_u **)&s); + const int c = mb_cptr2char_adv(&s); if (c < ' ' || c == DEL || (*s == NUL && (c == '0' || c == '^'))) { add_char_buff(&redobuff, Ctrl_V); } @@ -599,7 +599,7 @@ void stuffReadbuffSpec(const char *s) stuffReadbuffLen(s, 3); s += 3; } else { - int c = mb_cptr2char_adv((const char_u **)&s); + int c = mb_cptr2char_adv(&s); if (c == CAR || c == NL || c == ESC) { c = ' '; } @@ -640,7 +640,7 @@ void stuffescaped(const char *arg, bool literally) // stuff a single special character if (*arg != NUL) { - const int c = mb_cptr2char_adv((const char_u **)&arg); + const int c = mb_cptr2char_adv(&arg); if (literally && ((c < ' ' && c != TAB) || c == DEL)) { stuffcharReadbuff(Ctrl_V); } diff --git a/src/nvim/help.c b/src/nvim/help.c index 0a695a0aa7..91fda60859 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -412,7 +412,7 @@ int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep // And also "\_$" and "\_^". if (arg[0] == '\\' && ((arg[1] != NUL && arg[2] == NUL) - || (vim_strchr("%_z@", arg[1]) != NULL + || (vim_strchr("%_z@", (uint8_t)arg[1]) != NULL && arg[2] != NUL))) { vim_snprintf(d, IOSIZE, "/\\\\%s", arg + 1); // Check for "/\\_$", should be "/\\_\$" @@ -471,7 +471,7 @@ int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep // Insert '-' before and after "CTRL-X" when applicable. if (*s < ' ' || (*s == '^' && s[1] - && (ASCII_ISALPHA(s[1]) || vim_strchr("?@[\\]^", s[1]) != NULL))) { + && (ASCII_ISALPHA(s[1]) || vim_strchr("?@[\\]^", (uint8_t)s[1]) != NULL))) { if (d > IObuff && d[-1] != '_' && d[-1] != '\\') { *d++ = '_'; // prepend a '_' to make x_CTRL-x } @@ -974,12 +974,12 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool } if (in_example) { // skip over example; a non-white in the first column ends it - if (vim_strchr(" \t\n\r", IObuff[0])) { + if (vim_strchr(" \t\n\r", (uint8_t)IObuff[0])) { continue; } in_example = false; } - p1 = vim_strchr((char *)IObuff, '*'); // find first '*' + p1 = vim_strchr(IObuff, '*'); // find first '*' while (p1 != NULL) { p2 = strchr((const char *)p1 + 1, '*'); // Find second '*'. if (p2 != NULL && p2 > p1 + 1) { // Skip "*" and "**". @@ -994,7 +994,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool // followed by a white character or end-of-line. if (s == p2 && (p1 == IObuff || p1[-1] == ' ' || p1[-1] == '\t') - && (vim_strchr(" \t\n\r", s[1]) != NULL + && (vim_strchr(" \t\n\r", (uint8_t)s[1]) != NULL || s[1] == '\0')) { *p2 = '\0'; p1++; diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index 404835c4a9..2a81b4deb0 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -2921,9 +2921,9 @@ color_name_table_T color_name_table[] = { /// return the hex value or -1 if could not find a correct value RgbValue name_to_color(const char *name, int *idx) { - if (name[0] == '#' && isxdigit(name[1]) && isxdigit(name[2]) - && isxdigit(name[3]) && isxdigit(name[4]) && isxdigit(name[5]) - && isxdigit(name[6]) && name[7] == NUL) { + if (name[0] == '#' && isxdigit((uint8_t)name[1]) && isxdigit((uint8_t)name[2]) + && isxdigit((uint8_t)name[3]) && isxdigit((uint8_t)name[4]) && isxdigit((uint8_t)name[5]) + && isxdigit((uint8_t)name[6]) && name[7] == NUL) { // rgb hex string *idx = kColorIdxHex; return (RgbValue)strtol((char *)(name + 1), NULL, 16); diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index c2293add76..1c771073b2 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -704,7 +704,7 @@ static int cin_get_equal_amount(linenr_T lnum) s = ml_get(lnum); line = s; - while (*s != NUL && vim_strchr("=;{}\"'", *s) == NULL) { + while (*s != NUL && vim_strchr("=;{}\"'", (uint8_t)(*s)) == NULL) { if (cin_iscomment(s)) { // ignore comments s = cin_skipcomment(s); } else { diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index ba948ff924..38fb7a2873 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -598,7 +598,7 @@ static char *ins_compl_infercase_gettext(const char *str, int char_len, int comp // Allocate wide character array for the completion and fill it. int *const wca = xmalloc((size_t)char_len * sizeof(*wca)); { - const char_u *p = (char_u *)str; + const char *p = str; for (int i = 0; i < char_len; i++) { wca[i] = mb_ptr2char_adv(&p); } @@ -606,7 +606,7 @@ static char *ins_compl_infercase_gettext(const char *str, int char_len, int comp // Rule 1: Were any chars converted to lower? { - const char_u *p = (char_u *)compl_orig_text; + const char *p = compl_orig_text; for (int i = 0; i < min_len; i++) { const int c = mb_ptr2char_adv(&p); if (mb_islower(c)) { @@ -625,7 +625,7 @@ static char *ins_compl_infercase_gettext(const char *str, int char_len, int comp // Rule 2: No lower case, 2nd consecutive letter converted to // upper case. if (!has_lower) { - const char_u *p = (char_u *)compl_orig_text; + const char *p = compl_orig_text; for (int i = 0; i < min_len; i++) { const int c = mb_ptr2char_adv(&p); if (was_letter && mb_isupper(c) && mb_islower(wca[i])) { @@ -641,7 +641,7 @@ static char *ins_compl_infercase_gettext(const char *str, int char_len, int comp // Copy the original case of the part we typed. { - const char_u *p = (char_u *)compl_orig_text; + const char *p = compl_orig_text; for (int i = 0; i < min_len; i++) { const int c = mb_ptr2char_adv(&p); if (mb_islower(c)) { @@ -2857,7 +2857,7 @@ static int process_next_cpt_value(ins_compl_next_state_T *st, int *compl_type_ar // Remember the first match so that the loop stops when we // wrap and come back there a second time. st->set_match_pos = true; - } else if (vim_strchr("buwU", *st->e_cpt) != NULL + } else if (vim_strchr("buwU", (uint8_t)(*st->e_cpt)) != NULL && (st->ins_buf = ins_compl_next_buf(st->ins_buf, *st->e_cpt)) != curbuf) { // Scan a buffer, but not the current one. if (st->ins_buf->b_ml.ml_mfp != NULL) { // loaded buffer @@ -3161,7 +3161,7 @@ static int get_next_default_completion(ins_compl_next_state_T *st, pos_T *start_ compl_direction, compl_pattern); } else { found_new_match = searchit(NULL, st->ins_buf, st->cur_match_pos, - NULL, compl_direction, (char_u *)compl_pattern, 1L, + NULL, compl_direction, compl_pattern, 1L, SEARCH_KEEP + SEARCH_NFMSG, RE_LAST, NULL); } msg_silent--; diff --git a/src/nvim/lua/spell.c b/src/nvim/lua/spell.c index 0a566b2f86..d510d25e90 100644 --- a/src/nvim/lua/spell.c +++ b/src/nvim/lua/spell.c @@ -61,7 +61,7 @@ int nlua_spell_check(lua_State *lstate) while (*str != NUL) { attr = HLF_COUNT; - len = spell_check(curwin, (char_u *)str, &attr, &capcol, false); + len = spell_check(curwin, (char *)str, &attr, &capcol, false); assert(len <= INT_MAX); if (attr != HLF_COUNT) { diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 93ac0fccfa..b5274b9695 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -699,23 +699,23 @@ static int utf_safe_read_char_adv(const char_u **s, size_t *n) // Get character at **pp and advance *pp to the next character. // Note: composing characters are skipped! -int mb_ptr2char_adv(const char_u **const pp) +int mb_ptr2char_adv(const char **const pp) { int c; - c = utf_ptr2char((char *)(*pp)); - *pp += utfc_ptr2len((char *)(*pp)); + c = utf_ptr2char(*pp); + *pp += utfc_ptr2len(*pp); return c; } // Get character at **pp and advance *pp to the next character. // Note: composing characters are returned as separate characters. -int mb_cptr2char_adv(const char_u **pp) +int mb_cptr2char_adv(const char **pp) { int c; - c = utf_ptr2char((char *)(*pp)); - *pp += utf_ptr2len((char *)(*pp)); + c = utf_ptr2char(*pp); + *pp += utf_ptr2len(*pp); return c; } @@ -2232,7 +2232,7 @@ char_u *enc_locale(void) const char *p = vim_strchr(s, '.'); if (p != NULL) { if (p > s + 2 && !STRNICMP(p + 1, "EUC", 3) - && !isalnum((int)p[4]) && p[4] != '-' && p[-3] == '_') { + && !isalnum((uint8_t)p[4]) && p[4] != '-' && p[-3] == '_') { // Copy "XY.EUC" to "euc-XY" to buf[10]. memmove(buf, "euc-", 4); buf[4] = (char)(ASCII_ISALNUM(p[-2]) ? TOLOWER_ASC(p[-2]) : 0); diff --git a/src/nvim/memline.c b/src/nvim/memline.c index eee3b9d517..759920c4ec 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -749,7 +749,7 @@ void ml_recover(bool checkext) int len = (int)strlen(fname); if (checkext && len >= 4 && STRNICMP(fname + len - 4, ".s", 2) == 0 - && vim_strchr("abcdefghijklmnopqrstuvw", TOLOWER_ASC(fname[len - 2])) != NULL + && vim_strchr("abcdefghijklmnopqrstuvw", TOLOWER_ASC((uint8_t)fname[len - 2])) != NULL && ASCII_ISALPHA(fname[len - 1])) { directly = true; fname_used = xstrdup(fname); // make a copy for mf_open() @@ -3000,7 +3000,7 @@ int resolve_symlink(const char *fname, char *buf) // If it's relative, build a new path based on the directory // portion of the filename (if any) and the path the symlink // points to. - if (path_is_absolute((char_u *)buf)) { + if (path_is_absolute(buf)) { STRCPY(tmp, buf); } else { char *tail = path_tail(tmp); diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index 258f596ecc..950b025e53 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -86,17 +86,17 @@ static int get_mouse_class(char *p) /// Move "pos" back to the start of the word it's in. static void find_start_of_word(pos_T *pos) { - char_u *line; + char *line; int cclass; int col; - line = (char_u *)ml_get(pos->lnum); - cclass = get_mouse_class((char *)line + pos->col); + line = ml_get(pos->lnum); + cclass = get_mouse_class(line + pos->col); while (pos->col > 0) { col = pos->col - 1; - col -= utf_head_off((char *)line, (char *)line + col); - if (get_mouse_class((char *)line + col) != cclass) { + col -= utf_head_off(line, line + col); + if (get_mouse_class(line + col) != cclass) { break; } pos->col = col; @@ -107,19 +107,19 @@ static void find_start_of_word(pos_T *pos) /// When 'selection' is "exclusive", the position is just after the word. static void find_end_of_word(pos_T *pos) { - char_u *line; + char *line; int cclass; int col; - line = (char_u *)ml_get(pos->lnum); + line = ml_get(pos->lnum); if (*p_sel == 'e' && pos->col > 0) { pos->col--; - pos->col -= utf_head_off((char *)line, (char *)line + pos->col); + pos->col -= utf_head_off(line, line + pos->col); } - cclass = get_mouse_class((char *)line + pos->col); + cclass = get_mouse_class(line + pos->col); while (line[pos->col] != NUL) { - col = pos->col + utfc_ptr2len((char *)line + pos->col); - if (get_mouse_class((char *)line + col) != cclass) { + col = pos->col + utfc_ptr2len(line + pos->col); + if (get_mouse_class(line + col) != cclass) { if (*p_sel == 'e') { pos->col = col; } @@ -1540,16 +1540,16 @@ colnr_T vcol2col(win_T *const wp, const linenr_T lnum, const colnr_T vcol) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { // try to advance to the specified column - char_u *line = (char_u *)ml_get_buf(wp->w_buffer, lnum, false); + char *line = ml_get_buf(wp->w_buffer, lnum, false); chartabsize_T cts; - init_chartabsize_arg(&cts, wp, lnum, 0, (char *)line, (char *)line); + init_chartabsize_arg(&cts, wp, lnum, 0, line, line); while (cts.cts_vcol < vcol && *cts.cts_ptr != NUL) { cts.cts_vcol += win_lbr_chartabsize(&cts, NULL); MB_PTR_ADV(cts.cts_ptr); } clear_chartabsize_arg(&cts); - return (colnr_T)((char_u *)cts.cts_ptr - line); + return (colnr_T)(cts.cts_ptr - line); } /// Set UI mouse depending on current mode and 'mouse'. @@ -1575,10 +1575,10 @@ static void set_mouse_topline(win_T *wp) static colnr_T scroll_line_len(linenr_T lnum) { colnr_T col = 0; - char_u *line = (char_u *)ml_get(lnum); + char *line = ml_get(lnum); if (*line != NUL) { for (;;) { - int numchar = win_chartabsize(curwin, (char *)line, col); + int numchar = win_chartabsize(curwin, line, col); MB_PTR_ADV(line); if (*line == NUL) { // don't count the last character break; @@ -1680,10 +1680,10 @@ static int mouse_adjust_click(win_T *wp, int row, int col) // highlighting the second byte, not the ninth. linenr_T lnum = wp->w_cursor.lnum; - char_u *line = (char_u *)ml_get(lnum); - char_u *ptr = line; - char_u *ptr_end; - char_u *ptr_row_offset = line; // Where we begin adjusting `ptr_end` + char *line = ml_get(lnum); + char *ptr = line; + char *ptr_end; + char *ptr_row_offset = line; // Where we begin adjusting `ptr_end` // Find the offset where scanning should begin. int offset = wp->w_leftcol; @@ -1701,8 +1701,8 @@ static int mouse_adjust_click(win_T *wp, int row, int col) // checked for concealed characters. vcol = 0; while (vcol < offset && *ptr != NUL) { - vcol += win_chartabsize(curwin, (char *)ptr, vcol); - ptr += utfc_ptr2len((char *)ptr); + vcol += win_chartabsize(curwin, ptr, vcol); + ptr += utfc_ptr2len(ptr); } ptr_row_offset = ptr; @@ -1712,8 +1712,8 @@ static int mouse_adjust_click(win_T *wp, int row, int col) vcol = offset; ptr_end = ptr_row_offset; while (vcol < col && *ptr_end != NUL) { - vcol += win_chartabsize(curwin, (char *)ptr_end, vcol); - ptr_end += utfc_ptr2len((char *)ptr_end); + vcol += win_chartabsize(curwin, ptr_end, vcol); + ptr_end += utfc_ptr2len(ptr_end); } int matchid; @@ -1727,7 +1727,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col) #define DECR() nudge--; ptr_end -= utfc_ptr2len((char *)ptr_end) while (ptr < ptr_end && *ptr != NUL) { - cwidth = win_chartabsize(curwin, (char *)ptr, vcol); + cwidth = win_chartabsize(curwin, ptr, vcol); vcol += cwidth; if (cwidth > 1 && *ptr == '\t' && nudge > 0) { // A tab will "absorb" any previous adjustments. @@ -1755,7 +1755,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col) while (prev_matchid == matchid && *ptr != NUL) { INCR(); - ptr += utfc_ptr2len((char *)ptr); + ptr += utfc_ptr2len(ptr); matchid = syn_get_concealed_id(wp, lnum, (colnr_T)(ptr - line)); } @@ -1763,7 +1763,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col) } } - ptr += utfc_ptr2len((char *)ptr); + ptr += utfc_ptr2len(ptr); } return col + nudge; diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 8c499b28fc..6fb00ca6b5 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2337,7 +2337,7 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_ clearpos(&found_pos); for (;;) { t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD, - (char_u *)pat, 1L, searchflags, RE_LAST, NULL); + pat, 1L, searchflags, RE_LAST, NULL); if (curwin->w_cursor.lnum >= old_pos.lnum) { t = false; // match after start is failure too } @@ -3561,7 +3561,7 @@ static void nv_ident(cmdarg_T *cap) p = buf + strlen(buf); while (n-- > 0) { // put a backslash before \ and some others - if (vim_strchr(aux_ptr, *ptr) != NULL) { + if (vim_strchr(aux_ptr, (uint8_t)(*ptr)) != NULL) { *p++ = '\\'; } // When current byte is a part of multibyte character, copy all diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 73707e4122..42ff2b15ed 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1006,7 +1006,7 @@ static int stuff_yank(int regname, char *p) } else { free_register(reg); set_yreg_additional_data(reg, NULL); - reg->y_array = xmalloc(sizeof(char_u *)); + reg->y_array = xmalloc(sizeof(char *)); reg->y_array[0] = p; reg->y_size = 1; reg->y_type = kMTCharWise; @@ -1028,14 +1028,14 @@ static int execreg_lastc = NUL; /// with a \. Lines that start with a comment "\ character are ignored. /// @returns the concatenated line. The index of the line that should be /// processed next is returned in idx. -static char_u *execreg_line_continuation(char **lines, size_t *idx) +static char *execreg_line_continuation(char **lines, size_t *idx) { size_t i = *idx; assert(i > 0); const size_t cmd_end = i; garray_T ga; - ga_init(&ga, (int)sizeof(char_u), 400); + ga_init(&ga, (int)sizeof(char), 400); char *p; @@ -1068,7 +1068,7 @@ static char_u *execreg_line_continuation(char **lines, size_t *idx) ga_clear(&ga); *idx = i; - return (char_u *)str; + return str; } /// Execute a yank register: copy it into the stuff buffer @@ -1118,9 +1118,9 @@ int do_execreg(int regname, int colon, int addcr, int silent) // When in Visual mode "'<,'>" will be prepended to the command. // Remove it when it's already there. if (VIsual_active && strncmp(p, "'<,'>", 5) == 0) { - retval = put_in_typebuf((char_u *)p + 5, true, true, silent); + retval = put_in_typebuf(p + 5, true, true, silent); } else { - retval = put_in_typebuf((char_u *)p, true, true, silent); + retval = put_in_typebuf(p, true, true, silent); } xfree(p); } else if (regname == '=') { @@ -1128,7 +1128,7 @@ int do_execreg(int regname, int colon, int addcr, int silent) if (p == NULL) { return FAIL; } - retval = put_in_typebuf((char_u *)p, true, colon, silent); + retval = put_in_typebuf(p, true, colon, silent); xfree(p); } else if (regname == '.') { // use last inserted text p = (char *)get_last_insert_save(); @@ -1136,7 +1136,7 @@ int do_execreg(int regname, int colon, int addcr, int silent) emsg(_(e_noinstext)); return FAIL; } - retval = put_in_typebuf((char_u *)p, false, colon, silent); + retval = put_in_typebuf(p, false, colon, silent); xfree(p); } else { yankreg_T *reg = get_yank_register(regname, YREG_PASTE); @@ -1164,7 +1164,7 @@ int do_execreg(int regname, int colon, int addcr, int silent) if (colon && i > 0) { p = skipwhite(str); if (*p == '\\' || (p[0] == '"' && p[1] == '\\' && p[2] == ' ')) { - str = (char *)execreg_line_continuation(reg->y_array, &i); + str = execreg_line_continuation(reg->y_array, &i); free_str = true; } } @@ -1214,7 +1214,7 @@ static void put_reedit_in_typebuf(int silent) /// @param esc when true then it is to be taken literally: Escape K_SPECIAL /// characters and no remapping. /// @param colon add ':' before the line -static int put_in_typebuf(char_u *s, bool esc, bool colon, int silent) +static int put_in_typebuf(char *s, bool esc, bool colon, int silent) { int retval = OK; @@ -1226,9 +1226,9 @@ static int put_in_typebuf(char_u *s, bool esc, bool colon, int silent) char *p; if (esc) { - p = vim_strsave_escape_ks((char *)s); + p = vim_strsave_escape_ks(s); } else { - p = (char *)s; + p = s; } if (p == NULL) { retval = FAIL; @@ -1347,7 +1347,7 @@ bool get_spec_reg(int regname, char **argp, bool *allocated, bool errmsg) if (last_search_pat() == NULL && errmsg) { emsg(_(e_noprevre)); } - *argp = (char *)last_search_pat(); + *argp = last_search_pat(); return true; case '.': // last inserted text @@ -1418,11 +1418,11 @@ bool cmdline_paste_reg(int regname, bool literally_arg, bool remcr) } for (size_t i = 0; i < reg->y_size; i++) { - cmdline_paste_str((char_u *)reg->y_array[i], literally); + cmdline_paste_str(reg->y_array[i], literally); // Insert ^M between lines, unless `remcr` is true. if (i < reg->y_size - 1 && !remcr) { - cmdline_paste_str((char_u *)"\r", literally); + cmdline_paste_str("\r", literally); } // Check for CTRL-C, in case someone tries to paste a few thousand @@ -1455,7 +1455,7 @@ int op_delete(oparg_T *oap) { int n; linenr_T lnum; - char_u *ptr; + char *ptr; char *newp, *oldp; struct block_def bd = { 0 }; linenr_T old_lcount = curbuf->b_ml.ml_line_count; @@ -1489,11 +1489,11 @@ int op_delete(oparg_T *oap) && oap->line_count > 1 && oap->motion_force == NUL && oap->op_type == OP_DELETE) { - ptr = (char_u *)ml_get(oap->end.lnum) + oap->end.col; + ptr = ml_get(oap->end.lnum) + oap->end.col; if (*ptr != NUL) { ptr += oap->inclusive; } - ptr = (char_u *)skipwhite((char *)ptr); + ptr = skipwhite(ptr); if (*ptr == NUL && inindent(0)) { oap->motion_type = kMTLineWise; } @@ -2740,7 +2740,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) } if (curr != reg) { // append the new block to the old block - new_ptr = xmalloc(sizeof(char_u *) * (curr->y_size + reg->y_size)); + new_ptr = xmalloc(sizeof(char *) * (curr->y_size + reg->y_size)); for (j = 0; j < curr->y_size; j++) { new_ptr[j] = curr->y_array[j]; } @@ -3083,7 +3083,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) if (y_array != NULL) { break; } - y_array = xmalloc(y_size * sizeof(char_u *)); + y_array = xmalloc(y_size * sizeof(char *)); } } else { y_size = 1; // use fake one-line yank register @@ -3889,9 +3889,9 @@ void ex_display(exarg_T *eap) // display last search pattern if (last_search_pat() != NULL && (arg == NULL || vim_strchr(arg, '/') != NULL) && !got_int - && !message_filtered((char *)last_search_pat())) { + && !message_filtered(last_search_pat())) { msg_puts("\n c \"/ "); - dis_msg((char *)last_search_pat(), false); + dis_msg(last_search_pat(), false); } // display last used expression @@ -4475,7 +4475,7 @@ void op_addsub(oparg_T *oap, linenr_T Prenum1, bool g_cmd) int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) { int col; - char_u *buf1 = NULL; + char *buf1 = NULL; char buf2[NUMBUFLEN]; int pre; // 'X' or 'x': hex; '0': octal; 'B' or 'b': bin static bool hexupper = false; // 0xABC @@ -4747,7 +4747,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) // When there are many leading zeros it could be very long. // Allocate a bit too much. buf1 = xmalloc((size_t)length + NUMBUFLEN); - ptr = (char *)buf1; + ptr = buf1; if (negative && (!visual || was_positive)) { *ptr++ = '-'; } @@ -4799,7 +4799,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) } *ptr = NUL; STRCAT(buf1, buf2); - ins_str((char *)buf1); // insert the new number + ins_str(buf1); // insert the new number endpos = curwin->w_cursor; if (curwin->w_cursor.col) { curwin->w_cursor.col--; @@ -5088,7 +5088,7 @@ void write_reg_contents_ex(int name, const char *str, ssize_t len, bool must_app // Special case: '/' search pattern if (name == '/') { - set_last_search_pat((char_u *)str, RE_SEARCH, true, true); + set_last_search_pat(str, RE_SEARCH, true, true); return; } @@ -5200,7 +5200,7 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char *str, } // Grow the register array to hold the pointers to the new lines. - char **pp = xrealloc(y_ptr->y_array, (y_ptr->y_size + newlines) * sizeof(char_u *)); + char **pp = xrealloc(y_ptr->y_array, (y_ptr->y_size + newlines) * sizeof(char *)); y_ptr->y_array = pp; size_t lnum = y_ptr->y_size; // The current line number. @@ -5276,8 +5276,8 @@ void clear_oparg(oparg_T *oap) /// line, stopping if it encounters an end-of-line (NUL byte). In that /// case, eol_size will be added to the character count to account for /// the size of the EOL character. -static varnumber_T line_count_info(char_u *line, varnumber_T *wc, varnumber_T *cc, - varnumber_T limit, int eol_size) +static varnumber_T line_count_info(char *line, varnumber_T *wc, varnumber_T *cc, varnumber_T limit, + int eol_size) { varnumber_T i; varnumber_T words = 0; @@ -5294,7 +5294,7 @@ static varnumber_T line_count_info(char_u *line, varnumber_T *wc, varnumber_T *c is_word = 1; } chars++; - i += utfc_ptr2len((char *)line + i); + i += utfc_ptr2len(line + i); } if (is_word) { @@ -5319,8 +5319,8 @@ static varnumber_T line_count_info(char_u *line, varnumber_T *wc, varnumber_T *c void cursor_pos_info(dict_T *dict) { char *p; - char_u buf1[50]; - char_u buf2[40]; + char buf1[50]; + char buf2[40]; linenr_T lnum; varnumber_T byte_count = 0; varnumber_T bom_count = 0; @@ -5429,7 +5429,7 @@ void cursor_pos_info(dict_T *dict) break; } if (s != NULL) { - byte_count_cursor += line_count_info((char_u *)s, &word_count_cursor, + byte_count_cursor += line_count_info(s, &word_count_cursor, &char_count_cursor, len, eol_size); if (lnum == curbuf->b_ml.ml_line_count && !curbuf->b_p_eol @@ -5444,14 +5444,14 @@ void cursor_pos_info(dict_T *dict) word_count_cursor += word_count; char_count_cursor += char_count; byte_count_cursor = byte_count - + line_count_info((char_u *)ml_get(lnum), &word_count_cursor, + + line_count_info(ml_get(lnum), &word_count_cursor, &char_count_cursor, (varnumber_T)curwin->w_cursor.col + 1, eol_size); } } // Add to the running totals - byte_count += line_count_info((char_u *)ml_get(lnum), &word_count, &char_count, + byte_count += line_count_info(ml_get(lnum), &word_count, &char_count, (varnumber_T)MAXCOL, eol_size); } @@ -5466,7 +5466,7 @@ void cursor_pos_info(dict_T *dict) getvcols(curwin, &min_pos, &max_pos, &min_pos.col, &max_pos.col); int64_t cols; STRICT_SUB(oparg.end_vcol + 1, oparg.start_vcol, &cols, int64_t); - vim_snprintf((char *)buf1, sizeof(buf1), _("%" PRId64 " Cols; "), + vim_snprintf(buf1, sizeof(buf1), _("%" PRId64 " Cols; "), cols); } else { buf1[0] = NUL; @@ -5497,7 +5497,7 @@ void cursor_pos_info(dict_T *dict) } else { p = get_cursor_line_ptr(); validate_virtcol(); - col_print((char *)buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1, + col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1, (int)curwin->w_virtcol + 1); col_print((char *)buf2, sizeof(buf2), (int)strlen(p), linetabsize(p)); @@ -5507,7 +5507,7 @@ void cursor_pos_info(dict_T *dict) _("Col %s of %s; Line %" PRId64 " of %" PRId64 ";" " Word %" PRId64 " of %" PRId64 ";" " Byte %" PRId64 " of %" PRId64 ""), - (char *)buf1, (char *)buf2, + buf1, buf2, (int64_t)curwin->w_cursor.lnum, (int64_t)curbuf->b_ml.ml_line_count, (int64_t)word_count_cursor, (int64_t)word_count, @@ -5518,7 +5518,7 @@ void cursor_pos_info(dict_T *dict) " Word %" PRId64 " of %" PRId64 ";" " Char %" PRId64 " of %" PRId64 ";" " Byte %" PRId64 " of %" PRId64 ""), - (char *)buf1, (char *)buf2, + buf1, buf2, (int64_t)curwin->w_cursor.lnum, (int64_t)curbuf->b_ml.ml_line_count, (int64_t)word_count_cursor, (int64_t)word_count, diff --git a/src/nvim/option.c b/src/nvim/option.c index 024bf3af09..0c2a2f7060 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -999,14 +999,14 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar, // 'whichwrap' if (flags & P_ONECOMMA) { if (*s != ',' && *(s + 1) == ',' - && vim_strchr(s + 2, *s) != NULL) { + && vim_strchr(s + 2, (uint8_t)(*s)) != NULL) { // Remove the duplicated value and the next comma. STRMOVE(s, s + 2); continue; } } else { if ((!(flags & P_COMMA) || *s != ',') - && vim_strchr(s + 1, *s) != NULL) { + && vim_strchr(s + 1, (uint8_t)(*s)) != NULL) { STRMOVE(s, s + 1); continue; } @@ -1106,7 +1106,7 @@ int do_set(char *arg, int opt_flags) char *errmsg = NULL; char *startarg = arg; // remember for error message - if (strncmp(arg, "all", 3) == 0 && !isalpha(arg[3]) + if (strncmp(arg, "all", 3) == 0 && !isalpha((uint8_t)arg[3]) && !(opt_flags & OPT_MODELINE)) { // ":set all" show all options. // ":set all&" set all options to their default value. @@ -1210,7 +1210,7 @@ int do_set(char *arg, int opt_flags) if (options[opt_idx].var == NULL) { // hidden option: skip // Only give an error message when requesting the value of // a hidden option, ignore setting it. - if (vim_strchr("=:!&<", nextchar) == NULL + if (vim_strchr("=:!&<", (uint8_t)nextchar) == NULL && (!(options[opt_idx].flags & P_BOOL) || nextchar == '?')) { errmsg = e_unsupportedoption; @@ -1264,7 +1264,7 @@ int do_set(char *arg, int opt_flags) goto skip; } - if (vim_strchr("?=:!&<", nextchar) != NULL) { + if (vim_strchr("?=:!&<", (uint8_t)nextchar) != NULL) { arg += len; if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') { if (arg[3] == 'm') { // "opt&vim": set to Vim default @@ -1273,7 +1273,7 @@ int do_set(char *arg, int opt_flags) arg += 2; } } - if (vim_strchr("?!&<", nextchar) != NULL + if (vim_strchr("?!&<", (uint8_t)nextchar) != NULL && arg[1] != NUL && !ascii_iswhite(arg[1])) { errmsg = e_trailing; goto skip; @@ -1286,7 +1286,7 @@ int do_set(char *arg, int opt_flags) // if (nextchar == '?' || (prefix == 1 - && vim_strchr("=:&<", nextchar) == NULL + && vim_strchr("=:&<", (uint8_t)nextchar) == NULL && !(flags & P_BOOL))) { // print value if (did_show) { @@ -1359,7 +1359,7 @@ int do_set(char *arg, int opt_flags) errmsg = set_bool_option(opt_idx, (char_u *)varp, (int)value, opt_flags); } else { // Numeric or string. - if (vim_strchr("=:&<", nextchar) == NULL + if (vim_strchr("=:&<", (uint8_t)nextchar) == NULL || prefix != 1) { errmsg = e_invarg; goto skip; @@ -1775,7 +1775,7 @@ bool valid_name(const char *val, const char *allowed) { for (const char_u *s = (char_u *)val; *s != NUL; s++) { if (!ASCII_ISALNUM(*s) - && vim_strchr(allowed, *s) == NULL) { + && vim_strchr(allowed, (uint8_t)(*s)) == NULL) { return false; } } @@ -1974,7 +1974,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va || (opt_flags & OPT_GLOBAL) || opt_flags == 0) && !bufIsChanged(bp) && bp->b_ml.ml_mfp != NULL) { u_compute_hash(bp, hash); - u_read_undo(NULL, hash, (char_u *)bp->b_fname); + u_read_undo(NULL, hash, bp->b_fname); } } } @@ -5388,9 +5388,9 @@ size_t copy_option_part(char **option, char *buf, size_t maxlen, char *sep_chars if (*p == '.') { buf[len++] = *p++; } - while (*p != NUL && vim_strchr(sep_chars, *p) == NULL) { + while (*p != NUL && vim_strchr(sep_chars, (uint8_t)(*p)) == NULL) { // Skip backslash before a separator character and space. - if (p[0] == '\\' && vim_strchr(sep_chars, p[1]) != NULL) { + if (p[0] == '\\' && vim_strchr(sep_chars, (uint8_t)p[1]) != NULL) { p++; } if (len < maxlen - 1) { diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index a1a5cadd8d..ab58888482 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -614,7 +614,7 @@ char *check_stl_option(char *s) groupdepth++; continue; } - if (vim_strchr(STL_ALL, *s) == NULL) { + if (vim_strchr(STL_ALL, (uint8_t)(*s)) == NULL) { return illegal_char(errbuf, sizeof(errbuf), *s); } if (*s == '{') { @@ -946,7 +946,7 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf } else if (gvarp == &p_com) { // 'comments' for (s = *varp; *s;) { while (*s && *s != ':') { - if (vim_strchr(COM_ALL, *s) == NULL + if (vim_strchr(COM_ALL, (uint8_t)(*s)) == NULL && !ascii_isdigit(*s) && *s != '-') { errmsg = illegal_char(errbuf, errbuflen, *s); break; @@ -1016,7 +1016,7 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf free_oldval = (opt->flags & P_ALLOCED); for (s = p_shada; *s;) { // Check it's a valid character - if (vim_strchr("!\"%'/:<@cfhnrs", *s) == NULL) { + if (vim_strchr("!\"%'/:<@cfhnrs", (uint8_t)(*s)) == NULL) { errmsg = illegal_char(errbuf, errbuflen, *s); break; } @@ -1221,7 +1221,7 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf if (!*s) { break; } - if (vim_strchr(".wbuksid]tU", *s) == NULL) { + if (vim_strchr(".wbuksid]tU", (uint8_t)(*s)) == NULL) { errmsg = illegal_char(errbuf, errbuflen, *s); break; } @@ -1569,7 +1569,7 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf } if (p != NULL) { for (s = *varp; *s; s++) { - if (vim_strchr(p, *s) == NULL) { + if (vim_strchr(p, (uint8_t)(*s)) == NULL) { errmsg = illegal_char(errbuf, errbuflen, *s); break; } diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index e1db7a8ef7..ae34a79365 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -656,7 +656,7 @@ void expand_env_esc(char *restrict srcp, char *restrict dst, int dstlen, bool es #endif } else if (src[1] == NUL // home directory || vim_ispathsep(src[1]) - || vim_strchr(" ,\t\n", src[1]) != NULL) { + || vim_strchr(" ,\t\n", (uint8_t)src[1]) != NULL) { var = homedir; tail = src + 1; } else { // user directory @@ -1198,7 +1198,7 @@ bool os_setenv_append_path(const char *fname) // No prescribed maximum on unix. # define MAX_ENVPATHLEN INT_MAX #endif - if (!path_is_absolute((char_u *)fname)) { + if (!path_is_absolute(fname)) { internal_error("os_setenv_append_path()"); return false; } diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 98ec9aa826..ce1b2d1cf5 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -914,12 +914,11 @@ int os_file_is_writable(const char *name) /// Rename a file or directory. /// /// @return `OK` for success, `FAIL` for failure. -int os_rename(const char_u *path, const char_u *new_path) +int os_rename(const char *path, const char *new_path) FUNC_ATTR_NONNULL_ALL { int r; - RUN_UV_FS_FUNC(r, uv_fs_rename, (const char *)path, (const char *)new_path, - NULL); + RUN_UV_FS_FUNC(r, uv_fs_rename, path, new_path, NULL); return (r == kLibuvSuccess ? OK : FAIL); } @@ -1382,7 +1381,7 @@ bool os_is_reparse_point_include(const char *path) } p = utf16_path; - if (isalpha(p[0]) && p[1] == L':' && IS_PATH_SEP(p[2])) { + if (isalpha((uint8_t)p[0]) && p[1] == L':' && IS_PATH_SEP(p[2])) { p += 3; } else if (IS_PATH_SEP(p[0]) && IS_PATH_SEP(p[1])) { p += 2; diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 8177f06c64..ac8a141bbe 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -221,7 +221,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in // "command" below. len++; // add space for (j = 0; pat[i][j] != NUL; j++) { - if (vim_strchr(SHELL_SPECIAL, pat[i][j]) != NULL) { + if (vim_strchr(SHELL_SPECIAL, (uint8_t)pat[i][j]) != NULL) { len++; // may add a backslash } len++; @@ -304,14 +304,14 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in // backslash inside backticks, before a special character // and before a backtick. if (intick - || vim_strchr(SHELL_SPECIAL, pat[i][j + 1]) != NULL + || vim_strchr(SHELL_SPECIAL, (uint8_t)pat[i][j + 1]) != NULL || pat[i][j + 1] == '`') { *p++ = '\\'; } j++; } else if (!intick && ((flags & EW_KEEPDOLLAR) == 0 || pat[i][j] != '$') - && vim_strchr(SHELL_SPECIAL, pat[i][j]) != NULL) { + && vim_strchr(SHELL_SPECIAL, (uint8_t)pat[i][j]) != NULL) { // Put a backslash before a special character, but not // when inside ``. And not for $var when EW_KEEPDOLLAR is // set. diff --git a/src/nvim/path.c b/src/nvim/path.c index 6d14db7de1..afc0563498 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -155,7 +155,7 @@ char *path_tail_with_sep(char *fname) /// @post if `len` is not null, stores the length of the executable name. /// /// @return The position of the last path separator + 1. -const char_u *invocation_path_tail(const char *invocation, size_t *len) +const char *invocation_path_tail(const char *invocation, size_t *len) FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1) { const char *tail = get_past_head(invocation); @@ -172,7 +172,7 @@ const char_u *invocation_path_tail(const char *invocation, size_t *len) *len = (size_t)(p - tail); } - return (char_u *)tail; + return tail; } /// Get the next path component of a path name. @@ -211,10 +211,10 @@ int path_head_length(void) /// @return /// - True if path begins with a path head /// - False otherwise -bool is_path_head(const char_u *path) +bool is_path_head(const char *path) { #ifdef MSWIN - return isalpha(path[0]) && path[1] == ':'; + return isalpha((uint8_t)path[0]) && path[1] == ':'; #else return vim_ispathsep(*path); #endif @@ -511,7 +511,7 @@ char *FullName_save(const char *fname, bool force) char *save_abs_path(const char *name) FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL { - if (!path_is_absolute((char_u *)name)) { + if (!path_is_absolute(name)) { return FullName_save(name, true); } return xstrdup(name); @@ -536,7 +536,7 @@ bool path_has_wildcard(const char *p) // Windows: const char *wildcards = "?*$[`"; #endif - if (vim_strchr(wildcards, *p) != NULL + if (vim_strchr(wildcards, (uint8_t)(*p)) != NULL || (p[0] == '~' && p[1] != NUL)) { return true; } @@ -649,7 +649,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in } s = p + 1; } else if (path_end >= path + wildoff - && (vim_strchr("*?[{~$", *path_end) != NULL + && (vim_strchr("*?[{~$", (uint8_t)(*path_end)) != NULL #ifndef MSWIN || (!p_fic && (flags & EW_ICASE) && mb_isalpha(utf_ptr2char((char *)path_end))) #endif @@ -783,8 +783,8 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in // slow, thus skip it. size_t matches = (size_t)(gap->ga_len - start_len); if (matches > 0 && !got_int) { - qsort(((char_u **)gap->ga_data) + start_len, matches, - sizeof(char_u *), pstrcmp); + qsort(((char **)gap->ga_data) + start_len, matches, + sizeof(char *), pstrcmp); } return matches; } @@ -842,11 +842,11 @@ static bool is_unique(char *maybe_unique, garray_T *gap, int i) // expanding each into their equivalent path(s). static void expand_path_option(char *curdir, garray_T *gap) { - char_u *path_option = *curbuf->b_p_path == NUL ? p_path : (char_u *)curbuf->b_p_path; + char *path_option = *curbuf->b_p_path == NUL ? (char *)p_path : curbuf->b_p_path; char *buf = xmalloc(MAXPATHL); while (*path_option != NUL) { - copy_option_part((char **)&path_option, buf, MAXPATHL, " ,"); + copy_option_part(&path_option, buf, MAXPATHL, " ,"); if (buf[0] == '.' && (buf[1] == NUL || vim_ispathsep(buf[1]))) { // Relative to current buffer: @@ -871,7 +871,7 @@ static void expand_path_option(char *curdir, garray_T *gap) STRCPY(buf, curdir); // relative to current directory } else if (path_with_url(buf)) { continue; // URL can't be used here - } else if (!path_is_absolute((char_u *)buf)) { + } else if (!path_is_absolute(buf)) { // Expand relative path to their full path equivalent size_t len = strlen(curdir); if (len + strlen(buf) + 3 > MAXPATHL) { @@ -895,11 +895,11 @@ static void expand_path_option(char *curdir, garray_T *gap) // path: /foo/bar/baz // fname: /foo/bar/baz/quux.txt // returns: ^this -static char_u *get_path_cutoff(char_u *fname, garray_T *gap) +static char *get_path_cutoff(char *fname, garray_T *gap) { int maxlen = 0; - char_u **path_part = (char_u **)gap->ga_data; - char_u *cutoff = NULL; + char **path_part = gap->ga_data; + char *cutoff = NULL; for (int i = 0; i < gap->ga_len; i++) { int j = 0; @@ -985,7 +985,7 @@ static void uniquefy_paths(garray_T *gap, char *pattern) } // Shorten the filename while maintaining its uniqueness - path_cutoff = (char *)get_path_cutoff((char_u *)path, &path_ga); + path_cutoff = get_path_cutoff(path, &path_ga); // Don't assume all files can be reached without path when search // pattern starts with **/, so only remove path_cutoff @@ -1012,7 +1012,7 @@ static void uniquefy_paths(garray_T *gap, char *pattern) } } - if (path_is_absolute((char_u *)path)) { + if (path_is_absolute(path)) { // Last resort: shorten relative to curdir if possible. // 'possible' means: // 1. It is under the current directory. @@ -1128,7 +1128,7 @@ static int expand_in_path(garray_T *const gap, char *const pattern, const int fl return 0; } - char *const paths = (char *)ga_concat_strings(&path_ga); + char *const paths = ga_concat_strings(&path_ga); ga_clear_strings(&path_ga); int glob_flags = 0; @@ -1146,12 +1146,12 @@ static int expand_in_path(garray_T *const gap, char *const pattern, const int fl /// Return true if "p" contains what looks like an environment variable. /// Allowing for escaping. -static bool has_env_var(char_u *p) +static bool has_env_var(char *p) { for (; *p; MB_PTR_ADV(p)) { if (*p == '\\' && p[1] != NUL) { p++; - } else if (vim_strchr("$", *p) != NULL) { + } else if (vim_strchr("$", (uint8_t)(*p)) != NULL) { return true; } } @@ -1162,7 +1162,7 @@ static bool has_env_var(char_u *p) // Return true if "p" contains a special wildcard character, one that Vim // cannot expand, requires using a shell. -static bool has_special_wildchar(char_u *p) +static bool has_special_wildchar(char *p) { for (; *p; MB_PTR_ADV(p)) { // Disallow line break characters. @@ -1172,13 +1172,13 @@ static bool has_special_wildchar(char_u *p) // Allow for escaping. if (*p == '\\' && p[1] != NUL && p[1] != '\r' && p[1] != '\n') { p++; - } else if (vim_strchr(SPECIAL_WILDCHAR, *p) != NULL) { + } else if (vim_strchr(SPECIAL_WILDCHAR, (uint8_t)(*p)) != NULL) { // A { must be followed by a matching }. - if (*p == '{' && vim_strchr((char *)p, '}') == NULL) { + if (*p == '{' && vim_strchr(p, '}') == NULL) { continue; } // A quote and backtick must be followed by another one. - if ((*p == '`' || *p == '\'') && vim_strchr((char *)p, *p) == NULL) { + if ((*p == '`' || *p == '\'') && vim_strchr(p, (uint8_t)(*p)) == NULL) { continue; } return true; @@ -1232,7 +1232,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i // avoids starting the shell for each argument separately. // For `=expr` do use the internal function. for (int i = 0; i < num_pat; i++) { - if (has_special_wildchar((char_u *)pat[i]) + if (has_special_wildchar(pat[i]) && !(vim_backtick(pat[i]) && pat[i][1] == '=')) { return os_expand_wildcards(num_pat, pat, num_file, file, flags); } @@ -1259,7 +1259,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i } } else { // First expand environment variables, "~/" and "~user/". - if ((has_env_var((char_u *)p) && !(flags & EW_NOTENV)) || *p == '~') { + if ((has_env_var(p) && !(flags & EW_NOTENV)) || *p == '~') { p = (char *)expand_env_save_opt(p, true); if (p == NULL) { p = pat[i]; @@ -1268,7 +1268,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i // On Unix, if expand_env() can't expand an environment // variable, use the shell to do that. Discard previously // found file names and start all over again. - if (has_env_var((char_u *)p) || *p == '~') { + if (has_env_var(p) || *p == '~') { xfree(p); ga_clear_strings(&ga); i = os_expand_wildcards(num_pat, pat, num_file, file, @@ -1287,7 +1287,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i // given. if (path_has_exp_wildcard(p) || (flags & EW_ICASE)) { if ((flags & EW_PATH) - && !path_is_absolute((char_u *)p) + && !path_is_absolute(p) && !(p[0] == '.' && (vim_ispathsep(p[1]) || (p[1] == '.' @@ -1478,7 +1478,7 @@ void addfile(garray_T *gap, char *f, int flags) return; } - char_u *p = xmalloc(strlen(f) + 1 + isdir); + char *p = xmalloc(strlen(f) + 1 + isdir); STRCPY(p, f); #ifdef BACKSLASH_IN_FILENAME @@ -1486,9 +1486,9 @@ void addfile(garray_T *gap, char *f, int flags) #endif // Append a slash or backslash after directory names if none is present. if (isdir && (flags & EW_ADDSLASH)) { - add_pathsep((char *)p); + add_pathsep(p); } - GA_APPEND(char_u *, gap, p); + GA_APPEND(char *, gap, p); } // Converts a file name into a canonical form. It simplifies a file name into @@ -1768,7 +1768,7 @@ int path_with_url(const char *fname) // non-URL text. // first character must be alpha - if (!isalpha(*fname)) { + if (!isalpha((uint8_t)(*fname))) { return 0; } @@ -1777,7 +1777,7 @@ int path_with_url(const char *fname) } // check body: alpha or dash - for (p = fname + 1; (isalpha(*p) || (*p == '-')); p++) {} + for (p = fname + 1; (isalpha((uint8_t)(*p)) || (*p == '-')); p++) {} // check last char is not a dash if (p[-1] == '-') { @@ -1800,7 +1800,7 @@ bool path_with_extension(const char *path, const char *extension) /// Return true if "name" is a full (absolute) path name or URL. bool vim_isAbsName(char *name) { - return path_with_url(name) != 0 || path_is_absolute((char_u *)name); + return path_with_url(name) != 0 || path_is_absolute(name); } /// Save absolute file name to "buf[len]". @@ -2076,7 +2076,7 @@ char *path_shorten_fname(char *full_path, char *dir_name) size_t len = strlen(dir_name); // If dir_name is a path head, full_path can always be made relative. - if (len == (size_t)path_head_length() && is_path_head((char_u *)dir_name)) { + if (len == (size_t)path_head_length() && is_path_head(dir_name)) { return full_path + len; } @@ -2124,7 +2124,7 @@ int expand_wildcards_eval(char **pat, int *num_file, char ***file, int flags) if (is_cur_alt_file || *exp_pat == '<') { emsg_off++; - eval_pat = (char *)eval_vars((char_u *)exp_pat, (char_u *)exp_pat, &usedlen, NULL, &ignored_msg, + eval_pat = (char *)eval_vars(exp_pat, (char_u *)exp_pat, &usedlen, NULL, &ignored_msg, NULL, true); emsg_off--; @@ -2186,15 +2186,15 @@ int expand_wildcards(int num_pat, char **pat, int *num_files, char ***files, int // Remove names that match 'wildignore'. if (*p_wig) { - char_u *ffname; + char *ffname; // check all files in (*files)[] assert(*num_files == 0 || *files != NULL); for (i = 0; i < *num_files; i++) { - ffname = (char_u *)FullName_save((*files)[i], false); + ffname = FullName_save((*files)[i], false); assert((*files)[i] != NULL); assert(ffname != NULL); - if (match_file_list((char_u *)p_wig, (char_u *)(*files)[i], ffname)) { + if (match_file_list(p_wig, (*files)[i], ffname)) { // remove this matching file from the list xfree((*files)[i]); for (j = i; j + 1 < *num_files; j++) { @@ -2291,7 +2291,7 @@ int path_full_dir_name(char *directory, char *buffer, size_t len) // Path does not exist (yet). For a full path fail, // will use the path as-is. For a relative path use // the current directory and append the file name. - if (path_is_absolute((const char_u *)directory)) { + if (path_is_absolute(directory)) { // Do not return immediately since we may be in the wrong directory. retval = FAIL; } else { @@ -2361,7 +2361,7 @@ static int path_to_absolute(const char *fname, char *buf, size_t len, int force) char *end_of_path = (char *)fname; // expand it if forced or not an absolute path - if (force || !path_is_absolute((char_u *)fname)) { + if (force || !path_is_absolute(fname)) { p = strrchr(fname, '/'); #ifdef MSWIN if (p == NULL) { @@ -2390,14 +2390,14 @@ static int path_to_absolute(const char *fname, char *buf, size_t len, int force) /// Check if file `fname` is a full (absolute) path. /// /// @return `true` if "fname" is absolute. -int path_is_absolute(const char_u *fname) +int path_is_absolute(const char *fname) { #ifdef MSWIN if (*fname == NUL) { return false; } // A name like "d:/foo" and "//server/share" is absolute - return ((isalpha(fname[0]) && fname[1] == ':' && vim_ispathsep_nocolon(fname[2])) + return ((isalpha((uint8_t)fname[0]) && fname[1] == ':' && vim_ispathsep_nocolon(fname[2])) || (vim_ispathsep_nocolon(fname[0]) && fname[0] == fname[1])); #else // UNIX: This just checks if the file name starts with '/' or '~'. @@ -2417,7 +2417,7 @@ void path_guess_exepath(const char *argv0, char *buf, size_t bufsize) { const char *path = os_getenv("PATH"); - if (path == NULL || path_is_absolute((char_u *)argv0)) { + if (path == NULL || path_is_absolute(argv0)) { xstrlcpy(buf, argv0, bufsize); } else if (argv0[0] == '.' || strchr(argv0, PATHSEP)) { // Relative to CWD. diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 3d09fa1030..32ae0fc276 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -384,9 +384,9 @@ static char *efmpat_to_regpat(const char *efmpat, char *regpat, efm_T *efminfo, return NULL; } if ((idx && idx < FMT_PATTERN_R - && vim_strchr("DXOPQ", efminfo->prefix) != NULL) + && vim_strchr("DXOPQ", (uint8_t)efminfo->prefix) != NULL) || (idx == FMT_PATTERN_R - && vim_strchr("OPQ", efminfo->prefix) == NULL)) { + && vim_strchr("OPQ", (uint8_t)efminfo->prefix) == NULL)) { semsg(_("E373: Unexpected %%%c in format string"), *efmpat); return NULL; } @@ -468,10 +468,10 @@ static char *scanf_fmt_to_regpat(const char **pefmp, const char *efm, int len, c static const char *efm_analyze_prefix(const char *efmp, efm_T *efminfo) FUNC_ATTR_NONNULL_ALL { - if (vim_strchr("+-", *efmp) != NULL) { + if (vim_strchr("+-", (uint8_t)(*efmp)) != NULL) { efminfo->flags = *efmp++; } - if (vim_strchr("DXAEWINCZGOPQ", *efmp) != NULL) { + if (vim_strchr("DXAEWINCZGOPQ", (uint8_t)(*efmp)) != NULL) { efminfo->prefix = *efmp; } else { semsg(_("E376: Invalid %%%c in format string prefix"), *efmp); @@ -510,7 +510,7 @@ static int efm_to_regpat(const char *efm, int len, efm_T *fmt_ptr, char *regpat) if (ptr == NULL) { return FAIL; } - } else if (vim_strchr("%\\.^$~[", *efmp) != NULL) { + } else if (vim_strchr("%\\.^$~[", (uint8_t)(*efmp)) != NULL) { *ptr++ = *efmp; // regexp magic characters } else if (*efmp == '#') { *ptr++ = '*'; @@ -530,7 +530,7 @@ static int efm_to_regpat(const char *efm, int len, efm_T *fmt_ptr, char *regpat) } else { // copy normal character if (*efmp == '\\' && efmp + 1 < efm + len) { efmp++; - } else if (vim_strchr(".*^$~[", *efmp) != NULL) { + } else if (vim_strchr(".*^$~[", (uint8_t)(*efmp)) != NULL) { *ptr++ = '\\'; // escape regexp atoms } if (*efmp) { @@ -1483,7 +1483,7 @@ static int qf_parse_match(char *linebuf, size_t linelen, efm_T *fmt_ptr, regmatc if ((idx == 'C' || idx == 'Z') && !qf_multiline) { return QF_FAIL; } - if (vim_strchr("EWIN", idx) != NULL) { + if (vim_strchr("EWIN", (uint8_t)idx) != NULL) { fields->type = idx; } else { fields->type = 0; @@ -1524,7 +1524,7 @@ static int qf_parse_match(char *linebuf, size_t linelen, efm_T *fmt_ptr, regmatc static int qf_parse_get_fields(char *linebuf, size_t linelen, efm_T *fmt_ptr, qffields_T *fields, int qf_multiline, int qf_multiscan, char **tail) { - if (qf_multiscan && vim_strchr("OPQ", fmt_ptr->prefix) == NULL) { + if (qf_multiscan && vim_strchr("OPQ", (uint8_t)fmt_ptr->prefix) == NULL) { return QF_FAIL; } @@ -3959,11 +3959,11 @@ static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum, const qfli // buffer. if (first_bufline && (errbuf->b_sfname == NULL - || path_is_absolute((char_u *)errbuf->b_sfname))) { + || path_is_absolute(errbuf->b_sfname))) { if (*dirname == NUL) { os_dirname(dirname, MAXPATHL); } - shorten_buf_fname(errbuf, (char_u *)dirname, false); + shorten_buf_fname(errbuf, dirname, false); } xstrlcpy(IObuff, errbuf->b_fname, IOSIZE); } @@ -5105,7 +5105,7 @@ static void vgr_init_regmatch(regmmatch_T *regmatch, char *s) emsg(_(e_noprevre)); return; } - regmatch->regprog = vim_regcomp((char *)last_search_pat(), RE_MAGIC); + regmatch->regprog = vim_regcomp(last_search_pat(), RE_MAGIC); } else { regmatch->regprog = vim_regcomp(s, RE_MAGIC); } diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index e396e54ced..54461bfa07 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -456,9 +456,9 @@ static char_u *skip_anyof(char *p) MB_PTR_ADV(p); } } else if (*p == '\\' - && (vim_strchr(REGEXP_INRANGE, p[1]) != NULL + && (vim_strchr(REGEXP_INRANGE, (uint8_t)p[1]) != NULL || (!reg_cpo_lit - && vim_strchr(REGEXP_ABBR, p[1]) != NULL))) { + && vim_strchr(REGEXP_ABBR, (uint8_t)p[1]) != NULL))) { p += 2; } else if (*p == '[') { if (get_char_class(&p) == CLASS_NONE @@ -1399,8 +1399,8 @@ static int cstrncmp(char *s1, char *s2, int *n) str2 = s2; c1 = c2 = 0; while ((int)(str1 - s1) < *n) { - c1 = mb_ptr2char_adv((const char_u **)&str1); - c2 = mb_ptr2char_adv((const char_u **)&str2); + c1 = mb_ptr2char_adv((const char **)&str1); + c2 = mb_ptr2char_adv((const char **)&str2); // decompose the character if necessary, into 'base' characters // because I don't care about Arabic, I will hard-code the Hebrew @@ -1860,7 +1860,7 @@ static int vim_regsub_both(char *source, typval_T *expr, char *dest, int destlen no = 0; } else if ('0' <= *src && *src <= '9') { no = *src++ - '0'; - } else if (vim_strchr("uUlLeE", *src)) { + } else if (vim_strchr("uUlLeE", (uint8_t)(*src))) { switch (*src++) { case 'u': func_one = (fptr_T)do_upper; @@ -2497,9 +2497,9 @@ bool vim_regexec(regmatch_T *rmp, char *line, colnr_T col) // Like vim_regexec(), but consider a "\n" in "line" to be a line break. // Note: "rmp->regprog" may be freed and changed. // Return true if there is a match, false if not. -bool vim_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col) +bool vim_regexec_nl(regmatch_T *rmp, char *line, colnr_T col) { - return vim_regexec_string(rmp, line, col, true); + return vim_regexec_string(rmp, (char_u *)line, col, true); } /// Match a regexp against multiple lines. diff --git a/src/nvim/regexp_bt.c b/src/nvim/regexp_bt.c index f930d872b6..a047c51145 100644 --- a/src/nvim/regexp_bt.c +++ b/src/nvim/regexp_bt.c @@ -2165,7 +2165,7 @@ collection: endc = get_coll_element(®parse); } if (endc == 0) { - endc = mb_ptr2char_adv((const char_u **)®parse); + endc = mb_ptr2char_adv((const char **)®parse); } // Handle \o40, \x20 and \u20AC style sequences @@ -2197,10 +2197,10 @@ collection: // accepts "\t", "\e", etc., but only when the 'l' flag in // 'cpoptions' is not included. else if (*regparse == '\\' - && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL + && (vim_strchr(REGEXP_INRANGE, (uint8_t)regparse[1]) != NULL || (!reg_cpo_lit && vim_strchr(REGEXP_ABBR, - regparse[1]) != NULL))) { + (uint8_t)regparse[1]) != NULL))) { regparse++; if (*regparse == 'n') { // '\n' in range: also match NL diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 6e7ff31c03..66a31f0184 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -2363,9 +2363,9 @@ collection: // 'cpoptions' is not included. if (*regparse == '\\' && (char_u *)regparse + 1 <= endp - && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL + && (vim_strchr(REGEXP_INRANGE, (uint8_t)regparse[1]) != NULL || (!reg_cpo_lit - && vim_strchr(REGEXP_ABBR, regparse[1]) + && vim_strchr(REGEXP_ABBR, (uint8_t)regparse[1]) != NULL))) { MB_PTR_ADV(regparse); diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 6a3103123b..0b6b1d9e77 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -815,15 +815,15 @@ int number_width(win_T *wp) /// Calls mb_cptr2char_adv(p) and returns the character. /// If "p" starts with "\x", "\u" or "\U" the hex or unicode value is used. /// Returns 0 for invalid hex or invalid UTF-8 byte. -static int get_encoded_char_adv(const char_u **p) +static int get_encoded_char_adv(const char **p) { - const char *s = (const char *)(*p); + const char *s = *p; if (s[0] == '\\' && (s[1] == 'x' || s[1] == 'u' || s[1] == 'U')) { int64_t num = 0; for (int bytes = s[1] == 'x' ? 1 : s[1] == 'u' ? 2 : 4; bytes > 0; bytes--) { *p += 2; - int n = hexhex2nr((char *)(*p)); + int n = hexhex2nr(*p); if (n < 0) { return 0; } @@ -952,7 +952,7 @@ char *set_chars_option(win_T *wp, char **varp, bool apply) if (strncmp(p, tab[i].name, len) == 0 && p[len] == ':' && p[len + 1] != NUL) { - const char_u *s = (char_u *)p + len + 1; + const char *s = p + len + 1; int c1 = get_encoded_char_adv(&s); if (c1 == 0 || char2cells(c1) > 1) { return e_invarg; @@ -983,7 +983,7 @@ char *set_chars_option(win_T *wp, char **varp, bool apply) *(tab[i].cp) = c1; } } - p = (char *)s; + p = s; break; } } @@ -996,7 +996,7 @@ char *set_chars_option(win_T *wp, char **varp, bool apply) && strncmp(p, "multispace", len) == 0 && p[len] == ':' && p[len + 1] != NUL) { - const char_u *s = (char_u *)p + len + 1; + const char *s = p + len + 1; if (round == 0) { // Get length of lcs-multispace string in the first round last_multispace = p; @@ -1012,7 +1012,7 @@ char *set_chars_option(win_T *wp, char **varp, bool apply) // lcs-multispace cannot be an empty string return e_invarg; } - p = (char *)s; + p = s; } else { int multispace_pos = 0; while (*s != NUL && *s != ',') { @@ -1021,13 +1021,13 @@ char *set_chars_option(win_T *wp, char **varp, bool apply) wp->w_p_lcs_chars.multispace[multispace_pos++] = c1; } } - p = (char *)s; + p = s; } } else if (is_listchars && strncmp(p, "leadmultispace", len2) == 0 && p[len2] == ':' && p[len2 + 1] != NUL) { - const char_u *s = (char_u *)p + len2 + 1; + const char *s = p + len2 + 1; if (round == 0) { // get length of lcs-leadmultispace string in first round last_lmultispace = p; @@ -1043,7 +1043,7 @@ char *set_chars_option(win_T *wp, char **varp, bool apply) // lcs-leadmultispace cannot be an empty string return e_invarg; } - p = (char *)s; + p = s; } else { int multispace_pos = 0; while (*s != NUL && *s != ',') { @@ -1052,7 +1052,7 @@ char *set_chars_option(win_T *wp, char **varp, bool apply) wp->w_p_lcs_chars.leadmultispace[multispace_pos++] = c1; } } - p = (char *)s; + p = s; } } else { return e_invarg; diff --git a/src/nvim/search.c b/src/nvim/search.c index 205eec8b35..ea62a94f28 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -133,7 +133,7 @@ typedef struct SearchedFile { /// @param regmatch return: pattern and ignore-case flag /// /// @return FAIL if failed, OK otherwise. -int search_regcomp(char_u *pat, char_u **used_pat, int pat_save, int pat_use, int options, +int search_regcomp(char *pat, char **used_pat, int pat_save, int pat_use, int options, regmmatch_T *regmatch) { int magic; @@ -158,11 +158,11 @@ int search_regcomp(char_u *pat, char_u **used_pat, int pat_save, int pat_use, in rc_did_emsg = true; return FAIL; } - pat = (char_u *)spats[i].pat; + pat = spats[i].pat; magic = spats[i].magic; no_smartcase = spats[i].no_scs; } else if (options & SEARCH_HIS) { // put new pattern in history - add_to_history(HIST_SEARCH, (char *)pat, true, NUL); + add_to_history(HIST_SEARCH, pat, true, NUL); } if (used_pat) { @@ -171,9 +171,9 @@ int search_regcomp(char_u *pat, char_u **used_pat, int pat_save, int pat_use, in xfree(mr_pattern); if (curwin->w_p_rl && *curwin->w_p_rlc == 's') { - mr_pattern = reverse_text((char *)pat); + mr_pattern = reverse_text(pat); } else { - mr_pattern = xstrdup((char *)pat); + mr_pattern = xstrdup(pat); } // Save the currently used pattern in the appropriate place, @@ -181,17 +181,17 @@ int search_regcomp(char_u *pat, char_u **used_pat, int pat_save, int pat_use, in if (!(options & SEARCH_KEEP) && (cmdmod.cmod_flags & CMOD_KEEPPATTERNS) == 0) { // search or global command if (pat_save == RE_SEARCH || pat_save == RE_BOTH) { - save_re_pat(RE_SEARCH, (char *)pat, magic); + save_re_pat(RE_SEARCH, pat, magic); } // substitute or global command if (pat_save == RE_SUBST || pat_save == RE_BOTH) { - save_re_pat(RE_SUBST, (char *)pat, magic); + save_re_pat(RE_SUBST, pat, magic); } } - regmatch->rmm_ic = ignorecase((char *)pat); + regmatch->rmm_ic = ignorecase(pat); regmatch->rmm_maxcol = 0; - regmatch->regprog = vim_regcomp((char *)pat, magic ? RE_MAGIC : 0); + regmatch->regprog = vim_regcomp(pat, magic ? RE_MAGIC : 0); if (regmatch->regprog == NULL) { return FAIL; } @@ -346,9 +346,9 @@ static void restore_incsearch_state(void) search_match_lines = saved_search_match_lines; } -char_u *last_search_pattern(void) +char *last_search_pattern(void) { - return (char_u *)spats[RE_SEARCH].pat; + return spats[RE_SEARCH].pat; } /// Return true when case should be ignored for search pattern "pat". @@ -365,7 +365,7 @@ int ignorecase_opt(char *pat, int ic_in, int scs) if (ic && !no_smartcase && scs && !(ctrl_x_mode_not_default() && curbuf->b_p_inf)) { - ic = !pat_has_uppercase((char_u *)pat); + ic = !pat_has_uppercase(pat); } no_smartcase = false; @@ -373,14 +373,14 @@ int ignorecase_opt(char *pat, int ic_in, int scs) } /// Returns true if pattern `pat` has an uppercase character. -bool pat_has_uppercase(char_u *pat) +bool pat_has_uppercase(char *pat) FUNC_ATTR_NONNULL_ALL { - char *p = (char *)pat; + char *p = pat; magic_T magic_val = MAGIC_ON; // get the magicness of the pattern - (void)skip_regexp_ex((char *)pat, NUL, magic_isset(), NULL, NULL, &magic_val); + (void)skip_regexp_ex(pat, NUL, magic_isset(), NULL, NULL, &magic_val); while (*p != NUL) { const int l = utfc_ptr2len(p); @@ -431,7 +431,7 @@ int last_csearch_until(void) return last_t_cmd == true; } -void set_last_csearch(int c, char_u *s, int len) +void set_last_csearch(int c, char *s, int len) { *lastc = (char_u)c; lastc_bytelen = len; @@ -452,9 +452,9 @@ void set_csearch_until(int t_cmd) last_t_cmd = t_cmd; } -char_u *last_search_pat(void) +char *last_search_pat(void) { - return (char_u *)spats[last_idx].pat; + return spats[last_idx].pat; } // Reset search direction to forward. For "gd" and "gD" commands. @@ -466,14 +466,14 @@ void reset_search_dir(void) // Set the last search pattern. For ":let @/ =" and ShaDa file. // Also set the saved search pattern, so that this works in an autocommand. -void set_last_search_pat(const char_u *s, int idx, int magic, int setlast) +void set_last_search_pat(const char *s, int idx, int magic, int setlast) { free_spat(&spats[idx]); // An empty string means that nothing should be matched. if (*s == NUL) { spats[idx].pat = NULL; } else { - spats[idx].pat = xstrdup((char *)s); + spats[idx].pat = xstrdup(s); } spats[idx].timestamp = os_time(); spats[idx].additional_data = NULL; @@ -513,7 +513,7 @@ void last_pat_prog(regmmatch_T *regmatch) return; } emsg_off++; // So it doesn't beep if bad expr - (void)search_regcomp((char_u *)"", NULL, 0, last_idx, SEARCH_KEEP, regmatch); + (void)search_regcomp("", NULL, 0, last_idx, SEARCH_KEEP, regmatch); emsg_off--; } @@ -540,7 +540,7 @@ void last_pat_prog(regmmatch_T *regmatch) /// @returns FAIL (zero) for failure, non-zero for success. /// the index of the first matching /// subpattern plus one; one if there was none. -int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, char_u *pat, +int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, char *pat, long count, int options, int pat_use, searchit_arg_T *extra_arg) { int found; @@ -1296,7 +1296,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, long count, i } c = searchit(curwin, curbuf, &pos, NULL, dirc == '/' ? FORWARD : BACKWARD, - (char_u *)searchstr, count, + searchstr, count, (spats[0].off.end * SEARCH_END + (options & (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS + SEARCH_MSG @@ -2440,7 +2440,7 @@ int current_search(long count, bool forward) result = searchit(curwin, curbuf, &pos, &end_pos, (dir ? FORWARD : BACKWARD), - (char_u *)spats[last_idx].pat, i ? count : 1, + spats[last_idx].pat, i ? count : 1, SEARCH_KEEP | flags, RE_SEARCH, NULL); p_ws = old_p_ws; @@ -2527,7 +2527,7 @@ static int is_zero_width(char *pattern, int move, pos_T *cur, Direction directio pattern = spats[last_idx].pat; } - if (search_regcomp((char_u *)pattern, NULL, RE_SEARCH, RE_SEARCH, + if (search_regcomp(pattern, NULL, RE_SEARCH, RE_SEARCH, SEARCH_KEEP, ®match) == FAIL) { return -1; } @@ -2542,7 +2542,7 @@ static int is_zero_width(char *pattern, int move, pos_T *cur, Direction directio // accept a match at the cursor position flag = SEARCH_START; } - if (searchit(curwin, curbuf, &pos, NULL, direction, (char_u *)pattern, 1, + if (searchit(curwin, curbuf, &pos, NULL, direction, pattern, 1, SEARCH_KEEP + flag, RE_SEARCH, NULL) != FAIL) { // Zero-width pattern should match somewhere, then we can check if // start and end are in the same position. @@ -3637,8 +3637,8 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool 1L, p_fname); } else { // Use text after match with 'include'. - new_fname = (char *)file_name_in_line((char_u *)incl_regmatch.endp[0], 0, - FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, (char_u *)p_fname, + new_fname = (char *)file_name_in_line(incl_regmatch.endp[0], 0, + FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, p_fname, NULL); } already_searched = false; diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 48aed9c6de..c17fafd3d7 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -214,7 +214,7 @@ char *repl_to = NULL; /// /// @return the length of the word in bytes, also when it's OK, so that the /// caller can skip over the word. -size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docount) +size_t spell_check(win_T *wp, char *ptr, hlf_T *attrp, int *capcol, bool docount) { matchinf_T mi; // Most things are put in "mi" so that it can // be passed to functions quickly. @@ -226,7 +226,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou // A word never starts at a space or a control character. Return quickly // then, skipping over the character. - if (*ptr <= ' ') { + if ((uint8_t)(*ptr) <= ' ') { return 1; } @@ -242,18 +242,18 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou // julifeest". if (*ptr >= '0' && *ptr <= '9') { if (*ptr == '0' && (ptr[1] == 'b' || ptr[1] == 'B')) { - mi.mi_end = (char_u *)skipbin((char *)ptr + 2); + mi.mi_end = (char_u *)skipbin(ptr + 2); } else if (*ptr == '0' && (ptr[1] == 'x' || ptr[1] == 'X')) { - mi.mi_end = (char_u *)skiphex((char *)ptr + 2); + mi.mi_end = (char_u *)skiphex(ptr + 2); } else { - mi.mi_end = (char_u *)skipdigits((char *)ptr); + mi.mi_end = (char_u *)skipdigits(ptr); } - nrlen = (size_t)(mi.mi_end - ptr); + nrlen = (size_t)(mi.mi_end - (char_u *)ptr); } // Find the normal end of the word (until the next non-word character). - mi.mi_word = (char *)ptr; - mi.mi_fend = ptr; + mi.mi_word = ptr; + mi.mi_fend = (char_u *)ptr; if (spell_iswordp(mi.mi_fend, wp)) { bool this_upper = false; // init for gcc @@ -275,9 +275,9 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou if (capcol != NULL && *capcol == 0 && wp->w_s->b_cap_prog != NULL) { // Check word starting with capital letter. - int c = utf_ptr2char((char *)ptr); + int c = utf_ptr2char(ptr); if (!SPELL_ISUPPER(c)) { - wrongcaplen = (size_t)(mi.mi_fend - ptr); + wrongcaplen = (size_t)(mi.mi_fend - (char_u *)ptr); } } } @@ -300,7 +300,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou MB_PTR_ADV(mi.mi_fend); } - (void)spell_casefold(wp, ptr, (int)(mi.mi_fend - ptr), (char_u *)mi.mi_fword, + (void)spell_casefold(wp, (char_u *)ptr, (int)(mi.mi_fend - (char_u *)ptr), (char_u *)mi.mi_fword, MAXWLEN + 1); mi.mi_fwordlen = (int)strlen(mi.mi_fword); @@ -344,8 +344,8 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou // Count the word in the first language where it's found to be OK. if (count_word && mi.mi_result == SP_OK) { - count_common_word(mi.mi_lp->lp_slang, (char *)ptr, - (int)(mi.mi_end - ptr), 1); + count_common_word(mi.mi_lp->lp_slang, ptr, + (int)(mi.mi_end - (char_u *)ptr), 1); count_word = false; } } @@ -357,7 +357,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou if (mi.mi_result == SP_BAD || mi.mi_result == SP_BANNED) { return nrlen; } - } else if (!spell_iswordp_nmw(ptr, wp)) { + } else if (!spell_iswordp_nmw((char_u *)ptr, wp)) { // When we are at a non-word character there is no error, just // skip over the character (try looking for a word after it). if (capcol != NULL && wp->w_s->b_cap_prog != NULL) { @@ -366,15 +366,15 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou // Check for end of sentence. regmatch.regprog = wp->w_s->b_cap_prog; regmatch.rm_ic = false; - int r = vim_regexec(®match, (char *)ptr, 0); + int r = vim_regexec(®match, ptr, 0); wp->w_s->b_cap_prog = regmatch.regprog; if (r) { - *capcol = (int)(regmatch.endp[0] - (char *)ptr); + *capcol = (int)(regmatch.endp[0] - ptr); } } - return (size_t)(utfc_ptr2len((char *)ptr)); - } else if (mi.mi_end == ptr) { + return (size_t)(utfc_ptr2len(ptr)); + } else if (mi.mi_end == (char_u *)ptr) { // Always include at least one character. Required for when there // is a mixup in "midword". MB_PTR_ADV(mi.mi_end); @@ -421,7 +421,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou return wrongcaplen; } - return (size_t)(mi.mi_end - ptr); + return (size_t)(mi.mi_end - (char_u *)ptr); } // Check if the word at "mip->mi_word" is in the tree. @@ -1319,7 +1319,7 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att STRCPY(buf, line); if (lnum < wp->w_buffer->b_ml.ml_line_count) { spell_cat_line(buf + strlen(buf), - (char_u *)ml_get_buf(wp->w_buffer, lnum + 1, false), + ml_get_buf(wp->w_buffer, lnum + 1, false), MAXWLEN); } char *p = buf + skip; @@ -1336,7 +1336,7 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att // start of word attr = HLF_COUNT; - len = spell_check(wp, (char_u *)p, &attr, &capcol, false); + len = spell_check(wp, p, &attr, &capcol, false); if (attr != HLF_COUNT) { // We found a bad word. Check the attribute. @@ -1480,17 +1480,17 @@ theend: // "buf", blanking-out special characters. Copy less than "maxlen" bytes. // Keep the blanks at the start of the next line, this is used in win_line() // to skip those bytes if the word was OK. -void spell_cat_line(char *buf, char_u *line, int maxlen) +void spell_cat_line(char *buf, char *line, int maxlen) { - char_u *p = (char_u *)skipwhite((char *)line); - while (vim_strchr("*#/\"\t", *p) != NULL) { + char_u *p = (char_u *)skipwhite(line); + while (vim_strchr("*#/\"\t", (uint8_t)(*p)) != NULL) { p = (char_u *)skipwhite((char *)p + 1); } if (*p != NUL) { // Only worth concatenating if there is something else than spaces to // concatenate. - int n = (int)(p - line) + 1; + int n = (int)(p - (char_u *)line) + 1; if (n < maxlen - 1) { memset(buf, ' ', (size_t)n); xstrlcpy(buf + n, (char *)p, (size_t)(maxlen - n)); @@ -2213,24 +2213,24 @@ static int find_region(const char_u *rp, const char_u *region) int captype(char_u *word, const char_u *end) FUNC_ATTR_NONNULL_ARG(1) { - char_u *p; + char *p; // find first letter - for (p = word; !spell_iswordp_nmw(p, curwin); MB_PTR_ADV(p)) { - if (end == NULL ? *p == NUL : p >= end) { + for (p = (char *)word; !spell_iswordp_nmw((char_u *)p, curwin); MB_PTR_ADV(p)) { + if (end == NULL ? *p == NUL : (char_u *)p >= end) { return 0; // only non-word characters, illegal word } } - int c = mb_ptr2char_adv((const char_u **)&p); + int c = mb_ptr2char_adv((const char **)&p); bool allcap; bool firstcap = allcap = SPELL_ISUPPER(c); bool past_second = false; // past second word char // Need to check all letters to find a word with mixed upper/lower. // But a word with an upper char only at start is a ONECAP. - for (; end == NULL ? *p != NUL : p < end; MB_PTR_ADV(p)) { - if (spell_iswordp_nmw(p, curwin)) { - c = utf_ptr2char((char *)p); + for (; end == NULL ? *p != NUL : (char_u *)p < end; MB_PTR_ADV(p)) { + if (spell_iswordp_nmw((char_u *)p, curwin)) { + c = utf_ptr2char(p); if (!SPELL_ISUPPER(c)) { // UUl -> KEEPCAP if (past_second && allcap) { @@ -2482,18 +2482,18 @@ int spell_casefold(const win_T *wp, char_u *str, int len, char_u *buf, int bufle int outi = 0; // Fold one character at a time. - for (char_u *p = str; p < str + len;) { + for (char *p = (char *)str; (char_u *)p < str + len;) { if (outi + MB_MAXBYTES > buflen) { buf[outi] = NUL; return FAIL; } - int c = mb_cptr2char_adv((const char_u **)&p); + int c = mb_cptr2char_adv((const char **)&p); // Exception: greek capital sigma 0x03A3 folds to 0x03C3, except // when it is the last character in a word, then it folds to // 0x03C2. if (c == 0x03a3 || c == 0x03c2) { - if (p == str + len || !spell_iswordp(p, wp)) { + if (p == (char *)str + len || !spell_iswordp((char_u *)p, wp)) { c = 0x03c2; } else { c = 0x03c3; @@ -2636,15 +2636,15 @@ void ex_spellrepall(exarg_T *eap) /// @param[in] upper True to upper case, otherwise lower case void onecap_copy(char_u *word, char *wcopy, bool upper) { - char_u *p = word; - int c = mb_cptr2char_adv((const char_u **)&p); + char *p = (char *)word; + int c = mb_cptr2char_adv((const char **)&p); if (upper) { c = SPELL_TOUPPER(c); } else { c = SPELL_TOFOLD(c); } int l = utf_char2bytes(c, wcopy); - xstrlcpy(wcopy + l, (char *)p, (size_t)(MAXWLEN - l)); + xstrlcpy(wcopy + l, p, (size_t)(MAXWLEN - l)); } // Make a copy of "word" with all the letters upper cased into @@ -2652,8 +2652,8 @@ void onecap_copy(char_u *word, char *wcopy, bool upper) void allcap_copy(char_u *word, char_u *wcopy) { char_u *d = wcopy; - for (char_u *s = word; *s != NUL;) { - int c = mb_cptr2char_adv((const char_u **)&s); + for (char *s = (char *)word; *s != NUL;) { + int c = mb_cptr2char_adv((const char **)&s); if (c == 0xdf) { c = 'S'; @@ -2776,8 +2776,8 @@ static void spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res) // The sl_sal_first[] table contains the translation for chars up to // 255, sl_sal the rest. - for (char_u *s = inword; *s != NUL;) { - int c = mb_cptr2char_adv((const char_u **)&s); + for (char *s = (char *)inword; *s != NUL;) { + int c = mb_cptr2char_adv((const char **)&s); if (utf_class(c) == 0) { c = ' '; } else if (c < 256) { @@ -2837,8 +2837,8 @@ static void spell_soundfold_wsal(slang_T *slang, const char_u *inword, char_u *r // Remove accents, if wanted. We actually remove all non-word characters. // But keep white space. int wordlen = 0; - for (const char_u *s = inword; *s != NUL;) { - const char_u *t = s; + for (const char *s = (char *)inword; *s != NUL;) { + const char_u *t = (char_u *)s; int c = mb_cptr2char_adv(&s); if (slang->sl_rem_accents) { if (utf_class(c) == 0) { @@ -3524,11 +3524,11 @@ static linenr_T dump_prefixes(slang_T *slang, char *word, char_u *pat, Direction // Move "p" to the end of word "start". // Uses the spell-checking word characters. -char_u *spell_to_word_end(char_u *start, win_T *win) +char *spell_to_word_end(char *start, win_T *win) { - char_u *p = start; + char *p = start; - while (*p != NUL && spell_iswordp(p, win)) { + while (*p != NUL && spell_iswordp((char_u *)p, win)) { MB_PTR_ADV(p); } return p; diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index e6257aeca1..6f5bd836b1 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -1064,12 +1064,12 @@ static int read_region_section(FILE *fd, slang_T *lp, int len) // Return SP_*ERROR flags. static int read_charflags_section(FILE *fd) { - char_u *flags; + char *flags; char_u *fol; int flagslen, follen; // <charflagslen> <charflags> - flags = read_cnt_string(fd, 1, &flagslen); + flags = (char *)read_cnt_string(fd, 1, &flagslen); if (flagslen < 0) { return flagslen; } @@ -1083,7 +1083,7 @@ static int read_charflags_section(FILE *fd) // Set the word-char flags and fill SPELL_ISUPPER() table. if (flags != NULL && fol != NULL) { - set_spell_charflags(flags, flagslen, fol); + set_spell_charflags((char_u *)flags, flagslen, fol); } xfree(flags); @@ -1430,7 +1430,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len) return SP_TRUNCERROR; } todo -= 2; - ga_init(gap, sizeof(char_u *), c); + ga_init(gap, sizeof(char *), c); ga_grow(gap, c); while (--c >= 0) { ((char **)(gap->ga_data))[gap->ga_len++] = (char *)read_cnt_string(fd, 1, &cnt); @@ -1551,8 +1551,8 @@ static int read_compound(FILE *fd, slang_T *slang, int len) // Returns SP_*ERROR flags when there is something wrong. static int set_sofo(slang_T *lp, char_u *from, char_u *to) { - char_u *s; - char_u *p; + char *s; + char *p; // Use "sl_sal" as an array with 256 pointers to a list of wide // characters. The index is the low byte of the character. @@ -1566,8 +1566,8 @@ static int set_sofo(slang_T *lp, char_u *from, char_u *to) // First count the number of items for each list. Temporarily use // sl_sal_first[] for this. - for (p = from, s = to; *p != NUL && *s != NUL;) { - const int c = mb_cptr2char_adv((const char_u **)&p); + for (p = (char *)from, s = (char *)to; *p != NUL && *s != NUL;) { + const int c = mb_cptr2char_adv((const char **)&p); MB_CPTR_ADV(s); if (c >= 256) { lp->sl_sal_first[c & 0xff]++; @@ -1589,9 +1589,9 @@ static int set_sofo(slang_T *lp, char_u *from, char_u *to) // Put the characters up to 255 in sl_sal_first[] the rest in a sl_sal // list. memset(lp->sl_sal_first, 0, sizeof(salfirst_T) * 256); - for (p = from, s = to; *p != NUL && *s != NUL;) { - const int c = mb_cptr2char_adv((const char_u **)&p); - const int i = mb_cptr2char_adv((const char_u **)&s); + for (p = (char *)from, s = (char *)to; *p != NUL && *s != NUL;) { + const int c = mb_cptr2char_adv((const char **)&p); + const int i = mb_cptr2char_adv((const char **)&s); if (c >= 256) { // Append the from-to chars at the end of the list with // the low byte. @@ -1665,8 +1665,8 @@ static int *mb_str2wide(char_u *s) int i = 0; int *res = xmalloc(((size_t)mb_charlen((char *)s) + 1) * sizeof(int)); - for (char_u *p = s; *p != NUL;) { - res[i++] = mb_ptr2char_adv((const char_u **)&p); + for (char *p = (char *)s; *p != NUL;) { + res[i++] = mb_ptr2char_adv((const char **)&p); } res[i] = NUL; @@ -2608,7 +2608,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) } else if (is_aff_rule(items, itemcnt, "REP", 2) || is_aff_rule(items, itemcnt, "REPSAL", 2)) { // Ignore REP/REPSAL count - if (!isdigit(*items[1])) { + if (!isdigit((uint8_t)(*items[1]))) { smsg(_("Expected REP(SAL) count in %s line %d"), fname, lnum); } @@ -2643,7 +2643,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) if (!found_map) { // First line contains the count. found_map = true; - if (!isdigit(*items[1])) { + if (!isdigit((uint8_t)(*items[1]))) { smsg(_("Expected MAP count in %s line %d"), fname, lnum); } @@ -2652,7 +2652,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) // Check that every character appears only once. for (p = items[1]; *p != NUL;) { - c = mb_ptr2char_adv((const char_u **)&p); + c = mb_ptr2char_adv((const char **)&p); if ((!GA_EMPTY(&spin->si_map) && vim_strchr(spin->si_map.ga_data, c) != NULL) @@ -2802,18 +2802,18 @@ static bool is_aff_rule(char **items, int itemcnt, char *rulename, int mincount) // ae_flags to ae_comppermit and ae_compforbid. static void aff_process_flags(afffile_T *affile, affentry_T *entry) { - char_u *p; + char *p; char_u *prevp; unsigned flag; if (entry->ae_flags != NULL && (affile->af_compforbid != 0 || affile->af_comppermit != 0)) { - for (p = entry->ae_flags; *p != NUL;) { - prevp = p; + for (p = (char *)entry->ae_flags; *p != NUL;) { + prevp = (char_u *)p; flag = get_affitem(affile->af_flagtype, &p); if (flag == affile->af_comppermit || flag == affile->af_compforbid) { STRMOVE(prevp, (char *)p); - p = prevp; + p = (char *)prevp; if (flag == affile->af_comppermit) { entry->ae_comppermit = true; } else { @@ -2846,7 +2846,7 @@ static bool spell_info_item(char *s) static unsigned affitem2flag(int flagtype, char_u *item, char_u *fname, int lnum) { unsigned res; - char_u *p = item; + char *p = (char *)item; res = get_affitem(flagtype, &p); if (res == 0) { @@ -2869,7 +2869,7 @@ static unsigned affitem2flag(int flagtype, char_u *item, char_u *fname, int lnum // Get one affix name from "*pp" and advance the pointer. // Returns ZERO_FLAG for "0". // Returns zero for an error, still advances the pointer then. -static unsigned get_affitem(int flagtype, char_u **pp) +static unsigned get_affitem(int flagtype, char **pp) { int res; @@ -2878,18 +2878,18 @@ static unsigned get_affitem(int flagtype, char_u **pp) (*pp)++; // always advance, avoid getting stuck return 0; } - res = getdigits_int((char **)pp, true, 0); + res = getdigits_int(pp, true, 0); if (res == 0) { res = ZERO_FLAG; } } else { - res = mb_ptr2char_adv((const char_u **)pp); + res = mb_ptr2char_adv((const char **)pp); if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG && res >= 'A' && res <= 'Z')) { if (**pp == NUL) { return 0; } - res = mb_ptr2char_adv((const char_u **)pp) + (res << 16); + res = mb_ptr2char_adv((const char **)pp) + (res << 16); } } return (unsigned)res; @@ -2927,13 +2927,13 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char *compflags tp = (char_u *)p + strlen(p); for (p = compflags; *p != NUL;) { - if (vim_strchr("/?*+[]", *p) != NULL) { + if (vim_strchr("/?*+[]", (uint8_t)(*p)) != NULL) { // Copy non-flag characters directly. *tp++ = (char_u)(*p++); } else { // First get the flag number, also checks validity. prevp = p; - flag = get_affitem(aff->af_flagtype, (char_u **)&p); + flag = get_affitem(aff->af_flagtype, &p); if (flag != 0) { // Find the flag in the hashtable. If it was used before, use // the existing ID. Otherwise add a new entry. @@ -2990,10 +2990,10 @@ static bool flag_in_afflist(int flagtype, char_u *afflist, unsigned flag) case AFT_CAPLONG: case AFT_LONG: for (p = (char *)afflist; *p != NUL;) { - n = (unsigned)mb_ptr2char_adv((const char_u **)&p); + n = (unsigned)mb_ptr2char_adv((const char **)&p); if ((flagtype == AFT_LONG || (n >= 'A' && n <= 'Z')) && *p != NUL) { - n = (unsigned)mb_ptr2char_adv((const char_u **)&p) + (n << 16); + n = (unsigned)mb_ptr2char_adv((const char **)&p) + (n << 16); } if (n == flag) { return true; @@ -3266,7 +3266,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile) if (spin->si_compflags != NULL) { // Need to store the list of compound flags with the word. // Concatenate them to the list of prefix IDs. - get_compflags(affile, afflist, store_afflist + pfxlen); + get_compflags(affile, (char *)afflist, store_afflist + pfxlen); } } @@ -3352,19 +3352,19 @@ static int get_affix_flags(afffile_T *affile, char_u *afflist) // and return the number of affixes. static int get_pfxlist(afffile_T *affile, char_u *afflist, char_u *store_afflist) { - char_u *p; + char *p; char *prevp; int cnt = 0; int id; char key[AH_KEY_LEN]; hashitem_T *hi; - for (p = afflist; *p != NUL;) { - prevp = (char *)p; + for (p = (char *)afflist; *p != NUL;) { + prevp = p; if (get_affitem(affile->af_flagtype, &p) != 0) { // A flag is a postponed prefix flag if it appears in "af_pref" // and its ID is not zero. - xstrlcpy(key, prevp, (size_t)(p - (char_u *)prevp) + 1); + xstrlcpy(key, prevp, (size_t)(p - prevp) + 1); hi = hash_find(&affile->af_pref, (char *)key); if (!HASHITEM_EMPTY(hi)) { id = HI2AH(hi)->ah_newID; @@ -3385,19 +3385,19 @@ static int get_pfxlist(afffile_T *affile, char_u *afflist, char_u *store_afflist // Get the list of compound IDs from the affix list "afflist" that are used // for compound words. // Puts the flags in "store_afflist[]". -static void get_compflags(afffile_T *affile, char_u *afflist, char_u *store_afflist) +static void get_compflags(afffile_T *affile, char *afflist, char_u *store_afflist) { - char_u *p; + char *p; char *prevp; int cnt = 0; char key[AH_KEY_LEN]; hashitem_T *hi; for (p = afflist; *p != NUL;) { - prevp = (char *)p; + prevp = p; if (get_affitem(affile->af_flagtype, &p) != 0) { // A flag is a compound flag if it appears in "af_comp". - xstrlcpy(key, prevp, (size_t)(p - (char_u *)prevp) + 1); + xstrlcpy(key, prevp, (size_t)(p - prevp) + 1); hi = hash_find(&affile->af_comp, (char *)key); if (!HASHITEM_EMPTY(hi)) { store_afflist[cnt++] = (char_u)HI2CI(hi)->ci_newID; @@ -3437,7 +3437,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char_u *afflist, afffil char newword[MAXWLEN]; int retval = OK; int i, j; - char_u *p; + char *p; int use_flags; char *use_pfxlist; int use_pfxlen; @@ -3490,7 +3490,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char_u *afflist, afffil } else { xstrlcpy(newword, ae->ae_add, MAXWLEN); } - p = (char_u *)word; + p = word; if (ae->ae_chop != NULL) { // Skip chop string. i = mb_charlen(ae->ae_chop); @@ -3504,7 +3504,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char_u *afflist, afffil xstrlcpy(newword, word, MAXWLEN); if (ae->ae_chop != NULL) { // Remove chop string. - p = (char_u *)newword + strlen(newword); + p = newword + strlen(newword); i = mb_charlen(ae->ae_chop); for (; i > 0; i--) { MB_PTR_BACK(newword, p); @@ -3567,7 +3567,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char_u *afflist, afffil if (spin->si_compflags != NULL) { // Get compound IDS from the affix list. - get_compflags(affile, ae->ae_flags, + get_compflags(affile, (char *)ae->ae_flags, (char_u *)use_pfxlist + use_pfxlen); } else { use_pfxlist[use_pfxlen] = NUL; @@ -5702,7 +5702,7 @@ static void init_spellfile(void) // Find the end of the language name. Exclude the region. If there // is a path separator remember the start of the tail. for (lend = (char_u *)curwin->w_s->b_p_spl; *lend != NUL - && vim_strchr(",._", *lend) == NULL; lend++) { + && vim_strchr(",._", (uint8_t)(*lend)) == NULL; lend++) { if (vim_ispathsep(*lend)) { aspath = true; lstart = lend + 1; @@ -5765,7 +5765,7 @@ static void set_spell_charflags(const char_u *flags, int cnt, char_u *fol) // previous one. spelltab_T new_st; int i; - char_u *p = fol; + char *p = (char *)fol; int c; clear_spell_chartab(&new_st); @@ -5777,7 +5777,7 @@ static void set_spell_charflags(const char_u *flags, int cnt, char_u *fol) } if (*p != NUL) { - c = mb_ptr2char_adv((const char_u **)&p); + c = mb_ptr2char_adv((const char **)&p); new_st.st_fold[i + 128] = (char_u)c; if (i + 128 != c && new_st.st_isu[i + 128] && c < 256) { new_st.st_upper[c] = (char_u)(i + 128); @@ -5845,7 +5845,7 @@ static int write_spell_prefcond(FILE *fd, garray_T *gap, size_t *fwv) // Use map string "map" for languages "lp". static void set_map_str(slang_T *lp, char_u *map) { - char_u *p; + char *p; int headc = 0; int c; int i; @@ -5865,8 +5865,8 @@ static void set_map_str(slang_T *lp, char_u *map) // The similar characters are stored separated with slashes: // "aaa/bbb/ccc/". Fill sl_map_array[c] with the character before c and // before the same slash. For characters above 255 sl_map_hash is used. - for (p = map; *p != NUL;) { - c = mb_cptr2char_adv((const char_u **)&p); + for (p = (char *)map; *p != NUL;) { + c = mb_cptr2char_adv((const char **)&p); if (c == '/') { headc = 0; } else { diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index 0b18958af3..c2888b3945 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -738,7 +738,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma if (badlen != 0) { su->su_badlen = badlen; } else { - size_t tmplen = spell_check(curwin, (char_u *)su->su_badptr, &attr, NULL, false); + size_t tmplen = spell_check(curwin, su->su_badptr, &attr, NULL, false); assert(tmplen <= INT_MAX); su->su_badlen = (int)tmplen; } @@ -3225,7 +3225,7 @@ static void check_suggestions(suginfo_T *su, garray_T *gap) xstrlcpy(longword + len, su->su_badptr + stp[i].st_orglen, (size_t)(MAXWLEN - len + 1)); attr = HLF_COUNT; - (void)spell_check(curwin, (char_u *)longword, &attr, NULL, false); + (void)spell_check(curwin, longword, &attr, NULL, false); if (attr != HLF_COUNT) { // Remove this entry. xfree(stp[i].st_word); @@ -3585,12 +3585,12 @@ static int spell_edit_score(slang_T *slang, const char_u *badword, const char_u // Get the characters from the multi-byte strings and put them in an // int array for easy access. badlen = 0; - for (const char_u *p = badword; *p != NUL;) { + for (const char *p = (char *)badword; *p != NUL;) { wbadword[badlen++] = mb_cptr2char_adv(&p); } wbadword[badlen++] = 0; goodlen = 0; - for (const char_u *p = goodword; *p != NUL;) { + for (const char *p = (char *)goodword; *p != NUL;) { wgoodword[goodlen++] = mb_cptr2char_adv(&p); } wgoodword[goodlen++] = 0; @@ -3691,12 +3691,12 @@ static int spell_edit_score_limit_w(slang_T *slang, const char_u *badword, const // Get the characters from the multi-byte strings and put them in an // int array for easy access. bi = 0; - for (const char_u *p = badword; *p != NUL;) { + for (const char *p = (char *)badword; *p != NUL;) { wbadword[bi++] = mb_cptr2char_adv(&p); } wbadword[bi++] = 0; gi = 0; - for (const char_u *p = goodword; *p != NUL;) { + for (const char *p = (char *)goodword; *p != NUL;) { wgoodword[gi++] = mb_cptr2char_adv(&p); } wgoodword[gi++] = 0; diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index e0c531859c..46cd600d81 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1368,7 +1368,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // An invalid item was specified. // Continue processing on the next character of the format string. - if (vim_strchr(STL_ALL, *fmt_p) == NULL) { + if (vim_strchr(STL_ALL, (uint8_t)(*fmt_p)) == NULL) { fmt_p++; continue; } @@ -1682,7 +1682,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n vim_snprintf(buf_tmp, sizeof(buf_tmp), ",%s", wp->w_buffer->b_p_ft); // Uppercase the file extension for (char *t = buf_tmp; *t != 0; t++) { - *t = (char)TOUPPER_LOC(*t); + *t = (char)TOUPPER_LOC((uint8_t)(*t)); } str = buf_tmp; } diff --git a/src/nvim/strings.c b/src/nvim/strings.c index f0f9fbf51b..53b4d7082b 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -372,7 +372,7 @@ int vim_stricmp(const char *s1, const char *s2) int i; for (;;) { - i = (int)TOLOWER_LOC(*s1) - (int)TOLOWER_LOC(*s2); + i = (int)TOLOWER_LOC((uint8_t)(*s1)) - (int)TOLOWER_LOC((uint8_t)(*s2)); if (i != 0) { return i; // this character different } @@ -396,7 +396,7 @@ int vim_strnicmp(const char *s1, const char *s2, size_t len) int i; while (len > 0) { - i = (int)TOLOWER_LOC(*s1) - (int)TOLOWER_LOC(*s2); + i = (int)TOLOWER_LOC((uint8_t)(*s1)) - (int)TOLOWER_LOC((uint8_t)(*s2)); if (i != 0) { return i; // this character different } diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 721cc7707a..f18f445867 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -3524,7 +3524,7 @@ static void put_pattern(const char *const s, const int c, const synpat_T *const msg_putchar(c); // output the pattern, in between a char that is not in the pattern - for (i = 0; vim_strchr(spp->sp_pattern, sepchars[i]) != NULL;) { + for (i = 0; vim_strchr(spp->sp_pattern, (uint8_t)sepchars[i]) != NULL;) { if (sepchars[++i] == NUL) { i = 0; // no good char found, just use the first one break; @@ -4000,7 +4000,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing) // filename to include. eap->argt |= (EX_XFILE | EX_NOSPC); separate_nextcmd(eap); - if (*eap->arg == '<' || *eap->arg == '$' || path_is_absolute((char_u *)eap->arg)) { + if (*eap->arg == '<' || *eap->arg == '$' || path_is_absolute(eap->arg)) { // For an absolute path, "$VIM/..." or "<sfile>.." we ":source" the // file. Need to expand the file name first. In other cases // ":runtime!" is used. diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 73aa6eb9ca..75a2849fbd 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1019,7 +1019,7 @@ static int add_llist_tags(char *tag, int num_matches, char **matches) // Get the line number or the search pattern used to locate // the tag. lnum = 0; - if (isdigit(*tagp.command)) { + if (isdigit((uint8_t)(*tagp.command))) { // Line number is used to locate the tag lnum = atol(tagp.command); } else { @@ -1199,7 +1199,7 @@ static void prepare_pats(pat_T *pats, int has_re) } else { for (pats->headlen = 0; pats->head[pats->headlen] != NUL; pats->headlen++) { if (vim_strchr(magic_isset() ? ".[~*\\$" : "\\$", - pats->head[pats->headlen]) != NULL) { + (uint8_t)pats->head[pats->headlen]) != NULL) { break; } } diff --git a/src/nvim/testing.c b/src/nvim/testing.c index edb24c6dc5..e9bad2a0b3 100644 --- a/src/nvim/testing.c +++ b/src/nvim/testing.c @@ -119,10 +119,10 @@ static void ga_concat_shorten_esc(garray_T *gap, const char_u *str) for (const char_u *p = str; *p != NUL; p++) { int same_len = 1; - const char_u *s = p; + const char *s = (char *)p; const int c = mb_ptr2char_adv(&s); - const int clen = (int)(s - p); - while (*s != NUL && c == utf_ptr2char((char *)s)) { + const int clen = (int)((char_u *)s - p); + while (*s != NUL && c == utf_ptr2char(s)) { same_len++; s += clen; } @@ -133,7 +133,7 @@ static void ga_concat_shorten_esc(garray_T *gap, const char_u *str) vim_snprintf((char *)buf, NUMBUFLEN, "%d", same_len); ga_concat(gap, (char *)buf); ga_concat(gap, " times]"); - p = s - 1; + p = (char_u *)s - 1; } else { ga_concat_esc(gap, p, clen); } diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 85e261fc39..3e4aae62c9 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -1359,7 +1359,7 @@ theend: /// a bit more verbose. /// Otherwise use curbuf->b_ffname to generate the undo file name. /// "hash[UNDO_HASH_SIZE]" must be the hash value of the buffer text. -void u_read_undo(char *name, const char_u *hash, const char_u *orig_name FUNC_ATTR_UNUSED) +void u_read_undo(char *name, const char_u *hash, const char *orig_name FUNC_ATTR_UNUSED) FUNC_ATTR_NONNULL_ARG(2) { u_header_T **uhp_table = NULL; @@ -1377,7 +1377,7 @@ void u_read_undo(char *name, const char_u *hash, const char_u *orig_name FUNC_AT // owner of the text file or equal to the current user. FileInfo file_info_orig; FileInfo file_info_undo; - if (os_fileinfo((const char *)orig_name, &file_info_orig) + if (os_fileinfo(orig_name, &file_info_orig) && os_fileinfo(file_name, &file_info_undo) && file_info_orig.stat.st_uid != file_info_undo.stat.st_uid && file_info_undo.stat.st_uid != getuid()) { diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c index 9c4fdd4ead..a8e4603aa2 100644 --- a/src/nvim/usercmd.c +++ b/src/nvim/usercmd.c @@ -1424,7 +1424,7 @@ static size_t uc_check_code(char *code, size_t len, char *buf, ucmd_T *cmd, exar ct_NONE, } type = ct_NONE; - if ((vim_strchr("qQfF", *p) != NULL) && p[1] == '-') { + if ((vim_strchr("qQfF", (uint8_t)(*p)) != NULL) && p[1] == '-') { quote = (*p == 'q' || *p == 'Q') ? 1 : 2; p += 2; l -= 2; diff --git a/src/nvim/window.c b/src/nvim/window.c index 627d418a55..f16e9b8436 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -6767,7 +6767,7 @@ char_u *grab_file_name(long count, linenr_T *file_lnum) return NULL; } // Only recognize ":123" here - if (file_lnum != NULL && ptr[len] == ':' && isdigit(ptr[len + 1])) { + if (file_lnum != NULL && ptr[len] == ':' && isdigit((uint8_t)ptr[len + 1])) { char *p = ptr + len + 1; *file_lnum = (linenr_T)getdigits_long(&p, false, 0); @@ -6790,8 +6790,8 @@ char_u *grab_file_name(long count, linenr_T *file_lnum) // FNAME_INCL apply "includeexpr" char_u *file_name_at_cursor(int options, long count, linenr_T *file_lnum) { - return file_name_in_line((char_u *)get_cursor_line_ptr(), - curwin->w_cursor.col, options, count, (char_u *)curbuf->b_ffname, + return file_name_in_line(get_cursor_line_ptr(), + curwin->w_cursor.col, options, count, curbuf->b_ffname, file_lnum); } @@ -6799,11 +6799,11 @@ char_u *file_name_at_cursor(int options, long count, linenr_T *file_lnum) /// @param file_lnum line number after the file name /// /// @return the name of the file under or after ptr[col]. Otherwise like file_name_at_cursor(). -char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u *rel_fname, +char_u *file_name_in_line(char *line, int col, int options, long count, char *rel_fname, linenr_T *file_lnum) { // search forward for what could be the start of a file name - char *ptr = (char *)line + col; + char *ptr = line + col; while (*ptr != NUL && !vim_isfilec((uint8_t)(*ptr))) { MB_PTR_ADV(ptr); } @@ -6820,8 +6820,8 @@ char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u // Search backward for first char of the file name. // Go one char back to ":" before "//" even when ':' is not in 'isfname'. - while ((char_u *)ptr > line) { - if ((len = (size_t)(utf_head_off((char *)line, ptr - 1))) > 0) { + while (ptr > line) { + if ((len = (size_t)(utf_head_off(line, ptr - 1))) > 0) { ptr -= len + 1; } else if (vim_isfilec((uint8_t)ptr[-1]) || ((options & FNAME_HYP) && path_is_url(ptr - 1))) { @@ -6836,7 +6836,7 @@ char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u len = 0; while (vim_isfilec((uint8_t)ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ') || ((options & FNAME_HYP) && path_is_url(ptr + len)) - || (is_url && vim_strchr(":?&=", ptr[len]) != NULL)) { + || (is_url && vim_strchr(":?&=", (uint8_t)ptr[len]) != NULL)) { // After type:// we also include :, ?, & and = as valid characters, so that // http://google.com:8080?q=this&that=ok works. if ((ptr[len] >= 'A' && ptr[len] <= 'Z') @@ -6857,7 +6857,7 @@ char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u // If there is trailing punctuation, remove it. // But don't remove "..", could be a directory name. - if (len > 2 && vim_strchr(".,:;!", ptr[len - 1]) != NULL + if (len > 2 && vim_strchr(".,:;!", (uint8_t)ptr[len - 1]) != NULL && ptr[len - 2] != '.') { len--; } @@ -6878,17 +6878,17 @@ char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u p = skipwhite(p); } if (*p != NUL) { - if (!isdigit(*p)) { + if (!isdigit((uint8_t)(*p))) { p++; // skip the separator } p = skipwhite(p); - if (isdigit(*p)) { + if (isdigit((uint8_t)(*p))) { *file_lnum = (linenr_T)getdigits_long(&p, false, 0); } } } - return (char_u *)find_file_name_in_path(ptr, len, options, count, (char *)rel_fname); + return (char_u *)find_file_name_in_path(ptr, len, options, count, rel_fname); } /// Add or remove a status line from window(s), according to the |