diff options
Diffstat (limited to 'src')
65 files changed, 617 insertions, 661 deletions
diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index 506b3e7f10..42101af7f0 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -1058,7 +1058,7 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error if (p != NULL && ea.cmdidx == CMD_SIZE && ASCII_ISUPPER(*ea.cmd) && has_event(EVENT_CMDUNDEFINED)) { p = xstrdup(cmdname); - int ret = apply_autocmds(EVENT_CMDUNDEFINED, (char_u *)p, (char_u *)p, true, NULL); + int ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, true, NULL); xfree(p); // If the autocommands did something and didn't cause an error, try // finding the command again. diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 6699379ca9..6c7950fdd1 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -796,13 +796,13 @@ void do_autocmd(char *arg_in, int forceit) // Expand environment variables in the pattern. Set 'shellslash', we want // forward slashes here. - if (vim_strchr((char_u *)pat, '$') != NULL || vim_strchr((char_u *)pat, '~') != NULL) { + if (vim_strchr(pat, '$') != NULL || vim_strchr(pat, '~') != NULL) { #ifdef BACKSLASH_IN_FILENAME int p_ssl_save = p_ssl; p_ssl = true; #endif - envpat = (char *)expand_env_save((char_u *)pat); + envpat = expand_env_save(pat); #ifdef BACKSLASH_IN_FILENAME p_ssl = p_ssl_save; #endif @@ -1070,10 +1070,9 @@ int autocmd_register(int64_t id, event_T event, char *pat, int patlen, int group char *reg_pat; ap->buflocal_nr = 0; - reg_pat = (char *)file_pat_to_reg_pat((char_u *)pat, (char_u *)pat + patlen, &ap->allow_dirs, - true); + reg_pat = file_pat_to_reg_pat(pat, pat + patlen, &ap->allow_dirs, true); if (reg_pat != NULL) { - ap->reg_prog = vim_regcomp((char_u *)reg_pat, RE_MAGIC); + ap->reg_prog = vim_regcomp(reg_pat, RE_MAGIC); } xfree(reg_pat); if (reg_pat == NULL || ap->reg_prog == NULL) { @@ -1241,8 +1240,8 @@ void ex_doautoall(exarg_T *eap) { int retval = OK; aco_save_T aco; - char_u *arg = (char_u *)eap->arg; - int call_do_modelines = check_nomodeline((char **)&arg); + char *arg = eap->arg; + int call_do_modelines = check_nomodeline(&arg); bufref_T bufref; bool did_aucmd; @@ -1261,7 +1260,7 @@ void ex_doautoall(exarg_T *eap) set_bufref(&bufref, buf); // execute the autocommands for this buffer - retval = do_doautocmd((char *)arg, false, &did_aucmd); + retval = do_doautocmd(arg, false, &did_aucmd); if (call_do_modelines && did_aucmd) { // Execute the modeline settings, but don't set window-local @@ -1282,7 +1281,7 @@ void ex_doautoall(exarg_T *eap) // Execute autocommands for the current buffer last. if (retval == OK) { - (void)do_doautocmd((char *)arg, false, &did_aucmd); + (void)do_doautocmd(arg, false, &did_aucmd); if (call_do_modelines && did_aucmd) { do_modelines(0); } @@ -1364,7 +1363,7 @@ void aucmd_prepbuf(aco_save_T *aco, buf_T *buf) // Make sure w_localdir and globaldir are NULL to avoid a chdir() in // win_enter_ext(). XFREE_CLEAR(aucmd_win->w_localdir); - aco->globaldir = (char *)globaldir; + aco->globaldir = globaldir; globaldir = NULL; block_autocmds(); // We don't want BufEnter/WinEnter autocommands. @@ -1451,7 +1450,7 @@ win_found: hash_init(&aucmd_win->w_vars->dv_hashtab); // re-use the hashtab xfree(globaldir); - globaldir = (char_u *)aco->globaldir; + globaldir = aco->globaldir; // the buffer contents may have changed check_cursor(); @@ -1504,10 +1503,9 @@ win_found: /// @param buf Buffer for <abuf> /// /// @return true if some commands were executed. -bool apply_autocmds(event_T event, char_u *fname, char_u *fname_io, bool force, buf_T *buf) +bool apply_autocmds(event_T event, char *fname, char *fname_io, bool force, buf_T *buf) { - return apply_autocmds_group(event, (char *)fname, (char *)fname_io, force, AUGROUP_ALL, buf, - NULL); + return apply_autocmds_group(event, fname, fname_io, force, AUGROUP_ALL, buf, NULL); } /// Like apply_autocmds(), but with extra "eap" argument. This takes care of diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 18c8a2c250..4b1aea5720 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -112,7 +112,7 @@ static int read_buffer(int read_stdin, exarg_T *eap, int flags) // 'fileencoding' was guessed wrong. line_count = curbuf->b_ml.ml_line_count; retval = readfile(read_stdin ? NULL : (char *)curbuf->b_ffname, - read_stdin ? NULL : (char *)curbuf->b_fname, + read_stdin ? NULL : curbuf->b_fname, line_count, (linenr_T)0, (linenr_T)MAXLNUM, eap, flags | READ_BUFFER, silent); if (retval == OK) { @@ -229,7 +229,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags) } #endif - retval = readfile((char *)curbuf->b_ffname, (char *)curbuf->b_fname, + retval = readfile((char *)curbuf->b_ffname, curbuf->b_fname, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, eap, flags | READ_NEW | (read_fifo ? READ_FIFO : 0), silent); #ifdef UNIX @@ -1219,8 +1219,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit) return FAIL; } } else { - semsg(_("E89: %s will be killed (add ! to override)"), - (char *)buf->b_fname); + semsg(_("E89: %s will be killed (add ! to override)"), buf->b_fname); return FAIL; } } @@ -1803,7 +1802,7 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int fl hash_init(&buf->b_s.b_keywtab); hash_init(&buf->b_s.b_keywtab_ic); - buf->b_fname = buf->b_sfname; + buf->b_fname = (char *)buf->b_sfname; if (!file_id_valid) { buf->file_id_valid = false; } else { @@ -2113,10 +2112,10 @@ int buflist_findpat(const char_u *pattern, const char_u *pattern_end, bool unlis { int match = -1; int find_listed; - char_u *pat; - char_u *patend; + char *pat; + char *patend; int attempt; - char_u *p; + char *p; int toggledollar; if (pattern_end == pattern + 1 && (*pattern == '%' || *pattern == '#')) { @@ -2138,7 +2137,7 @@ int buflist_findpat(const char_u *pattern, const char_u *pattern_end, bool unlis // Repeat this for finding an unlisted buffer if there was no matching // listed buffer. - pat = file_pat_to_reg_pat(pattern, pattern_end, NULL, false); + pat = file_pat_to_reg_pat((char *)pattern, (char *)pattern_end, NULL, false); if (pat == NULL) { return -1; } @@ -2271,7 +2270,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options) } regmatch_T regmatch; - regmatch.regprog = vim_regcomp(patc + attempt * 11, RE_MAGIC); + regmatch.regprog = vim_regcomp((char *)patc + attempt * 11, RE_MAGIC); if (regmatch.regprog == NULL) { if (patc != pat) { xfree(patc); @@ -2426,7 +2425,7 @@ char_u *buflist_nr2name(int n, int fullname, int helptail) return NULL; } return home_replace_save(helptail ? buf : NULL, - fullname ? buf->b_ffname : buf->b_fname); + fullname ? buf->b_ffname : (char_u *)buf->b_fname); } /// Set the line and column numbers for the given buffer and window @@ -2622,7 +2621,7 @@ void buflist_list(exarg_T *eap) garray_T buflist; buf_T **buflist_data = NULL; - if (vim_strchr((char_u *)eap->arg, 't')) { + if (vim_strchr(eap->arg, 't')) { ga_init(&buflist, sizeof(buf_T *), 50); for (buf = firstbuf; buf != NULL; buf = buf->b_next) { ga_grow(&buflist, 1); @@ -2645,28 +2644,28 @@ void buflist_list(exarg_T *eap) const bool job_running = buf->terminal && terminal_running(buf->terminal); // skip unspecified buffers - if ((!buf->b_p_bl && !eap->forceit && !vim_strchr((char_u *)eap->arg, 'u')) - || (vim_strchr((char_u *)eap->arg, 'u') && buf->b_p_bl) - || (vim_strchr((char_u *)eap->arg, '+') + if ((!buf->b_p_bl && !eap->forceit && !vim_strchr(eap->arg, 'u')) + || (vim_strchr(eap->arg, 'u') && buf->b_p_bl) + || (vim_strchr(eap->arg, '+') && ((buf->b_flags & BF_READERR) || !bufIsChanged(buf))) - || (vim_strchr((char_u *)eap->arg, 'a') + || (vim_strchr(eap->arg, 'a') && (buf->b_ml.ml_mfp == NULL || buf->b_nwindows == 0)) - || (vim_strchr((char_u *)eap->arg, 'h') + || (vim_strchr(eap->arg, 'h') && (buf->b_ml.ml_mfp == NULL || buf->b_nwindows != 0)) - || (vim_strchr((char_u *)eap->arg, 'R') && (!is_terminal || !job_running)) - || (vim_strchr((char_u *)eap->arg, 'F') && (!is_terminal || job_running)) - || (vim_strchr((char_u *)eap->arg, '-') && buf->b_p_ma) - || (vim_strchr((char_u *)eap->arg, '=') && !buf->b_p_ro) - || (vim_strchr((char_u *)eap->arg, 'x') && !(buf->b_flags & BF_READERR)) - || (vim_strchr((char_u *)eap->arg, '%') && buf != curbuf) - || (vim_strchr((char_u *)eap->arg, '#') + || (vim_strchr(eap->arg, 'R') && (!is_terminal || !job_running)) + || (vim_strchr(eap->arg, 'F') && (!is_terminal || job_running)) + || (vim_strchr(eap->arg, '-') && buf->b_p_ma) + || (vim_strchr(eap->arg, '=') && !buf->b_p_ro) + || (vim_strchr(eap->arg, 'x') && !(buf->b_flags & BF_READERR)) + || (vim_strchr(eap->arg, '%') && buf != curbuf) + || (vim_strchr(eap->arg, '#') && (buf == curbuf || curwin->w_alt_fnum != buf->b_fnum))) { continue; } if (buf_spname(buf) != NULL) { STRLCPY(NameBuff, buf_spname(buf), MAXPATHL); } else { - home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, true); + home_replace(buf, (char_u *)buf->b_fname, NameBuff, MAXPATHL, true); } if (message_filtered(NameBuff)) { @@ -2700,7 +2699,7 @@ void buflist_list(exarg_T *eap) do { IObuff[len++] = ' '; } while (--i > 0 && len < IOSIZE - 18); - if (vim_strchr((char_u *)eap->arg, 't') && buf->b_last_used) { + if (vim_strchr(eap->arg, 't') && buf->b_last_used) { undo_fmt_time(IObuff + len, (size_t)(IOSIZE - len), buf->b_last_used); } else { vim_snprintf((char *)IObuff + len, (size_t)(IOSIZE - len), _("line %" PRId64), @@ -2730,7 +2729,7 @@ int buflist_name_nr(int fnum, char_u **fname, linenr_T *lnum) return FAIL; } - *fname = buf->b_fname; + *fname = (char_u *)buf->b_fname; *lnum = buflist_findlnum(buf); return OK; @@ -2794,7 +2793,7 @@ int setfname(buf_T *buf, char_u *ffname_arg, char_u *sfname_arg, bool message) buf->b_ffname = ffname; buf->b_sfname = sfname; } - buf->b_fname = buf->b_sfname; + buf->b_fname = (char *)buf->b_sfname; if (!file_id_valid) { buf->file_id_valid = false; } else { @@ -2823,7 +2822,7 @@ void buf_set_name(int fnum, char_u *name) // Allocate ffname and expand into full path. Also resolves .lnk // files on Win32. fname_expand(buf, &buf->b_ffname, &buf->b_sfname); - buf->b_fname = buf->b_sfname; + buf->b_fname = (char *)buf->b_sfname; } } @@ -2980,7 +2979,7 @@ void buf_set_file_id(buf_T *buf) { FileID file_id; if (buf->b_fname != NULL - && os_fileid((char *)buf->b_fname, &file_id)) { + && os_fileid(buf->b_fname, &file_id)) { buf->file_id_valid = true; buf->file_id = file_id; } else { @@ -3023,7 +3022,7 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate) STRLCPY(p, buf_spname(curbuf), IOSIZE - (p - buffer)); } else { if (!fullname && curbuf->b_fname != NULL) { - name = curbuf->b_fname; + name = (char_u *)curbuf->b_fname; } else { name = curbuf->b_ffname; } @@ -3175,7 +3174,7 @@ void maketitle(void) SPACE_FOR_FNAME + 1); buf_p += MIN(size, SPACE_FOR_FNAME); } else { - buf_p += transstr_buf((const char *)path_tail((char *)curbuf->b_fname), + buf_p += transstr_buf((const char *)path_tail(curbuf->b_fname), buf_p, SPACE_FOR_FNAME + 1, true); } @@ -3834,7 +3833,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, int use_san STRLCPY(NameBuff, buf_spname(wp->w_buffer), MAXPATHL); } else { char_u *t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname - : wp->w_buffer->b_fname; + : (char_u *)wp->w_buffer->b_fname; home_replace(wp->w_buffer, t, NameBuff, MAXPATHL, true); } trans_characters(NameBuff, MAXPATHL); @@ -4650,7 +4649,7 @@ char_u *alist_name(aentry_T *aep) if (bp == NULL || bp->b_fname == NULL) { return aep->ae_fname; } - return bp->b_fname; + return (char_u *)bp->b_fname; } /// do_arg_all(): Open up to 'count' windows, one for each argument. @@ -5234,7 +5233,7 @@ static int chk_modeline(linenr_T lnum, int flags) break; } end = true; - s = vim_strchr(s, ' ') + 1; + s = (char_u *)vim_strchr((char *)s, ' ') + 1; } *e = NUL; // truncate the set command @@ -5358,7 +5357,7 @@ char_u *buf_spname(buf_T *buf) // contains the name as specified by the user. if (bt_nofile(buf)) { if (buf->b_fname != NULL) { - return buf->b_fname; + return (char_u *)buf->b_fname; } if (bt_prompt(buf)) { return (char_u *)_("[Prompt]"); @@ -5552,7 +5551,7 @@ char_u *buf_get_fname(const buf_T *buf) if (buf->b_fname == NULL) { return (char_u *)_("[No Name]"); } - return buf->b_fname; + return (char_u *)buf->b_fname; } /// Set 'buflisted' for curbuf to "on" and trigger autocommands if it changed. @@ -5594,7 +5593,7 @@ bool buf_contents_changed(buf_T *buf) aucmd_prepbuf(&aco, newbuf); if (ml_open(curbuf) == OK - && readfile((char *)buf->b_ffname, (char *)buf->b_fname, + && readfile((char *)buf->b_ffname, buf->b_fname, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, &ea, READ_NEW | READ_DUMMY, false) == OK) { // compare the two files line by line diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 1d994a9ff0..2adeeadbca 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -537,16 +537,14 @@ struct file_buffer { int b_ro_locked; // Non-zero when the buffer can't be changed. // Used for FileChangedRO - // // b_ffname has the full path of the file (NULL for no name). // b_sfname is the name as the user typed it (or NULL). // b_fname is the same as b_sfname, unless ":cd" has been done, // then it is the same as b_ffname (NULL for no name). - // char_u *b_ffname; // full path file name, allocated char_u *b_sfname; // short file name, allocated, may be equal to // b_ffname - char_u *b_fname; // current file name, points to b_ffname or + char *b_fname; // current file name, points to b_ffname or // b_sfname bool file_id_valid; diff --git a/src/nvim/change.c b/src/nvim/change.c index 091e9b2830..a21665dc23 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -1498,7 +1498,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) while (off > 0 && lead_len > 0 && leader[lead_len - 1] == ' ') { // Don't do it when there is a tab before the space - if (vim_strchr((char_u *)skipwhite((char *)leader), '\t') != NULL) { + if (vim_strchr(skipwhite((char *)leader), '\t') != NULL) { break; } lead_len--; @@ -1878,7 +1878,7 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa { int j; int got_com = false; - char_u part_buf[COM_MAX_LEN]; // buffer for one option part + char part_buf[COM_MAX_LEN]; // buffer for one option part char_u *string; // pointer to comment string char_u *list; int middle_match_len = 0; @@ -1902,8 +1902,8 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa *flags = list; // remember where flags started } prev_list = list; - (void)copy_option_part(&list, part_buf, COM_MAX_LEN, ","); - string = vim_strchr(part_buf, ':'); + (void)copy_option_part(&list, (char_u *)part_buf, COM_MAX_LEN, ","); + string = (char_u *)vim_strchr(part_buf, ':'); if (string == NULL) { // missing ':', ignore this part continue; } @@ -2025,7 +2025,7 @@ int get_last_leader_offset(char_u *line, char_u **flags) char_u *com_leader; char_u *com_flags; char_u *list; - char_u part_buf[COM_MAX_LEN]; // buffer for one option part + char part_buf[COM_MAX_LEN]; // buffer for one option part // Repeat to match several nested comment strings. int i = (int)STRLEN(line); @@ -2037,8 +2037,8 @@ int get_last_leader_offset(char_u *line, char_u **flags) // Get one option part into part_buf[]. Advance list to next one. // put string at start of string. - (void)copy_option_part(&list, part_buf, COM_MAX_LEN, ","); - string = vim_strchr(part_buf, ':'); + (void)copy_option_part(&list, (char_u *)part_buf, COM_MAX_LEN, ","); + string = (char_u *)vim_strchr(part_buf, ':'); if (string == NULL) { // If everything is fine, this cannot actually // happen. continue; @@ -2096,7 +2096,7 @@ int get_last_leader_offset(char_u *line, char_u **flags) } if (found_one) { - char_u part_buf2[COM_MAX_LEN]; // buffer for one option part + char part_buf2[COM_MAX_LEN]; // buffer for one option part int len1, len2, off; result = i; @@ -2120,11 +2120,11 @@ int get_last_leader_offset(char_u *line, char_u **flags) for (list = curbuf->b_p_com; *list;) { char_u *flags_save = list; - (void)copy_option_part(&list, part_buf2, COM_MAX_LEN, ","); + (void)copy_option_part(&list, (char_u *)part_buf2, COM_MAX_LEN, ","); if (flags_save == com_flags) { continue; } - string = vim_strchr(part_buf2, ':'); + string = (char_u *)vim_strchr(part_buf2, ':'); string++; while (ascii_iswhite(*string)) { string++; diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 2a2b4588b9..b69505d7c9 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -120,8 +120,8 @@ char *parse_shape_opt(int what) // Repeat for all comma separated parts. char *modep = (char *)p_guicursor; while (modep != NULL && *modep != NUL) { - colonp = (char *)vim_strchr((char_u *)modep, ':'); - commap = (char *)vim_strchr((char_u *)modep, ','); + colonp = vim_strchr(modep, ':'); + commap = vim_strchr(modep, ','); if (colonp == NULL || (commap != NULL && commap < colonp)) { return N_("E545: Missing colon"); @@ -215,7 +215,7 @@ char *parse_shape_opt(int what) } p += 5; } else { // must be a highlight group name then - endp = (char *)vim_strchr((char_u *)p, '-'); + endp = vim_strchr(p, '-'); if (commap == NULL) { // last part if (endp == NULL) { endp = p + STRLEN(p); // find end of part @@ -223,7 +223,7 @@ char *parse_shape_opt(int what) } else if (endp > commap || endp == NULL) { endp = commap; } - slashp = (char *)vim_strchr((char_u *)p, '/'); + slashp = vim_strchr(p, '/'); if (slashp != NULL && slashp < endp) { // "group/langmap_group" i = syn_check_group(p, (size_t)(slashp - p)); diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 0f76c3e884..b2ac28629c 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -100,7 +100,7 @@ void do_debug(char_u *cmd) debug_newval = NULL; } if (sourcing_name != NULL) { - msg((char *)sourcing_name); + msg(sourcing_name); } if (sourcing_lnum != 0) { smsg(_("line %" PRId64 ": %s"), (int64_t)sourcing_lnum, cmd); @@ -293,7 +293,7 @@ static int get_maxbacktrace_level(void) int maxbacktrace = 0; if (sourcing_name != NULL) { - char *p = (char *)sourcing_name; + char *p = sourcing_name; char *q; while ((q = strstr(p, "..")) != NULL) { p = q + 2; @@ -334,7 +334,7 @@ static void do_showbacktrace(char_u *cmd) if (sourcing_name != NULL) { int i = 0; int max = get_maxbacktrace_level(); - char *cur = (char *)sourcing_name; + char *cur = sourcing_name; while (!got_int) { char *next = strstr(cur, ".."); if (next != NULL) { @@ -475,8 +475,8 @@ static typval_T *eval_expr_no_emsg(struct debuggy *const bp) /// @param gap either &dbg_breakp or &prof_ga static int dbg_parsearg(char_u *arg, garray_T *gap) { - char_u *p = arg; - char_u *q; + char *p = (char *)arg; + char *q; bool here = false; ga_grow(gap, 1); @@ -501,14 +501,14 @@ static int dbg_parsearg(char_u *arg, garray_T *gap) semsg(_(e_invarg2), p); return FAIL; } - p = (char_u *)skipwhite((char *)p + 4); + p = skipwhite(p + 4); // Find optional line number. if (here) { bp->dbg_lnum = curwin->w_cursor.lnum; } else if (gap != &prof_ga && ascii_isdigit(*p)) { - bp->dbg_lnum = getdigits_long(&p, true, 0); - p = (char_u *)skipwhite((char *)p); + bp->dbg_lnum = getdigits_long((char_u **)&p, true, 0); + p = skipwhite(p); } else { bp->dbg_lnum = 0; } @@ -516,17 +516,17 @@ static int dbg_parsearg(char_u *arg, garray_T *gap) // Find the function or file name. Don't accept a function name with (). if ((!here && *p == NUL) || (here && *p != NUL) - || (bp->dbg_type == DBG_FUNC && strstr((char *)p, "()") != NULL)) { + || (bp->dbg_type == DBG_FUNC && strstr(p, "()") != NULL)) { semsg(_(e_invarg2), arg); return FAIL; } if (bp->dbg_type == DBG_FUNC) { - bp->dbg_name = vim_strsave(p); + bp->dbg_name = vim_strsave((char_u *)p); } else if (here) { bp->dbg_name = vim_strsave(curbuf->b_ffname); } else if (bp->dbg_type == DBG_EXPR) { - bp->dbg_name = vim_strsave(p); + bp->dbg_name = vim_strsave((char_u *)p); bp->dbg_val = eval_expr_no_emsg(bp); } else { // Expand the file name in the same way as do_source(). This means @@ -542,10 +542,10 @@ static int dbg_parsearg(char_u *arg, garray_T *gap) return FAIL; } if (*p != '*') { - bp->dbg_name = (char_u *)fix_fname((char *)p); + bp->dbg_name = (char_u *)fix_fname(p); xfree(p); } else { - bp->dbg_name = p; + bp->dbg_name = (char_u *)p; } } @@ -568,7 +568,7 @@ void ex_breakadd(exarg_T *eap) bp->dbg_forceit = eap->forceit; if (bp->dbg_type != DBG_EXPR) { - char_u *pat = file_pat_to_reg_pat(bp->dbg_name, NULL, NULL, false); + char *pat = file_pat_to_reg_pat((char *)bp->dbg_name, NULL, NULL, false); if (pat != NULL) { bp->dbg_prog = vim_regcomp(pat, RE_MAGIC + RE_STRING); xfree(pat); diff --git a/src/nvim/diff.c b/src/nvim/diff.c index dcc9b51431..e8d54d7030 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1160,7 +1160,7 @@ void ex_diffpatch(exarg_T *eap) { char_u *buf = NULL; win_T *old_curwin = curwin; - char_u *newname = NULL; // name of patched file buffer + char *newname = NULL; // name of patched file buffer char_u *esc_name = NULL; #ifdef UNIX @@ -1258,7 +1258,7 @@ void ex_diffpatch(exarg_T *eap) emsg(_("E816: Cannot read patch output")); } else { if (curbuf->b_fname != NULL) { - newname = vim_strnsave(curbuf->b_fname, STRLEN(curbuf->b_fname) + 4); + newname = xstrnsave(curbuf->b_fname, STRLEN(curbuf->b_fname) + 4); STRCAT(newname, ".new"); } @@ -1279,7 +1279,7 @@ void ex_diffpatch(exarg_T *eap) if (newname != NULL) { // do a ":file filename.new" on the patched buffer - eap->arg = (char *)newname; + eap->arg = newname; ex_file(eap); // Do filetype detection with the new name. diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 43ea32fc09..1b536bdde6 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -2069,7 +2069,7 @@ void ex_loadkeymap(exarg_T *eap) #define KMAP_LLEN 200 // max length of "to" and "from" together char_u buf[KMAP_LLEN + 11]; - char_u *save_cpo = p_cpo; + char *save_cpo = p_cpo; if (!getline_equal(eap->getline, eap->cookie, getsourceline)) { emsg(_("E105: Using :loadkeymap not in a sourced file")); @@ -2083,7 +2083,7 @@ void ex_loadkeymap(exarg_T *eap) ga_init(&curbuf->b_kmap_ga, (int)sizeof(kmap_T), 20); // Set 'cpoptions' to "C" to avoid line continuation. - p_cpo = (char_u *)"C"; + p_cpo = "C"; // Get each line of the sourced file, break at the end. for (;;) { @@ -2093,7 +2093,7 @@ void ex_loadkeymap(exarg_T *eap) break; } - char_u *p = (char_u *)skipwhite((char *)line); + char_u *p = (char_u *)skipwhite(line); if ((*p != '"') && (*p != NUL)) { kmap_T *kp = GA_APPEND_VIA_PTR(kmap_T, &curbuf->b_kmap_ga); @@ -2144,22 +2144,22 @@ void keymap_ga_clear(garray_T *kmap_ga) /// Stop using 'keymap'. static void keymap_unload(void) { - char_u buf[KMAP_MAXLEN + 10]; - char_u *save_cpo = p_cpo; + char buf[KMAP_MAXLEN + 10]; + char *save_cpo = p_cpo; if (!(curbuf->b_kmap_state & KEYMAP_LOADED)) { return; } // Set 'cpoptions' to "C" to avoid line continuation. - p_cpo = (char_u *)"C"; + p_cpo = "C"; // clear the ":lmap"s kmap_T *kp = (kmap_T *)curbuf->b_kmap_ga.ga_data; for (int i = 0; i < curbuf->b_kmap_ga.ga_len; i++) { - vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s", kp[i].from); - (void)do_map(1, buf, MODE_LANGMAP, false); + vim_snprintf(buf, sizeof(buf), "<buffer> %s", kp[i].from); + (void)do_map(1, (char_u *)buf, MODE_LANGMAP, false); } keymap_ga_clear(&curbuf->b_kmap_ga); diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 215024f63a..357e9184d7 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1339,7 +1339,7 @@ normalchar: ins_char(s->c); } } - AppendToRedobuffLit((char *)str, -1); + AppendToRedobuffLit(str, -1); } xfree(str); s->c = NUL; @@ -2735,7 +2735,7 @@ static bool pum_wanted(void) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { // "completeopt" must contain "menu" or "menuone" - return vim_strchr(p_cot, 'm') != NULL; + return vim_strchr((char *)p_cot, 'm') != NULL; } /// Check that there are two or more matches to be shown in the popup menu. @@ -2983,11 +2983,11 @@ static void ins_compl_dictionaries(char_u *dict_start, char_u *pat, int flags, i size_t len = STRLEN(pat_esc) + 10; ptr = xmalloc(len); vim_snprintf((char *)ptr, len, "^\\s*\\zs\\V%s", pat_esc); - regmatch.regprog = vim_regcomp(ptr, RE_MAGIC); + regmatch.regprog = vim_regcomp((char *)ptr, RE_MAGIC); xfree(pat_esc); xfree(ptr); } else { - regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0); + regmatch.regprog = vim_regcomp((char *)pat, p_magic ? RE_MAGIC : 0); if (regmatch.regprog == NULL) { goto theend; } @@ -3007,7 +3007,7 @@ static void ins_compl_dictionaries(char_u *dict_start, char_u *pat, int flags, i copy_option_part(&dict, buf, LSIZE, ","); if (!thesaurus && STRCMP(buf, "spell") == 0) { count = -1; - } else if (vim_strchr(buf, '`') != NULL + } else if (vim_strchr((char *)buf, '`') != NULL || expand_wildcards(1, &buf, &count, &files, EW_FILE|EW_SILENT) != OK) { count = 0; @@ -4252,9 +4252,8 @@ static int ins_compl_get_exp(pos_T *ini) // Remember the first match so that the loop stops when we // wrap and come back there a second time. set_match_pos = true; - } else if (vim_strchr((char_u *)"buwU", *e_cpt) != NULL - && (ins_buf = - ins_compl_next_buf(ins_buf, *e_cpt)) != curbuf) { + } else if (vim_strchr("buwU", *e_cpt) != NULL + && (ins_buf = ins_compl_next_buf(ins_buf, *e_cpt)) != curbuf) { // Scan a buffer, but not the current one. if (ins_buf->b_ml.ml_mfp != NULL) { // loaded buffer compl_started = true; @@ -4268,7 +4267,7 @@ static int ins_compl_get_exp(pos_T *ini) continue; } type = CTRL_X_DICTIONARY; - dict = ins_buf->b_fname; + dict = (char_u *)ins_buf->b_fname; dict_f = DICT_EXACT; } msg_hist_off = true; // reset in msg_trunc_attr() @@ -4276,7 +4275,7 @@ static int ins_compl_get_exp(pos_T *ini) ins_buf->b_fname == NULL ? buf_spname(ins_buf) : ins_buf->b_sfname == NULL - ? ins_buf->b_fname + ? (char_u *)ins_buf->b_fname : ins_buf->b_sfname); (void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R)); } else if (*e_cpt == NUL) { @@ -5833,7 +5832,7 @@ void insertchar(int c, int flags, int second_indent) * comment leader. First, check what comment leader we can find. */ i = get_leader_len(line = get_cursor_line_ptr(), &p, false, true); - if (i > 0 && vim_strchr(p, COM_MIDDLE) != NULL) { // Just checking + if (i > 0 && vim_strchr((char *)p, COM_MIDDLE) != NULL) { // Just checking // Skip middle-comment string while (*p && p[-1] != ':') { // find end of middle flags p++; @@ -7580,7 +7579,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((char_u *)"<>!*oOe0:", look[1]) != NULL + if (vim_strchr("<>!*oOe0:", look[1]) != NULL && keytyped == look[1]) { return true; } @@ -7607,7 +7606,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) } else { icase = false; } - p = vim_strchr(look, ','); + p = (char_u *)vim_strchr((char *)look, ','); if (p == NULL) { p = look + STRLEN(look); } @@ -8697,7 +8696,7 @@ static void ins_left(void) revins_legal++; } revins_chars++; - } else if (vim_strchr(p_ww, '[') != NULL && curwin->w_cursor.lnum > 1) { + } else if (vim_strchr((char *)p_ww, '[') != NULL && curwin->w_cursor.lnum > 1) { // if 'whichwrap' set for cursor in insert mode may go to previous line. // always break undo when moving upwards/downwards, else undo may break start_arrow(&tpos); @@ -8790,7 +8789,7 @@ static void ins_right(void) if (revins_chars) { revins_chars--; } - } else if (vim_strchr(p_ww, ']') != NULL + } else if (vim_strchr((char *)p_ww, ']') != NULL && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { // if 'whichwrap' set for cursor in insert mode, may move the // cursor to the next line diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a1f9b7e154..9c2069663d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1407,7 +1407,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const) argend--; } expr = skipwhite(argend); - if (*expr != '=' && !((vim_strchr((char_u *)"+-*/%.", *expr) != NULL + if (*expr != '=' && !((vim_strchr("+-*/%.", *expr) != NULL && expr[1] == '=') || STRNCMP(expr, "..=", 3) == 0)) { // ":let" without "=": list variables if (*arg == '[') { @@ -1443,7 +1443,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const) op[0] = '='; op[1] = NUL; if (*expr != '=') { - if (vim_strchr((char_u *)"+-*/%.", *expr) != NULL) { + if (vim_strchr("+-*/%.", *expr) != NULL) { op[0] = *expr; // +=, -=, *=, /=, %= or .= if (expr[0] == '.' && expr[1] == '.') { // ..= expr++; @@ -1809,10 +1809,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((char_u *)"+-*/%", *op) != NULL) { + if (op != NULL && vim_strchr("+-*/%", *op) != NULL) { semsg(_(e_letwrong), op); } else if (endchars != NULL - && vim_strchr((char_u *)endchars, *skipwhite(arg)) == NULL) { + && vim_strchr(endchars, *skipwhite(arg)) == NULL) { emsg(_(e_letunexp)); } else if (!check_secure()) { const char c1 = name[len]; @@ -1855,7 +1855,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, &opt_flags); if (p == NULL || (endchars != NULL - && vim_strchr((char_u *)endchars, *skipwhite(p)) == NULL)) { + && vim_strchr(endchars, *skipwhite(p)) == NULL)) { emsg(_(e_letunexp)); } else { int opt_type; @@ -1914,10 +1914,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((char_u *)"+-*/%", *op) != NULL) { + if (op != NULL && vim_strchr("+-*/%", *op) != NULL) { semsg(_(e_letwrong), op); } else if (endchars != NULL - && vim_strchr((char_u *)endchars, *skipwhite(arg + 1)) == NULL) { + && vim_strchr(endchars, *skipwhite(arg + 1)) == NULL) { emsg(_(e_letunexp)); } else { char *s; @@ -1949,7 +1949,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((char_u *)endchars, *skipwhite(p)) == NULL) { + if (endchars != NULL && vim_strchr(endchars, *skipwhite(p)) == NULL) { emsg(_(e_letunexp)); } else { set_var_lval(&lv, p, tv, copy, is_const, op); @@ -2752,7 +2752,7 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx) break; } else if ((c == '<' || c == '#') && xp->xp_context == EXPAND_FUNCTIONS - && vim_strchr((char_u *)xp->xp_pattern, '(') == NULL) { + && vim_strchr(xp->xp_pattern, '(') == NULL) { // Function name can start with "<SNR>" and contain '#'. break; } else if (cmdidx != CMD_let || got_eq) { @@ -3263,15 +3263,15 @@ int pattern_match(char *pat, char *text, bool ic) regmatch_T regmatch; // avoid 'l' flag in 'cpoptions' - char *save_cpo = (char *)p_cpo; - p_cpo = (char_u *)""; - regmatch.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING); + char *save_cpo = p_cpo; + p_cpo = ""; + regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); if (regmatch.regprog != NULL) { regmatch.rm_ic = ic; matches = vim_regexec_nl(®match, (char_u *)text, (colnr_T)0); vim_regfree(regmatch.regprog); } - p_cpo = (char_u *)save_cpo; + p_cpo = save_cpo; return matches; } @@ -5872,7 +5872,7 @@ static int get_env_tv(char **arg, typval_T *rettv, int evaluate) xfree(string); // Next try expanding things like $VIM and ${HOME}. - string = (char *)expand_env_save((char_u *)name - 1); + string = expand_env_save(name - 1); if (string != NULL && *string == '$') { XFREE_CLEAR(string); } @@ -6141,7 +6141,7 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref, FunPtr use_string = true; } - if ((use_string && vim_strchr((char_u *)s, AUTOLOAD_CHAR) == NULL) || is_funcref) { + if ((use_string && vim_strchr(s, AUTOLOAD_CHAR) == NULL) || is_funcref) { name = s; trans_name = (char *)trans_function_name((char_u **)&name, false, TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD @@ -7958,7 +7958,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((char_u *)namespace_char, **arg) == NULL)) { + || (len == 1 && vim_strchr(namespace_char, **arg) == NULL)) { break; } } @@ -8089,7 +8089,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((char_u *)namespace_char, *arg) == NULL)) { + || (len == 1 && vim_strchr(namespace_char, *arg) == NULL)) { break; } } @@ -9279,7 +9279,7 @@ bool var_check_func_name(const char *const name, const bool new_var) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { // Allow for w: b: s: and t:. - if (!(vim_strchr((char_u *)"wbst", name[0]) != NULL && name[1] == ':') + if (!(vim_strchr("wbst", name[0]) != NULL && name[1] == ':') && !ASCII_ISUPPER((name[0] != NUL && name[1] == ':') ? name[2] : name[0])) { semsg(_("E704: Funcref variable name must start with a capital: %s"), name); @@ -10110,7 +10110,7 @@ repeat: || (*fnamep)[1] == NUL) #endif && !(tilde_file && (*fnamep)[1] == NUL)) { - *fnamep = (char *)expand_env_save((char_u *)(*fnamep)); + *fnamep = expand_env_save(*fnamep); xfree(*bufp); // free any allocated file name *bufp = *fnamep; if (*fnamep == NULL) { @@ -10163,7 +10163,7 @@ repeat: // Need full path first (use expand_env() to remove a "~/") if (!has_fullname && !has_homerelative) { if (**fnamep == '~') { - p = pbuf = (char *)expand_env_save((char_u *)(*fnamep)); + p = pbuf = expand_env_save(*fnamep); } else { p = pbuf = FullName_save(*fnamep, false); } @@ -10325,12 +10325,12 @@ repeat: sep = (char_u)(*s++); if (sep) { // find end of pattern - p = (char *)vim_strchr((char_u *)s, sep); + p = vim_strchr(s, sep); if (p != NULL) { char *const pat = xstrnsave(s, p - s); s = p + 1; // find end of substitution - p = (char *)vim_strchr((char_u *)s, sep); + p = vim_strchr(s, sep); if (p != NULL) { char *const sub = xstrnsave(s, p - s); char *const str = xstrnsave(*fnamep, *fnamelen); @@ -10389,15 +10389,15 @@ char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, char *flags char *zero_width = NULL; // Make 'cpoptions' empty, so that the 'l' flag doesn't work here - save_cpo = (char *)p_cpo; - p_cpo = empty_option; + save_cpo = p_cpo; + p_cpo = (char *)empty_option; ga_init(&ga, 1, 200); do_all = (flags[0] == 'g'); regmatch.rm_ic = p_ic; - regmatch.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING); + regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); if (regmatch.regprog != NULL) { tail = str; end = str + STRLEN(str); @@ -10449,8 +10449,8 @@ char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, char *flags char *ret = xstrdup(ga.ga_data == NULL ? str : ga.ga_data); ga_clear(&ga); - if (p_cpo == empty_option) { - p_cpo = (char_u *)save_cpo; + if ((char_u *)p_cpo == empty_option) { + p_cpo = save_cpo; } else { // Darn, evaluating {sub} expression or {expr} changed the value. free_string_option((char_u *)save_cpo); diff --git a/src/nvim/eval/executor.c b/src/nvim/eval/executor.c index c08b7b1b2d..3e66150180 100644 --- a/src/nvim/eval/executor.c +++ b/src/nvim/eval/executor.c @@ -63,7 +63,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((char_u *)"+-*/%", *op) != NULL) { + if (vim_strchr("+-*/%", *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 04e9ffa570..68c2e37f22 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -485,9 +485,7 @@ static buf_T *find_buffer(typval_T *avar) * buffer, these don't use the full path. */ FOR_ALL_BUFFERS(bp) { if (bp->b_fname != NULL - && (path_with_url((char *)bp->b_fname) - || bt_nofile(bp) - ) + && (path_with_url(bp->b_fname) || bt_nofile(bp)) && STRCMP(bp->b_fname, avar->vval.v_string) == 0) { buf = bp; break; @@ -557,7 +555,7 @@ static void f_bufname(typval_T *argvars, typval_T *rettv, FunPtr fptr) buf = tv_get_buf_from_arg(&argvars[0]); } if (buf != NULL && buf->b_fname != NULL) { - rettv->vval.v_string = xstrdup((char *)buf->b_fname); + rettv->vval.v_string = xstrdup(buf->b_fname); } } @@ -638,7 +636,7 @@ buf_T *tv_get_buf(typval_T *tv, int curtab_only) { char_u *name = (char_u *)tv->vval.v_string; int save_magic; - char_u *save_cpo; + char *save_cpo; buf_T *buf; if (tv->v_type == VAR_NUMBER) { @@ -658,7 +656,7 @@ buf_T *tv_get_buf(typval_T *tv, int curtab_only) save_magic = p_magic; p_magic = TRUE; save_cpo = p_cpo; - p_cpo = (char_u *)""; + p_cpo = ""; buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name), true, false, curtab_only)); @@ -2066,7 +2064,7 @@ static void f_exists(typval_T *argvars, typval_T *rettv, FunPtr fptr) n = true; } else { // Try expanding things like $VIM and ${HOME}. - char_u *const exp = expand_env_save((char_u *)p); + char *const exp = expand_env_save((char *)p); if (exp != NULL && *exp != '$') { n = true; } @@ -3390,7 +3388,7 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr) FALLTHROUGH; case kCdScopeGlobal: if (globaldir) { // `globaldir` is not always set. - from = globaldir; + from = (char_u *)globaldir; break; } FALLTHROUGH; // In global directory, just need to get OS CWD. @@ -4147,8 +4145,7 @@ static void f_glob2regpat(typval_T *argvars, typval_T *rettv, FunPtr fptr) const char *const pat = tv_get_string_chk(&argvars[0]); // NULL on type error rettv->v_type = VAR_STRING; - rettv->vval.v_string = - (char *)((pat == NULL) ? NULL : file_pat_to_reg_pat((char_u *)pat, NULL, NULL, false)); + rettv->vval.v_string = (pat == NULL) ? NULL : file_pat_to_reg_pat(pat, NULL, NULL, false); } /// "has()" function @@ -5780,7 +5777,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, long len = 0; char_u *expr = NULL; regmatch_T regmatch; - char_u *save_cpo; + char *save_cpo; long start = 0; long nth = 1; colnr_T startcol = 0; @@ -5792,7 +5789,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, // Make 'cpoptions' empty, the 'l' flag should not be used here. save_cpo = p_cpo; - p_cpo = (char_u *)""; + p_cpo = ""; rettv->vval.v_number = -1; switch (type) { @@ -5873,7 +5870,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, } } - regmatch.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING); + regmatch.regprog = vim_regcomp((char *)pat, RE_MAGIC + RE_STRING); if (regmatch.regprog != NULL) { regmatch.rm_ic = p_ic; @@ -8306,7 +8303,7 @@ long do_searchpair(const char *spat, const char *mpat, const char *epat, int dir long time_limit) FUNC_ATTR_NONNULL_ARG(1, 2, 3) { - char_u *save_cpo; + char *save_cpo; char_u *pat, *pat2 = NULL, *pat3 = NULL; long retval = 0; pos_T pos; @@ -8322,7 +8319,7 @@ long do_searchpair(const char *spat, const char *mpat, const char *epat, int dir // Make 'cpoptions' empty, the 'l' flag should not be used here. save_cpo = p_cpo; - p_cpo = empty_option; + p_cpo = (char *)empty_option; // Set the time limit, if there is one. tm = profile_setlimit(time_limit); @@ -8446,11 +8443,11 @@ long do_searchpair(const char *spat, const char *mpat, const char *epat, int dir xfree(pat2); xfree(pat3); - if (p_cpo == empty_option) { + if ((char_u *)p_cpo == empty_option) { p_cpo = save_cpo; } else { // Darn, evaluating the {skip} expression changed the value. - free_string_option(save_cpo); + free_string_option((char_u *)save_cpo); } return retval; @@ -9741,7 +9738,7 @@ f_spellsuggest_return: static void f_split(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - char_u *save_cpo; + char *save_cpo; int match; colnr_T col = 0; bool keepempty = false; @@ -9749,7 +9746,7 @@ static void f_split(typval_T *argvars, typval_T *rettv, FunPtr fptr) // Make 'cpoptions' empty, the 'l' flag should not be used here. save_cpo = p_cpo; - p_cpo = (char_u *)""; + p_cpo = ""; const char *str = tv_get_string(&argvars[0]); const char *pat = NULL; @@ -9774,7 +9771,7 @@ static void f_split(typval_T *argvars, typval_T *rettv, FunPtr fptr) } regmatch_T regmatch = { - .regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING), + .regprog = vim_regcomp((char *)pat, RE_MAGIC + RE_STRING), .startp = { NULL }, .endp = { NULL }, .rm_ic = false, diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index c6b6a8ead9..e5f48501f7 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -1536,7 +1536,7 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t // Trigger FuncUndefined event, may load the function. if (fp == NULL - && apply_autocmds(EVENT_FUNCUNDEFINED, rfname, rfname, true, NULL) + && apply_autocmds(EVENT_FUNCUNDEFINED, (char *)rfname, (char *)rfname, true, NULL) && !aborting()) { // executed an autocommand, search for the function again fp = find_func(rfname); @@ -1967,7 +1967,7 @@ void ex_function(exarg_T *eap) c = *p; *p = NUL; - regmatch.regprog = vim_regcomp((char_u *)eap->arg + 1, RE_MAGIC); + regmatch.regprog = vim_regcomp(eap->arg + 1, RE_MAGIC); *p = c; if (regmatch.regprog != NULL) { regmatch.rm_ic = p_ic; @@ -2009,7 +2009,7 @@ void ex_function(exarg_T *eap) // g:func global function name, same as "func" p = (char_u *)eap->arg; name = trans_function_name(&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL); - paren = (vim_strchr(p, '(') != NULL); + paren = (vim_strchr((char *)p, '(') != NULL); if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) { /* * Return on an invalid expression in braces, unless the expression @@ -2090,8 +2090,8 @@ void ex_function(exarg_T *eap) goto ret_free; } // attempt to continue by skipping some text - if (vim_strchr(p, '(') != NULL) { - p = vim_strchr(p, '('); + if (vim_strchr((char *)p, '(') != NULL) { + p = (char_u *)vim_strchr((char *)p, '('); } } p = (char_u *)skipwhite((char *)p + 1); @@ -2207,7 +2207,7 @@ void ex_function(exarg_T *eap) if (line_arg != NULL) { // Use eap->arg, split up in parts by line breaks. theline = line_arg; - p = vim_strchr(theline, '\n'); + p = (char_u *)vim_strchr((char *)theline, '\n'); if (p == NULL) { line_arg += STRLEN(line_arg); } else { @@ -2369,7 +2369,7 @@ void ex_function(exarg_T *eap) // and ":let [a, b] =<< [trim] EOF" arg = (char_u *)skipwhite((char *)skiptowhite(p)); if (*arg == '[') { - arg = vim_strchr(arg, ']'); + arg = (char_u *)vim_strchr((char *)arg, ']'); } if (arg != NULL) { arg = (char_u *)skipwhite((char *)skiptowhite(arg)); @@ -2490,7 +2490,7 @@ void ex_function(exarg_T *eap) } if (fp == NULL) { - if (fudi.fd_dict == NULL && vim_strchr(name, AUTOLOAD_CHAR) != NULL) { + if (fudi.fd_dict == NULL && vim_strchr((char *)name, AUTOLOAD_CHAR) != NULL) { int slen, plen; char_u *scriptname; @@ -2498,7 +2498,7 @@ void ex_function(exarg_T *eap) int j = FAIL; if (sourcing_name != NULL) { scriptname = (char_u *)autoload_name((const char *)name, STRLEN(name)); - p = vim_strchr(scriptname, '/'); + p = (char_u *)vim_strchr((char *)scriptname, '/'); plen = (int)STRLEN(p); slen = (int)STRLEN(sourcing_name); if (slen > plen && FNAMECMP(p, diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 1dbae13354..8369db7de1 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -350,7 +350,7 @@ static int linelen(int *has_tab) len = linetabsize((char_u *)line); // Check for embedded TAB. if (has_tab != NULL) { - *has_tab = vim_strchr((char_u *)first, TAB) != NULL; + *has_tab = vim_strchr(first, TAB) != NULL; } *last = save; @@ -529,9 +529,9 @@ void ex_sort(exarg_T *eap) emsg(_(e_noprevre)); goto sortend; } - regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC); + regmatch.regprog = vim_regcomp((char *)last_search_pat(), RE_MAGIC); } else { - regmatch.regprog = vim_regcomp((char_u *)p + 1, RE_MAGIC); + regmatch.regprog = vim_regcomp(p + 1, RE_MAGIC); } if (regmatch.regprog == NULL) { goto sortend; @@ -1718,7 +1718,7 @@ int rename_buffer(char *new_fname) */ fname = (char *)curbuf->b_ffname; sfname = (char *)curbuf->b_sfname; - xfname = (char *)curbuf->b_fname; + xfname = curbuf->b_fname; curbuf->b_ffname = NULL; curbuf->b_sfname = NULL; if (setfname(curbuf, (char_u *)new_fname, NULL, true) == FAIL) { @@ -1858,7 +1858,7 @@ int do_write(exarg_T *eap) if (!other) { ffname = (char *)curbuf->b_ffname; - fname = (char *)curbuf->b_fname; + fname = curbuf->b_fname; // Not writing the whole file is only allowed with '!'. if ((eap->line1 != 1 || eap->line2 != curbuf->b_ml.ml_line_count) @@ -1894,9 +1894,9 @@ int do_write(exarg_T *eap) // under the new name. Must be done before buf_write(), because // if there is no file name and 'cpo' contains 'F', it will set // the file name. - fname = (char *)alt_buf->b_fname; + fname = alt_buf->b_fname; alt_buf->b_fname = curbuf->b_fname; - curbuf->b_fname = (char_u *)fname; + curbuf->b_fname = fname; fname = (char *)alt_buf->b_ffname; alt_buf->b_ffname = curbuf->b_ffname; curbuf->b_ffname = (char_u *)fname; @@ -2096,8 +2096,7 @@ void do_wqall(exarg_T *eap) semsg(_("E141: No file name for buffer %" PRId64), (int64_t)buf->b_fnum); error++; } else if (check_readonly(&eap->forceit, buf) - || check_overwrite(eap, buf, (char *)buf->b_fname, (char *)buf->b_ffname, - false) == FAIL) { + || check_overwrite(eap, buf, buf->b_fname, (char *)buf->b_ffname, false) == FAIL) { error++; } else { bufref_T bufref; @@ -2148,12 +2147,12 @@ static int check_readonly(int *forceit, buf_T *buf) if (buf->b_p_ro) { dialog_msg((char *)buff, _("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"), - (char *)buf->b_fname); + buf->b_fname); } else { dialog_msg((char *)buff, _("File permissions of \"%s\" are read-only.\nIt may still be possible to " "write it.\nDo you wish to try?"), - (char *)buf->b_fname); + buf->b_fname); } if (vim_dialog_yesno(VIM_QUESTION, NULL, (char_u *)buff, 2) == VIM_YES) { @@ -2340,7 +2339,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum } else { if (*ffname == NUL) { // re-edit with same file name ffname = (char *)curbuf->b_ffname; - sfname = (char *)curbuf->b_fname; + sfname = curbuf->b_fname; } free_fname = fix_fname(ffname); // may expand to full path name if (free_fname != NULL) { @@ -2491,7 +2490,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum // - If we ended up in the new buffer already, need to skip a few // things, set auto_buf. if (buf->b_fname != NULL) { - new_name = (char *)vim_strsave(buf->b_fname); + new_name = xstrdup(buf->b_fname); } const bufref_T save_au_new_curbuf = au_new_curbuf; set_bufref(&au_new_curbuf, buf); @@ -2641,7 +2640,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum } buf = curbuf; if (buf->b_fname != NULL) { - new_name = (char *)vim_strsave(buf->b_fname); + new_name = (char *)vim_strsave((char_u *)buf->b_fname); } else { new_name = NULL; } @@ -2961,7 +2960,7 @@ void ex_append(exarg_T *eap) if (eap->nextcmd == NULL || *eap->nextcmd == NUL) { break; } - p = (char *)vim_strchr((char_u *)eap->nextcmd, NL); + p = vim_strchr(eap->nextcmd, NL); if (p == NULL) { p = eap->nextcmd + STRLEN(eap->nextcmd); } @@ -2975,8 +2974,7 @@ void ex_append(exarg_T *eap) // Set State to avoid the cursor shape to be set to MODE_INSERT // state when getline() returns. State = MODE_CMDLINE; - theline = (char *)eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : - NUL, eap->cookie, indent, true); + theline = eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : NUL, eap->cookie, indent, true); State = save_State; } lines_left = Rows - 1; @@ -3494,7 +3492,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle } // new pattern and substitution if (eap->cmd[0] == 's' && *cmd != NUL && !ascii_iswhite(*cmd) - && vim_strchr((char_u *)"0123456789cegriIp|\"", *cmd) == NULL) { + && vim_strchr("0123456789cegriIp|\"", *cmd) == NULL) { // don't accept alphanumeric for separator if (check_regexp_delim(*cmd) == FAIL) { return NULL; @@ -3504,8 +3502,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle // "\/sub/" and "\?sub?" use last used search pattern (almost like // //sub/r). "\&sub&" use last substitute pattern (like //sub/). if (*cmd == '\\') { - ++cmd; - if (vim_strchr((char_u *)"/?&", *cmd) == NULL) { + cmd++; + if (vim_strchr("/?&", *cmd) == NULL) { emsg(_(e_backslash)); return NULL; } @@ -3837,7 +3835,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle // When 'cpoptions' contains "u" don't sync undo when // asking for confirmation. if (vim_strchr(p_cpo, CPO_UNDO) != NULL) { - ++no_u_sync; + no_u_sync++; } /* @@ -3993,7 +3991,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle State = save_State; setmouse(); if (vim_strchr(p_cpo, CPO_UNDO) != NULL) { - --no_u_sync; + no_u_sync--; } if (typed == 'n') { @@ -4579,8 +4577,8 @@ void ex_global(exarg_T *eap) * "\&": use previous substitute pattern. */ if (*cmd == '\\') { - ++cmd; - if (vim_strchr((char_u *)"/?&", *cmd) == NULL) { + cmd++; + if (vim_strchr("/?&", *cmd) == NULL) { emsg(_(e_backslash)); return; } @@ -5114,7 +5112,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((char_u *)"%_z@", arg[1]) != NULL + || (vim_strchr("%_z@", arg[1]) != NULL && arg[2] != NUL))) { vim_snprintf(d, IOSIZE, "/\\\\%s", arg + 1); // Check for "/\\_$", should be "/\\_\$" @@ -5173,10 +5171,9 @@ int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep * ":help i_^_CTRL-D" work. * Insert '-' before and after "CTRL-X" when applicable. */ - if (*s < ' ' || (*s == '^' && s[1] && (ASCII_ISALPHA(s[1]) - || vim_strchr((char_u *) - "?@[\\]^", - s[1]) != NULL))) { + if (*s < ' ' + || (*s == '^' && s[1] + && (ASCII_ISALPHA(s[1]) || vim_strchr("?@[\\]^", s[1]) != NULL))) { if ((char_u *)d > IObuff && d[-1] != '_' && d[-1] != '\\') { *d++ = '_'; // prepend a '_' to make x_CTRL-x } @@ -5360,7 +5357,7 @@ void fix_help_buffer(void) * In the "help.txt" and "help.abx" file, add the locally added help * files. This uses the very first line in the help file. */ - char *const fname = path_tail((char *)curbuf->b_fname); + char *const fname = path_tail(curbuf->b_fname); if (FNAMECMP(fname, "help.txt") == 0 || (FNAMENCMP(fname, "help.", 5) == 0 && ASCII_ISALPHA(fname[5]) @@ -5448,7 +5445,7 @@ void fix_help_buffer(void) } vim_fgets(IObuff, IOSIZE, fd); if (IObuff[0] == '*' - && (s = (char *)vim_strchr(IObuff + 1, '*')) + && (s = vim_strchr((char *)IObuff + 1, '*')) != NULL) { TriState this_utf = kNone; // Change tag definition to a @@ -5635,7 +5632,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool } firstline = false; } - p1 = (char *)vim_strchr(IObuff, '*'); // find first '*' + p1 = vim_strchr((char *)IObuff, '*'); // find first '*' while (p1 != NULL) { p2 = strchr((const char *)p1 + 1, '*'); // Find second '*'. if (p2 != NULL && p2 > p1 + 1) { // Skip "*" and "**". @@ -5650,7 +5647,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 && ((char_u *)p1 == IObuff || p1[-1] == ' ' || p1[-1] == '\t') - && (vim_strchr((char_u *)" \t\n\r", s[1]) != NULL + && (vim_strchr(" \t\n\r", s[1]) != NULL || s[1] == '\0')) { *p2 = '\0'; p1++; @@ -5660,7 +5657,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool snprintf(s, s_len, "%s\t%s", p1, fname); // find next '*' - p2 = (char *)vim_strchr((char_u *)p2 + 1, '*'); + p2 = vim_strchr(p2 + 1, '*'); } } p1 = p2; @@ -6203,7 +6200,7 @@ void ex_oldfiles(exarg_T *eap) if (p == NULL) { return; } - char *const s = (char *)expand_env_save((char_u *)p); + char *const s = expand_env_save((char *)p); eap->arg = s; eap->cmdidx = CMD_edit; cmdmod.browse = false; diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 8624f6d676..a6cafb2628 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -554,7 +554,7 @@ void dialog_changed(buf_T *buf, bool checkall) .forceit = false, }; - dialog_msg((char *)buff, _("Save changes to \"%s\"?"), (char *)buf->b_fname); + dialog_msg((char *)buff, _("Save changes to \"%s\"?"), buf->b_fname); if (checkall) { ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, (char_u *)buff, 1); } else { @@ -563,11 +563,7 @@ void dialog_changed(buf_T *buf, bool checkall) if (ret == VIM_YES) { if (buf->b_fname != NULL - && check_overwrite(&ea, - buf, - (char *)buf->b_fname, - (char *)buf->b_ffname, - false) == OK) { + && check_overwrite(&ea, buf, buf->b_fname, (char *)buf->b_ffname, false) == OK) { // didn't hit Cancel (void)buf_write_all(buf, false); } @@ -583,7 +579,7 @@ void dialog_changed(buf_T *buf, bool checkall) set_bufref(&bufref, buf2); if (buf2->b_fname != NULL - && check_overwrite(&ea, buf2, (char *)buf2->b_fname, + && check_overwrite(&ea, buf2, buf2->b_fname, (char *)buf2->b_ffname, false) == OK) { // didn't hit Cancel (void)buf_write_all(buf2, false); @@ -611,7 +607,7 @@ bool dialog_close_terminal(buf_T *buf) char buff[DIALOG_MSG_SIZE]; dialog_msg(buff, _("Close \"%s\"?"), - (buf->b_fname != NULL) ? (char *)buf->b_fname : "?"); + (buf->b_fname != NULL) ? buf->b_fname : "?"); int ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, (char_u *)buff, 1); @@ -738,7 +734,7 @@ bool check_changed_any(bool hidden, bool unload) if ((buf->terminal && channel_job_running((uint64_t)buf->b_p_channel)) ? semsg(_("E947: Job still running in buffer \"%s\""), buf->b_fname) : semsg(_("E162: No write since last change for buffer \"%s\""), - buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname)) { + buf_spname(buf) != NULL ? buf_spname(buf) : (char_u *)buf->b_fname)) { save = no_wait_return; no_wait_return = false; wait_return(false); @@ -792,7 +788,7 @@ int buf_write_all(buf_T *buf, int forceit) int retval; buf_T *old_curbuf = curbuf; - retval = (buf_write(buf, (char *)buf->b_ffname, (char *)buf->b_fname, + retval = (buf_write(buf, (char *)buf->b_ffname, buf->b_fname, (linenr_T)1, buf->b_ml.ml_line_count, NULL, false, forceit, true, false)); if (curbuf != old_curbuf) { @@ -908,7 +904,7 @@ static int do_arglist(char *str, int what, int after, bool will_edit) if (curbuf->b_ffname == NULL) { return FAIL; } - str = (char *)curbuf->b_fname; + str = curbuf->b_fname; arg_escaped = false; } @@ -924,11 +920,11 @@ static int do_arglist(char *str, int what, int after, bool will_edit) regmatch.rm_ic = p_fic; // ignore case when 'fileignorecase' is set for (int i = 0; i < new_ga.ga_len && !got_int; i++) { p = ((char **)new_ga.ga_data)[i]; - p = (char *)file_pat_to_reg_pat((char_u *)p, NULL, NULL, false); + p = file_pat_to_reg_pat(p, NULL, NULL, false); if (p == NULL) { break; } - regmatch.regprog = vim_regcomp((char_u *)p, p_magic ? RE_MAGIC : 0); + regmatch.regprog = vim_regcomp(p, p_magic ? RE_MAGIC : 0); if (regmatch.regprog == NULL) { xfree(p); break; @@ -1518,12 +1514,11 @@ void ex_listdo(exarg_T *eap) // buffer was opened while Syntax autocommands were disabled, // need to trigger them now. if (buf == curbuf) { - apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, - curbuf->b_fname, true, curbuf); + apply_autocmds(EVENT_SYNTAX, (char *)curbuf->b_p_syn, curbuf->b_fname, true, + curbuf); } else { aucmd_prepbuf(&aco, buf); - apply_autocmds(EVENT_SYNTAX, buf->b_p_syn, - buf->b_fname, true, buf); + apply_autocmds(EVENT_SYNTAX, (char *)buf->b_p_syn, buf->b_fname, true, buf); aucmd_restbuf(&aco); } @@ -1920,7 +1915,7 @@ int do_source(char *fname, int check_other, int is_vimrc) proftime_T wait_start; bool trigger_source_post = false; - p = (char *)expand_env_save((char_u *)fname); + p = expand_env_save(fname); if (p == NULL) { return retval; } @@ -1936,18 +1931,18 @@ int do_source(char *fname, int check_other, int is_vimrc) // Apply SourceCmd autocommands, they should get the file and source it. if (has_autocmd(EVENT_SOURCECMD, fname_exp, NULL) - && apply_autocmds(EVENT_SOURCECMD, (char_u *)fname_exp, (char_u *)fname_exp, + && apply_autocmds(EVENT_SOURCECMD, fname_exp, fname_exp, false, curbuf)) { retval = aborting() ? FAIL : OK; if (retval == OK) { // Apply SourcePost autocommands. - apply_autocmds(EVENT_SOURCEPOST, (char_u *)fname_exp, (char_u *)fname_exp, false, curbuf); + apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, false, curbuf); } goto theend; } // Apply SourcePre autocommands, they may get the file. - apply_autocmds(EVENT_SOURCEPRE, (char_u *)fname_exp, (char_u *)fname_exp, false, curbuf); + apply_autocmds(EVENT_SOURCEPRE, fname_exp, fname_exp, false, curbuf); cookie.fp = fopen_noinh_readbin(fname_exp); if (cookie.fp == NULL && check_other) { @@ -2143,7 +2138,7 @@ int do_source(char *fname, int check_other, int is_vimrc) convert_setup(&cookie.conv, NULL, NULL); if (trigger_source_post) { - apply_autocmds(EVENT_SOURCEPOST, (char_u *)fname_exp, (char_u *)fname_exp, false, curbuf); + apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, false, curbuf); } theend: diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index cdf1564761..e845073c12 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1927,7 +1927,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter ++p; } p = xstrnsave(ea.cmd, (size_t)(p - ea.cmd)); - int ret = apply_autocmds(EVENT_CMDUNDEFINED, (char_u *)p, (char_u *)p, true, NULL); + int ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, true, NULL); xfree(p); // If the autocommands did something and didn't cause an error, try // finding the command again. @@ -2554,7 +2554,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only) break; } if (!skip_only) { - cmdmod.filter_regmatch.regprog = vim_regcomp((char_u *)reg_pat, RE_MAGIC); + cmdmod.filter_regmatch.regprog = vim_regcomp(reg_pat, RE_MAGIC); if (cmdmod.filter_regmatch.regprog == NULL) { break; } @@ -2971,7 +2971,7 @@ char *find_ex_command(exarg_T *eap, int *full) } // check for non-alpha command - if (p == eap->cmd && vim_strchr((char_u *)"@!=><&~#", *p) != NULL) { + if (p == eap->cmd && vim_strchr("@!=><&~#", *p) != NULL) { p++; } len = (int)(p - eap->cmd); @@ -3297,7 +3297,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) // 2. skip comment lines and leading space, colons or bars const char *cmd; - for (cmd = buff; vim_strchr((const char_u *)" \t:|", *cmd) != NULL; cmd++) {} + for (cmd = buff; vim_strchr(" \t:|", *cmd) != NULL; cmd++) {} xp->xp_pattern = (char *)cmd; if (*cmd == NUL) { @@ -3358,7 +3358,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) } } // check for non-alpha command - if (p == cmd && vim_strchr((const char_u *)"@*!=><&~#", *p) != NULL) { + if (p == cmd && vim_strchr("@*!=><&~#", *p) != NULL) { p++; } len = (size_t)(p - cmd); @@ -3390,7 +3390,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) } if (ea.cmdidx == CMD_SIZE) { - if (*cmd == 's' && vim_strchr((const char_u *)"cgriI", cmd[1]) != NULL) { + if (*cmd == 's' && vim_strchr("cgriI", cmd[1]) != NULL) { ea.cmdidx = CMD_substitute; p = cmd + 1; } else if (cmd[0] >= 'A' && cmd[0] <= 'Z') { @@ -4135,7 +4135,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) break; case CMD_argdelete: - while ((xp->xp_pattern = (char *)vim_strchr((const char_u *)arg, ' ')) != NULL) { + while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) { arg = (const char *)(xp->xp_pattern + 1); } xp->xp_context = EXPAND_ARGLIST; @@ -4166,7 +4166,7 @@ char *skip_range(const char *cmd, int *ctx) { unsigned delim; - while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;\\", *cmd) != NULL) { + while (vim_strchr(" \t0123456789.$%'/?-+,;\\", *cmd) != NULL) { if (*cmd == '\\') { if (cmd[1] == '?' || cmd[1] == '/' || cmd[1] == '&') { cmd++; @@ -4536,7 +4536,7 @@ error: /// Get flags from an Ex command argument. static void get_flags(exarg_T *eap) { - while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL) { + while (vim_strchr("lp#", *eap->arg) != NULL) { if (*eap->arg == 'l') { eap->flags |= EXFLAG_LIST; } else if (*eap->arg == 'p') { @@ -4792,8 +4792,8 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp) * Quick check if this cannot be the start of a special string. * Also removes backslash before '%', '#' and '<'. */ - if (vim_strchr((char_u *)"%#<", *p) == NULL) { - ++p; + if (vim_strchr("%#<", *p) == NULL) { + p++; continue; } @@ -4812,10 +4812,10 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp) // Wildcards won't be expanded below, the replacement is taken // literally. But do expand "~/file", "~user/file" and "$HOME/file". - if (vim_strchr((char_u *)repl, '$') != NULL || vim_strchr((char_u *)repl, '~') != NULL) { + if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL) { char *l = repl; - repl = (char *)expand_env_save((char_u *)repl); + repl = expand_env_save(repl); xfree(l); } @@ -4845,8 +4845,8 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp) # define ESCAPE_CHARS escape_chars #endif - for (l = repl; *l; ++l) { - if (vim_strchr(ESCAPE_CHARS, *l) != NULL) { + for (l = repl; *l; l++) { + if (vim_strchr((char *)ESCAPE_CHARS, *l) != NULL) { l = (char *)vim_strsave_escaped((char_u *)repl, ESCAPE_CHARS); xfree(repl); repl = l; @@ -4885,8 +4885,8 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp) * After expanding environment variables, check again * if there are still wildcards present. */ - if (vim_strchr((char_u *)eap->arg, '$') != NULL - || vim_strchr((char_u *)eap->arg, '~') != NULL) { + if (vim_strchr(eap->arg, '$') != NULL + || vim_strchr(eap->arg, '~') != NULL) { expand_env_esc((char_u *)eap->arg, NameBuff, MAXPATHL, true, true, NULL); has_wildcards = path_has_wildcard(NameBuff); p = (char *)NameBuff; @@ -6338,7 +6338,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((char_u *)"qQfF", *p) != NULL) && p[1] == '-') { + if ((vim_strchr("qQfF", *p) != NULL) && p[1] == '-') { quote = (*p == 'q' || *p == 'Q') ? 1 : 2; p += 2; l -= 2; @@ -6643,9 +6643,9 @@ static void do_ucmd(exarg_T *eap) totlen = 0; for (;;) { - start = (char *)vim_strchr((char_u *)p, '<'); + start = vim_strchr(p, '<'); if (start != NULL) { - end = (char *)vim_strchr((char_u *)start + 1, '>'); + end = vim_strchr(start + 1, '>'); } if (buf != NULL) { for (ksp = p; *ksp != NUL && (char_u)(*ksp) != K_SPECIAL; ksp++) {} @@ -7781,7 +7781,7 @@ static void ex_tabs(exarg_T *eap) if (buf_spname(wp->w_buffer) != NULL) { STRLCPY(IObuff, buf_spname(wp->w_buffer), IOSIZE); } else { - home_replace(wp->w_buffer, wp->w_buffer->b_fname, IObuff, IOSIZE, true); + home_replace(wp->w_buffer, (char_u *)wp->w_buffer->b_fname, IObuff, IOSIZE, true); } msg_outtrans(IObuff); ui_flush(); // output one line at a time @@ -8096,7 +8096,7 @@ static void ex_read(exarg_T *eap) if (check_fname() == FAIL) { // check for no file name return; } - i = readfile((char *)curbuf->b_ffname, (char *)curbuf->b_fname, + i = readfile((char *)curbuf->b_ffname, curbuf->b_fname, eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false); } else { if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) { @@ -8175,7 +8175,7 @@ static void post_chdir(CdScope scope, bool trigger_dirchanged) char *pdir = get_prevdir(scope); // If still in global directory, set CWD as the global directory. if (globaldir == NULL && pdir != NULL) { - globaldir = vim_strsave((char_u *)pdir); + globaldir = xstrdup(pdir); } } @@ -8593,8 +8593,7 @@ static void ex_at(exarg_T *eap) } // Put the register in the typeahead buffer with the "silent" flag. - if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE) - == FAIL) { + if (do_execreg(c, true, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, true) == FAIL) { beep_flush(); } else { bool save_efr = exec_from_reg; @@ -8737,7 +8736,7 @@ static void ex_redir(exarg_T *eap) close_redir(); // Expand environment variables and "~/". - fname = (char *)expand_env_save((char_u *)arg); + fname = expand_env_save(arg); if (fname == NULL) { return; } @@ -9478,7 +9477,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum result = ""; valid = 0; // Must have ":p:h" to be valid } else { - result = (char *)curbuf->b_fname; + result = curbuf->b_fname; tilde_file = STRCMP(result, "~") == 0; } break; @@ -9532,7 +9531,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum result = ""; valid = 0; // Must have ":p:h" to be valid } else { - result = (char *)buf->b_fname; + result = buf->b_fname; tilde_file = STRCMP(result, "~") == 0; } } diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 46f3a31120..fa70f762a2 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -1361,18 +1361,18 @@ void ex_catch(exarg_T *eap) save_char = *end; *end = NUL; } - save_cpo = (char *)p_cpo; - p_cpo = (char_u *)""; + save_cpo = p_cpo; + p_cpo = ""; // Disable error messages, it will make current exception // invalid emsg_off++; - regmatch.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING); + regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); emsg_off--; regmatch.rm_ic = false; if (end != NULL) { *end = save_char; } - p_cpo = (char_u *)save_cpo; + p_cpo = save_cpo; if (regmatch.regprog == NULL) { semsg(_(e_invarg2), pat); } else { diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index a7e843704f..114f1e2ae5 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -398,7 +398,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s cmdmod = save_cmdmod; cmd = skip_range(ea.cmd, NULL); - if (vim_strchr((char_u *)"sgvl", *cmd) == NULL) { + if (vim_strchr("sgvl", *cmd) == NULL) { goto theend; } @@ -687,8 +687,7 @@ static int may_add_char_to_search(int firstc, int *c, incsearch_state_T *s) *c = mb_tolower(*c); } if (*c == search_delim - || vim_strchr((char_u *)(p_magic ? "\\~^$.*[" : "\\^$"), *c) - != NULL) { + || vim_strchr((p_magic ? "\\~^$.*[" : "\\^$"), *c) != NULL) { // put a backslash before special characters stuffcharReadbuff(*c); *c = '\\'; @@ -908,8 +907,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init tv_dict_set_keys_readonly(dict); try_enter(&tstate); - apply_autocmds(EVENT_CMDLINEENTER, (char_u *)firstcbuf, (char_u *)firstcbuf, - false, curbuf); + apply_autocmds(EVENT_CMDLINEENTER, firstcbuf, firstcbuf, false, curbuf); restore_v_event(dict, &save_v_event); @@ -934,8 +932,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init tv_dict_add_bool(dict, S_LEN("abort"), s->gotesc ? kBoolVarTrue : kBoolVarFalse); try_enter(&tstate); - apply_autocmds(EVENT_CMDLINELEAVE, (char_u *)firstcbuf, (char_u *)firstcbuf, - false, curbuf); + apply_autocmds(EVENT_CMDLINELEAVE, firstcbuf, firstcbuf, false, curbuf); // error printed below, to avoid redraw issues tl_ret = try_leave(&tstate, &err); if (tv_dict_get_number(dict, "abort") != 0) { @@ -2306,7 +2303,7 @@ static int empty_pattern(char_u *p) // remove trailing \v and the like while (n >= 2 && p[n - 2] == '\\' - && vim_strchr((char_u *)"mMvVcCZ", p[n - 1]) != NULL) { + && vim_strchr("mMvVcCZ", p[n - 1]) != NULL) { n -= 2; } return n == 0 || (n >= 2 && p[n - 2] == '\\' && p[n - 1] == '|'); @@ -2331,8 +2328,7 @@ static int command_line_changed(CommandLineState *s) tv_dict_set_keys_readonly(dict); try_enter(&tstate); - apply_autocmds(EVENT_CMDLINECHANGED, (char_u *)firstcbuf, - (char_u *)firstcbuf, false, curbuf); + apply_autocmds(EVENT_CMDLINECHANGED, firstcbuf, firstcbuf, false, curbuf); restore_v_event(dict, &save_v_event); bool tl_ret = try_leave(&tstate, &err); @@ -4500,9 +4496,9 @@ static int expand_showtail(expand_T *xp) // Skip escaped wildcards. Only when the backslash is not a path // separator, on DOS the '*' "path\*\file" must not be skipped. if (rem_backslash(s)) { - ++s; - } else if (vim_strchr((char_u *)"*?[", *s) != NULL) { - return FALSE; + s++; + } else if (vim_strchr("*?[", *s) != NULL) { + return false; } } return TRUE; @@ -4630,8 +4626,8 @@ char_u *addstar(char_u *fname, size_t len, int context) #endif if ((*retval != '~' || tail != retval) && !ends_in_star - && vim_strchr(tail, '$') == NULL - && vim_strchr(retval, '`') == NULL) { + && vim_strchr((char *)tail, '$') == NULL + && vim_strchr((char *)retval, '`') == NULL) { retval[len++] = '*'; } else if (len > 0 && retval[len - 1] == '$') { --len; @@ -5003,7 +4999,7 @@ static int ExpandFromContext(expand_T *xp, char_u *pat, int *num_file, char_u ** return nlua_expand_pat(xp, pat, num_file, file); } - regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0); + regmatch.regprog = vim_regcomp((char *)pat, p_magic ? RE_MAGIC : 0); if (regmatch.regprog == NULL) { return FAIL; } @@ -5220,7 +5216,7 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file, int hashtab_T found_ht; hash_init(&found_ht); for (s = path;; s = e) { - e = vim_strchr(s, ENV_SEPCHAR); + e = (char_u *)vim_strchr((char *)s, ENV_SEPCHAR); if (e == NULL) { e = s + STRLEN(s); } @@ -5352,7 +5348,7 @@ static int ExpandUserDefined(expand_T *xp, regmatch_T *regmatch, int *num_file, ga_init(&ga, (int)sizeof(char *), 3); for (char_u *s = retstr; *s != NUL; s = e) { - e = vim_strchr(s, '\n'); + e = (char_u *)vim_strchr((char *)s, '\n'); if (e == NULL) { e = s + STRLEN(s); } @@ -5853,7 +5849,7 @@ HistoryType get_histtype(const char *const name, const size_t len, const bool re } } - if (vim_strchr((char_u *)":=@>?/", name[0]) != NULL && len == 1) { + if (vim_strchr(":=@>?/", name[0]) != NULL && len == 1) { return hist_char2type(name[0]); } @@ -6153,7 +6149,7 @@ int del_history_entry(int histype, char_u *str) && histype < HIST_COUNT && *str != NUL && (idx = hisidx[histype]) >= 0 - && (regmatch.regprog = vim_regcomp(str, RE_MAGIC + RE_STRING)) + && (regmatch.regprog = vim_regcomp((char *)str, RE_MAGIC + RE_STRING)) != NULL) { i = last = idx; do { @@ -6280,7 +6276,7 @@ void ex_history(exarg_T *eap) if (!(ascii_isdigit(*arg) || *arg == '-' || *arg == ',')) { end = arg; while (ASCII_ISALPHA(*end) - || vim_strchr((char_u *)":=@>/?", *end) != NULL) { + || vim_strchr(":=@>/?", *end) != NULL) { end++; } histype1 = get_histtype((const char *)arg, (size_t)(end - arg), false); @@ -6386,7 +6382,7 @@ static int open_cmdwin(void) int i; linenr_T lnum; garray_T winsizes; - char_u typestr[2]; + char typestr[2]; int save_restart_edit = restart_edit; int save_State = State; bool save_exmode = exmode_active; @@ -6490,7 +6486,7 @@ static int open_cmdwin(void) cmdwin_result = 0; // Trigger CmdwinEnter autocommands. - typestr[0] = (char_u)cmdwin_type; + typestr[0] = (char)cmdwin_type; typestr[1] = NUL; apply_autocmds(EVENT_CMDWINENTER, typestr, typestr, false, curbuf); if (restart_edit != 0) { // autocmd with ":startinsert" @@ -6642,8 +6638,8 @@ char *script_get(exarg_T *const eap, size_t *const lenp) const char *const end_pattern = (cmd[2] != NUL ? (const char *)skipwhite(cmd + 2) : "."); for (;;) { - char *const theline = (char *)eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : NUL, - eap->cookie, 0, true); + char *const theline = eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : NUL, eap->cookie, 0, + true); if (theline == NULL || strcmp(end_pattern, theline) == 0) { xfree(theline); diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index cb1d400c56..7eef6707dd 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -571,7 +571,7 @@ static int makeopens(FILE *fd, char_u *dirnow) if (ssop_flags & SSOP_SESDIR) { PUTLINE_FAIL("exe \"cd \" . escape(expand(\"<sfile>:p:h\"), ' ')"); } else if (ssop_flags & SSOP_CURDIR) { - sname = home_replace_save(NULL, globaldir != NULL ? globaldir : dirnow); + sname = home_replace_save(NULL, globaldir != NULL ? (char_u *)globaldir : dirnow); char *fname_esc = ses_escape_fname((char *)sname, &ssop_flags); if (fprintf(fd, "cd %s\n", fname_esc) < 0) { xfree(fname_esc); @@ -997,7 +997,7 @@ void ex_mkrc(exarg_T *eap) } } else if (*dirnow != NUL && (ssop_flags & SSOP_CURDIR) && globaldir != NULL) { - if (os_chdir((char *)globaldir) == 0) { + if (os_chdir(globaldir) == 0) { shorten_fnames(true); } } diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 02db5ded75..47e20d58a3 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -371,7 +371,7 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le ptr = xrealloc(search_ctx->ffsc_stopdirs_v, (dircount + 1) * sizeof(char_u *)); search_ctx->ffsc_stopdirs_v = ptr; - walker = vim_strchr(walker, ';'); + walker = (char_u *)vim_strchr((char *)walker, ';'); if (walker) { assert(walker - helper >= 0); search_ctx->ffsc_stopdirs_v[dircount - 1] = @@ -396,7 +396,7 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le * -fix path * -wildcard_stuff (might be NULL) */ - wc_part = vim_strchr(path, '*'); + wc_part = (char_u *)vim_strchr((char *)path, '*'); if (wc_part != NULL) { int64_t llevel; int len; @@ -1643,7 +1643,7 @@ void do_autocmd_dirchanged(char *new_dir, CdScope scope, CdCause cause, bool pre abort(); } - apply_autocmds(event, (char_u *)buf, (char_u *)new_dir, false, curbuf); + apply_autocmds(event, buf, new_dir, false, curbuf); restore_v_event(dict, &save_v_event); diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index c412af0eaa..06d72f3395 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -277,10 +277,10 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, // point to one of these values. old_curbuf = curbuf; old_b_ffname = (char *)curbuf->b_ffname; - old_b_fname = (char *)curbuf->b_fname; + old_b_fname = curbuf->b_fname; using_b_ffname = ((char_u *)fname == curbuf->b_ffname) || ((char_u *)sfname == curbuf->b_ffname); - using_b_fname = ((char_u *)fname == curbuf->b_fname) || ((char_u *)sfname == curbuf->b_fname); + using_b_fname = (fname == curbuf->b_fname) || (sfname == curbuf->b_fname); // After reading a file the cursor line changes but we don't want to // display the line. @@ -469,7 +469,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, || (using_b_ffname && ((char_u *)old_b_ffname != curbuf->b_ffname)) || (using_b_fname - && ((char_u *)old_b_fname != curbuf->b_fname))) { + && (old_b_fname != curbuf->b_fname))) { emsg(_(e_auchangedbuf)); return FAIL; } @@ -540,7 +540,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, if (!read_stdin && (curbuf != old_curbuf || (using_b_ffname && ((char_u *)old_b_ffname != curbuf->b_ffname)) - || (using_b_fname && ((char_u *)old_b_fname != curbuf->b_fname)))) { + || (using_b_fname && (old_b_fname != curbuf->b_fname)))) { emsg(_(e_auchangedbuf)); if (!read_buffer) { close(fd); @@ -646,7 +646,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, */ if (!read_stdin && (curbuf != old_curbuf || (using_b_ffname && ((char_u *)old_b_ffname != curbuf->b_ffname)) - || (using_b_fname && ((char_u *)old_b_fname != curbuf->b_fname)) + || (using_b_fname && (old_b_fname != curbuf->b_fname)) || (fd = os_open(fname, O_RDONLY, 0)) < 0)) { no_wait_return--; msg_scroll = msg_save; @@ -1957,8 +1957,7 @@ failed: if (!au_did_filetype && *curbuf->b_p_ft != NUL) { // EVENT_FILETYPE was not triggered but the buffer already has a // filetype. Trigger EVENT_FILETYPE using the existing filetype. - apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, curbuf->b_fname, - true, curbuf); + apply_autocmds(EVENT_FILETYPE, (char *)curbuf->b_p_ft, curbuf->b_fname, true, curbuf); } } else { apply_autocmds_exarg(EVENT_FILEREADPOST, sfname, sfname, @@ -2084,7 +2083,7 @@ static char_u *next_fenc(char_u **pp, bool *alloced) *pp = NULL; return (char_u *)""; } - p = vim_strchr(*pp, ','); + p = (char_u *)vim_strchr((char *)(*pp), ','); if (p == NULL) { r = enc_canonize(*pp); *pp += STRLEN(*pp); @@ -2466,8 +2465,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en } if (reset_changed && buf->b_changed && !append && (overwriting || vim_strchr(p_cpo, CPO_PLUS) != NULL)) { - /* Buffer still changed, the autocommands didn't work - * properly. */ + // Buffer still changed, the autocommands didn't work properly. return FAIL; } return OK; @@ -4327,7 +4325,7 @@ void shorten_buf_fname(buf_T *buf, char_u *dirname, int force) if (buf->b_fname != NULL && !bt_nofile(buf) - && !path_with_url((char *)buf->b_fname) + && !path_with_url(buf->b_fname) && (force || buf->b_sfname == NULL || path_is_absolute(buf->b_sfname))) { @@ -4337,10 +4335,10 @@ void shorten_buf_fname(buf_T *buf, char_u *dirname, int force) p = path_shorten_fname(buf->b_ffname, dirname); if (p != NULL) { buf->b_sfname = vim_strsave(p); - buf->b_fname = buf->b_sfname; + buf->b_fname = (char *)buf->b_sfname; } if (p == NULL) { - buf->b_fname = buf->b_ffname; + buf->b_fname = (char *)buf->b_ffname; } } } @@ -4957,7 +4955,7 @@ int buf_check_timestamp(buf_T *buf) buf_store_file_info(buf, &file_info); } - if (os_isdir(buf->b_fname)) { + if (os_isdir((char_u *)buf->b_fname)) { // Don't do anything for a directory. Might contain the file explorer. } else if ((buf->b_p_ar >= 0 ? buf->b_p_ar : p_ar) && !bufIsChanged(buf) && file_info_ok) { @@ -4985,8 +4983,7 @@ int buf_check_timestamp(buf_T *buf) set_vim_var_string(VV_FCS_REASON, reason, -1); set_vim_var_string(VV_FCS_CHOICE, "", -1); allbuf_lock++; - bool n = apply_autocmds(EVENT_FILECHANGEDSHELL, - buf->b_fname, buf->b_fname, false, buf); + bool n = apply_autocmds(EVENT_FILECHANGEDSHELL, buf->b_fname, buf->b_fname, false, buf); allbuf_lock--; busy = false; if (n) { @@ -5046,7 +5043,7 @@ int buf_check_timestamp(buf_T *buf) } if (mesg != NULL) { - path = home_replace_save(buf, buf->b_fname); + path = home_replace_save(buf, (char_u *)buf->b_fname); if (!helpmesg) { mesg2 = ""; } @@ -5117,8 +5114,7 @@ int buf_check_timestamp(buf_T *buf) // Trigger FileChangedShell when the file was changed in any way. if (bufref_valid(&bufref) && retval != 0) { - (void)apply_autocmds(EVENT_FILECHANGEDSHELLPOST, buf->b_fname, buf->b_fname, - false, buf); + (void)apply_autocmds(EVENT_FILECHANGEDSHELLPOST, buf->b_fname, buf->b_fname, false, buf); } return retval; } @@ -5192,7 +5188,7 @@ void buf_reload(buf_T *buf, int orig_mode, bool reload_options) if (saved == OK) { curbuf->b_flags |= BF_CHECK_RO; // check for RO again keep_filetype = true; // don't detect 'filetype' - if (readfile((char *)buf->b_ffname, (char *)buf->b_fname, (linenr_T)0, (linenr_T)0, + if (readfile((char *)buf->b_ffname, buf->b_fname, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, &ea, flags, false) != OK) { if (!aborting()) { semsg(_("E321: Could not reload \"%s\""), buf->b_fname); @@ -5523,7 +5519,7 @@ bool match_file_pat(char *pattern, regprog_T **prog, char *fname, char *sfname, if (prog != NULL) { regmatch.regprog = *prog; } else { - regmatch.regprog = vim_regcomp((char_u *)pattern, RE_MAGIC); + regmatch.regprog = vim_regcomp(pattern, RE_MAGIC); } } @@ -5575,7 +5571,7 @@ bool match_file_list(char_u *list, char_u *sfname, char_u *ffname) p = list; while (*p) { copy_option_part(&p, buf, ARRAY_SIZE(buf), ","); - regpat = file_pat_to_reg_pat(buf, NULL, &allow_dirs, false); + regpat = (char_u *)file_pat_to_reg_pat((char *)buf, NULL, &allow_dirs, false); if (regpat == NULL) { break; } @@ -5600,13 +5596,12 @@ bool match_file_list(char_u *list, char_u *sfname, char_u *ffname) /// @param no_bslash Don't use a backward slash as pathsep /// /// @return NULL on failure. -char_u *file_pat_to_reg_pat(const char_u *pat, const char_u *pat_end, char *allow_dirs, - int no_bslash) +char *file_pat_to_reg_pat(const char *pat, const char *pat_end, char *allow_dirs, int no_bslash) FUNC_ATTR_NONNULL_ARG(1) { - const char_u *endp; - char_u *reg_pat; - const char_u *p; + const char *endp; + char *reg_pat; + const char *p; int nested = 0; bool add_dollar = true; @@ -5618,7 +5613,7 @@ char_u *file_pat_to_reg_pat(const char_u *pat, const char_u *pat_end, char *allo } if (pat_end == pat) { - return (char_u *)xstrdup("^$"); + return xstrdup("^$"); } size_t size = 2; // '^' at start, '$' at end. diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 24f088e06f..090f754e93 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -2911,7 +2911,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((char *)flp->wp->w_p_fdi, *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; @@ -3042,7 +3042,7 @@ static void foldlevelExpr(fline_T *flp) /// Relies on the option value to have been checked for correctness already. static void parseMarker(win_T *wp) { - foldendmarker = vim_strchr(wp->w_p_fmr, ','); + foldendmarker = (char_u *)vim_strchr((char *)wp->w_p_fmr, ','); foldstartmarkerlen = (size_t)(foldendmarker++ - wp->w_p_fmr); foldendmarkerlen = STRLEN(foldendmarker); } diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index e64fda39e9..2cc068b30d 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -802,7 +802,7 @@ int start_redo_ins(void) // skip the count and the command character while ((c = read_redo(false, false)) != NUL) { - if (vim_strchr((char_u *)"AaIiRrOo", c) != NULL) { + if (vim_strchr("AaIiRrOo", c) != NULL) { if (c == 'O' || c == 'o') { add_buff(&readbuf2, NL_STR, -1L); } @@ -4736,9 +4736,9 @@ char_u *check_map(char_u *keys, int mode, int exact, int ign_mod, int abbr, mapb void add_map(char_u *map, int mode, bool nore) { char_u *s; - char_u *cpo_save = p_cpo; + char *cpo_save = p_cpo; - p_cpo = (char_u *)""; // Allow <> notation + p_cpo = ""; // Allow <> notation // Need to put string in allocated memory, because do_map() will modify it. s = vim_strsave(map); (void)do_map(nore ? 2 : 0, s, mode, false); diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 1a1f9bd866..e34e3983db 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -811,7 +811,7 @@ extern char_u *compiled_sys; // When a window has a local directory, the absolute path of the global // current directory is stored here (in allocated memory). If the current // directory is not a local directory, globaldir is NULL. -EXTERN char_u *globaldir INIT(= NULL); +EXTERN char *globaldir INIT(= NULL); EXTERN char *last_chdir_reason INIT(= NULL); diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index aec15234b9..fb174baef8 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -311,12 +311,12 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_ */ stringp = option_str; while (*stringp) { - colonp = vim_strchr(stringp, ':'); + colonp = (char_u *)vim_strchr((char *)stringp, ':'); if (colonp == NULL) { ret = N_("E550: Missing colon"); break; } - commap = vim_strchr(stringp, ','); + commap = (char_u *)vim_strchr((char *)stringp, ','); if (commap == NULL) { commap = option_str + STRLEN(option_str); } @@ -661,7 +661,7 @@ void ex_hardcopy(exarg_T *eap) */ if (mch_print_init(&settings, curbuf->b_fname == NULL ? buf_spname(curbuf) : curbuf->b_sfname == - NULL ? curbuf->b_fname : curbuf->b_sfname, eap->forceit) == FAIL) { + NULL ? (char_u *)curbuf->b_fname : curbuf->b_sfname, eap->forceit) == FAIL) { return; } @@ -1588,7 +1588,7 @@ static int prt_find_resource(char *name, struct prt_ps_resource_S *resource) STRLCAT(buffer, name, MAXPATHL); STRLCAT(buffer, ".ps", MAXPATHL); resource->filename[0] = NUL; - retval = (do_in_runtimepath((char *)buffer, 0, prt_resource_name, resource->filename) + retval = (do_in_runtimepath(buffer, 0, prt_resource_name, resource->filename) && resource->filename[0] != NUL); xfree(buffer); return retval; @@ -2344,7 +2344,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) * Set up the font size. */ fontsize = PRT_PS_DEFAULT_FONTSIZE; - for (p = p_pfn; (p = vim_strchr(p, ':')) != NULL; ++p) { + for (p = p_pfn; (p = (char_u *)vim_strchr((char *)p, ':')) != NULL; p++) { if (p[1] == 'h' && ascii_isdigit(p[2])) { fontsize = atoi((char *)p + 2); } @@ -2413,7 +2413,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) } prt_ps_fd = os_fopen((char *)prt_ps_file_name, WRITEBIN); } else { - p = expand_env_save(psettings->outfile); + p = (char_u *)expand_env_save((char *)psettings->outfile); if (p != NULL) { prt_ps_fd = os_fopen((char *)p, WRITEBIN); xfree(p); @@ -2525,7 +2525,7 @@ bool mch_print_begin(prt_settings_T *psettings) char ctime_buf[50]; char *p_time = os_ctime(ctime_buf, sizeof(ctime_buf)); // Note: os_ctime() adds a \n so we have to remove it :-( - p = vim_strchr((char_u *)p_time, '\n'); + p = (char_u *)vim_strchr(p_time, '\n'); if (p != NULL) { *p = NUL; } diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index 5e35b9bd91..240a96cb4b 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -560,7 +560,7 @@ int load_colors(char_u *name) recursive = true; size_t buflen = STRLEN(name) + 12; buf = xmalloc(buflen); - apply_autocmds(EVENT_COLORSCHEMEPRE, name, curbuf->b_fname, false, curbuf); + apply_autocmds(EVENT_COLORSCHEMEPRE, (char *)name, curbuf->b_fname, false, curbuf); snprintf((char *)buf, buflen, "colors/%s.vim", name); retval = source_runtime((char *)buf, DIP_START + DIP_OPT); if (retval == FAIL) { @@ -568,7 +568,7 @@ int load_colors(char_u *name) retval = source_runtime((char *)buf, DIP_START + DIP_OPT); } xfree(buf); - apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, false, curbuf); + apply_autocmds(EVENT_COLORSCHEME, (char *)name, curbuf->b_fname, false, curbuf); recursive = false; diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index 77154e8fce..7174e58986 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -962,7 +962,7 @@ static bool cs_find_common(char *opt, char *pat, int forceit, int verbose, bool cmdletter = opt[0]; } - qfpos = (char *)vim_strchr(p_csqf, cmdletter); + qfpos = vim_strchr((char *)p_csqf, cmdletter); if (qfpos != NULL) { qfpos++; // next symbol must be + or - @@ -972,8 +972,7 @@ static bool cs_find_common(char *opt, char *pat, int forceit, int verbose, bool } if (*qfpos != '0' - && apply_autocmds(EVENT_QUICKFIXCMDPRE, (char_u *)"cscope", - curbuf->b_fname, true, curbuf)) { + && apply_autocmds(EVENT_QUICKFIXCMDPRE, "cscope", curbuf->b_fname, true, curbuf)) { if (aborting()) { return false; } @@ -1049,8 +1048,7 @@ static bool cs_find_common(char *opt, char *pat, int forceit, int verbose, bool postponed_split = 0; } - apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)"cscope", - curbuf->b_fname, TRUE, curbuf); + apply_autocmds(EVENT_QUICKFIXCMDPOST, "cscope", curbuf->b_fname, true, curbuf); if (use_ll) { /* * In the location list window, use the displayed location diff --git a/src/nvim/indent.c b/src/nvim/indent.c index faf6f2dc8f..882a10e1e8 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -407,7 +407,7 @@ int get_number_indent(linenr_T lnum) if ((State & MODE_INSERT) || has_format_option(FO_Q_COMS)) { lead_len = get_leader_len(ml_get(lnum), NULL, false, true); } - regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC); + regmatch.regprog = vim_regcomp((char *)curbuf->b_p_flp, RE_MAGIC); if (regmatch.regprog != NULL) { regmatch.rm_ic = false; @@ -467,7 +467,7 @@ int get_breakindent_win(win_T *wp, char_u *line) // add additional indent for numbered lists if (wp->w_briopt_list != 0) { regmatch_T regmatch = { - .regprog = vim_regcomp(curbuf->b_p_flp, + .regprog = vim_regcomp((char *)curbuf->b_p_flp, RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT), }; diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 854487ccdb..6f75183a5a 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -167,8 +167,8 @@ static const char_u *skip_string(const char_u *p) } } else if (p[0] == 'R' && p[1] == '"') { // Raw string: R"[delim](...)[delim]" - const char_u *delim = p + 2; - const char_u *paren = vim_strchr(delim, '('); + const char *delim = (char *)p + 2; + const char *paren = vim_strchr((char *)delim, '('); if (paren != NULL) { const ptrdiff_t delim_len = paren - delim; @@ -737,7 +737,7 @@ static int cin_get_equal_amount(linenr_T lnum) } line = s = ml_get(lnum); - while (*s != NUL && vim_strchr((char_u *)"=;{}\"'", *s) == NULL) { + while (*s != NUL && vim_strchr("=;{}\"'", *s) == NULL) { if (cin_iscomment(s)) { // ignore comments s = cin_skipcomment(s); } else { @@ -3543,8 +3543,8 @@ term_again: */ if (cur_curpos.lnum < curbuf->b_ml.ml_line_count && !cin_nocode(theline) - && vim_strchr(theline, '{') == NULL - && vim_strchr(theline, '}') == NULL + && vim_strchr((char *)theline, '{') == NULL + && vim_strchr((char *)theline, '}') == NULL && !cin_ends_in(theline, (char_u *)":", NULL) && !cin_ends_in(theline, (char_u *)",", NULL) && cin_isfuncdecl(NULL, cur_curpos.lnum + 1, cur_curpos.lnum + 1) diff --git a/src/nvim/keycodes.h b/src/nvim/keycodes.h index 631a9f68d3..f6c576f6ee 100644 --- a/src/nvim/keycodes.h +++ b/src/nvim/keycodes.h @@ -473,7 +473,7 @@ enum key_extra { #define MAX_KEY_CODE_LEN 6 #define FLAG_CPO_BSLASH 0x01 -#define CPO_TO_CPO_FLAGS ((vim_strchr(p_cpo, CPO_BSLASH) == NULL) \ +#define CPO_TO_CPO_FLAGS ((vim_strchr((char *)p_cpo, CPO_BSLASH) == NULL) \ ? 0 \ : FLAG_CPO_BSLASH) diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index 52a9a1a84f..79e21e518c 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -295,7 +295,7 @@ int nlua_regex(lua_State *lstate) TRY_WRAP({ try_start(); - prog = vim_regcomp((char_u *)text, RE_AUTO | RE_MAGIC | RE_STRICT); + prog = vim_regcomp((char *)text, RE_AUTO | RE_MAGIC | RE_STRICT); try_end(&err); }); diff --git a/src/nvim/main.c b/src/nvim/main.c index 1cf3cdd872..80a856e91a 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -643,8 +643,7 @@ void getout(int exitval) bufref_T bufref; set_bufref(&bufref, buf); - apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, - buf->b_fname, false, buf); + apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, buf->b_fname, false, buf); if (bufref_valid(&bufref)) { buf_set_changedtick(buf, -1); // note that we did it already } diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 222b2a3cf3..6de8d5dfd5 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -717,7 +717,7 @@ static void show_one_mark(int c, char_u *arg, pos_T *p, char_u *name_arg, int cu } } } else if (!got_int - && (arg == NULL || vim_strchr(arg, c) != NULL) + && (arg == NULL || vim_strchr((char *)arg, c) != NULL) && p->lnum != 0) { // don't output anything if 'q' typed at --more-- prompt if (name == NULL && current) { diff --git a/src/nvim/match.c b/src/nvim/match.c index f10d63dd34..54f3bff472 100644 --- a/src/nvim/match.c +++ b/src/nvim/match.c @@ -65,7 +65,7 @@ static int match_add(win_T *wp, const char *const grp, const char *const pat, in if ((hlg_id = syn_check_group(grp, strlen(grp))) == 0) { return -1; } - if (pat != NULL && (regprog = vim_regcomp((char_u *)pat, RE_MAGIC)) == NULL) { + if (pat != NULL && (regprog = vim_regcomp((char *)pat, RE_MAGIC)) == NULL) { semsg(_(e_invarg2), pat); return -1; } diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index c7408c6260..3868d65ab9 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -2289,7 +2289,7 @@ char_u *enc_locale(void) // Make the name lowercase and replace '_' with '-'. // Exception: "ja_JP.EUC" == "euc-jp", "zh_CN.EUC" = "euc-cn", // "ko_KR.EUC" == "euc-kr" - const char *p = (char *)vim_strchr((char_u *)s, '.'); + 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] == '_') { diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 5ca33faec3..ac6bdfa1a4 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -531,8 +531,8 @@ void ml_open_file(buf_T *buf) need_wait_return = true; // call wait_return later no_wait_return++; (void)semsg(_("E303: Unable to open swap file for \"%s\", recovery impossible"), - buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname); - --no_wait_return; + buf_spname(buf) != NULL ? buf_spname(buf) : (char_u *)buf->b_fname); + no_wait_return--; } // don't try to open a swap file again @@ -777,15 +777,14 @@ void ml_recover(bool checkext) // If the file name ends in ".s[a-w][a-z]" we assume this is the swap file. // Otherwise a search is done to find the swap file(s). - fname = curbuf->b_fname; + fname = (char_u *)curbuf->b_fname; if (fname == NULL) { // When there is no file name fname = (char_u *)""; } len = (int)STRLEN(fname); if (checkext && len >= 4 && STRNICMP(fname + len - 4, ".s", 2) == 0 - && vim_strchr((char_u *)"abcdefghijklmnopqrstuvw", - TOLOWER_ASC(fname[len - 2])) != NULL + && vim_strchr("abcdefghijklmnopqrstuvw", TOLOWER_ASC(fname[len - 2])) != NULL && ASCII_ISALPHA(fname[len - 1])) { directly = true; fname_used = vim_strsave(fname); // make a copy for mf_open() @@ -1248,8 +1247,8 @@ theend: if (serious_error && called_from_main) { ml_close(curbuf, TRUE); } else { - apply_autocmds(EVENT_BUFREADPOST, NULL, curbuf->b_fname, FALSE, curbuf); - apply_autocmds(EVENT_BUFWINENTER, NULL, curbuf->b_fname, FALSE, curbuf); + apply_autocmds(EVENT_BUFREADPOST, NULL, curbuf->b_fname, false, curbuf); + apply_autocmds(EVENT_BUFWINENTER, NULL, curbuf->b_fname, false, curbuf); } } @@ -3321,10 +3320,10 @@ static void attention_message(buf_T *buf, char_u *fname) msg_puts("\"\n"); const time_t swap_mtime = swapfile_info(fname); msg_puts(_("While opening file \"")); - msg_outtrans(buf->b_fname); + msg_outtrans((char_u *)buf->b_fname); msg_puts("\"\n"); FileInfo file_info; - if (!os_fileinfo((char *)buf->b_fname, &file_info)) { + if (!os_fileinfo(buf->b_fname, &file_info)) { msg_puts(_(" CANNOT BE FOUND")); } else { msg_puts(_(" dated: ")); @@ -3343,7 +3342,7 @@ static void attention_message(buf_T *buf, char_u *fname) " Quit, or continue with caution.\n")); msg_puts(_("(2) An edit session for this file crashed.\n")); msg_puts(_(" If this is the case, use \":recover\" or \"vim -r ")); - msg_outtrans(buf->b_fname); + msg_outtrans((char_u *)buf->b_fname); msg_puts(_("\"\n to recover the changes (see \":help recovery\").\n")); msg_puts(_(" If you did this already, delete the swap file \"")); msg_outtrans(fname); @@ -3423,7 +3422,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_ char *fname; size_t n; char *dir_name; - char *buf_fname = (char *)buf->b_fname; + char *buf_fname = buf->b_fname; /* * Isolate a directory name from *dirp and put it in dir_name. @@ -3510,14 +3509,14 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_ // give the ATTENTION message when there is an old swap file // for the current file, and the buffer was not recovered. if (differ == false && !(curbuf->b_flags & BF_RECOVERED) - && vim_strchr(p_shm, SHM_ATTENTION) == NULL) { + && vim_strchr((char *)p_shm, SHM_ATTENTION) == NULL) { int choice = 0; process_still_running = false; // It's safe to delete the swap file if all these are true: // - the edited file exists // - the swap file has no changes and looks OK - if (os_path_exists(buf->b_fname) && swapfile_unchanged(fname)) { + if (os_path_exists((char_u *)buf->b_fname) && swapfile_unchanged(fname)) { choice = 4; if (p_verbose > 0) { verb_msg(_("Found a swap file that is not useful, deleting it")); diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 7b254f1b62..c1ce2eefe3 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -1301,7 +1301,7 @@ static char *menu_text(const char *str, int *mnemonic, char **actext) char *text; // Locate accelerator text, after the first TAB - p = (char *)vim_strchr((char_u *)str, TAB); + p = vim_strchr(str, TAB); if (p != NULL) { if (actext != NULL) { *actext = xstrdup(p + 1); @@ -1314,7 +1314,7 @@ static char *menu_text(const char *str, int *mnemonic, char **actext) // Find mnemonic characters "&a" and reduce "&&" to "&". for (p = text; p != NULL;) { - p = (char *)vim_strchr((char_u *)p, '&'); + p = vim_strchr(p, '&'); if (p != NULL) { if (p[1] == NUL) { // trailing "&" break; diff --git a/src/nvim/message.c b/src/nvim/message.c index 52eafe6e26..9ab086f1ea 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -598,8 +598,8 @@ void msg_source(int attr) /// If "emsg_skip" is set: never do error messages. int emsg_not_now(void) { - if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL - && vim_strchr(p_debug, 't') == NULL) + if ((emsg_off > 0 && vim_strchr((char *)p_debug, 'm') == NULL + && vim_strchr((char *)p_debug, 't') == NULL) || emsg_skip > 0) { return TRUE; } @@ -623,14 +623,12 @@ static bool emsg_multiline(const char *s, bool multiline) bool severe = emsg_severe; emsg_severe = false; - if (!emsg_off || vim_strchr(p_debug, 't') != NULL) { - /* - * Cause a throw of an error exception if appropriate. Don't display - * the error message in this case. (If no matching catch clause will - * be found, the message will be displayed later on.) "ignore" is set - * when the message should be ignored completely (used for the - * interrupt message). - */ + if (!emsg_off || vim_strchr((char *)p_debug, 't') != NULL) { + // Cause a throw of an error exception if appropriate. Don't display + // the error message in this case. (If no matching catch clause will + // be found, the message will be displayed later on.) "ignore" is set + // when the message should be ignored completely (used for the + // interrupt message). if (cause_errthrow(s, severe, &ignore)) { if (!ignore) { did_emsg++; @@ -1212,7 +1210,7 @@ void wait_return(int redraw) if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE || c == K_X1MOUSE || c == K_X2MOUSE) { (void)jump_to_mouse(MOUSE_SETPOS, NULL, 0); - } else if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C) { + } else if (vim_strchr("\r\n ", c) == NULL && c != Ctrl_C) { // Put the character back in the typeahead buffer. Don't use the // stuff buffer, because lmaps wouldn't work. ins_char_typebuf(vgetc_char, vgetc_mod_mask); diff --git a/src/nvim/normal.c b/src/nvim/normal.c index a983ff4436..2826b7dad1 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2191,7 +2191,7 @@ static int get_mouse_class(char_u *p) // characters to be considered as a single word. These are things like // "->", "/ *", "*=", "+=", "&=", "<=", ">=", "!=" etc. Otherwise, each // character is in its own class. - if (c != NUL && vim_strchr((char_u *)"-+*/%<>&|^!=", c) != NULL) { + if (c != NUL && vim_strchr("-+*/%<>&|^!=", c) != NULL) { return 1; } return c; @@ -3447,7 +3447,7 @@ dozet: // and "zC" only in Visual mode. "zj" and "zk" are motion // commands. if (cap->nchar != 'f' && cap->nchar != 'F' - && !(VIsual_active && vim_strchr((char_u *)"dcCoO", cap->nchar)) + && !(VIsual_active && vim_strchr("dcCoO", cap->nchar)) && cap->nchar != 'j' && cap->nchar != 'k' && checkclearop(cap->oap)) { return; @@ -3455,7 +3455,7 @@ dozet: // For "z+", "z<CR>", "zt", "z.", "zz", "z^", "z-", "zb": // If line number given, set cursor. - if ((vim_strchr((char_u *)"+\r\nt.z^-b", nchar) != NULL) + if ((vim_strchr("+\r\nt.z^-b", nchar) != NULL) && cap->count0 && cap->count0 != curwin->w_cursor.lnum) { setpcmark(); @@ -3800,7 +3800,7 @@ dozet: no_mapping--; allow_keys--; (void)add_to_showcmd(nchar); - if (vim_strchr((char_u *)"gGwW", nchar) == NULL) { + if (vim_strchr("gGwW", nchar) == NULL) { clearopbeep(cap->oap); break; } @@ -4234,7 +4234,7 @@ static void nv_ident(cmdarg_T *cap) p = (char_u *)buf + STRLEN(buf); while (n-- > 0) { // put a backslash before \ and some others - if (vim_strchr(aux_ptr, *ptr) != NULL) { + if (vim_strchr((char *)aux_ptr, *ptr) != NULL) { *p++ = '\\'; } // When current byte is a part of multibyte character, copy all @@ -4434,9 +4434,9 @@ static void nv_right(cmdarg_T *cap) // <Space> wraps to next line if 'whichwrap' has 's'. // 'l' wraps to next line if 'whichwrap' has 'l'. // CURS_RIGHT wraps to next line if 'whichwrap' has '>'. - if (((cap->cmdchar == ' ' && vim_strchr(p_ww, 's') != NULL) - || (cap->cmdchar == 'l' && vim_strchr(p_ww, 'l') != NULL) - || (cap->cmdchar == K_RIGHT && vim_strchr(p_ww, '>') != NULL)) + if (((cap->cmdchar == ' ' && vim_strchr((char *)p_ww, 's') != NULL) + || (cap->cmdchar == 'l' && vim_strchr((char *)p_ww, 'l') != NULL) + || (cap->cmdchar == K_RIGHT && vim_strchr((char *)p_ww, '>') != NULL)) && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { // When deleting we also count the NL as a character. // Set cap->oap->inclusive when last char in the line is @@ -4504,9 +4504,9 @@ static void nv_left(cmdarg_T *cap) // 'h' wraps to previous line if 'whichwrap' has 'h'. // CURS_LEFT wraps to previous line if 'whichwrap' has '<'. if ((((cap->cmdchar == K_BS || cap->cmdchar == Ctrl_H) - && vim_strchr(p_ww, 'b') != NULL) - || (cap->cmdchar == 'h' && vim_strchr(p_ww, 'h') != NULL) - || (cap->cmdchar == K_LEFT && vim_strchr(p_ww, '<') != NULL)) + && vim_strchr((char *)p_ww, 'b') != NULL) + || (cap->cmdchar == 'h' && vim_strchr((char *)p_ww, 'h') != NULL) + || (cap->cmdchar == K_LEFT && vim_strchr((char *)p_ww, '<') != NULL)) && curwin->w_cursor.lnum > 1) { curwin->w_cursor.lnum--; coladvance(MAXCOL); @@ -4802,7 +4802,7 @@ static void nv_brackets(cmdarg_T *cap) // "[f" or "]f" : Edit file under the cursor (same as "gf") if (cap->nchar == 'f') { nv_gotofile(cap); - } else if (vim_strchr((char_u *)"iI\011dD\004", cap->nchar) != NULL) { + } else if (vim_strchr("iI\011dD\004", cap->nchar) != NULL) { // Find the occurrence(s) of the identifier or define under cursor // in current and included files or jump to the first occurrence. // @@ -4831,8 +4831,8 @@ static void nv_brackets(cmdarg_T *cap) MAXLNUM); curwin->w_set_curswant = true; } - } else if ((cap->cmdchar == '[' && vim_strchr((char_u *)"{(*/#mM", cap->nchar) != NULL) - || (cap->cmdchar == ']' && vim_strchr((char_u *)"})*/#mM", cap->nchar) != NULL)) { + } else if ((cap->cmdchar == '[' && vim_strchr("{(*/#mM", cap->nchar) != NULL) + || (cap->cmdchar == ']' && vim_strchr("})*/#mM", cap->nchar) != NULL)) { // "[{", "[(", "]}" or "])": go to Nth unclosed '{', '(', '}' or ')' // "[#", "]#": go to start/end of Nth innermost #if..#endif construct. // "[/", "[*", "]/", "]*": go to Nth comment start/end. @@ -5403,7 +5403,7 @@ static void n_swapchar(cmdarg_T *cap) return; } - if (LINEEMPTY(curwin->w_cursor.lnum) && vim_strchr(p_ww, '~') == NULL) { + if (LINEEMPTY(curwin->w_cursor.lnum) && vim_strchr((char *)p_ww, '~') == NULL) { clearopbeep(cap->oap); return; } @@ -5419,7 +5419,7 @@ static void n_swapchar(cmdarg_T *cap) did_change |= swapchar(cap->oap->op_type, &curwin->w_cursor); inc_cursor(); if (gchar_cursor() == NUL) { - if (vim_strchr(p_ww, '~') != NULL + if (vim_strchr((char *)p_ww, '~') != NULL && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { curwin->w_cursor.lnum++; curwin->w_cursor.col = 0; @@ -5491,7 +5491,7 @@ static void v_visop(cmdarg_T *cap) curwin->w_curswant = MAXCOL; } } - cap->cmdchar = *(vim_strchr(trans, cap->cmdchar) + 1); + cap->cmdchar = (uint8_t)(*(vim_strchr((char *)trans, cap->cmdchar) + 1)); nv_operator(cap); } @@ -5754,7 +5754,8 @@ void start_selection(void) /// When "c" is 'o' (checking for "mouse") then also when mapped. void may_start_select(int c) { - VIsual_select = (c == 'o' || (stuff_empty() && typebuf_typed())) && vim_strchr(p_slm, c) != NULL; + VIsual_select = (c == 'o' || (stuff_empty() && typebuf_typed())) + && vim_strchr((char *)p_slm, c) != NULL; } /// Start Visual mode "c". diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 1342b10bf8..c3d7742307 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -800,7 +800,7 @@ char_u *get_expr_line_src(void) bool valid_yank_reg(int regname, bool writing) { if ((regname > 0 && ASCII_ISALNUM(regname)) - || (!writing && vim_strchr((char_u *)"/.%:=", regname) != NULL) + || (!writing && vim_strchr("/.%:=", regname) != NULL) || regname == '#' || regname == '"' || regname == '-' @@ -1184,7 +1184,7 @@ int do_execreg(int regname, int colon, int addcr, int silent) if (free_str) { xfree(str); } - retval = ins_typebuf((char *)escaped, remap, 0, true, silent); + retval = ins_typebuf(escaped, remap, 0, true, silent); xfree(escaped); if (retval == FAIL) { return FAIL; @@ -1247,7 +1247,7 @@ static int put_in_typebuf(char_u *s, bool esc, bool colon, int silent) if (p == NULL) { retval = FAIL; } else { - retval = ins_typebuf((char *)p, esc ? REMAP_NONE : REMAP_YES, 0, true, silent); + retval = ins_typebuf(p, esc ? REMAP_NONE : REMAP_YES, 0, true, silent); } if (esc) { xfree(p); @@ -1368,7 +1368,7 @@ bool get_spec_reg(int regname, char_u **argp, bool *allocated, bool errmsg) if (errmsg) { check_fname(); // will give emsg if not set } - *argp = curbuf->b_fname; + *argp = (char_u *)curbuf->b_fname; return true; case '#': // alternate file name @@ -3128,8 +3128,8 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) if (y_array != NULL) { y_array[y_size] = ptr; } - ++y_size; - ptr = vim_strchr(ptr, '\n'); + y_size++; + ptr = (char_u *)vim_strchr((char *)ptr, '\n'); if (ptr != NULL) { if (y_array != NULL) { *ptr = NUL; @@ -3849,7 +3849,7 @@ void ex_display(exarg_T *eap) type = 'b'; break; } - if (arg != NULL && vim_strchr(arg, name) == NULL) { + if (arg != NULL && vim_strchr((char *)arg, name) == NULL) { continue; // did not ask for this register } @@ -3912,14 +3912,14 @@ void ex_display(exarg_T *eap) // display last inserted text if ((p = get_last_insert()) != NULL - && (arg == NULL || vim_strchr(arg, '.') != NULL) && !got_int + && (arg == NULL || vim_strchr((char *)arg, '.') != NULL) && !got_int && !message_filtered(p)) { msg_puts("\n c \". "); dis_msg(p, true); } // display last command line - if (last_cmdline != NULL && (arg == NULL || vim_strchr(arg, ':') != NULL) + if (last_cmdline != NULL && (arg == NULL || vim_strchr((char *)arg, ':') != NULL) && !got_int && !message_filtered(last_cmdline)) { msg_puts("\n c \": "); dis_msg(last_cmdline, false); @@ -3927,14 +3927,14 @@ void ex_display(exarg_T *eap) // display current file name if (curbuf->b_fname != NULL - && (arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int - && !message_filtered(curbuf->b_fname)) { + && (arg == NULL || vim_strchr((char *)arg, '%') != NULL) && !got_int + && !message_filtered((char_u *)curbuf->b_fname)) { msg_puts("\n c \"% "); - dis_msg(curbuf->b_fname, false); + dis_msg((char_u *)curbuf->b_fname, false); } // display alternate file name - if ((arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int) { + if ((arg == NULL || vim_strchr((char *)arg, '%') != NULL) && !got_int) { char_u *fname; linenr_T dummy; @@ -3946,14 +3946,14 @@ void ex_display(exarg_T *eap) // display last search pattern if (last_search_pat() != NULL - && (arg == NULL || vim_strchr(arg, '/') != NULL) && !got_int + && (arg == NULL || vim_strchr((char *)arg, '/') != NULL) && !got_int && !message_filtered(last_search_pat())) { msg_puts("\n c \"/ "); dis_msg(last_search_pat(), false); } // display last used expression - if (expr_line != NULL && (arg == NULL || vim_strchr(arg, '=') != NULL) + if (expr_line != NULL && (arg == NULL || vim_strchr((char *)arg, '=') != NULL) && !got_int && !message_filtered(expr_line)) { msg_puts("\n c \"= "); dis_msg(expr_line, false); @@ -5027,12 +5027,12 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) pos_T endpos; colnr_T save_coladd = 0; - const bool do_hex = vim_strchr(curbuf->b_p_nf, 'x') != NULL; // "heX" - const bool do_oct = vim_strchr(curbuf->b_p_nf, 'o') != NULL; // "Octal" - const bool do_bin = vim_strchr(curbuf->b_p_nf, 'b') != NULL; // "Bin" - const bool do_alpha = vim_strchr(curbuf->b_p_nf, 'p') != NULL; // "alPha" + const bool do_hex = vim_strchr((char *)curbuf->b_p_nf, 'x') != NULL; // "heX" + const bool do_oct = vim_strchr((char *)curbuf->b_p_nf, 'o') != NULL; // "Octal" + const bool do_bin = vim_strchr((char *)curbuf->b_p_nf, 'b') != NULL; // "Bin" + const bool do_alpha = vim_strchr((char *)curbuf->b_p_nf, 'p') != NULL; // "alPha" // "Unsigned" - const bool do_unsigned = vim_strchr(curbuf->b_p_nf, 'u') != NULL; + const bool do_unsigned = vim_strchr((char *)curbuf->b_p_nf, 'u') != NULL; if (virtual_active()) { save_coladd = pos->coladd; diff --git a/src/nvim/option.c b/src/nvim/option.c index 2a2d2cce80..8267bcf9da 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -363,7 +363,7 @@ void set_init_1(bool clean_arg) { const char *shell = os_getenv("SHELL"); if (shell != NULL) { - if (vim_strchr((const char_u *)shell, ' ') != NULL) { + if (vim_strchr(shell, ' ') != NULL) { const size_t len = strlen(shell) + 3; // two quotes and a trailing NUL char *const cmd = xmalloc(len); snprintf(cmd, len, "\"%s\"", shell); @@ -1099,7 +1099,7 @@ int do_set(char_u *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((char_u *)"=:!&<", nextchar) == NULL + if (vim_strchr("=:!&<", nextchar) == NULL && (!(options[opt_idx].flags & P_BOOL) || nextchar == '?')) { errmsg = _(e_unsupportedoption); @@ -1153,7 +1153,7 @@ int do_set(char_u *arg, int opt_flags) goto skip; } - if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) { + if (vim_strchr("?=:!&<", nextchar) != NULL) { arg += len; if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') { if (arg[3] == 'm') { // "opt&vim": set to Vim default @@ -1162,7 +1162,7 @@ int do_set(char_u *arg, int opt_flags) arg += 2; } } - if (vim_strchr((char_u *)"?!&<", nextchar) != NULL + if (vim_strchr("?!&<", nextchar) != NULL && arg[1] != NUL && !ascii_iswhite(arg[1])) { errmsg = e_trailing; goto skip; @@ -1175,7 +1175,7 @@ int do_set(char_u *arg, int opt_flags) // if (nextchar == '?' || (prefix == 1 - && vim_strchr((char_u *)"=:&<", nextchar) == NULL + && vim_strchr("=:&<", nextchar) == NULL && !(flags & P_BOOL))) { /* * print value @@ -1255,7 +1255,7 @@ int do_set(char_u *arg, int opt_flags) errmsg = set_bool_option(opt_idx, varp, (int)value, opt_flags); } else { // Numeric or string. - if (vim_strchr((const char_u *)"=:&<", nextchar) == NULL + if (vim_strchr("=:&<", nextchar) == NULL || prefix != 1) { errmsg = e_invarg; goto skip; @@ -1609,14 +1609,14 @@ int do_set(char_u *arg, int opt_flags) // 'whichwrap' if (flags & P_ONECOMMA) { if (*s != ',' && *(s + 1) == ',' - && vim_strchr(s + 2, *s) != NULL) { + && vim_strchr((char *)s + 2, *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((char *)s + 1, *s) != NULL) { STRMOVE(s, s + 1); continue; } @@ -1917,7 +1917,7 @@ char_u *find_shada_parameter(int type) if (*p == 'n') { // 'n' is always the last one break; } - p = vim_strchr(p, ','); // skip until next ',' + p = (char_u *)vim_strchr((char *)p, ','); // skip until next ',' if (p == NULL) { // hit the end without finding parameter break; } @@ -2336,7 +2336,7 @@ static bool valid_name(const char_u *val, const char *allowed) { for (const char_u *s = val; *s != NUL; s++) { if (!ASCII_ISALNUM(*s) - && vim_strchr((const char_u *)allowed, *s) == NULL) { + && vim_strchr(allowed, *s) == NULL) { return false; } } @@ -2514,8 +2514,8 @@ static char *did_set_string_option(int opt_idx, char_u **varp, bool new_value_al if (opt_strings_flags(p_rdb, p_rdb_values, &rdb_flags, true) != OK) { errmsg = e_invarg; } - } else if (varp == &p_sbo) { // 'scrollopt' - if (check_opt_strings(p_sbo, p_scbopt_values, true) != OK) { + } else if (varp == (char_u **)&p_sbo) { // 'scrollopt' + if (check_opt_strings((char_u *)p_sbo, p_scbopt_values, true) != OK) { errmsg = e_invarg; } } else if (varp == &p_ambw || (int *)varp == &p_emoji) { @@ -2578,7 +2578,7 @@ ambw_end: if (gvarp == &p_fenc) { if (!MODIFIABLE(curbuf) && opt_flags != OPT_GLOBAL) { errmsg = e_modifiable; - } else if (vim_strchr(*varp, ',') != NULL) { + } else if (vim_strchr((char *)(*varp), ',') != NULL) { // No comma allowed in 'fileencoding'; catches confusing it // with 'fileencodings'. errmsg = e_invarg; @@ -2664,8 +2664,8 @@ ambw_end: redraw_curbuf_later(NOT_VALID); } } - } else if (varp == &p_ffs) { // 'fileformats' - if (check_opt_strings(p_ffs, p_ff_values, true) != OK) { + } else if (varp == (char_u **)&p_ffs) { // 'fileformats' + if (check_opt_strings((char_u *)p_ffs, p_ff_values, true) != OK) { errmsg = e_invarg; } } else if (gvarp == &p_mps) { // 'matchpairs' @@ -2692,7 +2692,7 @@ ambw_end: } else if (gvarp == &p_com) { // 'comments' for (s = *varp; *s;) { while (*s && *s != ':') { - if (vim_strchr((char_u *)COM_ALL, *s) == NULL + if (vim_strchr(COM_ALL, *s) == NULL && !ascii_isdigit(*s) && *s != '-') { errmsg = illegal_char(errbuf, errbuflen, *s); break; @@ -2771,7 +2771,7 @@ ambw_end: free_oldval = (options[opt_idx].flags & P_ALLOCED); for (s = p_shada; *s;) { // Check it's a valid character - if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) { + if (vim_strchr("!\"%'/:<@cfhnrs", *s) == NULL) { errmsg = illegal_char(errbuf, errbuflen, *s); break; } @@ -2835,7 +2835,7 @@ ambw_end: int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON; // NULL => statusline syntax - if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL) { + if (vim_strchr((char *)(*varp), '%') && check_stl_option(*varp) == NULL) { stl_syntax |= flagval; } else { stl_syntax &= ~flagval; @@ -2854,8 +2854,8 @@ ambw_end: if (check_opt_strings(p_km, p_km_values, true) != OK) { errmsg = e_invarg; } else { - km_stopsel = (vim_strchr(p_km, 'o') != NULL); - km_startsel = (vim_strchr(p_km, 'a') != NULL); + km_stopsel = (vim_strchr((char *)p_km, 'o') != NULL); + km_startsel = (vim_strchr((char *)p_km, 'a') != NULL); } } else if (varp == &p_mousem) { // 'mousemodel' if (check_opt_strings(p_mousem, p_mousem_values, false) != OK) { @@ -2965,7 +2965,7 @@ ambw_end: if (!*s) { break; } - if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL) { + if (vim_strchr(".wbuksid]tU", *s) == NULL) { errmsg = illegal_char(errbuf, errbuflen, *s); break; } @@ -3089,7 +3089,7 @@ ambw_end: foldUpdateAll(curwin); } } else if (gvarp == &curwin->w_allbuf_opt.wo_fmr) { // 'foldmarker' - p = vim_strchr(*varp, ','); + p = (char_u *)vim_strchr((char *)(*varp), ','); if (p == NULL) { errmsg = N_("E536: comma required"); } else if (p == *varp || p[1] == NUL) { @@ -3139,9 +3139,9 @@ ambw_end: if (p_csqf != NULL) { p = p_csqf; while (*p != NUL) { - if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL + if (vim_strchr(CSQF_CMDS, *p) == NULL || p[1] == NUL - || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL + || vim_strchr(CSQF_FLAGS, p[1]) == NULL || (p[2] != NUL && p[2] != ',')) { errmsg = e_invarg; break; @@ -3253,7 +3253,7 @@ ambw_end: } if (varp == &p_shm) { // 'shortmess' p = (char_u *)SHM_ALL; - } else if (varp == &(p_cpo)) { // 'cpoptions' + } else if (varp == (char_u **)&(p_cpo)) { // 'cpoptions' p = (char_u *)CPO_VI; } else if (varp == &(curbuf->b_p_fo)) { // 'formatoptions' p = (char_u *)FO_ALL; @@ -3264,7 +3264,7 @@ ambw_end: } if (p != NULL) { for (s = *varp; *s; s++) { - if (vim_strchr(p, *s) == NULL) { + if (vim_strchr((char *)p, *s) == NULL) { errmsg = illegal_char(errbuf, errbuflen, *s); break; } @@ -3323,7 +3323,7 @@ ambw_end: syn_recursive++; // Only pass true for "force" when the value changed or not used // recursively, to avoid endless recurrence. - apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname, + apply_autocmds(EVENT_SYNTAX, (char *)curbuf->b_p_syn, curbuf->b_fname, value_changed || syn_recursive == 1, curbuf); curbuf->b_flags |= BF_SYN_SET; syn_recursive--; @@ -3343,7 +3343,7 @@ ambw_end: did_filetype = true; // Only pass true for "force" when the value changed or not // used recursively, to avoid endless recurrence. - apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, curbuf->b_fname, + apply_autocmds(EVENT_FILETYPE, (char *)curbuf->b_p_ft, curbuf->b_fname, value_changed || ft_recursive == 1, curbuf); ft_recursive--; // Just in case the old "curbuf" is now invalid @@ -3844,7 +3844,7 @@ static char *compile_cap_prog(synblock_T *synblock) } else { // Prepend a ^ so that we only match at one column re = concat_str((char_u *)"^", synblock->b_p_spc); - synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC); + synblock->b_cap_prog = vim_regcomp((char *)re, RE_MAGIC); xfree(re); if (synblock->b_cap_prog == NULL) { synblock->b_cap_prog = rp; // restore the previous program @@ -3997,7 +3997,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, bp->b_fname); + u_read_undo(NULL, hash, (char_u *)bp->b_fname); } } } @@ -4044,9 +4044,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va } } else if ((int *)varp == &p_terse) { // when 'terse' is set change 'shortmess' - char_u *p; - - p = vim_strchr(p_shm, SHM_SEARCH); + char *p = vim_strchr((char *)p_shm, SHM_SEARCH); // insert 's' in p_shm if (p_terse && p == NULL) { @@ -4257,7 +4255,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va set_vim_var_string(VV_OPTION_COMMAND, "modeline", -1); set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); } - apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, false, NULL); + apply_autocmds(EVENT_OPTIONSET, options[opt_idx].fullname, NULL, false, NULL); reset_v_option_vars(); } @@ -4699,7 +4697,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf, set_vim_var_string(VV_OPTION_COMMAND, "modeline", -1); set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1); } - apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, false, NULL); + apply_autocmds(EVENT_OPTIONSET, options[opt_idx].fullname, NULL, false, NULL); reset_v_option_vars(); } @@ -4756,7 +4754,7 @@ static void trigger_optionsset_string(int opt_idx, int opt_flags, char *oldval, set_vim_var_string(VV_OPTION_COMMAND, "modeline", -1); set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1); } - apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, false, NULL); + apply_autocmds(EVENT_OPTIONSET, options[opt_idx].fullname, NULL, false, NULL); reset_v_option_vars(); } } @@ -5622,7 +5620,7 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, uint6 // each comma separated part of the option separately, so that it // can be expanded when read back. if (size >= MAXPATHL && (flags & P_COMMA) != 0 - && vim_strchr(*valuep, ',') != NULL) { + && vim_strchr((char *)(*valuep), ',') != NULL) { part = xmalloc(size); // write line break to clear the option, e.g. ':set rtp=' @@ -7215,7 +7213,7 @@ bool has_format_option(int x) if (p_paste) { return false; } - return vim_strchr(curbuf->b_p_fo, x) != NULL; + return vim_strchr((char *)curbuf->b_p_fo, x) != NULL; } /// @returns true if "x" is present in 'shortmess' option, or @@ -7223,9 +7221,9 @@ bool has_format_option(int x) bool shortmess(int x) { return (p_shm != NULL - && (vim_strchr(p_shm, x) != NULL - || (vim_strchr(p_shm, 'a') != NULL - && vim_strchr((char_u *)SHM_ALL_ABBREVIATIONS, x) != NULL))); + && (vim_strchr((char *)p_shm, x) != NULL + || (vim_strchr((char *)p_shm, 'a') != NULL + && vim_strchr((char *)SHM_ALL_ABBREVIATIONS, x) != NULL))); } /// paste_option_changed() - Called after p_paste was set or reset. @@ -7587,7 +7585,7 @@ bool can_bs(int what) case '0': return false; } - return vim_strchr(p_bs, what) != NULL; + return vim_strchr((char *)p_bs, what) != NULL; } /// Save the current values of 'fileformat' and 'fileencoding', so that we know @@ -8146,9 +8144,9 @@ size_t copy_option_part(char_u **option, char_u *buf, size_t maxlen, char *sep_c if (*p == '.') { buf[len++] = *p++; } - while (*p != NUL && vim_strchr((char_u *)sep_chars, *p) == NULL) { + while (*p != NUL && vim_strchr(sep_chars, *p) == NULL) { // Skip backslash before a separator character and space. - if (p[0] == '\\' && vim_strchr((char_u *)sep_chars, p[1]) != NULL) { + if (p[0] == '\\' && vim_strchr(sep_chars, p[1]) != NULL) { p++; } if (len < maxlen - 1) { diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index d90ed6812c..e358a29622 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -266,7 +266,7 @@ enum { STL_CLICK_FUNC = '@', ///< Click region start. }; /// C string containing all 'statusline' option flags -#define STL_ALL ((char_u[]) { \ +#define STL_ALL ((char[]) { \ STL_FILEPATH, STL_FULLPATH, STL_FILENAME, STL_COLUMN, STL_VIRTCOL, \ STL_VIRTCOL_ALT, STL_LINE, STL_NUMLINES, STL_BUFNO, STL_KEYMAP, STL_OFFSET, \ STL_OFFSET_X, STL_BYTEVAL, STL_BYTEVAL_X, STL_ROFLAG, STL_ROFLAG_ALT, \ @@ -392,7 +392,7 @@ EXTERN char_u *p_csl; // 'completeslash' EXTERN long p_pb; // 'pumblend' EXTERN long p_ph; // 'pumheight' EXTERN long p_pw; // 'pumwidth' -EXTERN char_u *p_cpo; // 'cpoptions' +EXTERN char *p_cpo; // 'cpoptions' EXTERN char_u *p_csprg; // 'cscopeprg' EXTERN int p_csre; // 'cscoperelative' EXTERN char_u *p_csqf; // 'cscopequickfix' @@ -434,7 +434,7 @@ EXTERN char_u *p_gp; // 'grepprg' EXTERN char_u *p_ei; // 'eventignore' EXTERN int p_exrc; // 'exrc' EXTERN char_u *p_fencs; // 'fileencodings' -EXTERN char_u *p_ffs; // 'fileformats' +EXTERN char *p_ffs; // 'fileformats' EXTERN int p_fic; // 'fileignorecase' EXTERN char_u *p_fcl; // 'foldclose' EXTERN long p_fdls; // 'foldlevelstart' @@ -571,7 +571,7 @@ EXTERN char_u *p_rtp; // 'runtimepath' EXTERN long p_scbk; // 'scrollback' EXTERN long p_sj; // 'scrolljump' EXTERN long p_so; // 'scrolloff' -EXTERN char_u *p_sbo; // 'scrollopt' +EXTERN char *p_sbo; // 'scrollopt' EXTERN char_u *p_sections; // 'sections' EXTERN int p_secure; // 'secure' EXTERN char_u *p_sel; // 'selection' diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index d0435cd968..c03fd60f03 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -529,9 +529,9 @@ void free_homedir(void) /// again soon. /// @param src String containing environment variables to expand /// @see {expand_env} -char_u *expand_env_save(char_u *src) +char *expand_env_save(char *src) { - return expand_env_save_opt(src, false); + return (char *)expand_env_save_opt((char_u *)src, false); } /// Similar to expand_env_save() but when "one" is `true` handle the string as @@ -644,7 +644,7 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo #endif } else if (src[1] == NUL // home directory || vim_ispathsep(src[1]) - || vim_strchr((char_u *)" ,\t\n", src[1]) != NULL) { + || vim_strchr(" ,\t\n", src[1]) != NULL) { var = (char_u *)homedir; tail = src + 1; } else { // user directory @@ -884,8 +884,7 @@ void vim_get_prefix_from_exepath(char *exe_name) { // TODO(bfredl): param could have been written as "char exe_name[MAXPATHL]" // but c_grammar.lua does not recognize it (yet). - xstrlcpy(exe_name, (char *)get_vim_var_str(VV_PROGPATH), - MAXPATHL * sizeof(*exe_name)); + xstrlcpy(exe_name, get_vim_var_str(VV_PROGPATH), MAXPATHL * sizeof(*exe_name)); char *path_end = (char *)path_tail_with_sep((char_u *)exe_name); *path_end = '\0'; // remove the trailing "nvim.exe" path_end = path_tail(exe_name); @@ -940,7 +939,7 @@ char *vim_getenv(const char *name) // - the directory name from 'helpfile' (unless it contains '$') // - the executable name from argv[0] if (vim_path == NULL) { - if (p_hf != NULL && vim_strchr(p_hf, '$') == NULL) { + if (p_hf != NULL && vim_strchr((char *)p_hf, '$') == NULL) { vim_path = (char *)p_hf; } diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 34d9015071..d331bd21a2 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -36,7 +36,7 @@ #define NS_1_SECOND 1000000000U // 1 second, in nanoseconds #define OUT_DATA_THRESHOLD 1024 * 10U // 10KB, "a few screenfuls" of data. -#define SHELL_SPECIAL (char_u *)"\t \"&'$;<>()\\|" +#define SHELL_SPECIAL "\t \"&'$;<>()\\|" typedef struct { char *data; @@ -73,7 +73,7 @@ static bool have_wildcard(int num, char_u **file) static bool have_dollars(int num, char_u **file) { for (int i = 0; i < num; i++) { - if (vim_strchr(file[i], '$') != NULL) { + if (vim_strchr((char *)file[i], '$') != NULL) { return true; } } @@ -151,7 +151,7 @@ int os_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file // Don't allow the use of backticks in secure. if (secure) { for (i = 0; i < num_pat; i++) { - if (vim_strchr(pat[i], '`') != NULL + if (vim_strchr((char *)pat[i], '`') != NULL && (check_secure())) { return FAIL; } @@ -1213,7 +1213,7 @@ static void read_input(DynamicBuffer *buf) dynamic_buffer_ensure(buf, buf->len + len); buf->data[buf->len++] = NUL; } else { - char_u *s = vim_strchr(lp + written, NL); + char_u *s = (char_u *)vim_strchr((char *)lp + written, NL); len = s == NULL ? l : (size_t)(s - (lp + written)); dynamic_buffer_ensure(buf, buf->len + len); memcpy(buf->data + buf->len, lp + written, len); diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index 79e042b8a5..cd591801ed 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -210,14 +210,12 @@ static void on_signal(SignalWatcher *handle, int signum, void *data) break; #ifdef SIGUSR1 case SIGUSR1: - apply_autocmds(EVENT_SIGNAL, (char_u *)"SIGUSR1", curbuf->b_fname, true, - curbuf); + apply_autocmds(EVENT_SIGNAL, "SIGUSR1", curbuf->b_fname, true, curbuf); break; #endif #ifdef SIGWINCH case SIGWINCH: - apply_autocmds(EVENT_SIGNAL, (char_u *)"SIGWINCH", curbuf->b_fname, true, - curbuf); + apply_autocmds(EVENT_SIGNAL, "SIGWINCH", curbuf->b_fname, true, curbuf); break; #endif default: diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index faeb2fe829..a382392bd3 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -82,7 +82,7 @@ char *stdpaths_get_xdg_var(const XDGVarType idx) if (env_val != NULL) { ret = xstrdup(env_val); } else if (fallback) { - ret = (char *)expand_env_save((char_u *)fallback); + ret = expand_env_save((char *)fallback); } return ret; diff --git a/src/nvim/path.c b/src/nvim/path.c index fd6cca63f4..fcb91a2783 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -525,7 +525,7 @@ bool path_has_wildcard(const char_u *p) // Windows: const char *wildcards = "?*$[`"; #endif - if (vim_strchr((char_u *)wildcards, *p) != NULL + if (vim_strchr(wildcards, *p) != NULL || (p[0] == '~' && p[1] != NUL)) { return true; } @@ -559,7 +559,7 @@ bool path_has_exp_wildcard(const char_u *p) #else const char *wildcards = "*?["; // Windows. #endif - if (vim_strchr((char_u *)wildcards, *p) != NULL) { + if (vim_strchr(wildcards, *p) != NULL) { return true; } } @@ -640,7 +640,7 @@ static size_t do_path_expand(garray_T *gap, const char_u *path, size_t wildoff, } s = p + 1; } else if (path_end >= path + wildoff - && (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL + && (vim_strchr("*?[{~$", *path_end) != NULL #ifndef WIN32 || (!p_fic && (flags & EW_ICASE) && mb_isalpha(utf_ptr2char((char *)path_end))) #endif @@ -675,7 +675,7 @@ static size_t do_path_expand(garray_T *gap, const char_u *path, size_t wildoff, // convert the file pattern to a regexp pattern int starts_with_dot = *s == '.'; - char_u *pat = file_pat_to_reg_pat(s, e, NULL, false); + char *pat = file_pat_to_reg_pat((char *)s, (char *)e, NULL, false); if (pat == NULL) { xfree(buf); return 0; @@ -949,13 +949,13 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern) file_pattern[0] = '*'; file_pattern[1] = NUL; STRCAT(file_pattern, pattern); - char_u *pat = file_pat_to_reg_pat(file_pattern, NULL, NULL, true); + char *pat = file_pat_to_reg_pat((char *)file_pattern, NULL, NULL, true); xfree(file_pattern); if (pat == NULL) { return; } - regmatch.rm_ic = TRUE; // always ignore case + regmatch.rm_ic = true; // always ignore case regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); xfree(pat); if (regmatch.regprog == NULL) { @@ -1153,7 +1153,7 @@ static bool has_env_var(char_u *p) for (; *p; MB_PTR_ADV(p)) { if (*p == '\\' && p[1] != NUL) { p++; - } else if (vim_strchr((char_u *)"$", *p) != NULL) { + } else if (vim_strchr("$", *p) != NULL) { return true; } } @@ -1174,13 +1174,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((char_u *)SPECIAL_WILDCHAR, *p) != NULL) { + } else if (vim_strchr(SPECIAL_WILDCHAR, *p) != NULL) { // A { must be followed by a matching }. - if (*p == '{' && vim_strchr(p, '}') == NULL) { + if (*p == '{' && vim_strchr((char *)p, '}') == NULL) { continue; } // A quote and backtick must be followed by another one. - if ((*p == '`' || *p == '\'') && vim_strchr(p, *p) == NULL) { + if ((*p == '`' || *p == '\'') && vim_strchr((char *)p, *p) == NULL) { continue; } return true; @@ -2248,7 +2248,7 @@ int match_suffix(char_u *fname) char_u *tail = (char_u *)path_tail((char *)fname); // empty entry: match name without a '.' - if (vim_strchr(tail, '.') == NULL) { + if (vim_strchr((char *)tail, '.') == NULL) { setsuflen = 1; break; } diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index 4317a4e2ce..c5c1d87919 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -694,7 +694,7 @@ static int pum_set_selected(int n, int repeat) if ((pum_array[pum_selected].pum_info != NULL) && (Rows > 10) && (repeat <= 1) - && (vim_strchr(p_cot, 'p') != NULL)) { + && (vim_strchr((char *)p_cot, 'p') != NULL)) { win_T *curwin_save = curwin; tabpage_T *curtab_save = curtab; int res = OK; @@ -748,7 +748,7 @@ static int pum_set_selected(int n, int repeat) linenr_T lnum = 0; for (p = pum_array[pum_selected].pum_info; *p != NUL;) { - e = vim_strchr(p, '\n'); + e = (char_u *)vim_strchr((char *)p, '\n'); if (e == NULL) { ml_append(lnum++, (char *)p, 0, false); break; diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 5a53eac020..883de85aee 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -369,9 +369,9 @@ static char *efmpat_to_regpat(const char *efmpat, char *regpat, efm_T *efminfo, return NULL; } if ((idx && idx < FMT_PATTERN_R - && vim_strchr((char_u *)"DXOPQ", efminfo->prefix) != NULL) + && vim_strchr("DXOPQ", efminfo->prefix) != NULL) || (idx == FMT_PATTERN_R - && vim_strchr((char_u *)"OPQ", efminfo->prefix) == NULL)) { + && vim_strchr("OPQ", efminfo->prefix) == NULL)) { semsg(_("E373: Unexpected %%%c in format string"), *efmpat); return NULL; } @@ -453,10 +453,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((char_u *)"+-", *efmp) != NULL) { + if (vim_strchr("+-", *efmp) != NULL) { efminfo->flags = *efmp++; } - if (vim_strchr((char_u *)"DXAEWINCZGOPQ", *efmp) != NULL) { + if (vim_strchr("DXAEWINCZGOPQ", *efmp) != NULL) { efminfo->prefix = *efmp; } else { semsg(_("E376: Invalid %%%c in format string prefix"), *efmp); @@ -496,7 +496,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((char_u *)"%\\.^$~[", *efmp) != NULL) { + } else if (vim_strchr("%\\.^$~[", *efmp) != NULL) { *ptr++ = *efmp; // regexp magic characters } else if (*efmp == '#') { *ptr++ = '*'; @@ -516,7 +516,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((char_u *)".*^$~[", *efmp) != NULL) { + } else if (vim_strchr(".*^$~[", *efmp) != NULL) { *ptr++ = '\\'; // escape regexp atoms } if (*efmp) { @@ -609,7 +609,7 @@ static efm_T *parse_efm_option(char *efm) if (efm_to_regpat(efm, len, fmt_ptr, fmtstr) == FAIL) { goto parse_efm_error; } - if ((fmt_ptr->prog = vim_regcomp((char_u *)fmtstr, RE_MAGIC + RE_STRING)) == NULL) { + if ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL) { goto parse_efm_error; } // Advance to next part @@ -659,7 +659,7 @@ static int qf_get_next_str_line(qfstate_T *state) return QF_END_OF_INPUT; } - p = (char *)vim_strchr((char_u *)p_str, '\n'); + p = vim_strchr(p_str, '\n'); if (p != NULL) { len = (size_t)(p - p_str) + 1; } else { @@ -961,16 +961,16 @@ restofline: fmt_start = fmt_ptr; } - if (vim_strchr((char_u *)"AEWIN", idx) != NULL) { + if (vim_strchr("AEWIN", idx) != NULL) { qfl->qf_multiline = true; // start of a multi-line message qfl->qf_multiignore = false; // reset continuation - } else if (vim_strchr((char_u *)"CZ", idx) != NULL) { + } else if (vim_strchr("CZ", idx) != NULL) { // continuation of multi-line msg status = qf_parse_multiline_pfx(idx, qfl, fields); if (status != QF_OK) { return status; } - } else if (vim_strchr((char_u *)"OPQ", idx) != NULL) { + } else if (vim_strchr("OPQ", idx) != NULL) { // global file names status = qf_parse_file_pfx(idx, fields, qfl, tail); if (status == QF_MULTISCAN) { @@ -1273,7 +1273,7 @@ static int qf_parse_fmt_f(regmatch_T *rmp, int midx, qffields_T *fields, int pre // For separate filename patterns (%O, %P and %Q), the specified file // should exist. - if (vim_strchr((char_u *)"OPQ", prefix) != NULL + if (vim_strchr("OPQ", prefix) != NULL && !os_path_exists((char_u *)fields->namebuf)) { return QF_FAIL; } @@ -1500,7 +1500,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((char_u *)"EWIN", idx) != NULL) { + if (vim_strchr("EWIN", idx) != NULL) { fields->type = idx; } else { fields->type = 0; @@ -1545,7 +1545,7 @@ static int qf_parse_get_fields(char *linebuf, size_t linelen, efm_T *fmt_ptr, qf int status = QF_FAIL; int r; - if (qf_multiscan && vim_strchr((char_u *)"OPQ", fmt_ptr->prefix) == NULL) { + if (qf_multiscan && vim_strchr("OPQ", fmt_ptr->prefix) == NULL) { return QF_FAIL; } @@ -3102,7 +3102,7 @@ static void qf_list_entry(qfline_T *qfp, int qf_idx, bool cursel) } else { if (qfp->qf_fnum != 0 && (buf = buflist_findnr(qfp->qf_fnum)) != NULL) { - fname = (char *)buf->b_fname; + fname = buf->b_fname; if (qfp->qf_type == 1) { // :helpgrep fname = path_tail(fname); } @@ -4038,7 +4038,7 @@ static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum, const qfli && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL && errbuf->b_fname != NULL) { if (qfp->qf_type == 1) { // :helpgrep - STRLCPY(IObuff, path_tail((char *)errbuf->b_fname), IOSIZE); + STRLCPY(IObuff, path_tail(errbuf->b_fname), IOSIZE); } else { // Shorten the file name if not done already. // For optimization, do this only for the first entry in a @@ -4230,10 +4230,8 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int q curbuf->b_p_ma = false; keep_filetype = true; // don't detect 'filetype' - apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL, - false, curbuf); - apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL, - false, curbuf); + apply_autocmds(EVENT_BUFREADPOST, "quickfix", NULL, false, curbuf); + apply_autocmds(EVENT_BUFWINENTER, "quickfix", NULL, false, curbuf); keep_filetype = false; curbuf->b_ro_locked--; @@ -4374,7 +4372,7 @@ void ex_make(exarg_T *eap) } char *const au_name = make_get_auname(eap->cmdidx); - if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, (char_u *)au_name, + if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, curbuf->b_fname, true, curbuf)) { if (aborting()) { return; @@ -4415,7 +4413,7 @@ void ex_make(exarg_T *eap) // check for autocommands changing the current quickfix list. unsigned save_qfid = qf_get_curlist(qi)->qf_id; if (au_name != NULL) { - apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name, curbuf->b_fname, true, + apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, true, curbuf); } if (res > 0 && !eap->forceit && qflist_valid(wp, save_qfid)) { @@ -5106,7 +5104,7 @@ void ex_cfile(exarg_T *eap) au_name = cfile_get_auname(eap->cmdidx); if (au_name != NULL - && apply_autocmds(EVENT_QUICKFIXCMDPRE, (char_u *)au_name, NULL, false, curbuf)) { + && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, false, curbuf)) { if (aborting()) { return; } @@ -5146,7 +5144,7 @@ void ex_cfile(exarg_T *eap) } unsigned save_qfid = qf_get_curlist(qi)->qf_id; if (au_name != NULL) { - apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name, NULL, false, curbuf); + apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, false, curbuf); } // Jump to the first error for a new list and if autocmds didn't free the // list. @@ -5196,9 +5194,9 @@ static void vgr_init_regmatch(regmmatch_T *regmatch, char *s) emsg(_(e_noprevre)); return; } - regmatch->regprog = vim_regcomp(last_search_pat(), RE_MAGIC); + regmatch->regprog = vim_regcomp((char *)last_search_pat(), RE_MAGIC); } else { - regmatch->regprog = vim_regcomp((char_u *)s, RE_MAGIC); + regmatch->regprog = vim_regcomp(s, RE_MAGIC); } regmatch->rmm_ic = p_ic; @@ -5565,7 +5563,7 @@ static int vgr_process_files(win_T *wp, qf_info_T *qi, vgr_args_T *cmd_args, boo // options! aco_save_T aco; aucmd_prepbuf(&aco, buf); - apply_autocmds(EVENT_FILETYPE, buf->b_p_ft, buf->b_fname, true, buf); + apply_autocmds(EVENT_FILETYPE, (char *)buf->b_p_ft, buf->b_fname, true, buf); do_modelines(OPT_NOWIN); aucmd_restbuf(&aco); } @@ -5588,7 +5586,7 @@ theend: void ex_vimgrep(exarg_T *eap) { char *au_name = vgr_get_auname(eap->cmdidx); - if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, (char_u *)au_name, + if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, curbuf->b_fname, true, curbuf)) { if (aborting()) { return; @@ -5637,7 +5635,7 @@ void ex_vimgrep(exarg_T *eap) unsigned save_qfid = qf_get_curlist(qi)->qf_id; if (au_name != NULL) { - apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name, curbuf->b_fname, true, curbuf); + apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, true, curbuf); } // The QuickFixCmdPost autocmd may free the quickfix list. Check the list @@ -6935,7 +6933,7 @@ void ex_cbuffer(exarg_T *eap) linenr_T line2; au_name = cbuffer_get_auname(eap->cmdidx); - if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, (char_u *)au_name, + if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, curbuf->b_fname, true, curbuf)) { if (aborting()) { return; @@ -6975,8 +6973,7 @@ void ex_cbuffer(exarg_T *eap) unsigned save_qfid = qf_get_curlist(qi)->qf_id; if (au_name != NULL) { const buf_T *const curbuf_old = curbuf; - apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name, - curbuf->b_fname, true, curbuf); + apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, true, curbuf); if (curbuf != curbuf_old) { // Autocommands changed buffer, don't jump now, "qi" may // be invalid. @@ -7023,7 +7020,7 @@ void ex_cexpr(exarg_T *eap) win_T *wp = NULL; au_name = cexpr_get_auname(eap->cmdidx); - if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, (char_u *)au_name, + if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, curbuf->b_fname, true, curbuf)) { if (aborting()) { return; @@ -7055,8 +7052,7 @@ void ex_cexpr(exarg_T *eap) // check for autocommands changing the current quickfix list. unsigned save_qfid = qf_get_curlist(qi)->qf_id; if (au_name != NULL) { - apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name, - curbuf->b_fname, true, curbuf); + apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, true, curbuf); } // Jump to the first error for a new list and if autocmds didn't // free the list. @@ -7220,7 +7216,7 @@ void ex_helpgrep(exarg_T *eap) default: break; } - if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, (char_u *)au_name, + if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, curbuf->b_fname, true, curbuf)) { if (aborting()) { return; @@ -7228,8 +7224,8 @@ void ex_helpgrep(exarg_T *eap) } // Make 'cpoptions' empty, the 'l' flag should not be used here. - char *const save_cpo = (char *)p_cpo; - p_cpo = empty_option; + char *const save_cpo = p_cpo; + p_cpo = (char *)empty_option; if (is_loclist_cmd(eap->cmdidx)) { qi = hgr_get_ll(&new_qi); @@ -7240,7 +7236,7 @@ void ex_helpgrep(exarg_T *eap) // Check for a specified language char *const lang = check_help_lang(eap->arg); regmatch_T regmatch = { - .regprog = vim_regcomp((char_u *)eap->arg, RE_MAGIC + RE_STRING), + .regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING), .rm_ic = false, }; if (regmatch.regprog != NULL) { @@ -7259,16 +7255,15 @@ void ex_helpgrep(exarg_T *eap) qf_update_buffer(qi, NULL); } - if (p_cpo == empty_option) { - p_cpo = (char_u *)save_cpo; + if ((char_u *)p_cpo == empty_option) { + p_cpo = save_cpo; } else { // Darn, some plugin changed the value. free_string_option((char_u *)save_cpo); } if (au_name != NULL) { - apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name, - curbuf->b_fname, true, curbuf); + apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, true, curbuf); // When adding a location list to an existing location list stack, // if the autocmd made the stack invalid, then just return. if (!new_qi && IS_LL_STACK(qi) && qf_find_win_with_loclist(qi) == NULL) { diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 118e344641..f0ccd19478 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -154,8 +154,8 @@ static char_u *reg_prev_sub = NULL; * \u - Multibyte character code, eg \u20ac * \U - Long multibyte character code, eg \U12345678 */ -static char_u REGEXP_INRANGE[] = "]^-n\\"; -static char_u REGEXP_ABBR[] = "nrtebdoxuU"; +static char REGEXP_INRANGE[] = "]^-n\\"; +static char REGEXP_ABBR[] = "nrtebdoxuU"; /* @@ -1477,7 +1477,7 @@ static inline char_u *cstrchr(const char_u *const s, const int c) FUNC_ATTR_ALWAYS_INLINE { if (!rex.reg_ic) { - return vim_strchr(s, c); + return (char_u *)vim_strchr((char *)s, c); } // Use folded case for UTF-8, slow! For ASCII use libc strpbrk which is @@ -1498,7 +1498,7 @@ static inline char_u *cstrchr(const char_u *const s, const int c) } else if (ASCII_ISLOWER(c)) { cc = TOUPPER_ASC(c); } else { - return vim_strchr(s, c); + return (char_u *)vim_strchr((char *)s, c); } char tofind[] = { (char)c, (char)cc, NUL }; @@ -1882,7 +1882,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int cop no = 0; } else if ('0' <= *src && *src <= '9') { no = *src++ - '0'; - } else if (vim_strchr((char_u *)"uUlLeE", *src)) { + } else if (vim_strchr("uUlLeE", *src)) { switch (*src++) { case 'u': func_one = (fptr_T)do_upper; @@ -2285,10 +2285,10 @@ static char_u regname[][30] = { * Use vim_regfree() to free the memory. * Returns NULL for an error. */ -regprog_T *vim_regcomp(char_u *expr_arg, int re_flags) +regprog_T *vim_regcomp(char *expr_arg, int re_flags) { regprog_T *prog = NULL; - char_u *expr = expr_arg; + char_u *expr = (char_u *)expr_arg; int save_called_emsg; regexp_engine = p_re; @@ -2448,7 +2448,7 @@ static bool vim_regexec_string(regmatch_T *rmp, char_u *line, colnr_T col, bool p_re = BACKTRACKING_ENGINE; vim_regfree(rmp->regprog); report_re_switch(pat); - rmp->regprog = vim_regcomp(pat, re_flags); + rmp->regprog = vim_regcomp((char *)pat, re_flags); if (rmp->regprog != NULL) { rmp->regprog->re_in_use = true; result = rmp->regprog->engine->regexec_nl(rmp, line, col, nl); @@ -2544,7 +2544,7 @@ long vim_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, // checking for \z misuse was already done when compiling for NFA, // allow all here reg_do_extmatch = REX_ALL; - rmp->regprog = vim_regcomp(pat, re_flags); + rmp->regprog = vim_regcomp((char *)pat, re_flags); reg_do_extmatch = 0; if (rmp->regprog == NULL) { diff --git a/src/nvim/regexp_bt.c b/src/nvim/regexp_bt.c index e5964e6f88..c13c2c6832 100644 --- a/src/nvim/regexp_bt.c +++ b/src/nvim/regexp_bt.c @@ -1802,7 +1802,7 @@ static char_u *regatom(int *flagp) case Magic('L'): case Magic('u'): case Magic('U'): - p = vim_strchr(classchars, no_Magic(c)); + p = (char_u *)vim_strchr((char *)classchars, no_Magic(c)); if (p == NULL) { EMSG_RET_NULL(_("E63: invalid use of \\_")); } @@ -5080,7 +5080,7 @@ static long bt_regexec_both(char_u *line, colnr_T col, proftime_T *tm, int *time // This is used very often, esp. for ":global". Use two versions of // the loop to avoid overhead of conditions. if (!rex.reg_ic) { - while ((s = vim_strchr(s, c)) != NULL) { + while ((s = (char_u *)vim_strchr((char *)s, c)) != NULL) { if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) { break; // Found it. } diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 4a73941f47..cad5e9df29 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -1892,7 +1892,7 @@ static int nfa_regatom(void) case Magic('L'): case Magic('u'): case Magic('U'): - p = vim_strchr(classchars, no_Magic(c)); + p = (char_u *)vim_strchr((char *)classchars, no_Magic(c)); if (p == NULL) { if (extra == NFA_ADD_NL) { semsg(_(e_ill_char_class), (int64_t)c); diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 003230d110..686516f17b 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -650,7 +650,7 @@ bool conceal_cursor_line(const win_T *wp) } else { return false; } - return vim_strchr(wp->w_p_cocu, c) != NULL; + return vim_strchr((char *)wp->w_p_cocu, c) != NULL; } // Check if the cursor line needs to be redrawn because of 'concealcursor'. @@ -3672,7 +3672,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc if (wp->w_p_cole > 0 && (wp != curwin || lnum != wp->w_cursor.lnum || conceal_cursor_line(wp)) && ((syntax_flags & HL_CONCEAL) != 0 || has_match_conc > 0 || decor_conceal > 0) - && !(lnum_in_visual_area && vim_strchr(wp->w_p_cocu, 'v') == NULL)) { + && !(lnum_in_visual_area && vim_strchr((char *)wp->w_p_cocu, 'v') == NULL)) { char_attr = conceal_attr; if (((prev_syntax_id != syntax_seqnr && (syntax_flags & HL_CONCEAL) != 0) || has_match_conc > 1 || decor_conceal > 1) @@ -6394,7 +6394,7 @@ void get_trans_bufname(buf_T *buf) if (buf_spname(buf) != NULL) { STRLCPY(NameBuff, buf_spname(buf), MAXPATHL); } else { - home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE); + home_replace(buf, (char_u *)buf->b_fname, NameBuff, MAXPATHL, true); } trans_characters(NameBuff, MAXPATHL); } diff --git a/src/nvim/search.c b/src/nvim/search.c index 9143632c64..11d40c058c 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -189,7 +189,7 @@ int search_regcomp(char_u *pat, int pat_save, int pat_use, int options, regmmatc regmatch->rmm_ic = ignorecase(pat); regmatch->rmm_maxcol = 0; - regmatch->regprog = vim_regcomp(pat, magic ? RE_MAGIC : 0); + regmatch->regprog = vim_regcomp((char *)pat, magic ? RE_MAGIC : 0); if (regmatch->regprog == NULL) { return FAIL; } @@ -1055,7 +1055,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, * A line offset is not remembered, this is vi compatible. */ if (spats[0].off.line && vim_strchr(p_cpo, CPO_LINEOFF) != NULL) { - spats[0].off.line = FALSE; + spats[0].off.line = false; spats[0].off.off = 0; } @@ -1979,7 +1979,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) // This is just guessing: when 'rightleft' is set, search for a matching // paren/brace in the other direction. - if (curwin->w_p_rl && vim_strchr((char_u *)"()[]{}<>", initc) != NULL) { + if (curwin->w_p_rl && vim_strchr("()[]{}<>", initc) != NULL) { backwards = !backwards; } @@ -2092,7 +2092,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) } else if (raw_string) { if (linep[pos.col - 1] == 'R' && linep[pos.col] == '"' - && vim_strchr(linep + pos.col + 1, '(') != NULL) { + && vim_strchr((char *)linep + pos.col + 1, '(') != NULL) { // Possible start of raw string. Now that we have the // delimiter we can check if it ends before where we // started searching, or before the previously found @@ -2273,7 +2273,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) * (actually, we skip #\( et al) */ if (curbuf->b_p_lisp - && vim_strchr((char_u *)"(){}[]", c) != NULL + && vim_strchr("(){}[]", c) != NULL && pos.col > 1 && check_prevcol(linep, pos.col, '\\', NULL) && check_prevcol(linep, pos.col - 1, '#', NULL)) { @@ -2321,7 +2321,7 @@ int check_linecomment(const char_u *line) const char_u *p = line; // scan from start // skip Lispish one-line comments if (curbuf->b_p_lisp) { - if (vim_strchr(p, ';') != NULL) { // there may be comments + if (vim_strchr((char *)p, ';') != NULL) { // there may be comments bool in_str = false; // inside of string while ((p = (char_u *)strpbrk((char *)p, "\";")) != NULL) { @@ -2346,7 +2346,7 @@ int check_linecomment(const char_u *line) p = NULL; } } else { - while ((p = vim_strchr(p, '/')) != NULL) { + while ((p = (char_u *)vim_strchr((char *)p, '/')) != NULL) { // Accept a double /, unless it's preceded with * and followed by *, // because * / / * is an end and start of a C comment. // Only accept the position if it is not inside a string. @@ -2507,7 +2507,7 @@ int findsent(Direction dir, long count) // go back to the previous non-white non-punctuation character bool found_dot = false; while (c = gchar_pos(&pos), ascii_iswhite(c) - || vim_strchr((char_u *)".!?)]\"'", c) != NULL) { + || vim_strchr(".!?)]\"'", c) != NULL) { tpos = pos; if (decl(&tpos) == -1 || (LINEEMPTY(tpos.lnum) && dir == FORWARD)) { break; @@ -2515,11 +2515,11 @@ int findsent(Direction dir, long count) if (found_dot) { break; } - if (vim_strchr((char_u *)".!?", c) != NULL) { + if (vim_strchr(".!?", c) != NULL) { found_dot = true; } - if (vim_strchr((char_u *)")]\"'", c) != NULL - && vim_strchr((char_u *)".!?)]\"'", gchar_pos(&tpos)) == NULL) { + if (vim_strchr(")]\"'", c) != NULL + && vim_strchr(".!?)]\"'", gchar_pos(&tpos)) == NULL) { break; } decl(&pos); @@ -2543,7 +2543,7 @@ int findsent(Direction dir, long count) if ((c = inc(&tpos)) == -1) { break; } - } while (vim_strchr((char_u *)")]\"'", c = gchar_pos(&tpos)) + } while (vim_strchr(")]\"'", c = gchar_pos(&tpos)) != NULL); if (c == -1 || (!cpo_J && (c == ' ' || c == '\t')) || c == NUL || (cpo_J && (c == ' ' && inc(&tpos) >= 0 @@ -3399,7 +3399,7 @@ int current_block(oparg_T *oap, long count, int include, int what, int other) pos_T start_pos; pos_T *end_pos; pos_T old_start, old_end; - char_u *save_cpo; + char *save_cpo; bool sol = false; // '{' at start of line old_pos = curwin->w_cursor; @@ -3434,7 +3434,7 @@ int current_block(oparg_T *oap, long count, int include, int what, int other) // Ignore quotes here. Keep the "M" flag in 'cpo', as that is what the // user wants. save_cpo = p_cpo; - p_cpo = (char_u *)(vim_strchr(p_cpo, CPO_MATCHBSL) != NULL ? "%M" : "%"); + p_cpo = vim_strchr(p_cpo, CPO_MATCHBSL) != NULL ? "%M" : "%"; if ((pos = findmatch(NULL, what)) != NULL) { while (count-- > 0) { if ((pos = findmatch(NULL, what)) == NULL) { @@ -3967,7 +3967,7 @@ static int find_next_quote(char_u *line, int col, int quotechar, char_u *escape) c = line[col]; if (c == NUL) { return -1; - } else if (escape != NULL && vim_strchr(escape, c)) { + } else if (escape != NULL && vim_strchr((char *)escape, c)) { col++; if (line[col] == NUL) { return -1; @@ -3996,7 +3996,7 @@ static int find_prev_quote(char_u *line, int col_start, int quotechar, char_u *e col_start -= utf_head_off(line, line + col_start); n = 0; if (escape != NULL) { - while (col_start - n > 0 && vim_strchr(escape, + while (col_start - n > 0 && vim_strchr((char *)escape, line[col_start - n - 1]) != NULL) { ++n; } @@ -5332,7 +5332,7 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo char_u *pat; char_u *new_fname; - char_u *curr_fname = curbuf->b_fname; + char_u *curr_fname = (char_u *)curbuf->b_fname; char_u *prev_fname = NULL; linenr_T lnum; int depth; @@ -5372,7 +5372,7 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo sprintf((char *)pat, whole ? "\\<%.*s\\>" : "%.*s", (int)len, ptr); // ignore case according to p_ic, p_scs and pat regmatch.rm_ic = ignorecase(pat); - regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0); + regmatch.regprog = vim_regcomp((char *)pat, p_magic ? RE_MAGIC : 0); xfree(pat); if (regmatch.regprog == NULL) { goto fpip_end; @@ -5380,7 +5380,7 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo } inc_opt = (*curbuf->b_p_inc == NUL) ? p_inc : curbuf->b_p_inc; if (*inc_opt != NUL) { - incl_regmatch.regprog = vim_regcomp(inc_opt, p_magic ? RE_MAGIC : 0); + incl_regmatch.regprog = vim_regcomp((char *)inc_opt, p_magic ? RE_MAGIC : 0); if (incl_regmatch.regprog == NULL) { goto fpip_end; } @@ -5388,7 +5388,8 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo } if (type == FIND_DEFINE && (*curbuf->b_p_def != NUL || *p_def != NUL)) { def_regmatch.regprog = vim_regcomp(*curbuf->b_p_def == NUL - ? p_def : curbuf->b_p_def, p_magic ? RE_MAGIC : 0); + ? (char *)p_def : (char *)curbuf->b_p_def, + p_magic ? RE_MAGIC : 0); if (def_regmatch.regprog == NULL) { goto fpip_end; } @@ -5410,7 +5411,7 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo for (;;) { if (incl_regmatch.regprog != NULL && vim_regexec(&incl_regmatch, line, (colnr_T)0)) { - char_u *p_fname = (curr_fname == curbuf->b_fname) + char_u *p_fname = (curr_fname == (char_u *)curbuf->b_fname) ? curbuf->b_ffname : curr_fname; if (inc_opt != NULL && strstr((char *)inc_opt, "\\zs") != NULL) { @@ -5737,7 +5738,8 @@ search_line: } const int add_r = ins_compl_add_infercase(aux, i, p_ic, - curr_fname == curbuf->b_fname ? NULL : curr_fname, + curr_fname == (char_u *)curbuf->b_fname + ? NULL : curr_fname, dir, cont_s_ipos); if (add_r == OK) { // if dir was BACKWARD then honor it just once @@ -5865,8 +5867,8 @@ exit_matched: --old_files; files[old_files].name = files[depth].name; files[old_files].matched = files[depth].matched; - --depth; - curr_fname = (depth == -1) ? curbuf->b_fname + depth--; + curr_fname = (depth == -1) ? (char_u *)curbuf->b_fname : files[depth].name; if (depth < depth_displayed) { depth_displayed = depth; diff --git a/src/nvim/sign.c b/src/nvim/sign.c index 99a00aefa9..dd6fdf3cd5 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -1815,7 +1815,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg) p = skiptowhite(p); } while (*p != NUL); - p = vim_strchr(last, '='); + p = (char_u *)vim_strchr((char *)last, '='); // :sign define {name} {args}... {last}= // | | diff --git a/src/nvim/spell.c b/src/nvim/spell.c index b2969c5332..1ba29e3fc1 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1173,7 +1173,7 @@ static bool match_compoundrule(slang_T *slang, char_u *compflags) } // Skip to the next "/", where the next pattern starts. - p = vim_strchr(p, '/'); + p = (char_u *)vim_strchr((char *)p, '/'); if (p == NULL) { break; } @@ -1637,7 +1637,7 @@ void spell_cat_line(char_u *buf, char_u *line, int maxlen) int n; p = (char_u *)skipwhite((char *)line); - while (vim_strchr((char_u *)"*#/\"\t", *p) != NULL) { + while (vim_strchr("*#/\"\t", *p) != NULL) { p = (char_u *)skipwhite((char *)p + 1); } @@ -1682,8 +1682,8 @@ static void spell_load_lang(char_u *lang) r = do_in_runtimepath((char *)fname_enc, 0, spell_load_cb, &sl); if (r == FAIL && *sl.sl_lang != NUL && round == 1 - && apply_autocmds(EVENT_SPELLFILEMISSING, lang, - curbuf->b_fname, FALSE, curbuf)) { + && apply_autocmds(EVENT_SPELLFILEMISSING, (char *)lang, + curbuf->b_fname, false, curbuf)) { continue; } break; @@ -1961,14 +1961,14 @@ int init_syl_tab(slang_T *slang) int l; ga_init(&slang->sl_syl_items, sizeof(syl_item_T), 4); - p = vim_strchr(slang->sl_syllable, '/'); + p = (char_u *)vim_strchr((char *)slang->sl_syllable, '/'); while (p != NULL) { *p++ = NUL; if (*p == NUL) { // trailing slash break; } s = p; - p = vim_strchr(p, '/'); + p = (char_u *)vim_strchr((char *)p, '/'); if (p == NULL) { l = (int)STRLEN(s); } else { @@ -2025,7 +2025,7 @@ static int count_syllables(slang_T *slang, const char_u *word) // No recognized syllable item, at least a syllable char then? c = utf_ptr2char((char *)p); len = utfc_ptr2len((char *)p); - if (vim_strchr(slang->sl_syllable, c) == NULL) { + if (vim_strchr((char *)slang->sl_syllable, c) == NULL) { skip = false; // No, search for next syllable } else if (!skip) { ++cnt; // Yes, count it @@ -2105,7 +2105,7 @@ char *did_set_spelllang(win_T *wp) filename = true; // Locate a region and remove it from the file name. - p = vim_strchr((char_u *)path_tail((char *)lang), '_'); + p = (char_u *)vim_strchr(path_tail((char *)lang), '_'); if (p != NULL && ASCII_ISALPHA(p[1]) && ASCII_ISALPHA(p[2]) && !ASCII_ISALPHA(p[3])) { STRLCPY(region_cp, p + 1, 3); @@ -2248,7 +2248,7 @@ char *did_set_spelllang(win_T *wp) STRCPY(lang, "internal wordlist"); } else { STRLCPY(lang, path_tail((char *)spf_name), MAXWLEN + 1); - p = vim_strchr(lang, '.'); + p = (char_u *)vim_strchr((char *)lang, '.'); if (p != NULL) { *p = NUL; // truncate at ".encoding.add" } @@ -2686,7 +2686,7 @@ static bool spell_iswordp(const char_u *p, const win_T *wp) if (c < 256 ? wp->w_s->b_spell_ismw[c] : (wp->w_s->b_spell_ismw_mb != NULL - && vim_strchr(wp->w_s->b_spell_ismw_mb, c) != NULL)) { + && vim_strchr((char *)wp->w_s->b_spell_ismw_mb, c) != NULL)) { s = p + l; } } @@ -2730,9 +2730,10 @@ static bool spell_iswordp_w(const int *p, const win_T *wp) { const int *s; - if (*p < 256 ? wp->w_s->b_spell_ismw[*p] - : (wp->w_s->b_spell_ismw_mb != NULL - && vim_strchr(wp->w_s->b_spell_ismw_mb, *p) != NULL)) { + if (*p < + 256 ? wp->w_s->b_spell_ismw[*p] : (wp->w_s->b_spell_ismw_mb != NULL + && vim_strchr((char *)wp->w_s->b_spell_ismw_mb, + *p) != NULL)) { s = p + 1; } else { s = p; @@ -3413,7 +3414,7 @@ static void spell_suggest_file(suginfo_T *su, char_u *fname) while (!vim_fgets(line, MAXWLEN * 2, fd) && !got_int) { line_breakcheck(); - p = vim_strchr(line, '/'); + p = (char_u *)vim_strchr((char *)line, '/'); if (p == NULL) { continue; // No Tab found, just skip the line. } @@ -6260,7 +6261,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) // replace string ws = smp[n].sm_to_w; s = smp[n].sm_rules; - p0 = (vim_strchr(s, '<') != NULL) ? 1 : 0; + p0 = (vim_strchr((char *)s, '<') != NULL) ? 1 : 0; if (p0 == 1 && z == 0) { // rule with '<' is used if (reslen > 0 && ws != NULL && *ws != NUL diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 6f0bd04d39..f8c01bc27f 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -1100,7 +1100,7 @@ static int read_prefcond_section(FILE *fd, slang_T *lp) buf[0] = '^'; // always match at one position only SPELL_READ_NONNUL_BYTES(buf + 1, (size_t)n, fd,; ); buf[n + 1] = NUL; - lp->sl_prefprog[i] = vim_regcomp((char_u *)buf, RE_MAGIC | RE_STRING); + lp->sl_prefprog[i] = vim_regcomp(buf, RE_MAGIC | RE_STRING); } } return 0; @@ -1202,7 +1202,7 @@ static int read_sal_section(FILE *fd, slang_T *slang) int i = 0; for (; i < ccnt; ++i) { c = getc(fd); // <salfrom> - if (vim_strchr((char_u *)"0123456789(-<^$", c) != NULL) { + if (vim_strchr("0123456789(-<^$", c) != NULL) { break; } *p++ = c; @@ -1466,7 +1466,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len) } // Add all flags to "sl_compallflags". - if (vim_strchr((char_u *)"?*+[]/", c) == NULL + if (vim_strchr("?*+[]/", c) == NULL && !byte_in_str(slang->sl_compallflags, c)) { *ap++ = c; *ap = NUL; @@ -1521,7 +1521,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len) *crp = NUL; } - slang->sl_compprog = vim_regcomp(pat, RE_MAGIC + RE_STRING + RE_STRICT); + slang->sl_compprog = vim_regcomp((char *)pat, RE_MAGIC + RE_STRING + RE_STRICT); xfree(pat); if (slang->sl_compprog == NULL) { return SP_FORMERROR; @@ -2461,7 +2461,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) aff_entry->ae_add = getroom_save(spin, items[3]); // Recognize flags on the affix: abcd/XYZ - aff_entry->ae_flags = vim_strchr(aff_entry->ae_add, '/'); + aff_entry->ae_flags = (char_u *)vim_strchr((char *)aff_entry->ae_add, '/'); if (aff_entry->ae_flags != NULL) { *aff_entry->ae_flags++ = NUL; aff_process_flags(aff, aff_entry); @@ -2484,8 +2484,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) } else { sprintf((char *)buf, "%s$", items[4]); } - aff_entry->ae_prog = vim_regcomp(buf, - RE_MAGIC + RE_STRING + RE_STRICT); + aff_entry->ae_prog = vim_regcomp((char *)buf, RE_MAGIC + RE_STRING + RE_STRICT); if (aff_entry->ae_prog == NULL) { smsg(_("Broken condition in %s line %d: %s"), fname, lnum, items[4]); @@ -2533,7 +2532,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) sprintf((char *)buf, "^%s", aff_entry->ae_cond); vim_regfree(aff_entry->ae_prog); - aff_entry->ae_prog = vim_regcomp(buf, RE_MAGIC + RE_STRING); + aff_entry->ae_prog = vim_regcomp((char *)buf, RE_MAGIC + RE_STRING); } } } @@ -2652,7 +2651,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) if ((!GA_EMPTY(&spin->si_map) && vim_strchr(spin->si_map.ga_data, c) != NULL) - || vim_strchr(p, c) != NULL) { + || vim_strchr((char *)p, c) != NULL) { smsg(_("Duplicate character in MAP in %s line %d"), fname, lnum); } @@ -2924,7 +2923,7 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compfla tp = p + STRLEN(p); for (p = compflags; *p != NUL;) { - if (vim_strchr((char_u *)"/?*+[]", *p) != NULL) { + if (vim_strchr("/?*+[]", *p) != NULL) { // Copy non-flag characters directly. *tp++ = *p++; } else { @@ -2947,7 +2946,7 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compfla do { check_renumber(spin); id = spin->si_newcompID--; - } while (vim_strchr((char_u *)"/?*+[]\\-^", id) != NULL); + } while (vim_strchr("/?*+[]\\-^", id) != NULL); ci->ci_newID = id; hash_add(&aff->af_comp, ci->ci_key); } @@ -2982,7 +2981,7 @@ static bool flag_in_afflist(int flagtype, char_u *afflist, unsigned flag) switch (flagtype) { case AFT_CHAR: - return vim_strchr(afflist, flag) != NULL; + return vim_strchr((char *)afflist, flag) != NULL; case AFT_CAPLONG: case AFT_LONG: @@ -3783,7 +3782,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname) regionmask = spin->si_region; // Check for flags and region after a slash. - p = vim_strchr(line, '/'); + p = (char_u *)vim_strchr((char *)line, '/'); if (p != NULL) { *p++ = NUL; while (*p != NUL) { @@ -5338,7 +5337,7 @@ static void mkspell(int fcount, char_u **fnames, bool ascii, bool over_write, bo if (incount <= 0) { emsg(_(e_invarg)); // need at least output and input names - } else if (vim_strchr((char_u *)path_tail((char *)wfname), '_') != NULL) { + } else if (vim_strchr(path_tail((char *)wfname), '_') != NULL) { emsg(_("E751: Output file name must not have region name")); } else if (incount > MAXREGIONS) { semsg(_("E754: Only up to %d regions supported"), MAXREGIONS); @@ -5693,7 +5692,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 = curwin->w_s->b_p_spl; *lend != NUL - && vim_strchr((char_u *)",._", *lend) == NULL; ++lend) { + && vim_strchr(",._", *lend) == NULL; lend++) { if (vim_ispathsep(*lend)) { aspath = true; lstart = lend + 1; @@ -5878,9 +5877,9 @@ static void set_map_str(slang_T *lp, char_u *map) hashitem_T *hi; b = xmalloc(cl + headcl + 2); - utf_char2bytes(c, (char *)b); + utf_char2bytes(c, b); b[cl] = NUL; - utf_char2bytes(headc, (char *)b + cl + 1); + utf_char2bytes(headc, b + cl + 1); b[cl + 1 + headcl] = NUL; hash = hash_hash((char_u *)b); hi = hash_lookup(&lp->sl_map_hash, (const char *)b, STRLEN(b), hash); diff --git a/src/nvim/state.c b/src/nvim/state.c index d82dc59e75..36789016a9 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -233,7 +233,7 @@ void may_trigger_modechanged(void) } char curr_mode[MODE_MAX_LENGTH]; - char_u pattern_buf[2 * MODE_MAX_LENGTH]; + char pattern_buf[2 * MODE_MAX_LENGTH]; get_mode(curr_mode); if (STRCMP(curr_mode, last_mode) == 0) { @@ -247,7 +247,7 @@ void may_trigger_modechanged(void) tv_dict_set_keys_readonly(v_event); // concatenate modes in format "old_mode:new_mode" - vim_snprintf((char *)pattern_buf, sizeof(pattern_buf), "%s:%s", last_mode, curr_mode); + vim_snprintf(pattern_buf, sizeof(pattern_buf), "%s:%s", last_mode, curr_mode); apply_autocmds(EVENT_MODECHANGED, pattern_buf, NULL, false, curbuf); STRCPY(last_mode, curr_mode); diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 55b4628c9e..c0c942ffd2 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -104,8 +104,8 @@ char_u *vim_strsave_escaped_ext(const char_u *string, const char_u *esc_chars, c p += l - 1; continue; } - if (vim_strchr(esc_chars, *p) != NULL || (bsl && rem_backslash(p))) { - ++length; // count a backslash + if (vim_strchr((char *)esc_chars, *p) != NULL || (bsl && rem_backslash(p))) { + length++; // count a backslash } ++length; // count an ordinary char } @@ -120,7 +120,7 @@ char_u *vim_strsave_escaped_ext(const char_u *string, const char_u *esc_chars, c p += l - 1; // skip multibyte char continue; } - if (vim_strchr(esc_chars, *p) != NULL || (bsl && rem_backslash(p))) { + if (vim_strchr((char *)esc_chars, *p) != NULL || (bsl && rem_backslash(p))) { *p2++ = cc; } *p2++ = *p; @@ -473,18 +473,18 @@ int vim_strnicmp(const char *s1, const char *s2, size_t len) /// @return Pointer to the first byte of the found character in string or NULL /// if it was not found or character is invalid. NUL character is never /// found, use `strlen()` instead. -char_u *vim_strchr(const char_u *const string, const int c) +char *vim_strchr(const char *const string, const int c) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { if (c <= 0) { return NULL; } else if (c < 0x80) { - return (char_u *)strchr((const char *)string, c); + return strchr(string, c); } else { char u8char[MB_MAXBYTES + 1]; const int len = utf_char2bytes(c, u8char); u8char[len] = NUL; - return (char_u *)strstr((const char *)string, u8char); + return strstr(string, u8char); } } @@ -1313,8 +1313,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap, t if (fmt_spec == 'f' || fmt_spec == 'F') { tp = tmp + str_arg_l - 1; } else { - tp = (char *)vim_strchr((char_u *)tmp, - fmt_spec == 'e' ? 'e' : 'E'); + tp = vim_strchr(tmp, fmt_spec == 'e' ? 'e' : 'E'); if (tp) { // remove superfluous '+' and leading zeroes from exponent if (tp[1] == '+') { @@ -1343,8 +1342,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap, t } else { // Be consistent: some printf("%e") use 1.0e+12 and some // 1.0e+012; remove one zero in the last case. - char *tp = (char *)vim_strchr((char_u *)tmp, - fmt_spec == 'e' ? 'e' : 'E'); + char *tp = vim_strchr(tmp, fmt_spec == 'e' ? 'e' : 'E'); if (tp && (tp[1] == '+' || tp[1] == '-') && tp[2] == '0' && ascii_isdigit(tp[3]) && ascii_isdigit(tp[4])) { STRMOVE(tp + 2, tp + 3); diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index d82e337aa6..6744e4445c 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -3807,7 +3807,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((char *)spp->sp_pattern, sepchars[i]) != NULL;) { if (sepchars[++i] == NUL) { i = 0; // no good char found, just use the first one break; @@ -4393,7 +4393,7 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing) // 2: Add an entry for each keyword. for (kw = keyword_copy; --cnt >= 0; kw += STRLEN(kw) + 1) { - for (p = vim_strchr(kw, '[');;) { + for (p = (char_u *)vim_strchr((char *)kw, '[');;) { if (p != NULL) { *p = NUL; } @@ -5075,7 +5075,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci) char_u *end; int *p; int idx; - char_u *cpo_save; + char *cpo_save; // need at least three chars if (arg == NULL || arg[0] == NUL || arg[1] == NUL || arg[2] == NUL) { @@ -5092,8 +5092,8 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci) // Make 'cpoptions' empty, to avoid the 'l' flag cpo_save = p_cpo; - p_cpo = (char_u *)""; - ci->sp_prog = vim_regcomp(ci->sp_pattern, RE_MAGIC); + p_cpo = ""; + ci->sp_prog = vim_regcomp((char *)ci->sp_pattern, RE_MAGIC); p_cpo = cpo_save; if (ci->sp_prog == NULL) { @@ -5174,7 +5174,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing) int illegal = FALSE; int finished = FALSE; long n; - char_u *cpo_save; + char *cpo_save; if (ends_excmd(*arg_start)) { syn_cmd_list(eap, TRUE); @@ -5253,9 +5253,9 @@ static void syn_cmd_sync(exarg_T *eap, int syncing) // Make 'cpoptions' empty, to avoid the 'l' flag cpo_save = p_cpo; - p_cpo = (char_u *)""; + p_cpo = ""; curwin->w_s->b_syn_linecont_prog = - vim_regcomp(curwin->w_s->b_syn_linecont_pat, RE_MAGIC); + vim_regcomp((char *)curwin->w_s->b_syn_linecont_pat, RE_MAGIC); p_cpo = cpo_save; syn_clear_time(&curwin->w_s->b_syn_linecont_time); @@ -5333,7 +5333,7 @@ static int get_id_list(char_u **const arg, const int keylen, int16_t **const lis int count = 0; do { for (end = p; *end && !ascii_iswhite(*end) && *end != ','; end++) {} - char_u *const name = xmalloc(end - p + 3); // leave room for "^$" + char *const name = xmalloc(end - p + 3); // leave room for "^$" STRLCPY(name + 1, p, end - p + 1); if (STRCMP(name + 1, "ALLBUT") == 0 || STRCMP(name + 1, "ALL") == 0 @@ -5367,14 +5367,14 @@ static int get_id_list(char_u **const arg, const int keylen, int16_t **const lis if (skip) { id = -1; } else { - id = syn_check_cluster(name + 2, (int)(end - p - 1)); + id = syn_check_cluster((char_u *)name + 2, (int)(end - p - 1)); } } else { /* * Handle full group name. */ - if (strpbrk((char *)name + 1, "\\.*^$~[") == NULL) { - id = syn_check_group((char *)(name + 1), (int)(end - p)); + if (strpbrk(name + 1, "\\.*^$~[") == NULL) { + id = syn_check_group((name + 1), (int)(end - p)); } else { // Handle match of regexp with group names. *name = '^'; @@ -5669,7 +5669,7 @@ void ex_ownsyntax(exarg_T *eap) } // Apply the "syntax" autocommand event, this finds and loads the syntax file. - apply_autocmds(EVENT_SYNTAX, (char_u *)eap->arg, curbuf->b_fname, true, curbuf); + apply_autocmds(EVENT_SYNTAX, eap->arg, curbuf->b_fname, true, curbuf); // Move value of b:current_syntax to w:current_syntax. new_value = get_var_value("b:current_syntax"); diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 1f0d027321..8a21ec3e5d 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1108,10 +1108,8 @@ static void prepare_pats(pat_T *pats, int has_re) if (pats->head == pats->pat) { pats->headlen = 0; } else { - for (pats->headlen = 0; pats->head[pats->headlen] != NUL; - ++pats->headlen) { - if (vim_strchr((char_u *)(p_magic ? ".[~*\\$" : "\\$"), - pats->head[pats->headlen]) != NULL) { + for (pats->headlen = 0; pats->head[pats->headlen] != NUL; pats->headlen++) { + if (vim_strchr((p_magic ? ".[~*\\$" : "\\$"), pats->head[pats->headlen]) != NULL) { break; } } @@ -1122,7 +1120,7 @@ static void prepare_pats(pat_T *pats, int has_re) } if (has_re) { - pats->regmatch.regprog = vim_regcomp(pats->pat, p_magic ? RE_MAGIC : 0); + pats->regmatch.regprog = vim_regcomp((char *)pats->pat, p_magic ? RE_MAGIC : 0); } else { pats->regmatch.regprog = NULL; } @@ -1604,8 +1602,8 @@ int find_tags(char_u *pat, int *num_matches, char_u ***matchesp, int flags, int if (STRNICMP(s, help_lang, 2) == 0) { break; } - ++help_pri; - if ((s = vim_strchr(s, ',')) == NULL) { + help_pri++; + if ((s = (char_u *)vim_strchr((char *)s, ',')) == NULL) { break; } } @@ -1864,7 +1862,7 @@ parse_line: // This speeds up tag searching a lot! if (orgpat.headlen) { tagp.tagname = lbuf; - tagp.tagname_end = vim_strchr(lbuf, TAB); + tagp.tagname_end = (char_u *)vim_strchr((char *)lbuf, TAB); if (tagp.tagname_end == NULL) { // Corrupted tag line. line_error = true; @@ -1982,7 +1980,7 @@ parse_line: // Can be a matching tag, isolate the file name and command. tagp.fname = tagp.tagname_end + 1; - tagp.fname_end = vim_strchr(tagp.fname, TAB); + tagp.fname_end = (char_u *)vim_strchr((char *)tagp.fname, TAB); tagp.command = tagp.fname_end + 1; if (tagp.fname_end == NULL) { i = FAIL; @@ -2473,7 +2471,7 @@ static int parse_tag_line(char_u *lbuf, tagptrs_T *tagp) // Isolate the tagname, from lbuf up to the first white tagp->tagname = lbuf; - p = vim_strchr(lbuf, TAB); + p = (char_u *)vim_strchr((char *)lbuf, TAB); if (p == NULL) { return FAIL; } @@ -2484,7 +2482,7 @@ static int parse_tag_line(char_u *lbuf, tagptrs_T *tagp) ++p; } tagp->fname = p; - p = vim_strchr(p, TAB); + p = (char_u *)vim_strchr((char *)p, TAB); if (p == NULL) { return FAIL; } @@ -2522,8 +2520,8 @@ static bool test_for_static(tagptrs_T *tagp) // Check for new style static tag ":...<Tab>file:[<Tab>...]" p = tagp->command; - while ((p = vim_strchr(p, '\t')) != NULL) { - ++p; + while ((p = (char_u *)vim_strchr((char *)p, '\t')) != NULL) { + p++; if (STRNCMP(p, "file:", 5) == 0) { return TRUE; } @@ -2595,8 +2593,8 @@ static int parse_match(char_u *lbuf, tagptrs_T *tagp) break; } - pc = vim_strchr(p, ':'); - pt = vim_strchr(p, '\t'); + pc = (char_u *)vim_strchr((char *)p, ':'); + pt = (char_u *)vim_strchr((char *)p, '\t'); if (pc == NULL || (pt != NULL && pc > pt)) { tagp->tagkind = p; } diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 2dc1e0ec25..9e2d1f8e68 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -344,7 +344,7 @@ void vim_beep(unsigned val) // When 'debug' contains "beep" produce a message. If we are sourcing // a script or executing a function give the user a hint where the beep // comes from. - if (vim_strchr(p_debug, 'e') != NULL) { + if (vim_strchr((char *)p_debug, 'e') != NULL) { msg_source(HL_ATTR(HLF_W)); msg_attr(_("Beep!"), HL_ATTR(HLF_W)); } @@ -567,7 +567,7 @@ void ui_check_mouse(void) for (char_u *p = p_mouse; *p; p++) { switch (*p) { case 'a': - if (vim_strchr((char_u *)MOUSE_A, checkfor) != NULL) { + if (vim_strchr(MOUSE_A, checkfor) != NULL) { has_mouse = true; return; } diff --git a/src/nvim/version.c b/src/nvim/version.c index 8d1173de05..1b520780d1 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -2201,8 +2201,8 @@ void maybe_intro_message(void) if (buf_is_empty(curbuf) && (curbuf->b_fname == NULL) && (firstwin->w_next == NULL) - && (vim_strchr(p_shm, SHM_INTRO) == NULL)) { - intro_message(FALSE); + && (vim_strchr((char *)p_shm, SHM_INTRO) == NULL)) { + intro_message(false); } } diff --git a/src/nvim/window.c b/src/nvim/window.c index 9f7e2f8341..2c27a5d6a5 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2916,8 +2916,8 @@ static void do_autocmd_winclosed(win_T *win) return; } recursive = true; - char_u winid[NUMBUFLEN]; - vim_snprintf((char *)winid, sizeof(winid), "%d", win->handle); + char winid[NUMBUFLEN]; + vim_snprintf(winid, sizeof(winid), "%d", win->handle); apply_autocmds(EVENT_WINCLOSED, winid, winid, false, win->w_buffer); recursive = false; } @@ -2984,9 +2984,9 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) // When closing the last window in a tab page remove the tab page. if (tp->tp_firstwin == tp->tp_lastwin) { - char_u prev_idx[NUMBUFLEN]; + char prev_idx[NUMBUFLEN]; if (has_event(EVENT_TABCLOSED)) { - vim_snprintf((char *)prev_idx, NUMBUFLEN, "%i", tabpage_index(tp)); + vim_snprintf(prev_idx, NUMBUFLEN, "%i", tabpage_index(tp)); } if (tp == first_tabpage) { @@ -4098,7 +4098,7 @@ int win_new_tabpage(int after, char_u *filename) apply_autocmds(EVENT_WINNEW, NULL, NULL, false, curbuf); apply_autocmds(EVENT_WINENTER, NULL, NULL, false, curbuf); - apply_autocmds(EVENT_TABNEW, filename, filename, false, curbuf); + apply_autocmds(EVENT_TABNEW, (char *)filename, (char *)filename, false, curbuf); apply_autocmds(EVENT_TABENTER, NULL, NULL, false, curbuf); return OK; @@ -4890,7 +4890,7 @@ void fix_current_dir(void) // (unless that was done already) and change to the local directory. if (globaldir == NULL) { if (cwd[0] != NUL) { - globaldir = (char_u *)xstrdup(cwd); + globaldir = xstrdup(cwd); } } bool dir_differs = pathcmp(new_dir, cwd, -1) != 0; @@ -4909,13 +4909,13 @@ void fix_current_dir(void) } else if (globaldir != NULL) { // Window doesn't have a local directory and we are not in the global // directory: Change to the global directory. - bool dir_differs = pathcmp((char *)globaldir, cwd, -1) != 0; + bool dir_differs = pathcmp(globaldir, cwd, -1) != 0; if (!p_acd && dir_differs) { - do_autocmd_dirchanged((char *)globaldir, kCdScopeGlobal, kCdCauseWindow, true); + do_autocmd_dirchanged(globaldir, kCdScopeGlobal, kCdCauseWindow, true); } - if (os_chdir((char *)globaldir) == 0) { + if (os_chdir(globaldir) == 0) { if (!p_acd && dir_differs) { - do_autocmd_dirchanged((char *)globaldir, kCdScopeGlobal, kCdCauseWindow, false); + do_autocmd_dirchanged(globaldir, kCdScopeGlobal, kCdCauseWindow, false); } } XFREE_CLEAR(globaldir); @@ -5317,8 +5317,8 @@ void may_trigger_winscrolled(void) || wp->w_last_leftcol != wp->w_leftcol || wp->w_last_width != wp->w_width || wp->w_last_height != wp->w_height) { - char_u winid[NUMBUFLEN]; - vim_snprintf((char *)winid, sizeof(winid), "%d", wp->handle); + char winid[NUMBUFLEN]; + vim_snprintf(winid, sizeof(winid), "%d", wp->handle); recursive = true; apply_autocmds(EVENT_WINSCROLLED, winid, winid, false, wp->w_buffer); @@ -6517,7 +6517,7 @@ char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u len = 0; while (vim_isfilec(ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ') || ((options & FNAME_HYP) && path_is_url(ptr + len)) - || (is_url && vim_strchr((char_u *)":?&=", ptr[len]) != NULL)) { + || (is_url && vim_strchr(":?&=", 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') @@ -6540,7 +6540,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((char_u *)".,:;!", ptr[len - 1]) != NULL + if (len > 2 && vim_strchr(".,:;!", ptr[len - 1]) != NULL && ptr[len - 2] != '.') { --len; } |