Merge pull request #18578 from dundargoc/refactor/remove-char_u

refactor: remove char_u
This commit is contained in:
bfredl 2022-05-16 14:24:29 +02:00 committed by GitHub
commit b9b5577d6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 617 additions and 661 deletions

View File

@ -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) if (p != NULL && ea.cmdidx == CMD_SIZE && ASCII_ISUPPER(*ea.cmd)
&& has_event(EVENT_CMDUNDEFINED)) { && has_event(EVENT_CMDUNDEFINED)) {
p = xstrdup(cmdname); 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); xfree(p);
// If the autocommands did something and didn't cause an error, try // If the autocommands did something and didn't cause an error, try
// finding the command again. // finding the command again.

View File

@ -796,13 +796,13 @@ void do_autocmd(char *arg_in, int forceit)
// Expand environment variables in the pattern. Set 'shellslash', we want // Expand environment variables in the pattern. Set 'shellslash', we want
// forward slashes here. // 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 #ifdef BACKSLASH_IN_FILENAME
int p_ssl_save = p_ssl; int p_ssl_save = p_ssl;
p_ssl = true; p_ssl = true;
#endif #endif
envpat = (char *)expand_env_save((char_u *)pat); envpat = expand_env_save(pat);
#ifdef BACKSLASH_IN_FILENAME #ifdef BACKSLASH_IN_FILENAME
p_ssl = p_ssl_save; p_ssl = p_ssl_save;
#endif #endif
@ -1070,10 +1070,9 @@ int autocmd_register(int64_t id, event_T event, char *pat, int patlen, int group
char *reg_pat; char *reg_pat;
ap->buflocal_nr = 0; ap->buflocal_nr = 0;
reg_pat = (char *)file_pat_to_reg_pat((char_u *)pat, (char_u *)pat + patlen, &ap->allow_dirs, reg_pat = file_pat_to_reg_pat(pat, pat + patlen, &ap->allow_dirs, true);
true);
if (reg_pat != NULL) { 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); xfree(reg_pat);
if (reg_pat == NULL || ap->reg_prog == NULL) { if (reg_pat == NULL || ap->reg_prog == NULL) {
@ -1241,8 +1240,8 @@ void ex_doautoall(exarg_T *eap)
{ {
int retval = OK; int retval = OK;
aco_save_T aco; aco_save_T aco;
char_u *arg = (char_u *)eap->arg; char *arg = eap->arg;
int call_do_modelines = check_nomodeline((char **)&arg); int call_do_modelines = check_nomodeline(&arg);
bufref_T bufref; bufref_T bufref;
bool did_aucmd; bool did_aucmd;
@ -1261,7 +1260,7 @@ void ex_doautoall(exarg_T *eap)
set_bufref(&bufref, buf); set_bufref(&bufref, buf);
// execute the autocommands for this buffer // 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) { if (call_do_modelines && did_aucmd) {
// Execute the modeline settings, but don't set window-local // 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. // Execute autocommands for the current buffer last.
if (retval == OK) { if (retval == OK) {
(void)do_doautocmd((char *)arg, false, &did_aucmd); (void)do_doautocmd(arg, false, &did_aucmd);
if (call_do_modelines && did_aucmd) { if (call_do_modelines && did_aucmd) {
do_modelines(0); 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 // Make sure w_localdir and globaldir are NULL to avoid a chdir() in
// win_enter_ext(). // win_enter_ext().
XFREE_CLEAR(aucmd_win->w_localdir); XFREE_CLEAR(aucmd_win->w_localdir);
aco->globaldir = (char *)globaldir; aco->globaldir = globaldir;
globaldir = NULL; globaldir = NULL;
block_autocmds(); // We don't want BufEnter/WinEnter autocommands. 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 hash_init(&aucmd_win->w_vars->dv_hashtab); // re-use the hashtab
xfree(globaldir); xfree(globaldir);
globaldir = (char_u *)aco->globaldir; globaldir = aco->globaldir;
// the buffer contents may have changed // the buffer contents may have changed
check_cursor(); check_cursor();
@ -1504,10 +1503,9 @@ win_found:
/// @param buf Buffer for <abuf> /// @param buf Buffer for <abuf>
/// ///
/// @return true if some commands were executed. /// @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, return apply_autocmds_group(event, fname, fname_io, force, AUGROUP_ALL, buf, NULL);
NULL);
} }
/// Like apply_autocmds(), but with extra "eap" argument. This takes care of /// Like apply_autocmds(), but with extra "eap" argument. This takes care of

View File

@ -112,7 +112,7 @@ static int read_buffer(int read_stdin, exarg_T *eap, int flags)
// 'fileencoding' was guessed wrong. // 'fileencoding' was guessed wrong.
line_count = curbuf->b_ml.ml_line_count; line_count = curbuf->b_ml.ml_line_count;
retval = readfile(read_stdin ? NULL : (char *)curbuf->b_ffname, 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, line_count, (linenr_T)0, (linenr_T)MAXLNUM, eap,
flags | READ_BUFFER, silent); flags | READ_BUFFER, silent);
if (retval == OK) { if (retval == OK) {
@ -229,7 +229,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
} }
#endif #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, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, eap,
flags | READ_NEW | (read_fifo ? READ_FIFO : 0), silent); flags | READ_NEW | (read_fifo ? READ_FIFO : 0), silent);
#ifdef UNIX #ifdef UNIX
@ -1219,8 +1219,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
return FAIL; return FAIL;
} }
} else { } else {
semsg(_("E89: %s will be killed (add ! to override)"), semsg(_("E89: %s will be killed (add ! to override)"), buf->b_fname);
(char *)buf->b_fname);
return FAIL; 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);
hash_init(&buf->b_s.b_keywtab_ic); 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) { if (!file_id_valid) {
buf->file_id_valid = false; buf->file_id_valid = false;
} else { } else {
@ -2113,10 +2112,10 @@ int buflist_findpat(const char_u *pattern, const char_u *pattern_end, bool unlis
{ {
int match = -1; int match = -1;
int find_listed; int find_listed;
char_u *pat; char *pat;
char_u *patend; char *patend;
int attempt; int attempt;
char_u *p; char *p;
int toggledollar; int toggledollar;
if (pattern_end == pattern + 1 && (*pattern == '%' || *pattern == '#')) { 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 // Repeat this for finding an unlisted buffer if there was no matching
// listed buffer. // 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) { if (pat == NULL) {
return -1; return -1;
} }
@ -2271,7 +2270,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
} }
regmatch_T regmatch; 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 (regmatch.regprog == NULL) {
if (patc != pat) { if (patc != pat) {
xfree(patc); xfree(patc);
@ -2426,7 +2425,7 @@ char_u *buflist_nr2name(int n, int fullname, int helptail)
return NULL; return NULL;
} }
return home_replace_save(helptail ? buf : 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 /// 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; garray_T buflist;
buf_T **buflist_data = NULL; 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); ga_init(&buflist, sizeof(buf_T *), 50);
for (buf = firstbuf; buf != NULL; buf = buf->b_next) { for (buf = firstbuf; buf != NULL; buf = buf->b_next) {
ga_grow(&buflist, 1); ga_grow(&buflist, 1);
@ -2645,28 +2644,28 @@ void buflist_list(exarg_T *eap)
const bool job_running = buf->terminal && terminal_running(buf->terminal); const bool job_running = buf->terminal && terminal_running(buf->terminal);
// skip unspecified buffers // skip unspecified buffers
if ((!buf->b_p_bl && !eap->forceit && !vim_strchr((char_u *)eap->arg, 'u')) if ((!buf->b_p_bl && !eap->forceit && !vim_strchr(eap->arg, 'u'))
|| (vim_strchr((char_u *)eap->arg, 'u') && buf->b_p_bl) || (vim_strchr(eap->arg, 'u') && buf->b_p_bl)
|| (vim_strchr((char_u *)eap->arg, '+') || (vim_strchr(eap->arg, '+')
&& ((buf->b_flags & BF_READERR) || !bufIsChanged(buf))) && ((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)) && (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)) && (buf->b_ml.ml_mfp == NULL || buf->b_nwindows != 0))
|| (vim_strchr((char_u *)eap->arg, 'R') && (!is_terminal || !job_running)) || (vim_strchr(eap->arg, 'R') && (!is_terminal || !job_running))
|| (vim_strchr((char_u *)eap->arg, 'F') && (!is_terminal || job_running)) || (vim_strchr(eap->arg, 'F') && (!is_terminal || job_running))
|| (vim_strchr((char_u *)eap->arg, '-') && buf->b_p_ma) || (vim_strchr(eap->arg, '-') && buf->b_p_ma)
|| (vim_strchr((char_u *)eap->arg, '=') && !buf->b_p_ro) || (vim_strchr(eap->arg, '=') && !buf->b_p_ro)
|| (vim_strchr((char_u *)eap->arg, 'x') && !(buf->b_flags & BF_READERR)) || (vim_strchr(eap->arg, 'x') && !(buf->b_flags & BF_READERR))
|| (vim_strchr((char_u *)eap->arg, '%') && buf != curbuf) || (vim_strchr(eap->arg, '%') && buf != curbuf)
|| (vim_strchr((char_u *)eap->arg, '#') || (vim_strchr(eap->arg, '#')
&& (buf == curbuf || curwin->w_alt_fnum != buf->b_fnum))) { && (buf == curbuf || curwin->w_alt_fnum != buf->b_fnum))) {
continue; continue;
} }
if (buf_spname(buf) != NULL) { if (buf_spname(buf) != NULL) {
STRLCPY(NameBuff, buf_spname(buf), MAXPATHL); STRLCPY(NameBuff, buf_spname(buf), MAXPATHL);
} else { } 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)) { if (message_filtered(NameBuff)) {
@ -2700,7 +2699,7 @@ void buflist_list(exarg_T *eap)
do { do {
IObuff[len++] = ' '; IObuff[len++] = ' ';
} while (--i > 0 && len < IOSIZE - 18); } 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); undo_fmt_time(IObuff + len, (size_t)(IOSIZE - len), buf->b_last_used);
} else { } else {
vim_snprintf((char *)IObuff + len, (size_t)(IOSIZE - len), _("line %" PRId64), 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; return FAIL;
} }
*fname = buf->b_fname; *fname = (char_u *)buf->b_fname;
*lnum = buflist_findlnum(buf); *lnum = buflist_findlnum(buf);
return OK; 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_ffname = ffname;
buf->b_sfname = sfname; buf->b_sfname = sfname;
} }
buf->b_fname = buf->b_sfname; buf->b_fname = (char *)buf->b_sfname;
if (!file_id_valid) { if (!file_id_valid) {
buf->file_id_valid = false; buf->file_id_valid = false;
} else { } else {
@ -2823,7 +2822,7 @@ void buf_set_name(int fnum, char_u *name)
// Allocate ffname and expand into full path. Also resolves .lnk // Allocate ffname and expand into full path. Also resolves .lnk
// files on Win32. // files on Win32.
fname_expand(buf, &buf->b_ffname, &buf->b_sfname); 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; FileID file_id;
if (buf->b_fname != NULL 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_valid = true;
buf->file_id = file_id; buf->file_id = file_id;
} else { } else {
@ -3023,7 +3022,7 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate)
STRLCPY(p, buf_spname(curbuf), IOSIZE - (p - buffer)); STRLCPY(p, buf_spname(curbuf), IOSIZE - (p - buffer));
} else { } else {
if (!fullname && curbuf->b_fname != NULL) { if (!fullname && curbuf->b_fname != NULL) {
name = curbuf->b_fname; name = (char_u *)curbuf->b_fname;
} else { } else {
name = curbuf->b_ffname; name = curbuf->b_ffname;
} }
@ -3175,7 +3174,7 @@ void maketitle(void)
SPACE_FOR_FNAME + 1); SPACE_FOR_FNAME + 1);
buf_p += MIN(size, SPACE_FOR_FNAME); buf_p += MIN(size, SPACE_FOR_FNAME);
} else { } 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); 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); STRLCPY(NameBuff, buf_spname(wp->w_buffer), MAXPATHL);
} else { } else {
char_u *t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname 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); home_replace(wp->w_buffer, t, NameBuff, MAXPATHL, true);
} }
trans_characters(NameBuff, MAXPATHL); trans_characters(NameBuff, MAXPATHL);
@ -4650,7 +4649,7 @@ char_u *alist_name(aentry_T *aep)
if (bp == NULL || bp->b_fname == NULL) { if (bp == NULL || bp->b_fname == NULL) {
return aep->ae_fname; 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. /// 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; break;
} }
end = true; end = true;
s = vim_strchr(s, ' ') + 1; s = (char_u *)vim_strchr((char *)s, ' ') + 1;
} }
*e = NUL; // truncate the set command *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. // contains the name as specified by the user.
if (bt_nofile(buf)) { if (bt_nofile(buf)) {
if (buf->b_fname != NULL) { if (buf->b_fname != NULL) {
return buf->b_fname; return (char_u *)buf->b_fname;
} }
if (bt_prompt(buf)) { if (bt_prompt(buf)) {
return (char_u *)_("[Prompt]"); return (char_u *)_("[Prompt]");
@ -5552,7 +5551,7 @@ char_u *buf_get_fname(const buf_T *buf)
if (buf->b_fname == NULL) { if (buf->b_fname == NULL) {
return (char_u *)_("[No Name]"); 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. /// 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); aucmd_prepbuf(&aco, newbuf);
if (ml_open(curbuf) == OK 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, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,
&ea, READ_NEW | READ_DUMMY, false) == OK) { &ea, READ_NEW | READ_DUMMY, false) == OK) {
// compare the two files line by line // compare the two files line by line

View File

@ -537,16 +537,14 @@ struct file_buffer {
int b_ro_locked; // Non-zero when the buffer can't be changed. int b_ro_locked; // Non-zero when the buffer can't be changed.
// Used for FileChangedRO // Used for FileChangedRO
//
// b_ffname has the full path of the file (NULL for no name). // 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_sfname is the name as the user typed it (or NULL).
// b_fname is the same as b_sfname, unless ":cd" has been done, // 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). // then it is the same as b_ffname (NULL for no name).
//
char_u *b_ffname; // full path file name, allocated char_u *b_ffname; // full path file name, allocated
char_u *b_sfname; // short file name, allocated, may be equal to char_u *b_sfname; // short file name, allocated, may be equal to
// b_ffname // 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 // b_sfname
bool file_id_valid; bool file_id_valid;

View File

@ -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 while (off > 0 && lead_len > 0
&& leader[lead_len - 1] == ' ') { && leader[lead_len - 1] == ' ') {
// Don't do it when there is a tab before the space // 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; break;
} }
lead_len--; lead_len--;
@ -1878,7 +1878,7 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa
{ {
int j; int j;
int got_com = false; 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 *string; // pointer to comment string
char_u *list; char_u *list;
int middle_match_len = 0; 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 *flags = list; // remember where flags started
} }
prev_list = list; prev_list = list;
(void)copy_option_part(&list, part_buf, COM_MAX_LEN, ","); (void)copy_option_part(&list, (char_u *)part_buf, COM_MAX_LEN, ",");
string = vim_strchr(part_buf, ':'); string = (char_u *)vim_strchr(part_buf, ':');
if (string == NULL) { // missing ':', ignore this part if (string == NULL) { // missing ':', ignore this part
continue; continue;
} }
@ -2025,7 +2025,7 @@ int get_last_leader_offset(char_u *line, char_u **flags)
char_u *com_leader; char_u *com_leader;
char_u *com_flags; char_u *com_flags;
char_u *list; 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. // Repeat to match several nested comment strings.
int i = (int)STRLEN(line); 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. // Get one option part into part_buf[]. Advance list to next one.
// put string at start of string. // put string at start of string.
(void)copy_option_part(&list, part_buf, COM_MAX_LEN, ","); (void)copy_option_part(&list, (char_u *)part_buf, COM_MAX_LEN, ",");
string = vim_strchr(part_buf, ':'); string = (char_u *)vim_strchr(part_buf, ':');
if (string == NULL) { // If everything is fine, this cannot actually if (string == NULL) { // If everything is fine, this cannot actually
// happen. // happen.
continue; continue;
@ -2096,7 +2096,7 @@ int get_last_leader_offset(char_u *line, char_u **flags)
} }
if (found_one) { 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; int len1, len2, off;
result = i; result = i;
@ -2120,11 +2120,11 @@ int get_last_leader_offset(char_u *line, char_u **flags)
for (list = curbuf->b_p_com; *list;) { for (list = curbuf->b_p_com; *list;) {
char_u *flags_save = 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) { if (flags_save == com_flags) {
continue; continue;
} }
string = vim_strchr(part_buf2, ':'); string = (char_u *)vim_strchr(part_buf2, ':');
string++; string++;
while (ascii_iswhite(*string)) { while (ascii_iswhite(*string)) {
string++; string++;

View File

@ -120,8 +120,8 @@ char *parse_shape_opt(int what)
// Repeat for all comma separated parts. // Repeat for all comma separated parts.
char *modep = (char *)p_guicursor; char *modep = (char *)p_guicursor;
while (modep != NULL && *modep != NUL) { while (modep != NULL && *modep != NUL) {
colonp = (char *)vim_strchr((char_u *)modep, ':'); colonp = vim_strchr(modep, ':');
commap = (char *)vim_strchr((char_u *)modep, ','); commap = vim_strchr(modep, ',');
if (colonp == NULL || (commap != NULL && commap < colonp)) { if (colonp == NULL || (commap != NULL && commap < colonp)) {
return N_("E545: Missing colon"); return N_("E545: Missing colon");
@ -215,7 +215,7 @@ char *parse_shape_opt(int what)
} }
p += 5; p += 5;
} else { // must be a highlight group name then } 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 (commap == NULL) { // last part
if (endp == NULL) { if (endp == NULL) {
endp = p + STRLEN(p); // find end of part endp = p + STRLEN(p); // find end of part
@ -223,7 +223,7 @@ char *parse_shape_opt(int what)
} else if (endp > commap || endp == NULL) { } else if (endp > commap || endp == NULL) {
endp = commap; endp = commap;
} }
slashp = (char *)vim_strchr((char_u *)p, '/'); slashp = vim_strchr(p, '/');
if (slashp != NULL && slashp < endp) { if (slashp != NULL && slashp < endp) {
// "group/langmap_group" // "group/langmap_group"
i = syn_check_group(p, (size_t)(slashp - p)); i = syn_check_group(p, (size_t)(slashp - p));

View File

@ -100,7 +100,7 @@ void do_debug(char_u *cmd)
debug_newval = NULL; debug_newval = NULL;
} }
if (sourcing_name != NULL) { if (sourcing_name != NULL) {
msg((char *)sourcing_name); msg(sourcing_name);
} }
if (sourcing_lnum != 0) { if (sourcing_lnum != 0) {
smsg(_("line %" PRId64 ": %s"), (int64_t)sourcing_lnum, cmd); smsg(_("line %" PRId64 ": %s"), (int64_t)sourcing_lnum, cmd);
@ -293,7 +293,7 @@ static int get_maxbacktrace_level(void)
int maxbacktrace = 0; int maxbacktrace = 0;
if (sourcing_name != NULL) { if (sourcing_name != NULL) {
char *p = (char *)sourcing_name; char *p = sourcing_name;
char *q; char *q;
while ((q = strstr(p, "..")) != NULL) { while ((q = strstr(p, "..")) != NULL) {
p = q + 2; p = q + 2;
@ -334,7 +334,7 @@ static void do_showbacktrace(char_u *cmd)
if (sourcing_name != NULL) { if (sourcing_name != NULL) {
int i = 0; int i = 0;
int max = get_maxbacktrace_level(); int max = get_maxbacktrace_level();
char *cur = (char *)sourcing_name; char *cur = sourcing_name;
while (!got_int) { while (!got_int) {
char *next = strstr(cur, ".."); char *next = strstr(cur, "..");
if (next != NULL) { 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 /// @param gap either &dbg_breakp or &prof_ga
static int dbg_parsearg(char_u *arg, garray_T *gap) static int dbg_parsearg(char_u *arg, garray_T *gap)
{ {
char_u *p = arg; char *p = (char *)arg;
char_u *q; char *q;
bool here = false; bool here = false;
ga_grow(gap, 1); ga_grow(gap, 1);
@ -501,14 +501,14 @@ static int dbg_parsearg(char_u *arg, garray_T *gap)
semsg(_(e_invarg2), p); semsg(_(e_invarg2), p);
return FAIL; return FAIL;
} }
p = (char_u *)skipwhite((char *)p + 4); p = skipwhite(p + 4);
// Find optional line number. // Find optional line number.
if (here) { if (here) {
bp->dbg_lnum = curwin->w_cursor.lnum; bp->dbg_lnum = curwin->w_cursor.lnum;
} else if (gap != &prof_ga && ascii_isdigit(*p)) { } else if (gap != &prof_ga && ascii_isdigit(*p)) {
bp->dbg_lnum = getdigits_long(&p, true, 0); bp->dbg_lnum = getdigits_long((char_u **)&p, true, 0);
p = (char_u *)skipwhite((char *)p); p = skipwhite(p);
} else { } else {
bp->dbg_lnum = 0; 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 (). // Find the function or file name. Don't accept a function name with ().
if ((!here && *p == NUL) if ((!here && *p == NUL)
|| (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); semsg(_(e_invarg2), arg);
return FAIL; return FAIL;
} }
if (bp->dbg_type == DBG_FUNC) { if (bp->dbg_type == DBG_FUNC) {
bp->dbg_name = vim_strsave(p); bp->dbg_name = vim_strsave((char_u *)p);
} else if (here) { } else if (here) {
bp->dbg_name = vim_strsave(curbuf->b_ffname); bp->dbg_name = vim_strsave(curbuf->b_ffname);
} else if (bp->dbg_type == DBG_EXPR) { } 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); bp->dbg_val = eval_expr_no_emsg(bp);
} else { } else {
// Expand the file name in the same way as do_source(). This means // 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; return FAIL;
} }
if (*p != '*') { if (*p != '*') {
bp->dbg_name = (char_u *)fix_fname((char *)p); bp->dbg_name = (char_u *)fix_fname(p);
xfree(p); xfree(p);
} else { } 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; bp->dbg_forceit = eap->forceit;
if (bp->dbg_type != DBG_EXPR) { 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) { if (pat != NULL) {
bp->dbg_prog = vim_regcomp(pat, RE_MAGIC + RE_STRING); bp->dbg_prog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
xfree(pat); xfree(pat);

View File

@ -1160,7 +1160,7 @@ void ex_diffpatch(exarg_T *eap)
{ {
char_u *buf = NULL; char_u *buf = NULL;
win_T *old_curwin = curwin; 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; char_u *esc_name = NULL;
#ifdef UNIX #ifdef UNIX
@ -1258,7 +1258,7 @@ void ex_diffpatch(exarg_T *eap)
emsg(_("E816: Cannot read patch output")); emsg(_("E816: Cannot read patch output"));
} else { } else {
if (curbuf->b_fname != NULL) { 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"); STRCAT(newname, ".new");
} }
@ -1279,7 +1279,7 @@ void ex_diffpatch(exarg_T *eap)
if (newname != NULL) { if (newname != NULL) {
// do a ":file filename.new" on the patched buffer // do a ":file filename.new" on the patched buffer
eap->arg = (char *)newname; eap->arg = newname;
ex_file(eap); ex_file(eap);
// Do filetype detection with the new name. // Do filetype detection with the new name.

View File

@ -2069,7 +2069,7 @@ void ex_loadkeymap(exarg_T *eap)
#define KMAP_LLEN 200 // max length of "to" and "from" together #define KMAP_LLEN 200 // max length of "to" and "from" together
char_u buf[KMAP_LLEN + 11]; 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)) { if (!getline_equal(eap->getline, eap->cookie, getsourceline)) {
emsg(_("E105: Using :loadkeymap not in a sourced file")); 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); ga_init(&curbuf->b_kmap_ga, (int)sizeof(kmap_T), 20);
// Set 'cpoptions' to "C" to avoid line continuation. // 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. // Get each line of the sourced file, break at the end.
for (;;) { for (;;) {
@ -2093,7 +2093,7 @@ void ex_loadkeymap(exarg_T *eap)
break; break;
} }
char_u *p = (char_u *)skipwhite((char *)line); char_u *p = (char_u *)skipwhite(line);
if ((*p != '"') && (*p != NUL)) { if ((*p != '"') && (*p != NUL)) {
kmap_T *kp = GA_APPEND_VIA_PTR(kmap_T, &curbuf->b_kmap_ga); 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'. /// Stop using 'keymap'.
static void keymap_unload(void) static void keymap_unload(void)
{ {
char_u buf[KMAP_MAXLEN + 10]; char buf[KMAP_MAXLEN + 10];
char_u *save_cpo = p_cpo; char *save_cpo = p_cpo;
if (!(curbuf->b_kmap_state & KEYMAP_LOADED)) { if (!(curbuf->b_kmap_state & KEYMAP_LOADED)) {
return; return;
} }
// Set 'cpoptions' to "C" to avoid line continuation. // Set 'cpoptions' to "C" to avoid line continuation.
p_cpo = (char_u *)"C"; p_cpo = "C";
// clear the ":lmap"s // clear the ":lmap"s
kmap_T *kp = (kmap_T *)curbuf->b_kmap_ga.ga_data; kmap_T *kp = (kmap_T *)curbuf->b_kmap_ga.ga_data;
for (int i = 0; i < curbuf->b_kmap_ga.ga_len; i++) { for (int i = 0; i < curbuf->b_kmap_ga.ga_len; i++) {
vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s", kp[i].from); vim_snprintf(buf, sizeof(buf), "<buffer> %s", kp[i].from);
(void)do_map(1, buf, MODE_LANGMAP, false); (void)do_map(1, (char_u *)buf, MODE_LANGMAP, false);
} }
keymap_ga_clear(&curbuf->b_kmap_ga); keymap_ga_clear(&curbuf->b_kmap_ga);

View File

@ -1339,7 +1339,7 @@ normalchar:
ins_char(s->c); ins_char(s->c);
} }
} }
AppendToRedobuffLit((char *)str, -1); AppendToRedobuffLit(str, -1);
} }
xfree(str); xfree(str);
s->c = NUL; s->c = NUL;
@ -2735,7 +2735,7 @@ static bool pum_wanted(void)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
// "completeopt" must contain "menu" or "menuone" // "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. /// 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; size_t len = STRLEN(pat_esc) + 10;
ptr = xmalloc(len); ptr = xmalloc(len);
vim_snprintf((char *)ptr, len, "^\\s*\\zs\\V%s", pat_esc); 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(pat_esc);
xfree(ptr); xfree(ptr);
} else { } 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) { if (regmatch.regprog == NULL) {
goto theend; 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, ","); copy_option_part(&dict, buf, LSIZE, ",");
if (!thesaurus && STRCMP(buf, "spell") == 0) { if (!thesaurus && STRCMP(buf, "spell") == 0) {
count = -1; count = -1;
} else if (vim_strchr(buf, '`') != NULL } else if (vim_strchr((char *)buf, '`') != NULL
|| expand_wildcards(1, &buf, &count, &files, || expand_wildcards(1, &buf, &count, &files,
EW_FILE|EW_SILENT) != OK) { EW_FILE|EW_SILENT) != OK) {
count = 0; 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 // Remember the first match so that the loop stops when we
// wrap and come back there a second time. // wrap and come back there a second time.
set_match_pos = true; set_match_pos = true;
} else if (vim_strchr((char_u *)"buwU", *e_cpt) != NULL } else if (vim_strchr("buwU", *e_cpt) != NULL
&& (ins_buf = && (ins_buf = ins_compl_next_buf(ins_buf, *e_cpt)) != curbuf) {
ins_compl_next_buf(ins_buf, *e_cpt)) != curbuf) {
// Scan a buffer, but not the current one. // Scan a buffer, but not the current one.
if (ins_buf->b_ml.ml_mfp != NULL) { // loaded buffer if (ins_buf->b_ml.ml_mfp != NULL) { // loaded buffer
compl_started = true; compl_started = true;
@ -4268,7 +4267,7 @@ static int ins_compl_get_exp(pos_T *ini)
continue; continue;
} }
type = CTRL_X_DICTIONARY; type = CTRL_X_DICTIONARY;
dict = ins_buf->b_fname; dict = (char_u *)ins_buf->b_fname;
dict_f = DICT_EXACT; dict_f = DICT_EXACT;
} }
msg_hist_off = true; // reset in msg_trunc_attr() 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 ins_buf->b_fname == NULL
? buf_spname(ins_buf) ? buf_spname(ins_buf)
: ins_buf->b_sfname == NULL : ins_buf->b_sfname == NULL
? ins_buf->b_fname ? (char_u *)ins_buf->b_fname
: ins_buf->b_sfname); : ins_buf->b_sfname);
(void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R)); (void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R));
} else if (*e_cpt == NUL) { } 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. * comment leader. First, check what comment leader we can find.
*/ */
i = get_leader_len(line = get_cursor_line_ptr(), &p, false, true); 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 // Skip middle-comment string
while (*p && p[-1] != ':') { // find end of middle flags while (*p && p[-1] != ':') { // find end of middle flags
p++; 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>, <>>, <<>, <*>, // make up some named keys <o>, <O>, <e>, <0>, <>>, <<>, <*>,
// <:> and <!> so that people can re-indent on o, O, e, 0, <, // <:> and <!> so that people can re-indent on o, O, e, 0, <,
// >, *, : and ! keys if they really really want to. // >, *, : 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]) { && keytyped == look[1]) {
return true; return true;
} }
@ -7607,7 +7606,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
} else { } else {
icase = false; icase = false;
} }
p = vim_strchr(look, ','); p = (char_u *)vim_strchr((char *)look, ',');
if (p == NULL) { if (p == NULL) {
p = look + STRLEN(look); p = look + STRLEN(look);
} }
@ -8697,7 +8696,7 @@ static void ins_left(void)
revins_legal++; revins_legal++;
} }
revins_chars++; 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. // if 'whichwrap' set for cursor in insert mode may go to previous line.
// always break undo when moving upwards/downwards, else undo may break // always break undo when moving upwards/downwards, else undo may break
start_arrow(&tpos); start_arrow(&tpos);
@ -8790,7 +8789,7 @@ static void ins_right(void)
if (revins_chars) { if (revins_chars) {
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) { && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) {
// if 'whichwrap' set for cursor in insert mode, may move the // if 'whichwrap' set for cursor in insert mode, may move the
// cursor to the next line // cursor to the next line

View File

@ -1407,7 +1407,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
argend--; argend--;
} }
expr = skipwhite(argend); expr = skipwhite(argend);
if (*expr != '=' && !((vim_strchr((char_u *)"+-*/%.", *expr) != NULL if (*expr != '=' && !((vim_strchr("+-*/%.", *expr) != NULL
&& expr[1] == '=') || STRNCMP(expr, "..=", 3) == 0)) { && expr[1] == '=') || STRNCMP(expr, "..=", 3) == 0)) {
// ":let" without "=": list variables // ":let" without "=": list variables
if (*arg == '[') { if (*arg == '[') {
@ -1443,7 +1443,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
op[0] = '='; op[0] = '=';
op[1] = NUL; op[1] = NUL;
if (*expr != '=') { if (*expr != '=') {
if (vim_strchr((char_u *)"+-*/%.", *expr) != NULL) { if (vim_strchr("+-*/%.", *expr) != NULL) {
op[0] = *expr; // +=, -=, *=, /=, %= or .= op[0] = *expr; // +=, -=, *=, /=, %= or .=
if (expr[0] == '.' && expr[1] == '.') { // ..= if (expr[0] == '.' && expr[1] == '.') { // ..=
expr++; expr++;
@ -1809,10 +1809,10 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo
if (len == 0) { if (len == 0) {
semsg(_(e_invarg2), name - 1); semsg(_(e_invarg2), name - 1);
} else { } else {
if (op != NULL && vim_strchr((char_u *)"+-*/%", *op) != NULL) { if (op != NULL && vim_strchr("+-*/%", *op) != NULL) {
semsg(_(e_letwrong), op); semsg(_(e_letwrong), op);
} else if (endchars != NULL } else if (endchars != NULL
&& vim_strchr((char_u *)endchars, *skipwhite(arg)) == NULL) { && vim_strchr(endchars, *skipwhite(arg)) == NULL) {
emsg(_(e_letunexp)); emsg(_(e_letunexp));
} else if (!check_secure()) { } else if (!check_secure()) {
const char c1 = name[len]; 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); char *const p = (char *)find_option_end((const char **)&arg, &opt_flags);
if (p == NULL if (p == NULL
|| (endchars != NULL || (endchars != NULL
&& vim_strchr((char_u *)endchars, *skipwhite(p)) == NULL)) { && vim_strchr(endchars, *skipwhite(p)) == NULL)) {
emsg(_(e_letunexp)); emsg(_(e_letunexp));
} else { } else {
int opt_type; 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; return NULL;
} }
arg++; arg++;
if (op != NULL && vim_strchr((char_u *)"+-*/%", *op) != NULL) { if (op != NULL && vim_strchr("+-*/%", *op) != NULL) {
semsg(_(e_letwrong), op); semsg(_(e_letwrong), op);
} else if (endchars != NULL } else if (endchars != NULL
&& vim_strchr((char_u *)endchars, *skipwhite(arg + 1)) == NULL) { && vim_strchr(endchars, *skipwhite(arg + 1)) == NULL) {
emsg(_(e_letunexp)); emsg(_(e_letunexp));
} else { } else {
char *s; 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); char *const p = get_lval(arg, tv, &lv, false, false, 0, FNE_CHECK_START);
if (p != NULL && lv.ll_name != NULL) { 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)); emsg(_(e_letunexp));
} else { } else {
set_var_lval(&lv, p, tv, copy, is_const, op); 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; break;
} else if ((c == '<' || c == '#') } else if ((c == '<' || c == '#')
&& xp->xp_context == EXPAND_FUNCTIONS && 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 '#'. // Function name can start with "<SNR>" and contain '#'.
break; break;
} else if (cmdidx != CMD_let || got_eq) { } else if (cmdidx != CMD_let || got_eq) {
@ -3263,15 +3263,15 @@ int pattern_match(char *pat, char *text, bool ic)
regmatch_T regmatch; regmatch_T regmatch;
// avoid 'l' flag in 'cpoptions' // avoid 'l' flag in 'cpoptions'
char *save_cpo = (char *)p_cpo; char *save_cpo = p_cpo;
p_cpo = (char_u *)""; p_cpo = "";
regmatch.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING); regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
if (regmatch.regprog != NULL) { if (regmatch.regprog != NULL) {
regmatch.rm_ic = ic; regmatch.rm_ic = ic;
matches = vim_regexec_nl(&regmatch, (char_u *)text, (colnr_T)0); matches = vim_regexec_nl(&regmatch, (char_u *)text, (colnr_T)0);
vim_regfree(regmatch.regprog); vim_regfree(regmatch.regprog);
} }
p_cpo = (char_u *)save_cpo; p_cpo = save_cpo;
return matches; return matches;
} }
@ -5872,7 +5872,7 @@ static int get_env_tv(char **arg, typval_T *rettv, int evaluate)
xfree(string); xfree(string);
// Next try expanding things like $VIM and ${HOME}. // 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 == '$') { if (string != NULL && *string == '$') {
XFREE_CLEAR(string); XFREE_CLEAR(string);
} }
@ -6141,7 +6141,7 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref, FunPtr
use_string = true; 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; name = s;
trans_name = (char *)trans_function_name((char_u **)&name, false, trans_name = (char *)trans_function_name((char_u **)&name, false,
TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD 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. // slice "[n:]". Also "xx:" is not a namespace.
len = (int)(p - *arg); len = (int)(p - *arg);
if (len > 1 if (len > 1
|| (len == 1 && vim_strchr((char_u *)namespace_char, **arg) == NULL)) { || (len == 1 && vim_strchr(namespace_char, **arg) == NULL)) {
break; 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. // slice "[n:]". Also "xx:" is not a namespace. But {ns}: is.
len = (int)(p - arg); len = (int)(p - arg);
if ((len > 1 && p[-1] != '}') if ((len > 1 && p[-1] != '}')
|| (len == 1 && vim_strchr((char_u *)namespace_char, *arg) == NULL)) { || (len == 1 && vim_strchr(namespace_char, *arg) == NULL)) {
break; 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 FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{ {
// Allow for w: b: s: and t:. // 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] == ':') && !ASCII_ISUPPER((name[0] != NUL && name[1] == ':')
? name[2] : name[0])) { ? name[2] : name[0])) {
semsg(_("E704: Funcref variable name must start with a capital: %s"), name); semsg(_("E704: Funcref variable name must start with a capital: %s"), name);
@ -10110,7 +10110,7 @@ repeat:
|| (*fnamep)[1] == NUL) || (*fnamep)[1] == NUL)
#endif #endif
&& !(tilde_file && (*fnamep)[1] == NUL)) { && !(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 xfree(*bufp); // free any allocated file name
*bufp = *fnamep; *bufp = *fnamep;
if (*fnamep == NULL) { if (*fnamep == NULL) {
@ -10163,7 +10163,7 @@ repeat:
// Need full path first (use expand_env() to remove a "~/") // Need full path first (use expand_env() to remove a "~/")
if (!has_fullname && !has_homerelative) { if (!has_fullname && !has_homerelative) {
if (**fnamep == '~') { if (**fnamep == '~') {
p = pbuf = (char *)expand_env_save((char_u *)(*fnamep)); p = pbuf = expand_env_save(*fnamep);
} else { } else {
p = pbuf = FullName_save(*fnamep, false); p = pbuf = FullName_save(*fnamep, false);
} }
@ -10325,12 +10325,12 @@ repeat:
sep = (char_u)(*s++); sep = (char_u)(*s++);
if (sep) { if (sep) {
// find end of pattern // find end of pattern
p = (char *)vim_strchr((char_u *)s, sep); p = vim_strchr(s, sep);
if (p != NULL) { if (p != NULL) {
char *const pat = xstrnsave(s, p - s); char *const pat = xstrnsave(s, p - s);
s = p + 1; s = p + 1;
// find end of substitution // find end of substitution
p = (char *)vim_strchr((char_u *)s, sep); p = vim_strchr(s, sep);
if (p != NULL) { if (p != NULL) {
char *const sub = xstrnsave(s, p - s); char *const sub = xstrnsave(s, p - s);
char *const str = xstrnsave(*fnamep, *fnamelen); 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; char *zero_width = NULL;
// Make 'cpoptions' empty, so that the 'l' flag doesn't work here // Make 'cpoptions' empty, so that the 'l' flag doesn't work here
save_cpo = (char *)p_cpo; save_cpo = p_cpo;
p_cpo = empty_option; p_cpo = (char *)empty_option;
ga_init(&ga, 1, 200); ga_init(&ga, 1, 200);
do_all = (flags[0] == 'g'); do_all = (flags[0] == 'g');
regmatch.rm_ic = p_ic; 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) { if (regmatch.regprog != NULL) {
tail = str; tail = str;
end = str + STRLEN(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); char *ret = xstrdup(ga.ga_data == NULL ? str : ga.ga_data);
ga_clear(&ga); ga_clear(&ga);
if (p_cpo == empty_option) { if ((char_u *)p_cpo == empty_option) {
p_cpo = (char_u *)save_cpo; p_cpo = save_cpo;
} else { } else {
// Darn, evaluating {sub} expression or {expr} changed the value. // Darn, evaluating {sub} expression or {expr} changed the value.
free_string_option((char_u *)save_cpo); free_string_option((char_u *)save_cpo);

View File

@ -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) { if (tv2->v_type == VAR_LIST) {
break; break;
} }
if (vim_strchr((char_u *)"+-*/%", *op) != NULL) { if (vim_strchr("+-*/%", *op) != NULL) {
// nr += nr or nr -= nr, nr *= nr, nr /= nr, nr %= nr // nr += nr or nr -= nr, nr *= nr, nr /= nr, nr %= nr
varnumber_T n = tv_get_number(tv1); varnumber_T n = tv_get_number(tv1);
if (tv2->v_type == VAR_FLOAT) { if (tv2->v_type == VAR_FLOAT) {

View File

@ -485,9 +485,7 @@ static buf_T *find_buffer(typval_T *avar)
* buffer, these don't use the full path. */ * buffer, these don't use the full path. */
FOR_ALL_BUFFERS(bp) { FOR_ALL_BUFFERS(bp) {
if (bp->b_fname != NULL if (bp->b_fname != NULL
&& (path_with_url((char *)bp->b_fname) && (path_with_url(bp->b_fname) || bt_nofile(bp))
|| bt_nofile(bp)
)
&& STRCMP(bp->b_fname, avar->vval.v_string) == 0) { && STRCMP(bp->b_fname, avar->vval.v_string) == 0) {
buf = bp; buf = bp;
break; 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]); buf = tv_get_buf_from_arg(&argvars[0]);
} }
if (buf != NULL && buf->b_fname != NULL) { 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; char_u *name = (char_u *)tv->vval.v_string;
int save_magic; int save_magic;
char_u *save_cpo; char *save_cpo;
buf_T *buf; buf_T *buf;
if (tv->v_type == VAR_NUMBER) { 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; save_magic = p_magic;
p_magic = TRUE; p_magic = TRUE;
save_cpo = p_cpo; save_cpo = p_cpo;
p_cpo = (char_u *)""; p_cpo = "";
buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name), buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name),
true, false, curtab_only)); true, false, curtab_only));
@ -2066,7 +2064,7 @@ static void f_exists(typval_T *argvars, typval_T *rettv, FunPtr fptr)
n = true; n = true;
} else { } else {
// Try expanding things like $VIM and ${HOME}. // 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 != '$') { if (exp != NULL && *exp != '$') {
n = true; n = true;
} }
@ -3390,7 +3388,7 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
FALLTHROUGH; FALLTHROUGH;
case kCdScopeGlobal: case kCdScopeGlobal:
if (globaldir) { // `globaldir` is not always set. if (globaldir) { // `globaldir` is not always set.
from = globaldir; from = (char_u *)globaldir;
break; break;
} }
FALLTHROUGH; // In global directory, just need to get OS CWD. 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 const char *const pat = tv_get_string_chk(&argvars[0]); // NULL on type error
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;
rettv->vval.v_string = rettv->vval.v_string = (pat == NULL) ? NULL : file_pat_to_reg_pat(pat, NULL, NULL, false);
(char *)((pat == NULL) ? NULL : file_pat_to_reg_pat((char_u *)pat, NULL, NULL, false));
} }
/// "has()" function /// "has()" function
@ -5780,7 +5777,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv,
long len = 0; long len = 0;
char_u *expr = NULL; char_u *expr = NULL;
regmatch_T regmatch; regmatch_T regmatch;
char_u *save_cpo; char *save_cpo;
long start = 0; long start = 0;
long nth = 1; long nth = 1;
colnr_T startcol = 0; 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. // Make 'cpoptions' empty, the 'l' flag should not be used here.
save_cpo = p_cpo; save_cpo = p_cpo;
p_cpo = (char_u *)""; p_cpo = "";
rettv->vval.v_number = -1; rettv->vval.v_number = -1;
switch (type) { 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) { if (regmatch.regprog != NULL) {
regmatch.rm_ic = p_ic; 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) long time_limit)
FUNC_ATTR_NONNULL_ARG(1, 2, 3) FUNC_ATTR_NONNULL_ARG(1, 2, 3)
{ {
char_u *save_cpo; char *save_cpo;
char_u *pat, *pat2 = NULL, *pat3 = NULL; char_u *pat, *pat2 = NULL, *pat3 = NULL;
long retval = 0; long retval = 0;
pos_T pos; 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. // Make 'cpoptions' empty, the 'l' flag should not be used here.
save_cpo = p_cpo; save_cpo = p_cpo;
p_cpo = empty_option; p_cpo = (char *)empty_option;
// Set the time limit, if there is one. // Set the time limit, if there is one.
tm = profile_setlimit(time_limit); 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(pat2);
xfree(pat3); xfree(pat3);
if (p_cpo == empty_option) { if ((char_u *)p_cpo == empty_option) {
p_cpo = save_cpo; p_cpo = save_cpo;
} else { } else {
// Darn, evaluating the {skip} expression changed the value. // Darn, evaluating the {skip} expression changed the value.
free_string_option(save_cpo); free_string_option((char_u *)save_cpo);
} }
return retval; return retval;
@ -9741,7 +9738,7 @@ f_spellsuggest_return:
static void f_split(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void f_split(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{ {
char_u *save_cpo; char *save_cpo;
int match; int match;
colnr_T col = 0; colnr_T col = 0;
bool keepempty = false; 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. // Make 'cpoptions' empty, the 'l' flag should not be used here.
save_cpo = p_cpo; save_cpo = p_cpo;
p_cpo = (char_u *)""; p_cpo = "";
const char *str = tv_get_string(&argvars[0]); const char *str = tv_get_string(&argvars[0]);
const char *pat = NULL; const char *pat = NULL;
@ -9774,7 +9771,7 @@ static void f_split(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} }
regmatch_T regmatch = { regmatch_T regmatch = {
.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING), .regprog = vim_regcomp((char *)pat, RE_MAGIC + RE_STRING),
.startp = { NULL }, .startp = { NULL },
.endp = { NULL }, .endp = { NULL },
.rm_ic = false, .rm_ic = false,

View File

@ -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. // Trigger FuncUndefined event, may load the function.
if (fp == NULL if (fp == NULL
&& apply_autocmds(EVENT_FUNCUNDEFINED, rfname, rfname, true, NULL) && apply_autocmds(EVENT_FUNCUNDEFINED, (char *)rfname, (char *)rfname, true, NULL)
&& !aborting()) { && !aborting()) {
// executed an autocommand, search for the function again // executed an autocommand, search for the function again
fp = find_func(rfname); fp = find_func(rfname);
@ -1967,7 +1967,7 @@ void ex_function(exarg_T *eap)
c = *p; c = *p;
*p = NUL; *p = NUL;
regmatch.regprog = vim_regcomp((char_u *)eap->arg + 1, RE_MAGIC); regmatch.regprog = vim_regcomp(eap->arg + 1, RE_MAGIC);
*p = c; *p = c;
if (regmatch.regprog != NULL) { if (regmatch.regprog != NULL) {
regmatch.rm_ic = p_ic; regmatch.rm_ic = p_ic;
@ -2009,7 +2009,7 @@ void ex_function(exarg_T *eap)
// g:func global function name, same as "func" // g:func global function name, same as "func"
p = (char_u *)eap->arg; p = (char_u *)eap->arg;
name = trans_function_name(&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL); 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) { if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) {
/* /*
* Return on an invalid expression in braces, unless the expression * Return on an invalid expression in braces, unless the expression
@ -2090,8 +2090,8 @@ void ex_function(exarg_T *eap)
goto ret_free; goto ret_free;
} }
// attempt to continue by skipping some text // attempt to continue by skipping some text
if (vim_strchr(p, '(') != NULL) { if (vim_strchr((char *)p, '(') != NULL) {
p = vim_strchr(p, '('); p = (char_u *)vim_strchr((char *)p, '(');
} }
} }
p = (char_u *)skipwhite((char *)p + 1); p = (char_u *)skipwhite((char *)p + 1);
@ -2207,7 +2207,7 @@ void ex_function(exarg_T *eap)
if (line_arg != NULL) { if (line_arg != NULL) {
// Use eap->arg, split up in parts by line breaks. // Use eap->arg, split up in parts by line breaks.
theline = line_arg; theline = line_arg;
p = vim_strchr(theline, '\n'); p = (char_u *)vim_strchr((char *)theline, '\n');
if (p == NULL) { if (p == NULL) {
line_arg += STRLEN(line_arg); line_arg += STRLEN(line_arg);
} else { } else {
@ -2369,7 +2369,7 @@ void ex_function(exarg_T *eap)
// and ":let [a, b] =<< [trim] EOF" // and ":let [a, b] =<< [trim] EOF"
arg = (char_u *)skipwhite((char *)skiptowhite(p)); arg = (char_u *)skipwhite((char *)skiptowhite(p));
if (*arg == '[') { if (*arg == '[') {
arg = vim_strchr(arg, ']'); arg = (char_u *)vim_strchr((char *)arg, ']');
} }
if (arg != NULL) { if (arg != NULL) {
arg = (char_u *)skipwhite((char *)skiptowhite(arg)); arg = (char_u *)skipwhite((char *)skiptowhite(arg));
@ -2490,7 +2490,7 @@ void ex_function(exarg_T *eap)
} }
if (fp == NULL) { 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; int slen, plen;
char_u *scriptname; char_u *scriptname;
@ -2498,7 +2498,7 @@ void ex_function(exarg_T *eap)
int j = FAIL; int j = FAIL;
if (sourcing_name != NULL) { if (sourcing_name != NULL) {
scriptname = (char_u *)autoload_name((const char *)name, STRLEN(name)); 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); plen = (int)STRLEN(p);
slen = (int)STRLEN(sourcing_name); slen = (int)STRLEN(sourcing_name);
if (slen > plen && FNAMECMP(p, if (slen > plen && FNAMECMP(p,

View File

@ -350,7 +350,7 @@ static int linelen(int *has_tab)
len = linetabsize((char_u *)line); len = linetabsize((char_u *)line);
// Check for embedded TAB. // Check for embedded TAB.
if (has_tab != NULL) { if (has_tab != NULL) {
*has_tab = vim_strchr((char_u *)first, TAB) != NULL; *has_tab = vim_strchr(first, TAB) != NULL;
} }
*last = save; *last = save;
@ -529,9 +529,9 @@ void ex_sort(exarg_T *eap)
emsg(_(e_noprevre)); emsg(_(e_noprevre));
goto sortend; goto sortend;
} }
regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC); regmatch.regprog = vim_regcomp((char *)last_search_pat(), RE_MAGIC);
} else { } else {
regmatch.regprog = vim_regcomp((char_u *)p + 1, RE_MAGIC); regmatch.regprog = vim_regcomp(p + 1, RE_MAGIC);
} }
if (regmatch.regprog == NULL) { if (regmatch.regprog == NULL) {
goto sortend; goto sortend;
@ -1718,7 +1718,7 @@ int rename_buffer(char *new_fname)
*/ */
fname = (char *)curbuf->b_ffname; fname = (char *)curbuf->b_ffname;
sfname = (char *)curbuf->b_sfname; sfname = (char *)curbuf->b_sfname;
xfname = (char *)curbuf->b_fname; xfname = curbuf->b_fname;
curbuf->b_ffname = NULL; curbuf->b_ffname = NULL;
curbuf->b_sfname = NULL; curbuf->b_sfname = NULL;
if (setfname(curbuf, (char_u *)new_fname, NULL, true) == FAIL) { if (setfname(curbuf, (char_u *)new_fname, NULL, true) == FAIL) {
@ -1858,7 +1858,7 @@ int do_write(exarg_T *eap)
if (!other) { if (!other) {
ffname = (char *)curbuf->b_ffname; ffname = (char *)curbuf->b_ffname;
fname = (char *)curbuf->b_fname; fname = curbuf->b_fname;
// Not writing the whole file is only allowed with '!'. // Not writing the whole file is only allowed with '!'.
if ((eap->line1 != 1 if ((eap->line1 != 1
|| eap->line2 != curbuf->b_ml.ml_line_count) || 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 // under the new name. Must be done before buf_write(), because
// if there is no file name and 'cpo' contains 'F', it will set // if there is no file name and 'cpo' contains 'F', it will set
// the file name. // the file name.
fname = (char *)alt_buf->b_fname; fname = alt_buf->b_fname;
alt_buf->b_fname = curbuf->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; fname = (char *)alt_buf->b_ffname;
alt_buf->b_ffname = curbuf->b_ffname; alt_buf->b_ffname = curbuf->b_ffname;
curbuf->b_ffname = (char_u *)fname; 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); semsg(_("E141: No file name for buffer %" PRId64), (int64_t)buf->b_fnum);
error++; error++;
} else if (check_readonly(&eap->forceit, buf) } else if (check_readonly(&eap->forceit, buf)
|| check_overwrite(eap, buf, (char *)buf->b_fname, (char *)buf->b_ffname, || check_overwrite(eap, buf, buf->b_fname, (char *)buf->b_ffname, false) == FAIL) {
false) == FAIL) {
error++; error++;
} else { } else {
bufref_T bufref; bufref_T bufref;
@ -2148,12 +2147,12 @@ static int check_readonly(int *forceit, buf_T *buf)
if (buf->b_p_ro) { if (buf->b_p_ro) {
dialog_msg((char *)buff, dialog_msg((char *)buff,
_("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"), _("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"),
(char *)buf->b_fname); buf->b_fname);
} else { } else {
dialog_msg((char *)buff, dialog_msg((char *)buff,
_("File permissions of \"%s\" are read-only.\nIt may still be possible to " _("File permissions of \"%s\" are read-only.\nIt may still be possible to "
"write it.\nDo you wish to try?"), "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) { 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 { } else {
if (*ffname == NUL) { // re-edit with same file name if (*ffname == NUL) { // re-edit with same file name
ffname = (char *)curbuf->b_ffname; 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 free_fname = fix_fname(ffname); // may expand to full path name
if (free_fname != NULL) { 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 // - If we ended up in the new buffer already, need to skip a few
// things, set auto_buf. // things, set auto_buf.
if (buf->b_fname != NULL) { 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; const bufref_T save_au_new_curbuf = au_new_curbuf;
set_bufref(&au_new_curbuf, buf); 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; buf = curbuf;
if (buf->b_fname != NULL) { if (buf->b_fname != NULL) {
new_name = (char *)vim_strsave(buf->b_fname); new_name = (char *)vim_strsave((char_u *)buf->b_fname);
} else { } else {
new_name = NULL; new_name = NULL;
} }
@ -2961,7 +2960,7 @@ void ex_append(exarg_T *eap)
if (eap->nextcmd == NULL || *eap->nextcmd == NUL) { if (eap->nextcmd == NULL || *eap->nextcmd == NUL) {
break; break;
} }
p = (char *)vim_strchr((char_u *)eap->nextcmd, NL); p = vim_strchr(eap->nextcmd, NL);
if (p == NULL) { if (p == NULL) {
p = eap->nextcmd + STRLEN(eap->nextcmd); 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 // Set State to avoid the cursor shape to be set to MODE_INSERT
// state when getline() returns. // state when getline() returns.
State = MODE_CMDLINE; State = MODE_CMDLINE;
theline = (char *)eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : theline = eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : NUL, eap->cookie, indent, true);
NUL, eap->cookie, indent, true);
State = save_State; State = save_State;
} }
lines_left = Rows - 1; 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 // new pattern and substitution
if (eap->cmd[0] == 's' && *cmd != NUL && !ascii_iswhite(*cmd) 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 // don't accept alphanumeric for separator
if (check_regexp_delim(*cmd) == FAIL) { if (check_regexp_delim(*cmd) == FAIL) {
return NULL; 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/" and "\?sub?" use last used search pattern (almost like
// //sub/r). "\&sub&" use last substitute pattern (like //sub/). // //sub/r). "\&sub&" use last substitute pattern (like //sub/).
if (*cmd == '\\') { if (*cmd == '\\') {
++cmd; cmd++;
if (vim_strchr((char_u *)"/?&", *cmd) == NULL) { if (vim_strchr("/?&", *cmd) == NULL) {
emsg(_(e_backslash)); emsg(_(e_backslash));
return NULL; 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 // When 'cpoptions' contains "u" don't sync undo when
// asking for confirmation. // asking for confirmation.
if (vim_strchr(p_cpo, CPO_UNDO) != NULL) { 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; State = save_State;
setmouse(); setmouse();
if (vim_strchr(p_cpo, CPO_UNDO) != NULL) { if (vim_strchr(p_cpo, CPO_UNDO) != NULL) {
--no_u_sync; no_u_sync--;
} }
if (typed == 'n') { if (typed == 'n') {
@ -4579,8 +4577,8 @@ void ex_global(exarg_T *eap)
* "\&": use previous substitute pattern. * "\&": use previous substitute pattern.
*/ */
if (*cmd == '\\') { if (*cmd == '\\') {
++cmd; cmd++;
if (vim_strchr((char_u *)"/?&", *cmd) == NULL) { if (vim_strchr("/?&", *cmd) == NULL) {
emsg(_(e_backslash)); emsg(_(e_backslash));
return; return;
} }
@ -5114,7 +5112,7 @@ int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep
// And also "\_$" and "\_^". // And also "\_$" and "\_^".
if (arg[0] == '\\' if (arg[0] == '\\'
&& ((arg[1] != NUL && arg[2] == NUL) && ((arg[1] != NUL && arg[2] == NUL)
|| (vim_strchr((char_u *)"%_z@", arg[1]) != NULL || (vim_strchr("%_z@", arg[1]) != NULL
&& arg[2] != NUL))) { && arg[2] != NUL))) {
vim_snprintf(d, IOSIZE, "/\\\\%s", arg + 1); vim_snprintf(d, IOSIZE, "/\\\\%s", arg + 1);
// Check for "/\\_$", should be "/\\_\$" // 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. * ":help i_^_CTRL-D" work.
* Insert '-' before and after "CTRL-X" when applicable. * Insert '-' before and after "CTRL-X" when applicable.
*/ */
if (*s < ' ' || (*s == '^' && s[1] && (ASCII_ISALPHA(s[1]) if (*s < ' '
|| vim_strchr((char_u *) || (*s == '^' && s[1]
"?@[\\]^", && (ASCII_ISALPHA(s[1]) || vim_strchr("?@[\\]^", s[1]) != NULL))) {
s[1]) != NULL))) {
if ((char_u *)d > IObuff && d[-1] != '_' && d[-1] != '\\') { if ((char_u *)d > IObuff && d[-1] != '_' && d[-1] != '\\') {
*d++ = '_'; // prepend a '_' to make x_CTRL-x *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 * In the "help.txt" and "help.abx" file, add the locally added help
* files. This uses the very first line in the help file. * 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 if (FNAMECMP(fname, "help.txt") == 0
|| (FNAMENCMP(fname, "help.", 5) == 0 || (FNAMENCMP(fname, "help.", 5) == 0
&& ASCII_ISALPHA(fname[5]) && ASCII_ISALPHA(fname[5])
@ -5448,7 +5445,7 @@ void fix_help_buffer(void)
} }
vim_fgets(IObuff, IOSIZE, fd); vim_fgets(IObuff, IOSIZE, fd);
if (IObuff[0] == '*' if (IObuff[0] == '*'
&& (s = (char *)vim_strchr(IObuff + 1, '*')) && (s = vim_strchr((char *)IObuff + 1, '*'))
!= NULL) { != NULL) {
TriState this_utf = kNone; TriState this_utf = kNone;
// Change tag definition to a // Change tag definition to a
@ -5635,7 +5632,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool
} }
firstline = false; firstline = false;
} }
p1 = (char *)vim_strchr(IObuff, '*'); // find first '*' p1 = vim_strchr((char *)IObuff, '*'); // find first '*'
while (p1 != NULL) { while (p1 != NULL) {
p2 = strchr((const char *)p1 + 1, '*'); // Find second '*'. p2 = strchr((const char *)p1 + 1, '*'); // Find second '*'.
if (p2 != NULL && p2 > p1 + 1) { // Skip "*" and "**". 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. // followed by a white character or end-of-line.
if (s == p2 if (s == p2
&& ((char_u *)p1 == IObuff || p1[-1] == ' ' || p1[-1] == '\t') && ((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')) { || s[1] == '\0')) {
*p2 = '\0'; *p2 = '\0';
p1++; 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); snprintf(s, s_len, "%s\t%s", p1, fname);
// find next '*' // find next '*'
p2 = (char *)vim_strchr((char_u *)p2 + 1, '*'); p2 = vim_strchr(p2 + 1, '*');
} }
} }
p1 = p2; p1 = p2;
@ -6203,7 +6200,7 @@ void ex_oldfiles(exarg_T *eap)
if (p == NULL) { if (p == NULL) {
return; return;
} }
char *const s = (char *)expand_env_save((char_u *)p); char *const s = expand_env_save((char *)p);
eap->arg = s; eap->arg = s;
eap->cmdidx = CMD_edit; eap->cmdidx = CMD_edit;
cmdmod.browse = false; cmdmod.browse = false;

View File

@ -554,7 +554,7 @@ void dialog_changed(buf_T *buf, bool checkall)
.forceit = false, .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) { if (checkall) {
ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, (char_u *)buff, 1); ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, (char_u *)buff, 1);
} else { } else {
@ -563,11 +563,7 @@ void dialog_changed(buf_T *buf, bool checkall)
if (ret == VIM_YES) { if (ret == VIM_YES) {
if (buf->b_fname != NULL if (buf->b_fname != NULL
&& check_overwrite(&ea, && check_overwrite(&ea, buf, buf->b_fname, (char *)buf->b_ffname, false) == OK) {
buf,
(char *)buf->b_fname,
(char *)buf->b_ffname,
false) == OK) {
// didn't hit Cancel // didn't hit Cancel
(void)buf_write_all(buf, false); (void)buf_write_all(buf, false);
} }
@ -583,7 +579,7 @@ void dialog_changed(buf_T *buf, bool checkall)
set_bufref(&bufref, buf2); set_bufref(&bufref, buf2);
if (buf2->b_fname != NULL 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) { (char *)buf2->b_ffname, false) == OK) {
// didn't hit Cancel // didn't hit Cancel
(void)buf_write_all(buf2, false); (void)buf_write_all(buf2, false);
@ -611,7 +607,7 @@ bool dialog_close_terminal(buf_T *buf)
char buff[DIALOG_MSG_SIZE]; char buff[DIALOG_MSG_SIZE];
dialog_msg(buff, _("Close \"%s\"?"), 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); 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)) if ((buf->terminal && channel_job_running((uint64_t)buf->b_p_channel))
? semsg(_("E947: Job still running in buffer \"%s\""), buf->b_fname) ? semsg(_("E947: Job still running in buffer \"%s\""), buf->b_fname)
: semsg(_("E162: No write since last change for buffer \"%s\""), : 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; save = no_wait_return;
no_wait_return = false; no_wait_return = false;
wait_return(false); wait_return(false);
@ -792,7 +788,7 @@ int buf_write_all(buf_T *buf, int forceit)
int retval; int retval;
buf_T *old_curbuf = curbuf; 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, (linenr_T)1, buf->b_ml.ml_line_count, NULL,
false, forceit, true, false)); false, forceit, true, false));
if (curbuf != old_curbuf) { 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) { if (curbuf->b_ffname == NULL) {
return FAIL; return FAIL;
} }
str = (char *)curbuf->b_fname; str = curbuf->b_fname;
arg_escaped = false; 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 regmatch.rm_ic = p_fic; // ignore case when 'fileignorecase' is set
for (int i = 0; i < new_ga.ga_len && !got_int; i++) { for (int i = 0; i < new_ga.ga_len && !got_int; i++) {
p = ((char **)new_ga.ga_data)[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) { if (p == NULL) {
break; 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) { if (regmatch.regprog == NULL) {
xfree(p); xfree(p);
break; break;
@ -1518,12 +1514,11 @@ void ex_listdo(exarg_T *eap)
// buffer was opened while Syntax autocommands were disabled, // buffer was opened while Syntax autocommands were disabled,
// need to trigger them now. // need to trigger them now.
if (buf == curbuf) { if (buf == curbuf) {
apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, apply_autocmds(EVENT_SYNTAX, (char *)curbuf->b_p_syn, curbuf->b_fname, true,
curbuf->b_fname, true, curbuf); curbuf);
} else { } else {
aucmd_prepbuf(&aco, buf); aucmd_prepbuf(&aco, buf);
apply_autocmds(EVENT_SYNTAX, buf->b_p_syn, apply_autocmds(EVENT_SYNTAX, (char *)buf->b_p_syn, buf->b_fname, true, buf);
buf->b_fname, true, buf);
aucmd_restbuf(&aco); aucmd_restbuf(&aco);
} }
@ -1920,7 +1915,7 @@ int do_source(char *fname, int check_other, int is_vimrc)
proftime_T wait_start; proftime_T wait_start;
bool trigger_source_post = false; bool trigger_source_post = false;
p = (char *)expand_env_save((char_u *)fname); p = expand_env_save(fname);
if (p == NULL) { if (p == NULL) {
return retval; 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. // Apply SourceCmd autocommands, they should get the file and source it.
if (has_autocmd(EVENT_SOURCECMD, fname_exp, NULL) 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)) { false, curbuf)) {
retval = aborting() ? FAIL : OK; retval = aborting() ? FAIL : OK;
if (retval == OK) { if (retval == OK) {
// Apply SourcePost autocommands. // 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; goto theend;
} }
// Apply SourcePre autocommands, they may get the file. // 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); cookie.fp = fopen_noinh_readbin(fname_exp);
if (cookie.fp == NULL && check_other) { 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); convert_setup(&cookie.conv, NULL, NULL);
if (trigger_source_post) { 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: theend:

View File

@ -1927,7 +1927,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
++p; ++p;
} }
p = xstrnsave(ea.cmd, (size_t)(p - ea.cmd)); 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); xfree(p);
// If the autocommands did something and didn't cause an error, try // If the autocommands did something and didn't cause an error, try
// finding the command again. // finding the command again.
@ -2554,7 +2554,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
break; break;
} }
if (!skip_only) { 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) { if (cmdmod.filter_regmatch.regprog == NULL) {
break; break;
} }
@ -2971,7 +2971,7 @@ char *find_ex_command(exarg_T *eap, int *full)
} }
// check for non-alpha command // check for non-alpha command
if (p == eap->cmd && vim_strchr((char_u *)"@!=><&~#", *p) != NULL) { if (p == eap->cmd && vim_strchr("@!=><&~#", *p) != NULL) {
p++; p++;
} }
len = (int)(p - eap->cmd); 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 // 2. skip comment lines and leading space, colons or bars
const char *cmd; 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; xp->xp_pattern = (char *)cmd;
if (*cmd == NUL) { if (*cmd == NUL) {
@ -3358,7 +3358,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
} }
} }
// check for non-alpha command // check for non-alpha command
if (p == cmd && vim_strchr((const char_u *)"@*!=><&~#", *p) != NULL) { if (p == cmd && vim_strchr("@*!=><&~#", *p) != NULL) {
p++; p++;
} }
len = (size_t)(p - cmd); 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 (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; ea.cmdidx = CMD_substitute;
p = cmd + 1; p = cmd + 1;
} else if (cmd[0] >= 'A' && cmd[0] <= 'Z') { } 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; break;
case CMD_argdelete: 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); arg = (const char *)(xp->xp_pattern + 1);
} }
xp->xp_context = EXPAND_ARGLIST; xp->xp_context = EXPAND_ARGLIST;
@ -4166,7 +4166,7 @@ char *skip_range(const char *cmd, int *ctx)
{ {
unsigned delim; unsigned delim;
while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;\\", *cmd) != NULL) { while (vim_strchr(" \t0123456789.$%'/?-+,;\\", *cmd) != NULL) {
if (*cmd == '\\') { if (*cmd == '\\') {
if (cmd[1] == '?' || cmd[1] == '/' || cmd[1] == '&') { if (cmd[1] == '?' || cmd[1] == '/' || cmd[1] == '&') {
cmd++; cmd++;
@ -4536,7 +4536,7 @@ error:
/// Get flags from an Ex command argument. /// Get flags from an Ex command argument.
static void get_flags(exarg_T *eap) 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') { if (*eap->arg == 'l') {
eap->flags |= EXFLAG_LIST; eap->flags |= EXFLAG_LIST;
} else if (*eap->arg == 'p') { } 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. * Quick check if this cannot be the start of a special string.
* Also removes backslash before '%', '#' and '<'. * Also removes backslash before '%', '#' and '<'.
*/ */
if (vim_strchr((char_u *)"%#<", *p) == NULL) { if (vim_strchr("%#<", *p) == NULL) {
++p; p++;
continue; 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 // Wildcards won't be expanded below, the replacement is taken
// literally. But do expand "~/file", "~user/file" and "$HOME/file". // 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; char *l = repl;
repl = (char *)expand_env_save((char_u *)repl); repl = expand_env_save(repl);
xfree(l); xfree(l);
} }
@ -4845,8 +4845,8 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
# define ESCAPE_CHARS escape_chars # define ESCAPE_CHARS escape_chars
#endif #endif
for (l = repl; *l; ++l) { for (l = repl; *l; l++) {
if (vim_strchr(ESCAPE_CHARS, *l) != NULL) { if (vim_strchr((char *)ESCAPE_CHARS, *l) != NULL) {
l = (char *)vim_strsave_escaped((char_u *)repl, ESCAPE_CHARS); l = (char *)vim_strsave_escaped((char_u *)repl, ESCAPE_CHARS);
xfree(repl); xfree(repl);
repl = l; repl = l;
@ -4885,8 +4885,8 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
* After expanding environment variables, check again * After expanding environment variables, check again
* if there are still wildcards present. * if there are still wildcards present.
*/ */
if (vim_strchr((char_u *)eap->arg, '$') != NULL if (vim_strchr(eap->arg, '$') != NULL
|| vim_strchr((char_u *)eap->arg, '~') != NULL) { || vim_strchr(eap->arg, '~') != NULL) {
expand_env_esc((char_u *)eap->arg, NameBuff, MAXPATHL, true, true, NULL); expand_env_esc((char_u *)eap->arg, NameBuff, MAXPATHL, true, true, NULL);
has_wildcards = path_has_wildcard(NameBuff); has_wildcards = path_has_wildcard(NameBuff);
p = (char *)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, ct_NONE,
} type = 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; quote = (*p == 'q' || *p == 'Q') ? 1 : 2;
p += 2; p += 2;
l -= 2; l -= 2;
@ -6643,9 +6643,9 @@ static void do_ucmd(exarg_T *eap)
totlen = 0; totlen = 0;
for (;;) { for (;;) {
start = (char *)vim_strchr((char_u *)p, '<'); start = vim_strchr(p, '<');
if (start != NULL) { if (start != NULL) {
end = (char *)vim_strchr((char_u *)start + 1, '>'); end = vim_strchr(start + 1, '>');
} }
if (buf != NULL) { if (buf != NULL) {
for (ksp = p; *ksp != NUL && (char_u)(*ksp) != K_SPECIAL; ksp++) {} 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) { if (buf_spname(wp->w_buffer) != NULL) {
STRLCPY(IObuff, buf_spname(wp->w_buffer), IOSIZE); STRLCPY(IObuff, buf_spname(wp->w_buffer), IOSIZE);
} else { } 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); msg_outtrans(IObuff);
ui_flush(); // output one line at a time 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 if (check_fname() == FAIL) { // check for no file name
return; 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); eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false);
} else { } else {
if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) { 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); char *pdir = get_prevdir(scope);
// If still in global directory, set CWD as the global directory. // If still in global directory, set CWD as the global directory.
if (globaldir == NULL && pdir != NULL) { 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. // Put the register in the typeahead buffer with the "silent" flag.
if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE) if (do_execreg(c, true, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, true) == FAIL) {
== FAIL) {
beep_flush(); beep_flush();
} else { } else {
bool save_efr = exec_from_reg; bool save_efr = exec_from_reg;
@ -8737,7 +8736,7 @@ static void ex_redir(exarg_T *eap)
close_redir(); close_redir();
// Expand environment variables and "~/". // Expand environment variables and "~/".
fname = (char *)expand_env_save((char_u *)arg); fname = expand_env_save(arg);
if (fname == NULL) { if (fname == NULL) {
return; return;
} }
@ -9478,7 +9477,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
result = ""; result = "";
valid = 0; // Must have ":p:h" to be valid valid = 0; // Must have ":p:h" to be valid
} else { } else {
result = (char *)curbuf->b_fname; result = curbuf->b_fname;
tilde_file = STRCMP(result, "~") == 0; tilde_file = STRCMP(result, "~") == 0;
} }
break; break;
@ -9532,7 +9531,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
result = ""; result = "";
valid = 0; // Must have ":p:h" to be valid valid = 0; // Must have ":p:h" to be valid
} else { } else {
result = (char *)buf->b_fname; result = buf->b_fname;
tilde_file = STRCMP(result, "~") == 0; tilde_file = STRCMP(result, "~") == 0;
} }
} }

View File

@ -1361,18 +1361,18 @@ void ex_catch(exarg_T *eap)
save_char = *end; save_char = *end;
*end = NUL; *end = NUL;
} }
save_cpo = (char *)p_cpo; save_cpo = p_cpo;
p_cpo = (char_u *)""; p_cpo = "";
// Disable error messages, it will make current exception // Disable error messages, it will make current exception
// invalid // invalid
emsg_off++; emsg_off++;
regmatch.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING); regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
emsg_off--; emsg_off--;
regmatch.rm_ic = false; regmatch.rm_ic = false;
if (end != NULL) { if (end != NULL) {
*end = save_char; *end = save_char;
} }
p_cpo = (char_u *)save_cpo; p_cpo = save_cpo;
if (regmatch.regprog == NULL) { if (regmatch.regprog == NULL) {
semsg(_(e_invarg2), pat); semsg(_(e_invarg2), pat);
} else { } else {

View File

@ -398,7 +398,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
cmdmod = save_cmdmod; cmdmod = save_cmdmod;
cmd = skip_range(ea.cmd, NULL); cmd = skip_range(ea.cmd, NULL);
if (vim_strchr((char_u *)"sgvl", *cmd) == NULL) { if (vim_strchr("sgvl", *cmd) == NULL) {
goto theend; 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); *c = mb_tolower(*c);
} }
if (*c == search_delim if (*c == search_delim
|| vim_strchr((char_u *)(p_magic ? "\\~^$.*[" : "\\^$"), *c) || vim_strchr((p_magic ? "\\~^$.*[" : "\\^$"), *c) != NULL) {
!= NULL) {
// put a backslash before special characters // put a backslash before special characters
stuffcharReadbuff(*c); stuffcharReadbuff(*c);
*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); tv_dict_set_keys_readonly(dict);
try_enter(&tstate); try_enter(&tstate);
apply_autocmds(EVENT_CMDLINEENTER, (char_u *)firstcbuf, (char_u *)firstcbuf, apply_autocmds(EVENT_CMDLINEENTER, firstcbuf, firstcbuf, false, curbuf);
false, curbuf);
restore_v_event(dict, &save_v_event); 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"), tv_dict_add_bool(dict, S_LEN("abort"),
s->gotesc ? kBoolVarTrue : kBoolVarFalse); s->gotesc ? kBoolVarTrue : kBoolVarFalse);
try_enter(&tstate); try_enter(&tstate);
apply_autocmds(EVENT_CMDLINELEAVE, (char_u *)firstcbuf, (char_u *)firstcbuf, apply_autocmds(EVENT_CMDLINELEAVE, firstcbuf, firstcbuf, false, curbuf);
false, curbuf);
// error printed below, to avoid redraw issues // error printed below, to avoid redraw issues
tl_ret = try_leave(&tstate, &err); tl_ret = try_leave(&tstate, &err);
if (tv_dict_get_number(dict, "abort") != 0) { 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 // remove trailing \v and the like
while (n >= 2 && p[n - 2] == '\\' while (n >= 2 && p[n - 2] == '\\'
&& vim_strchr((char_u *)"mMvVcCZ", p[n - 1]) != NULL) { && vim_strchr("mMvVcCZ", p[n - 1]) != NULL) {
n -= 2; n -= 2;
} }
return n == 0 || (n >= 2 && p[n - 2] == '\\' && p[n - 1] == '|'); 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); tv_dict_set_keys_readonly(dict);
try_enter(&tstate); try_enter(&tstate);
apply_autocmds(EVENT_CMDLINECHANGED, (char_u *)firstcbuf, apply_autocmds(EVENT_CMDLINECHANGED, firstcbuf, firstcbuf, false, curbuf);
(char_u *)firstcbuf, false, curbuf);
restore_v_event(dict, &save_v_event); restore_v_event(dict, &save_v_event);
bool tl_ret = try_leave(&tstate, &err); 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 // Skip escaped wildcards. Only when the backslash is not a path
// separator, on DOS the '*' "path\*\file" must not be skipped. // separator, on DOS the '*' "path\*\file" must not be skipped.
if (rem_backslash(s)) { if (rem_backslash(s)) {
++s; s++;
} else if (vim_strchr((char_u *)"*?[", *s) != NULL) { } else if (vim_strchr("*?[", *s) != NULL) {
return FALSE; return false;
} }
} }
return TRUE; return TRUE;
@ -4630,8 +4626,8 @@ char_u *addstar(char_u *fname, size_t len, int context)
#endif #endif
if ((*retval != '~' || tail != retval) if ((*retval != '~' || tail != retval)
&& !ends_in_star && !ends_in_star
&& vim_strchr(tail, '$') == NULL && vim_strchr((char *)tail, '$') == NULL
&& vim_strchr(retval, '`') == NULL) { && vim_strchr((char *)retval, '`') == NULL) {
retval[len++] = '*'; retval[len++] = '*';
} else if (len > 0 && retval[len - 1] == '$') { } else if (len > 0 && retval[len - 1] == '$') {
--len; --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); 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) { if (regmatch.regprog == NULL) {
return FAIL; return FAIL;
} }
@ -5220,7 +5216,7 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file, int
hashtab_T found_ht; hashtab_T found_ht;
hash_init(&found_ht); hash_init(&found_ht);
for (s = path;; s = e) { for (s = path;; s = e) {
e = vim_strchr(s, ENV_SEPCHAR); e = (char_u *)vim_strchr((char *)s, ENV_SEPCHAR);
if (e == NULL) { if (e == NULL) {
e = s + STRLEN(s); 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); ga_init(&ga, (int)sizeof(char *), 3);
for (char_u *s = retstr; *s != NUL; s = e) { 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) { if (e == NULL) {
e = s + STRLEN(s); 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]); return hist_char2type(name[0]);
} }
@ -6153,7 +6149,7 @@ int del_history_entry(int histype, char_u *str)
&& histype < HIST_COUNT && histype < HIST_COUNT
&& *str != NUL && *str != NUL
&& (idx = hisidx[histype]) >= 0 && (idx = hisidx[histype]) >= 0
&& (regmatch.regprog = vim_regcomp(str, RE_MAGIC + RE_STRING)) && (regmatch.regprog = vim_regcomp((char *)str, RE_MAGIC + RE_STRING))
!= NULL) { != NULL) {
i = last = idx; i = last = idx;
do { do {
@ -6280,7 +6276,7 @@ void ex_history(exarg_T *eap)
if (!(ascii_isdigit(*arg) || *arg == '-' || *arg == ',')) { if (!(ascii_isdigit(*arg) || *arg == '-' || *arg == ',')) {
end = arg; end = arg;
while (ASCII_ISALPHA(*end) while (ASCII_ISALPHA(*end)
|| vim_strchr((char_u *)":=@>/?", *end) != NULL) { || vim_strchr(":=@>/?", *end) != NULL) {
end++; end++;
} }
histype1 = get_histtype((const char *)arg, (size_t)(end - arg), false); histype1 = get_histtype((const char *)arg, (size_t)(end - arg), false);
@ -6386,7 +6382,7 @@ static int open_cmdwin(void)
int i; int i;
linenr_T lnum; linenr_T lnum;
garray_T winsizes; garray_T winsizes;
char_u typestr[2]; char typestr[2];
int save_restart_edit = restart_edit; int save_restart_edit = restart_edit;
int save_State = State; int save_State = State;
bool save_exmode = exmode_active; bool save_exmode = exmode_active;
@ -6490,7 +6486,7 @@ static int open_cmdwin(void)
cmdwin_result = 0; cmdwin_result = 0;
// Trigger CmdwinEnter autocommands. // Trigger CmdwinEnter autocommands.
typestr[0] = (char_u)cmdwin_type; typestr[0] = (char)cmdwin_type;
typestr[1] = NUL; typestr[1] = NUL;
apply_autocmds(EVENT_CMDWINENTER, typestr, typestr, false, curbuf); apply_autocmds(EVENT_CMDWINENTER, typestr, typestr, false, curbuf);
if (restart_edit != 0) { // autocmd with ":startinsert" 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) : "."); const char *const end_pattern = (cmd[2] != NUL ? (const char *)skipwhite(cmd + 2) : ".");
for (;;) { for (;;) {
char *const theline = (char *)eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : NUL, char *const theline = eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : NUL, eap->cookie, 0,
eap->cookie, 0, true); true);
if (theline == NULL || strcmp(end_pattern, theline) == 0) { if (theline == NULL || strcmp(end_pattern, theline) == 0) {
xfree(theline); xfree(theline);

View File

@ -571,7 +571,7 @@ static int makeopens(FILE *fd, char_u *dirnow)
if (ssop_flags & SSOP_SESDIR) { if (ssop_flags & SSOP_SESDIR) {
PUTLINE_FAIL("exe \"cd \" . escape(expand(\"<sfile>:p:h\"), ' ')"); PUTLINE_FAIL("exe \"cd \" . escape(expand(\"<sfile>:p:h\"), ' ')");
} else if (ssop_flags & SSOP_CURDIR) { } 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); char *fname_esc = ses_escape_fname((char *)sname, &ssop_flags);
if (fprintf(fd, "cd %s\n", fname_esc) < 0) { if (fprintf(fd, "cd %s\n", fname_esc) < 0) {
xfree(fname_esc); xfree(fname_esc);
@ -997,7 +997,7 @@ void ex_mkrc(exarg_T *eap)
} }
} else if (*dirnow != NUL } else if (*dirnow != NUL
&& (ssop_flags & SSOP_CURDIR) && globaldir != NULL) { && (ssop_flags & SSOP_CURDIR) && globaldir != NULL) {
if (os_chdir((char *)globaldir) == 0) { if (os_chdir(globaldir) == 0) {
shorten_fnames(true); shorten_fnames(true);
} }
} }

View File

@ -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, ptr = xrealloc(search_ctx->ffsc_stopdirs_v,
(dircount + 1) * sizeof(char_u *)); (dircount + 1) * sizeof(char_u *));
search_ctx->ffsc_stopdirs_v = ptr; search_ctx->ffsc_stopdirs_v = ptr;
walker = vim_strchr(walker, ';'); walker = (char_u *)vim_strchr((char *)walker, ';');
if (walker) { if (walker) {
assert(walker - helper >= 0); assert(walker - helper >= 0);
search_ctx->ffsc_stopdirs_v[dircount - 1] = 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 * -fix path
* -wildcard_stuff (might be NULL) * -wildcard_stuff (might be NULL)
*/ */
wc_part = vim_strchr(path, '*'); wc_part = (char_u *)vim_strchr((char *)path, '*');
if (wc_part != NULL) { if (wc_part != NULL) {
int64_t llevel; int64_t llevel;
int len; int len;
@ -1643,7 +1643,7 @@ void do_autocmd_dirchanged(char *new_dir, CdScope scope, CdCause cause, bool pre
abort(); 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); restore_v_event(dict, &save_v_event);

View File

@ -277,10 +277,10 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
// point to one of these values. // point to one of these values.
old_curbuf = curbuf; old_curbuf = curbuf;
old_b_ffname = (char *)curbuf->b_ffname; 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) using_b_ffname = ((char_u *)fname == curbuf->b_ffname)
|| ((char_u *)sfname == 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 // After reading a file the cursor line changes but we don't want to
// display the line. // display the line.
@ -469,7 +469,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
|| (using_b_ffname || (using_b_ffname
&& ((char_u *)old_b_ffname != curbuf->b_ffname)) && ((char_u *)old_b_ffname != curbuf->b_ffname))
|| (using_b_fname || (using_b_fname
&& ((char_u *)old_b_fname != curbuf->b_fname))) { && (old_b_fname != curbuf->b_fname))) {
emsg(_(e_auchangedbuf)); emsg(_(e_auchangedbuf));
return FAIL; return FAIL;
} }
@ -540,7 +540,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
if (!read_stdin if (!read_stdin
&& (curbuf != old_curbuf && (curbuf != old_curbuf
|| (using_b_ffname && ((char_u *)old_b_ffname != curbuf->b_ffname)) || (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)); emsg(_(e_auchangedbuf));
if (!read_buffer) { if (!read_buffer) {
close(fd); 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 if (!read_stdin && (curbuf != old_curbuf
|| (using_b_ffname && ((char_u *)old_b_ffname != curbuf->b_ffname)) || (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)) { || (fd = os_open(fname, O_RDONLY, 0)) < 0)) {
no_wait_return--; no_wait_return--;
msg_scroll = msg_save; msg_scroll = msg_save;
@ -1957,8 +1957,7 @@ failed:
if (!au_did_filetype && *curbuf->b_p_ft != NUL) { if (!au_did_filetype && *curbuf->b_p_ft != NUL) {
// EVENT_FILETYPE was not triggered but the buffer already has a // EVENT_FILETYPE was not triggered but the buffer already has a
// filetype. Trigger EVENT_FILETYPE using the existing filetype. // filetype. Trigger EVENT_FILETYPE using the existing filetype.
apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, curbuf->b_fname, apply_autocmds(EVENT_FILETYPE, (char *)curbuf->b_p_ft, curbuf->b_fname, true, curbuf);
true, curbuf);
} }
} else { } else {
apply_autocmds_exarg(EVENT_FILEREADPOST, sfname, sfname, apply_autocmds_exarg(EVENT_FILEREADPOST, sfname, sfname,
@ -2084,7 +2083,7 @@ static char_u *next_fenc(char_u **pp, bool *alloced)
*pp = NULL; *pp = NULL;
return (char_u *)""; return (char_u *)"";
} }
p = vim_strchr(*pp, ','); p = (char_u *)vim_strchr((char *)(*pp), ',');
if (p == NULL) { if (p == NULL) {
r = enc_canonize(*pp); r = enc_canonize(*pp);
*pp += STRLEN(*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 if (reset_changed && buf->b_changed && !append
&& (overwriting || vim_strchr(p_cpo, CPO_PLUS) != NULL)) { && (overwriting || vim_strchr(p_cpo, CPO_PLUS) != NULL)) {
/* Buffer still changed, the autocommands didn't work // Buffer still changed, the autocommands didn't work properly.
* properly. */
return FAIL; return FAIL;
} }
return OK; return OK;
@ -4327,7 +4325,7 @@ void shorten_buf_fname(buf_T *buf, char_u *dirname, int force)
if (buf->b_fname != NULL if (buf->b_fname != NULL
&& !bt_nofile(buf) && !bt_nofile(buf)
&& !path_with_url((char *)buf->b_fname) && !path_with_url(buf->b_fname)
&& (force && (force
|| buf->b_sfname == NULL || buf->b_sfname == NULL
|| path_is_absolute(buf->b_sfname))) { || 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); p = path_shorten_fname(buf->b_ffname, dirname);
if (p != NULL) { if (p != NULL) {
buf->b_sfname = vim_strsave(p); buf->b_sfname = vim_strsave(p);
buf->b_fname = buf->b_sfname; buf->b_fname = (char *)buf->b_sfname;
} }
if (p == NULL) { 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); 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. // 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) } else if ((buf->b_p_ar >= 0 ? buf->b_p_ar : p_ar)
&& !bufIsChanged(buf) && file_info_ok) { && !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_REASON, reason, -1);
set_vim_var_string(VV_FCS_CHOICE, "", -1); set_vim_var_string(VV_FCS_CHOICE, "", -1);
allbuf_lock++; allbuf_lock++;
bool n = apply_autocmds(EVENT_FILECHANGEDSHELL, bool n = apply_autocmds(EVENT_FILECHANGEDSHELL, buf->b_fname, buf->b_fname, false, buf);
buf->b_fname, buf->b_fname, false, buf);
allbuf_lock--; allbuf_lock--;
busy = false; busy = false;
if (n) { if (n) {
@ -5046,7 +5043,7 @@ int buf_check_timestamp(buf_T *buf)
} }
if (mesg != NULL) { if (mesg != NULL) {
path = home_replace_save(buf, buf->b_fname); path = home_replace_save(buf, (char_u *)buf->b_fname);
if (!helpmesg) { if (!helpmesg) {
mesg2 = ""; mesg2 = "";
} }
@ -5117,8 +5114,7 @@ int buf_check_timestamp(buf_T *buf)
// Trigger FileChangedShell when the file was changed in any way. // Trigger FileChangedShell when the file was changed in any way.
if (bufref_valid(&bufref) && retval != 0) { if (bufref_valid(&bufref) && retval != 0) {
(void)apply_autocmds(EVENT_FILECHANGEDSHELLPOST, buf->b_fname, buf->b_fname, (void)apply_autocmds(EVENT_FILECHANGEDSHELLPOST, buf->b_fname, buf->b_fname, false, buf);
false, buf);
} }
return retval; return retval;
} }
@ -5192,7 +5188,7 @@ void buf_reload(buf_T *buf, int orig_mode, bool reload_options)
if (saved == OK) { if (saved == OK) {
curbuf->b_flags |= BF_CHECK_RO; // check for RO again curbuf->b_flags |= BF_CHECK_RO; // check for RO again
keep_filetype = true; // don't detect 'filetype' 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) { (linenr_T)MAXLNUM, &ea, flags, false) != OK) {
if (!aborting()) { if (!aborting()) {
semsg(_("E321: Could not reload \"%s\""), buf->b_fname); 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) { if (prog != NULL) {
regmatch.regprog = *prog; regmatch.regprog = *prog;
} else { } 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; p = list;
while (*p) { while (*p) {
copy_option_part(&p, buf, ARRAY_SIZE(buf), ","); 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) { if (regpat == NULL) {
break; 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 /// @param no_bslash Don't use a backward slash as pathsep
/// ///
/// @return NULL on failure. /// @return NULL on failure.
char_u *file_pat_to_reg_pat(const char_u *pat, const char_u *pat_end, char *allow_dirs, char *file_pat_to_reg_pat(const char *pat, const char *pat_end, char *allow_dirs, int no_bslash)
int no_bslash)
FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_NONNULL_ARG(1)
{ {
const char_u *endp; const char *endp;
char_u *reg_pat; char *reg_pat;
const char_u *p; const char *p;
int nested = 0; int nested = 0;
bool add_dollar = true; 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) { if (pat_end == pat) {
return (char_u *)xstrdup("^$"); return xstrdup("^$");
} }
size_t size = 2; // '^' at start, '$' at end. size_t size = 2; // '^' at start, '$' at end.

View File

@ -2911,7 +2911,7 @@ static void foldlevelIndent(fline_T *flp)
// empty line or lines starting with a character in 'foldignore': level // empty line or lines starting with a character in 'foldignore': level
// depends on surrounding lines // depends on surrounding lines
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 // first and last line can't be undefined, use level 0
if (lnum == 1 || lnum == buf->b_ml.ml_line_count) { if (lnum == 1 || lnum == buf->b_ml.ml_line_count) {
flp->lvl = 0; 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. /// Relies on the option value to have been checked for correctness already.
static void parseMarker(win_T *wp) 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); foldstartmarkerlen = (size_t)(foldendmarker++ - wp->w_p_fmr);
foldendmarkerlen = STRLEN(foldendmarker); foldendmarkerlen = STRLEN(foldendmarker);
} }

View File

@ -802,7 +802,7 @@ int start_redo_ins(void)
// skip the count and the command character // skip the count and the command character
while ((c = read_redo(false, false)) != NUL) { 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') { if (c == 'O' || c == 'o') {
add_buff(&readbuf2, NL_STR, -1L); 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) void add_map(char_u *map, int mode, bool nore)
{ {
char_u *s; 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. // Need to put string in allocated memory, because do_map() will modify it.
s = vim_strsave(map); s = vim_strsave(map);
(void)do_map(nore ? 2 : 0, s, mode, false); (void)do_map(nore ? 2 : 0, s, mode, false);

View File

@ -811,7 +811,7 @@ extern char_u *compiled_sys;
// When a window has a local directory, the absolute path of the global // When a window has a local directory, the absolute path of the global
// current directory is stored here (in allocated memory). If the current // current directory is stored here (in allocated memory). If the current
// directory is not a local directory, globaldir is NULL. // 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); EXTERN char *last_chdir_reason INIT(= NULL);

View File

@ -311,12 +311,12 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_
*/ */
stringp = option_str; stringp = option_str;
while (*stringp) { while (*stringp) {
colonp = vim_strchr(stringp, ':'); colonp = (char_u *)vim_strchr((char *)stringp, ':');
if (colonp == NULL) { if (colonp == NULL) {
ret = N_("E550: Missing colon"); ret = N_("E550: Missing colon");
break; break;
} }
commap = vim_strchr(stringp, ','); commap = (char_u *)vim_strchr((char *)stringp, ',');
if (commap == NULL) { if (commap == NULL) {
commap = option_str + STRLEN(option_str); commap = option_str + STRLEN(option_str);
} }
@ -661,7 +661,7 @@ void ex_hardcopy(exarg_T *eap)
*/ */
if (mch_print_init(&settings, if (mch_print_init(&settings,
curbuf->b_fname == NULL ? buf_spname(curbuf) : curbuf->b_sfname == 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; return;
} }
@ -1588,7 +1588,7 @@ static int prt_find_resource(char *name, struct prt_ps_resource_S *resource)
STRLCAT(buffer, name, MAXPATHL); STRLCAT(buffer, name, MAXPATHL);
STRLCAT(buffer, ".ps", MAXPATHL); STRLCAT(buffer, ".ps", MAXPATHL);
resource->filename[0] = NUL; 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); && resource->filename[0] != NUL);
xfree(buffer); xfree(buffer);
return retval; return retval;
@ -2344,7 +2344,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
* Set up the font size. * Set up the font size.
*/ */
fontsize = PRT_PS_DEFAULT_FONTSIZE; 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])) { if (p[1] == 'h' && ascii_isdigit(p[2])) {
fontsize = atoi((char *)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); prt_ps_fd = os_fopen((char *)prt_ps_file_name, WRITEBIN);
} else { } else {
p = expand_env_save(psettings->outfile); p = (char_u *)expand_env_save((char *)psettings->outfile);
if (p != NULL) { if (p != NULL) {
prt_ps_fd = os_fopen((char *)p, WRITEBIN); prt_ps_fd = os_fopen((char *)p, WRITEBIN);
xfree(p); xfree(p);
@ -2525,7 +2525,7 @@ bool mch_print_begin(prt_settings_T *psettings)
char ctime_buf[50]; char ctime_buf[50];
char *p_time = os_ctime(ctime_buf, sizeof(ctime_buf)); char *p_time = os_ctime(ctime_buf, sizeof(ctime_buf));
// Note: os_ctime() adds a \n so we have to remove it :-( // 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) { if (p != NULL) {
*p = NUL; *p = NUL;
} }

View File

@ -560,7 +560,7 @@ int load_colors(char_u *name)
recursive = true; recursive = true;
size_t buflen = STRLEN(name) + 12; size_t buflen = STRLEN(name) + 12;
buf = xmalloc(buflen); 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); snprintf((char *)buf, buflen, "colors/%s.vim", name);
retval = source_runtime((char *)buf, DIP_START + DIP_OPT); retval = source_runtime((char *)buf, DIP_START + DIP_OPT);
if (retval == FAIL) { if (retval == FAIL) {
@ -568,7 +568,7 @@ int load_colors(char_u *name)
retval = source_runtime((char *)buf, DIP_START + DIP_OPT); retval = source_runtime((char *)buf, DIP_START + DIP_OPT);
} }
xfree(buf); 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; recursive = false;

View File

@ -962,7 +962,7 @@ static bool cs_find_common(char *opt, char *pat, int forceit, int verbose, bool
cmdletter = opt[0]; cmdletter = opt[0];
} }
qfpos = (char *)vim_strchr(p_csqf, cmdletter); qfpos = vim_strchr((char *)p_csqf, cmdletter);
if (qfpos != NULL) { if (qfpos != NULL) {
qfpos++; qfpos++;
// next symbol must be + or - // 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' if (*qfpos != '0'
&& apply_autocmds(EVENT_QUICKFIXCMDPRE, (char_u *)"cscope", && apply_autocmds(EVENT_QUICKFIXCMDPRE, "cscope", curbuf->b_fname, true, curbuf)) {
curbuf->b_fname, true, curbuf)) {
if (aborting()) { if (aborting()) {
return false; return false;
} }
@ -1049,8 +1048,7 @@ static bool cs_find_common(char *opt, char *pat, int forceit, int verbose, bool
postponed_split = 0; postponed_split = 0;
} }
apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)"cscope", apply_autocmds(EVENT_QUICKFIXCMDPOST, "cscope", curbuf->b_fname, true, curbuf);
curbuf->b_fname, TRUE, curbuf);
if (use_ll) { if (use_ll) {
/* /*
* In the location list window, use the displayed location * In the location list window, use the displayed location

View File

@ -407,7 +407,7 @@ int get_number_indent(linenr_T lnum)
if ((State & MODE_INSERT) || has_format_option(FO_Q_COMS)) { if ((State & MODE_INSERT) || has_format_option(FO_Q_COMS)) {
lead_len = get_leader_len(ml_get(lnum), NULL, false, true); 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) { if (regmatch.regprog != NULL) {
regmatch.rm_ic = false; regmatch.rm_ic = false;
@ -467,7 +467,7 @@ int get_breakindent_win(win_T *wp, char_u *line)
// add additional indent for numbered lists // add additional indent for numbered lists
if (wp->w_briopt_list != 0) { if (wp->w_briopt_list != 0) {
regmatch_T regmatch = { 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), RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT),
}; };

View File

@ -167,8 +167,8 @@ static const char_u *skip_string(const char_u *p)
} }
} else if (p[0] == 'R' && p[1] == '"') { } else if (p[0] == 'R' && p[1] == '"') {
// Raw string: R"[delim](...)[delim]" // Raw string: R"[delim](...)[delim]"
const char_u *delim = p + 2; const char *delim = (char *)p + 2;
const char_u *paren = vim_strchr(delim, '('); const char *paren = vim_strchr((char *)delim, '(');
if (paren != NULL) { if (paren != NULL) {
const ptrdiff_t delim_len = paren - delim; 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); 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 if (cin_iscomment(s)) { // ignore comments
s = cin_skipcomment(s); s = cin_skipcomment(s);
} else { } else {
@ -3543,8 +3543,8 @@ term_again:
*/ */
if (cur_curpos.lnum < curbuf->b_ml.ml_line_count if (cur_curpos.lnum < curbuf->b_ml.ml_line_count
&& !cin_nocode(theline) && !cin_nocode(theline)
&& vim_strchr(theline, '{') == NULL && vim_strchr((char *)theline, '{') == NULL
&& vim_strchr(theline, '}') == NULL && vim_strchr((char *)theline, '}') == NULL
&& !cin_ends_in(theline, (char_u *)":", NULL) && !cin_ends_in(theline, (char_u *)":", 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) && cin_isfuncdecl(NULL, cur_curpos.lnum + 1, cur_curpos.lnum + 1)

View File

@ -473,7 +473,7 @@ enum key_extra {
#define MAX_KEY_CODE_LEN 6 #define MAX_KEY_CODE_LEN 6
#define FLAG_CPO_BSLASH 0x01 #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 \ ? 0 \
: FLAG_CPO_BSLASH) : FLAG_CPO_BSLASH)

View File

@ -295,7 +295,7 @@ int nlua_regex(lua_State *lstate)
TRY_WRAP({ TRY_WRAP({
try_start(); 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); try_end(&err);
}); });

View File

@ -643,8 +643,7 @@ void getout(int exitval)
bufref_T bufref; bufref_T bufref;
set_bufref(&bufref, buf); set_bufref(&bufref, buf);
apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, buf->b_fname, false, buf);
buf->b_fname, false, buf);
if (bufref_valid(&bufref)) { if (bufref_valid(&bufref)) {
buf_set_changedtick(buf, -1); // note that we did it already buf_set_changedtick(buf, -1); // note that we did it already
} }

View File

@ -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 } else if (!got_int
&& (arg == NULL || vim_strchr(arg, c) != NULL) && (arg == NULL || vim_strchr((char *)arg, c) != NULL)
&& p->lnum != 0) { && p->lnum != 0) {
// don't output anything if 'q' typed at --more-- prompt // don't output anything if 'q' typed at --more-- prompt
if (name == NULL && current) { if (name == NULL && current) {

View File

@ -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) { if ((hlg_id = syn_check_group(grp, strlen(grp))) == 0) {
return -1; 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); semsg(_(e_invarg2), pat);
return -1; return -1;
} }

View File

@ -2289,7 +2289,7 @@ char_u *enc_locale(void)
// Make the name lowercase and replace '_' with '-'. // Make the name lowercase and replace '_' with '-'.
// Exception: "ja_JP.EUC" == "euc-jp", "zh_CN.EUC" = "euc-cn", // Exception: "ja_JP.EUC" == "euc-jp", "zh_CN.EUC" = "euc-cn",
// "ko_KR.EUC" == "euc-kr" // "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 != NULL) {
if (p > s + 2 && !STRNICMP(p + 1, "EUC", 3) if (p > s + 2 && !STRNICMP(p + 1, "EUC", 3)
&& !isalnum((int)p[4]) && p[4] != '-' && p[-3] == '_') { && !isalnum((int)p[4]) && p[4] != '-' && p[-3] == '_') {

View File

@ -531,8 +531,8 @@ void ml_open_file(buf_T *buf)
need_wait_return = true; // call wait_return later need_wait_return = true; // call wait_return later
no_wait_return++; no_wait_return++;
(void)semsg(_("E303: Unable to open swap file for \"%s\", recovery impossible"), (void)semsg(_("E303: Unable to open swap file for \"%s\", recovery impossible"),
buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname); buf_spname(buf) != NULL ? buf_spname(buf) : (char_u *)buf->b_fname);
--no_wait_return; no_wait_return--;
} }
// don't try to open a swap file again // 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. // 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). // 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 if (fname == NULL) { // When there is no file name
fname = (char_u *)""; fname = (char_u *)"";
} }
len = (int)STRLEN(fname); len = (int)STRLEN(fname);
if (checkext && len >= 4 if (checkext && len >= 4
&& STRNICMP(fname + len - 4, ".s", 2) == 0 && STRNICMP(fname + len - 4, ".s", 2) == 0
&& vim_strchr((char_u *)"abcdefghijklmnopqrstuvw", && vim_strchr("abcdefghijklmnopqrstuvw", TOLOWER_ASC(fname[len - 2])) != NULL
TOLOWER_ASC(fname[len - 2])) != NULL
&& ASCII_ISALPHA(fname[len - 1])) { && ASCII_ISALPHA(fname[len - 1])) {
directly = true; directly = true;
fname_used = vim_strsave(fname); // make a copy for mf_open() fname_used = vim_strsave(fname); // make a copy for mf_open()
@ -1248,8 +1247,8 @@ theend:
if (serious_error && called_from_main) { if (serious_error && called_from_main) {
ml_close(curbuf, TRUE); ml_close(curbuf, TRUE);
} else { } else {
apply_autocmds(EVENT_BUFREADPOST, 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); 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"); msg_puts("\"\n");
const time_t swap_mtime = swapfile_info(fname); const time_t swap_mtime = swapfile_info(fname);
msg_puts(_("While opening file \"")); msg_puts(_("While opening file \""));
msg_outtrans(buf->b_fname); msg_outtrans((char_u *)buf->b_fname);
msg_puts("\"\n"); msg_puts("\"\n");
FileInfo file_info; 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")); msg_puts(_(" CANNOT BE FOUND"));
} else { } else {
msg_puts(_(" dated: ")); msg_puts(_(" dated: "));
@ -3343,7 +3342,7 @@ static void attention_message(buf_T *buf, char_u *fname)
" Quit, or continue with caution.\n")); " Quit, or continue with caution.\n"));
msg_puts(_("(2) An edit session for this file crashed.\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_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(_("\"\n to recover the changes (see \":help recovery\").\n"));
msg_puts(_(" If you did this already, delete the swap file \"")); msg_puts(_(" If you did this already, delete the swap file \""));
msg_outtrans(fname); msg_outtrans(fname);
@ -3423,7 +3422,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
char *fname; char *fname;
size_t n; size_t n;
char *dir_name; 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. * 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 // give the ATTENTION message when there is an old swap file
// for the current file, and the buffer was not recovered. // for the current file, and the buffer was not recovered.
if (differ == false && !(curbuf->b_flags & BF_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; int choice = 0;
process_still_running = false; process_still_running = false;
// It's safe to delete the swap file if all these are true: // It's safe to delete the swap file if all these are true:
// - the edited file exists // - the edited file exists
// - the swap file has no changes and looks OK // - 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; choice = 4;
if (p_verbose > 0) { if (p_verbose > 0) {
verb_msg(_("Found a swap file that is not useful, deleting it")); verb_msg(_("Found a swap file that is not useful, deleting it"));

View File

@ -1301,7 +1301,7 @@ static char *menu_text(const char *str, int *mnemonic, char **actext)
char *text; char *text;
// Locate accelerator text, after the first TAB // Locate accelerator text, after the first TAB
p = (char *)vim_strchr((char_u *)str, TAB); p = vim_strchr(str, TAB);
if (p != NULL) { if (p != NULL) {
if (actext != NULL) { if (actext != NULL) {
*actext = xstrdup(p + 1); *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 "&". // Find mnemonic characters "&a" and reduce "&&" to "&".
for (p = text; p != NULL;) { for (p = text; p != NULL;) {
p = (char *)vim_strchr((char_u *)p, '&'); p = vim_strchr(p, '&');
if (p != NULL) { if (p != NULL) {
if (p[1] == NUL) { // trailing "&" if (p[1] == NUL) { // trailing "&"
break; break;

View File

@ -598,8 +598,8 @@ void msg_source(int attr)
/// If "emsg_skip" is set: never do error messages. /// If "emsg_skip" is set: never do error messages.
int emsg_not_now(void) int emsg_not_now(void)
{ {
if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL if ((emsg_off > 0 && vim_strchr((char *)p_debug, 'm') == NULL
&& vim_strchr(p_debug, 't') == NULL) && vim_strchr((char *)p_debug, 't') == NULL)
|| emsg_skip > 0) { || emsg_skip > 0) {
return TRUE; return TRUE;
} }
@ -623,14 +623,12 @@ static bool emsg_multiline(const char *s, bool multiline)
bool severe = emsg_severe; bool severe = emsg_severe;
emsg_severe = false; emsg_severe = false;
if (!emsg_off || vim_strchr(p_debug, 't') != NULL) { if (!emsg_off || vim_strchr((char *)p_debug, 't') != NULL) {
/* // Cause a throw of an error exception if appropriate. Don't display
* Cause a throw of an error exception if appropriate. Don't display // the error message in this case. (If no matching catch clause will
* the error message in this case. (If no matching catch clause will // be found, the message will be displayed later on.) "ignore" is set
* be found, the message will be displayed later on.) "ignore" is set // when the message should be ignored completely (used for the
* when the message should be ignored completely (used for the // interrupt message).
* interrupt message).
*/
if (cause_errthrow(s, severe, &ignore)) { if (cause_errthrow(s, severe, &ignore)) {
if (!ignore) { if (!ignore) {
did_emsg++; did_emsg++;
@ -1212,7 +1210,7 @@ void wait_return(int redraw)
if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE
|| c == K_X1MOUSE || c == K_X2MOUSE) { || c == K_X1MOUSE || c == K_X2MOUSE) {
(void)jump_to_mouse(MOUSE_SETPOS, NULL, 0); (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 // Put the character back in the typeahead buffer. Don't use the
// stuff buffer, because lmaps wouldn't work. // stuff buffer, because lmaps wouldn't work.
ins_char_typebuf(vgetc_char, vgetc_mod_mask); ins_char_typebuf(vgetc_char, vgetc_mod_mask);

View File

@ -2191,7 +2191,7 @@ static int get_mouse_class(char_u *p)
// characters to be considered as a single word. These are things like // characters to be considered as a single word. These are things like
// "->", "/ *", "*=", "+=", "&=", "<=", ">=", "!=" etc. Otherwise, each // "->", "/ *", "*=", "+=", "&=", "<=", ">=", "!=" etc. Otherwise, each
// character is in its own class. // 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 1;
} }
return c; return c;
@ -3447,7 +3447,7 @@ dozet:
// and "zC" only in Visual mode. "zj" and "zk" are motion // and "zC" only in Visual mode. "zj" and "zk" are motion
// commands. // commands.
if (cap->nchar != 'f' && cap->nchar != 'F' 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' && cap->nchar != 'j' && cap->nchar != 'k'
&& checkclearop(cap->oap)) { && checkclearop(cap->oap)) {
return; return;
@ -3455,7 +3455,7 @@ dozet:
// For "z+", "z<CR>", "zt", "z.", "zz", "z^", "z-", "zb": // For "z+", "z<CR>", "zt", "z.", "zz", "z^", "z-", "zb":
// If line number given, set cursor. // 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
&& cap->count0 != curwin->w_cursor.lnum) { && cap->count0 != curwin->w_cursor.lnum) {
setpcmark(); setpcmark();
@ -3800,7 +3800,7 @@ dozet:
no_mapping--; no_mapping--;
allow_keys--; allow_keys--;
(void)add_to_showcmd(nchar); (void)add_to_showcmd(nchar);
if (vim_strchr((char_u *)"gGwW", nchar) == NULL) { if (vim_strchr("gGwW", nchar) == NULL) {
clearopbeep(cap->oap); clearopbeep(cap->oap);
break; break;
} }
@ -4234,7 +4234,7 @@ static void nv_ident(cmdarg_T *cap)
p = (char_u *)buf + STRLEN(buf); p = (char_u *)buf + STRLEN(buf);
while (n-- > 0) { while (n-- > 0) {
// put a backslash before \ and some others // put a backslash before \ and some others
if (vim_strchr(aux_ptr, *ptr) != NULL) { if (vim_strchr((char *)aux_ptr, *ptr) != NULL) {
*p++ = '\\'; *p++ = '\\';
} }
// When current byte is a part of multibyte character, copy all // 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'. // <Space> wraps to next line if 'whichwrap' has 's'.
// 'l' wraps to next line if 'whichwrap' has 'l'. // 'l' wraps to next line if 'whichwrap' has 'l'.
// CURS_RIGHT wraps to next line if 'whichwrap' has '>'. // CURS_RIGHT wraps to next line if 'whichwrap' has '>'.
if (((cap->cmdchar == ' ' && vim_strchr(p_ww, 's') != NULL) if (((cap->cmdchar == ' ' && vim_strchr((char *)p_ww, 's') != NULL)
|| (cap->cmdchar == 'l' && vim_strchr(p_ww, 'l') != NULL) || (cap->cmdchar == 'l' && vim_strchr((char *)p_ww, 'l') != NULL)
|| (cap->cmdchar == K_RIGHT && vim_strchr(p_ww, '>') != NULL)) || (cap->cmdchar == K_RIGHT && vim_strchr((char *)p_ww, '>') != NULL))
&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) {
// When deleting we also count the NL as a character. // When deleting we also count the NL as a character.
// Set cap->oap->inclusive when last char in the line is // 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'. // 'h' wraps to previous line if 'whichwrap' has 'h'.
// CURS_LEFT wraps to previous line if 'whichwrap' has '<'. // CURS_LEFT wraps to previous line if 'whichwrap' has '<'.
if ((((cap->cmdchar == K_BS || cap->cmdchar == Ctrl_H) if ((((cap->cmdchar == K_BS || cap->cmdchar == Ctrl_H)
&& vim_strchr(p_ww, 'b') != NULL) && vim_strchr((char *)p_ww, 'b') != NULL)
|| (cap->cmdchar == 'h' && vim_strchr(p_ww, 'h') != NULL) || (cap->cmdchar == 'h' && vim_strchr((char *)p_ww, 'h') != NULL)
|| (cap->cmdchar == K_LEFT && vim_strchr(p_ww, '<') != NULL)) || (cap->cmdchar == K_LEFT && vim_strchr((char *)p_ww, '<') != NULL))
&& curwin->w_cursor.lnum > 1) { && curwin->w_cursor.lnum > 1) {
curwin->w_cursor.lnum--; curwin->w_cursor.lnum--;
coladvance(MAXCOL); coladvance(MAXCOL);
@ -4802,7 +4802,7 @@ static void nv_brackets(cmdarg_T *cap)
// "[f" or "]f" : Edit file under the cursor (same as "gf") // "[f" or "]f" : Edit file under the cursor (same as "gf")
if (cap->nchar == 'f') { if (cap->nchar == 'f') {
nv_gotofile(cap); 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 // Find the occurrence(s) of the identifier or define under cursor
// in current and included files or jump to the first occurrence. // in current and included files or jump to the first occurrence.
// //
@ -4831,8 +4831,8 @@ static void nv_brackets(cmdarg_T *cap)
MAXLNUM); MAXLNUM);
curwin->w_set_curswant = true; curwin->w_set_curswant = true;
} }
} else if ((cap->cmdchar == '[' && vim_strchr((char_u *)"{(*/#mM", cap->nchar) != NULL) } else if ((cap->cmdchar == '[' && vim_strchr("{(*/#mM", cap->nchar) != NULL)
|| (cap->cmdchar == ']' && vim_strchr((char_u *)"})*/#mM", cap->nchar) != NULL)) { || (cap->cmdchar == ']' && vim_strchr("})*/#mM", cap->nchar) != NULL)) {
// "[{", "[(", "]}" or "])": go to Nth unclosed '{', '(', '}' or ')' // "[{", "[(", "]}" or "])": go to Nth unclosed '{', '(', '}' or ')'
// "[#", "]#": go to start/end of Nth innermost #if..#endif construct. // "[#", "]#": go to start/end of Nth innermost #if..#endif construct.
// "[/", "[*", "]/", "]*": go to Nth comment start/end. // "[/", "[*", "]/", "]*": go to Nth comment start/end.
@ -5403,7 +5403,7 @@ static void n_swapchar(cmdarg_T *cap)
return; 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); clearopbeep(cap->oap);
return; return;
} }
@ -5419,7 +5419,7 @@ static void n_swapchar(cmdarg_T *cap)
did_change |= swapchar(cap->oap->op_type, &curwin->w_cursor); did_change |= swapchar(cap->oap->op_type, &curwin->w_cursor);
inc_cursor(); inc_cursor();
if (gchar_cursor() == NUL) { 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 < curbuf->b_ml.ml_line_count) {
curwin->w_cursor.lnum++; curwin->w_cursor.lnum++;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
@ -5491,7 +5491,7 @@ static void v_visop(cmdarg_T *cap)
curwin->w_curswant = MAXCOL; 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); nv_operator(cap);
} }
@ -5754,7 +5754,8 @@ void start_selection(void)
/// When "c" is 'o' (checking for "mouse") then also when mapped. /// When "c" is 'o' (checking for "mouse") then also when mapped.
void may_start_select(int c) 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". /// Start Visual mode "c".

View File

@ -800,7 +800,7 @@ char_u *get_expr_line_src(void)
bool valid_yank_reg(int regname, bool writing) bool valid_yank_reg(int regname, bool writing)
{ {
if ((regname > 0 && ASCII_ISALNUM(regname)) if ((regname > 0 && ASCII_ISALNUM(regname))
|| (!writing && vim_strchr((char_u *)"/.%:=", regname) != NULL) || (!writing && vim_strchr("/.%:=", regname) != NULL)
|| regname == '#' || regname == '#'
|| regname == '"' || regname == '"'
|| regname == '-' || regname == '-'
@ -1184,7 +1184,7 @@ int do_execreg(int regname, int colon, int addcr, int silent)
if (free_str) { if (free_str) {
xfree(str); xfree(str);
} }
retval = ins_typebuf((char *)escaped, remap, 0, true, silent); retval = ins_typebuf(escaped, remap, 0, true, silent);
xfree(escaped); xfree(escaped);
if (retval == FAIL) { if (retval == FAIL) {
return FAIL; return FAIL;
@ -1247,7 +1247,7 @@ static int put_in_typebuf(char_u *s, bool esc, bool colon, int silent)
if (p == NULL) { if (p == NULL) {
retval = FAIL; retval = FAIL;
} else { } 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) { if (esc) {
xfree(p); xfree(p);
@ -1368,7 +1368,7 @@ bool get_spec_reg(int regname, char_u **argp, bool *allocated, bool errmsg)
if (errmsg) { if (errmsg) {
check_fname(); // will give emsg if not set check_fname(); // will give emsg if not set
} }
*argp = curbuf->b_fname; *argp = (char_u *)curbuf->b_fname;
return true; return true;
case '#': // alternate file name 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) { if (y_array != NULL) {
y_array[y_size] = ptr; y_array[y_size] = ptr;
} }
++y_size; y_size++;
ptr = vim_strchr(ptr, '\n'); ptr = (char_u *)vim_strchr((char *)ptr, '\n');
if (ptr != NULL) { if (ptr != NULL) {
if (y_array != NULL) { if (y_array != NULL) {
*ptr = NUL; *ptr = NUL;
@ -3849,7 +3849,7 @@ void ex_display(exarg_T *eap)
type = 'b'; break; 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 continue; // did not ask for this register
} }
@ -3912,14 +3912,14 @@ void ex_display(exarg_T *eap)
// display last inserted text // display last inserted text
if ((p = get_last_insert()) != NULL 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)) { && !message_filtered(p)) {
msg_puts("\n c \". "); msg_puts("\n c \". ");
dis_msg(p, true); dis_msg(p, true);
} }
// display last command line // 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)) { && !got_int && !message_filtered(last_cmdline)) {
msg_puts("\n c \": "); msg_puts("\n c \": ");
dis_msg(last_cmdline, false); dis_msg(last_cmdline, false);
@ -3927,14 +3927,14 @@ void ex_display(exarg_T *eap)
// display current file name // display current file name
if (curbuf->b_fname != NULL if (curbuf->b_fname != NULL
&& (arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int && (arg == NULL || vim_strchr((char *)arg, '%') != NULL) && !got_int
&& !message_filtered(curbuf->b_fname)) { && !message_filtered((char_u *)curbuf->b_fname)) {
msg_puts("\n c \"% "); msg_puts("\n c \"% ");
dis_msg(curbuf->b_fname, false); dis_msg((char_u *)curbuf->b_fname, false);
} }
// display alternate file name // 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; char_u *fname;
linenr_T dummy; linenr_T dummy;
@ -3946,14 +3946,14 @@ void ex_display(exarg_T *eap)
// display last search pattern // display last search pattern
if (last_search_pat() != NULL 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())) { && !message_filtered(last_search_pat())) {
msg_puts("\n c \"/ "); msg_puts("\n c \"/ ");
dis_msg(last_search_pat(), false); dis_msg(last_search_pat(), false);
} }
// display last used expression // 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)) { && !got_int && !message_filtered(expr_line)) {
msg_puts("\n c \"= "); msg_puts("\n c \"= ");
dis_msg(expr_line, false); 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; pos_T endpos;
colnr_T save_coladd = 0; colnr_T save_coladd = 0;
const bool do_hex = vim_strchr(curbuf->b_p_nf, 'x') != NULL; // "heX" const bool do_hex = vim_strchr((char *)curbuf->b_p_nf, 'x') != NULL; // "heX"
const bool do_oct = vim_strchr(curbuf->b_p_nf, 'o') != NULL; // "Octal" const bool do_oct = vim_strchr((char *)curbuf->b_p_nf, 'o') != NULL; // "Octal"
const bool do_bin = vim_strchr(curbuf->b_p_nf, 'b') != NULL; // "Bin" const bool do_bin = vim_strchr((char *)curbuf->b_p_nf, 'b') != NULL; // "Bin"
const bool do_alpha = vim_strchr(curbuf->b_p_nf, 'p') != NULL; // "alPha" const bool do_alpha = vim_strchr((char *)curbuf->b_p_nf, 'p') != NULL; // "alPha"
// "Unsigned" // "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()) { if (virtual_active()) {
save_coladd = pos->coladd; save_coladd = pos->coladd;

View File

@ -363,7 +363,7 @@ void set_init_1(bool clean_arg)
{ {
const char *shell = os_getenv("SHELL"); const char *shell = os_getenv("SHELL");
if (shell != NULL) { 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 const size_t len = strlen(shell) + 3; // two quotes and a trailing NUL
char *const cmd = xmalloc(len); char *const cmd = xmalloc(len);
snprintf(cmd, len, "\"%s\"", shell); 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 if (options[opt_idx].var == NULL) { // hidden option: skip
// Only give an error message when requesting the value of // Only give an error message when requesting the value of
// a hidden option, ignore setting it. // a hidden option, ignore setting it.
if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL if (vim_strchr("=:!&<", nextchar) == NULL
&& (!(options[opt_idx].flags & P_BOOL) && (!(options[opt_idx].flags & P_BOOL)
|| nextchar == '?')) { || nextchar == '?')) {
errmsg = _(e_unsupportedoption); errmsg = _(e_unsupportedoption);
@ -1153,7 +1153,7 @@ int do_set(char_u *arg, int opt_flags)
goto skip; goto skip;
} }
if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) { if (vim_strchr("?=:!&<", nextchar) != NULL) {
arg += len; arg += len;
if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') { if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') {
if (arg[3] == 'm') { // "opt&vim": set to Vim default 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; arg += 2;
} }
} }
if (vim_strchr((char_u *)"?!&<", nextchar) != NULL if (vim_strchr("?!&<", nextchar) != NULL
&& arg[1] != NUL && !ascii_iswhite(arg[1])) { && arg[1] != NUL && !ascii_iswhite(arg[1])) {
errmsg = e_trailing; errmsg = e_trailing;
goto skip; goto skip;
@ -1175,7 +1175,7 @@ int do_set(char_u *arg, int opt_flags)
// //
if (nextchar == '?' if (nextchar == '?'
|| (prefix == 1 || (prefix == 1
&& vim_strchr((char_u *)"=:&<", nextchar) == NULL && vim_strchr("=:&<", nextchar) == NULL
&& !(flags & P_BOOL))) { && !(flags & P_BOOL))) {
/* /*
* print value * print value
@ -1255,7 +1255,7 @@ int do_set(char_u *arg, int opt_flags)
errmsg = set_bool_option(opt_idx, varp, (int)value, errmsg = set_bool_option(opt_idx, varp, (int)value,
opt_flags); opt_flags);
} else { // Numeric or string. } else { // Numeric or string.
if (vim_strchr((const char_u *)"=:&<", nextchar) == NULL if (vim_strchr("=:&<", nextchar) == NULL
|| prefix != 1) { || prefix != 1) {
errmsg = e_invarg; errmsg = e_invarg;
goto skip; goto skip;
@ -1609,14 +1609,14 @@ int do_set(char_u *arg, int opt_flags)
// 'whichwrap' // 'whichwrap'
if (flags & P_ONECOMMA) { if (flags & P_ONECOMMA) {
if (*s != ',' && *(s + 1) == ',' 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. // Remove the duplicated value and the next comma.
STRMOVE(s, s + 2); STRMOVE(s, s + 2);
continue; continue;
} }
} else { } else {
if ((!(flags & P_COMMA) || *s != ',') if ((!(flags & P_COMMA) || *s != ',')
&& vim_strchr(s + 1, *s) != NULL) { && vim_strchr((char *)s + 1, *s) != NULL) {
STRMOVE(s, s + 1); STRMOVE(s, s + 1);
continue; continue;
} }
@ -1917,7 +1917,7 @@ char_u *find_shada_parameter(int type)
if (*p == 'n') { // 'n' is always the last one if (*p == 'n') { // 'n' is always the last one
break; 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 if (p == NULL) { // hit the end without finding parameter
break; 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++) { for (const char_u *s = val; *s != NUL; s++) {
if (!ASCII_ISALNUM(*s) if (!ASCII_ISALNUM(*s)
&& vim_strchr((const char_u *)allowed, *s) == NULL) { && vim_strchr(allowed, *s) == NULL) {
return false; 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) { if (opt_strings_flags(p_rdb, p_rdb_values, &rdb_flags, true) != OK) {
errmsg = e_invarg; errmsg = e_invarg;
} }
} else if (varp == &p_sbo) { // 'scrollopt' } else if (varp == (char_u **)&p_sbo) { // 'scrollopt'
if (check_opt_strings(p_sbo, p_scbopt_values, true) != OK) { if (check_opt_strings((char_u *)p_sbo, p_scbopt_values, true) != OK) {
errmsg = e_invarg; errmsg = e_invarg;
} }
} else if (varp == &p_ambw || (int *)varp == &p_emoji) { } else if (varp == &p_ambw || (int *)varp == &p_emoji) {
@ -2578,7 +2578,7 @@ ambw_end:
if (gvarp == &p_fenc) { if (gvarp == &p_fenc) {
if (!MODIFIABLE(curbuf) && opt_flags != OPT_GLOBAL) { if (!MODIFIABLE(curbuf) && opt_flags != OPT_GLOBAL) {
errmsg = e_modifiable; errmsg = e_modifiable;
} else if (vim_strchr(*varp, ',') != NULL) { } else if (vim_strchr((char *)(*varp), ',') != NULL) {
// No comma allowed in 'fileencoding'; catches confusing it // No comma allowed in 'fileencoding'; catches confusing it
// with 'fileencodings'. // with 'fileencodings'.
errmsg = e_invarg; errmsg = e_invarg;
@ -2664,8 +2664,8 @@ ambw_end:
redraw_curbuf_later(NOT_VALID); redraw_curbuf_later(NOT_VALID);
} }
} }
} else if (varp == &p_ffs) { // 'fileformats' } else if (varp == (char_u **)&p_ffs) { // 'fileformats'
if (check_opt_strings(p_ffs, p_ff_values, true) != OK) { if (check_opt_strings((char_u *)p_ffs, p_ff_values, true) != OK) {
errmsg = e_invarg; errmsg = e_invarg;
} }
} else if (gvarp == &p_mps) { // 'matchpairs' } else if (gvarp == &p_mps) { // 'matchpairs'
@ -2692,7 +2692,7 @@ ambw_end:
} else if (gvarp == &p_com) { // 'comments' } else if (gvarp == &p_com) { // 'comments'
for (s = *varp; *s;) { for (s = *varp; *s;) {
while (*s && *s != ':') { while (*s && *s != ':') {
if (vim_strchr((char_u *)COM_ALL, *s) == NULL if (vim_strchr(COM_ALL, *s) == NULL
&& !ascii_isdigit(*s) && *s != '-') { && !ascii_isdigit(*s) && *s != '-') {
errmsg = illegal_char(errbuf, errbuflen, *s); errmsg = illegal_char(errbuf, errbuflen, *s);
break; break;
@ -2771,7 +2771,7 @@ ambw_end:
free_oldval = (options[opt_idx].flags & P_ALLOCED); free_oldval = (options[opt_idx].flags & P_ALLOCED);
for (s = p_shada; *s;) { for (s = p_shada; *s;) {
// Check it's a valid character // 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); errmsg = illegal_char(errbuf, errbuflen, *s);
break; break;
} }
@ -2835,7 +2835,7 @@ ambw_end:
int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON; int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
// NULL => statusline syntax // 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; stl_syntax |= flagval;
} else { } else {
stl_syntax &= ~flagval; stl_syntax &= ~flagval;
@ -2854,8 +2854,8 @@ ambw_end:
if (check_opt_strings(p_km, p_km_values, true) != OK) { if (check_opt_strings(p_km, p_km_values, true) != OK) {
errmsg = e_invarg; errmsg = e_invarg;
} else { } else {
km_stopsel = (vim_strchr(p_km, 'o') != NULL); km_stopsel = (vim_strchr((char *)p_km, 'o') != NULL);
km_startsel = (vim_strchr(p_km, 'a') != NULL); km_startsel = (vim_strchr((char *)p_km, 'a') != NULL);
} }
} else if (varp == &p_mousem) { // 'mousemodel' } else if (varp == &p_mousem) { // 'mousemodel'
if (check_opt_strings(p_mousem, p_mousem_values, false) != OK) { if (check_opt_strings(p_mousem, p_mousem_values, false) != OK) {
@ -2965,7 +2965,7 @@ ambw_end:
if (!*s) { if (!*s) {
break; break;
} }
if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL) { if (vim_strchr(".wbuksid]tU", *s) == NULL) {
errmsg = illegal_char(errbuf, errbuflen, *s); errmsg = illegal_char(errbuf, errbuflen, *s);
break; break;
} }
@ -3089,7 +3089,7 @@ ambw_end:
foldUpdateAll(curwin); foldUpdateAll(curwin);
} }
} else if (gvarp == &curwin->w_allbuf_opt.wo_fmr) { // 'foldmarker' } else if (gvarp == &curwin->w_allbuf_opt.wo_fmr) { // 'foldmarker'
p = vim_strchr(*varp, ','); p = (char_u *)vim_strchr((char *)(*varp), ',');
if (p == NULL) { if (p == NULL) {
errmsg = N_("E536: comma required"); errmsg = N_("E536: comma required");
} else if (p == *varp || p[1] == NUL) { } else if (p == *varp || p[1] == NUL) {
@ -3139,9 +3139,9 @@ ambw_end:
if (p_csqf != NULL) { if (p_csqf != NULL) {
p = p_csqf; p = p_csqf;
while (*p != NUL) { while (*p != NUL) {
if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL if (vim_strchr(CSQF_CMDS, *p) == NULL
|| p[1] == NUL || p[1] == NUL
|| vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL || vim_strchr(CSQF_FLAGS, p[1]) == NULL
|| (p[2] != NUL && p[2] != ',')) { || (p[2] != NUL && p[2] != ',')) {
errmsg = e_invarg; errmsg = e_invarg;
break; break;
@ -3253,7 +3253,7 @@ ambw_end:
} }
if (varp == &p_shm) { // 'shortmess' if (varp == &p_shm) { // 'shortmess'
p = (char_u *)SHM_ALL; p = (char_u *)SHM_ALL;
} else if (varp == &(p_cpo)) { // 'cpoptions' } else if (varp == (char_u **)&(p_cpo)) { // 'cpoptions'
p = (char_u *)CPO_VI; p = (char_u *)CPO_VI;
} else if (varp == &(curbuf->b_p_fo)) { // 'formatoptions' } else if (varp == &(curbuf->b_p_fo)) { // 'formatoptions'
p = (char_u *)FO_ALL; p = (char_u *)FO_ALL;
@ -3264,7 +3264,7 @@ ambw_end:
} }
if (p != NULL) { if (p != NULL) {
for (s = *varp; *s; s++) { for (s = *varp; *s; s++) {
if (vim_strchr(p, *s) == NULL) { if (vim_strchr((char *)p, *s) == NULL) {
errmsg = illegal_char(errbuf, errbuflen, *s); errmsg = illegal_char(errbuf, errbuflen, *s);
break; break;
} }
@ -3323,7 +3323,7 @@ ambw_end:
syn_recursive++; syn_recursive++;
// Only pass true for "force" when the value changed or not used // Only pass true for "force" when the value changed or not used
// recursively, to avoid endless recurrence. // 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); value_changed || syn_recursive == 1, curbuf);
curbuf->b_flags |= BF_SYN_SET; curbuf->b_flags |= BF_SYN_SET;
syn_recursive--; syn_recursive--;
@ -3343,7 +3343,7 @@ ambw_end:
did_filetype = true; did_filetype = true;
// Only pass true for "force" when the value changed or not // Only pass true for "force" when the value changed or not
// used recursively, to avoid endless recurrence. // 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); value_changed || ft_recursive == 1, curbuf);
ft_recursive--; ft_recursive--;
// Just in case the old "curbuf" is now invalid // Just in case the old "curbuf" is now invalid
@ -3844,7 +3844,7 @@ static char *compile_cap_prog(synblock_T *synblock)
} else { } else {
// Prepend a ^ so that we only match at one column // Prepend a ^ so that we only match at one column
re = concat_str((char_u *)"^", synblock->b_p_spc); 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); xfree(re);
if (synblock->b_cap_prog == NULL) { if (synblock->b_cap_prog == NULL) {
synblock->b_cap_prog = rp; // restore the previous program 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) || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
&& !bufIsChanged(bp) && bp->b_ml.ml_mfp != NULL) { && !bufIsChanged(bp) && bp->b_ml.ml_mfp != NULL) {
u_compute_hash(bp, hash); 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) { } else if ((int *)varp == &p_terse) {
// when 'terse' is set change 'shortmess' // when 'terse' is set change 'shortmess'
char_u *p; char *p = vim_strchr((char *)p_shm, SHM_SEARCH);
p = vim_strchr(p_shm, SHM_SEARCH);
// insert 's' in p_shm // insert 's' in p_shm
if (p_terse && p == NULL) { 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_COMMAND, "modeline", -1);
set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -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(); 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_COMMAND, "modeline", -1);
set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -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(); 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_COMMAND, "modeline", -1);
set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -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(); 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 // each comma separated part of the option separately, so that it
// can be expanded when read back. // can be expanded when read back.
if (size >= MAXPATHL && (flags & P_COMMA) != 0 if (size >= MAXPATHL && (flags & P_COMMA) != 0
&& vim_strchr(*valuep, ',') != NULL) { && vim_strchr((char *)(*valuep), ',') != NULL) {
part = xmalloc(size); part = xmalloc(size);
// write line break to clear the option, e.g. ':set rtp=' // write line break to clear the option, e.g. ':set rtp='
@ -7215,7 +7213,7 @@ bool has_format_option(int x)
if (p_paste) { if (p_paste) {
return false; 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 /// @returns true if "x" is present in 'shortmess' option, or
@ -7223,9 +7221,9 @@ bool has_format_option(int x)
bool shortmess(int x) bool shortmess(int x)
{ {
return (p_shm != NULL return (p_shm != NULL
&& (vim_strchr(p_shm, x) != NULL && (vim_strchr((char *)p_shm, x) != NULL
|| (vim_strchr(p_shm, 'a') != NULL || (vim_strchr((char *)p_shm, 'a') != NULL
&& vim_strchr((char_u *)SHM_ALL_ABBREVIATIONS, x) != NULL))); && vim_strchr((char *)SHM_ALL_ABBREVIATIONS, x) != NULL)));
} }
/// paste_option_changed() - Called after p_paste was set or reset. /// paste_option_changed() - Called after p_paste was set or reset.
@ -7587,7 +7585,7 @@ bool can_bs(int what)
case '0': case '0':
return false; 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 /// 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 == '.') { if (*p == '.') {
buf[len++] = *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. // 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++; p++;
} }
if (len < maxlen - 1) { if (len < maxlen - 1) {

View File

@ -266,7 +266,7 @@ enum {
STL_CLICK_FUNC = '@', ///< Click region start. STL_CLICK_FUNC = '@', ///< Click region start.
}; };
/// C string containing all 'statusline' option flags /// 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_FILEPATH, STL_FULLPATH, STL_FILENAME, STL_COLUMN, STL_VIRTCOL, \
STL_VIRTCOL_ALT, STL_LINE, STL_NUMLINES, STL_BUFNO, STL_KEYMAP, STL_OFFSET, \ 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, \ 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_pb; // 'pumblend'
EXTERN long p_ph; // 'pumheight' EXTERN long p_ph; // 'pumheight'
EXTERN long p_pw; // 'pumwidth' EXTERN long p_pw; // 'pumwidth'
EXTERN char_u *p_cpo; // 'cpoptions' EXTERN char *p_cpo; // 'cpoptions'
EXTERN char_u *p_csprg; // 'cscopeprg' EXTERN char_u *p_csprg; // 'cscopeprg'
EXTERN int p_csre; // 'cscoperelative' EXTERN int p_csre; // 'cscoperelative'
EXTERN char_u *p_csqf; // 'cscopequickfix' EXTERN char_u *p_csqf; // 'cscopequickfix'
@ -434,7 +434,7 @@ EXTERN char_u *p_gp; // 'grepprg'
EXTERN char_u *p_ei; // 'eventignore' EXTERN char_u *p_ei; // 'eventignore'
EXTERN int p_exrc; // 'exrc' EXTERN int p_exrc; // 'exrc'
EXTERN char_u *p_fencs; // 'fileencodings' EXTERN char_u *p_fencs; // 'fileencodings'
EXTERN char_u *p_ffs; // 'fileformats' EXTERN char *p_ffs; // 'fileformats'
EXTERN int p_fic; // 'fileignorecase' EXTERN int p_fic; // 'fileignorecase'
EXTERN char_u *p_fcl; // 'foldclose' EXTERN char_u *p_fcl; // 'foldclose'
EXTERN long p_fdls; // 'foldlevelstart' EXTERN long p_fdls; // 'foldlevelstart'
@ -571,7 +571,7 @@ EXTERN char_u *p_rtp; // 'runtimepath'
EXTERN long p_scbk; // 'scrollback' EXTERN long p_scbk; // 'scrollback'
EXTERN long p_sj; // 'scrolljump' EXTERN long p_sj; // 'scrolljump'
EXTERN long p_so; // 'scrolloff' EXTERN long p_so; // 'scrolloff'
EXTERN char_u *p_sbo; // 'scrollopt' EXTERN char *p_sbo; // 'scrollopt'
EXTERN char_u *p_sections; // 'sections' EXTERN char_u *p_sections; // 'sections'
EXTERN int p_secure; // 'secure' EXTERN int p_secure; // 'secure'
EXTERN char_u *p_sel; // 'selection' EXTERN char_u *p_sel; // 'selection'

View File

@ -529,9 +529,9 @@ void free_homedir(void)
/// again soon. /// again soon.
/// @param src String containing environment variables to expand /// @param src String containing environment variables to expand
/// @see {expand_env} /// @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 /// 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 #endif
} else if (src[1] == NUL // home directory } else if (src[1] == NUL // home directory
|| vim_ispathsep(src[1]) || vim_ispathsep(src[1])
|| vim_strchr((char_u *)" ,\t\n", src[1]) != NULL) { || vim_strchr(" ,\t\n", src[1]) != NULL) {
var = (char_u *)homedir; var = (char_u *)homedir;
tail = src + 1; tail = src + 1;
} else { // user directory } 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]" // TODO(bfredl): param could have been written as "char exe_name[MAXPATHL]"
// but c_grammar.lua does not recognize it (yet). // but c_grammar.lua does not recognize it (yet).
xstrlcpy(exe_name, (char *)get_vim_var_str(VV_PROGPATH), xstrlcpy(exe_name, get_vim_var_str(VV_PROGPATH), MAXPATHL * sizeof(*exe_name));
MAXPATHL * sizeof(*exe_name));
char *path_end = (char *)path_tail_with_sep((char_u *)exe_name); char *path_end = (char *)path_tail_with_sep((char_u *)exe_name);
*path_end = '\0'; // remove the trailing "nvim.exe" *path_end = '\0'; // remove the trailing "nvim.exe"
path_end = path_tail(exe_name); 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 directory name from 'helpfile' (unless it contains '$')
// - the executable name from argv[0] // - the executable name from argv[0]
if (vim_path == NULL) { 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; vim_path = (char *)p_hf;
} }

View File

@ -36,7 +36,7 @@
#define NS_1_SECOND 1000000000U // 1 second, in nanoseconds #define NS_1_SECOND 1000000000U // 1 second, in nanoseconds
#define OUT_DATA_THRESHOLD 1024 * 10U // 10KB, "a few screenfuls" of data. #define OUT_DATA_THRESHOLD 1024 * 10U // 10KB, "a few screenfuls" of data.
#define SHELL_SPECIAL (char_u *)"\t \"&'$;<>()\\|" #define SHELL_SPECIAL "\t \"&'$;<>()\\|"
typedef struct { typedef struct {
char *data; char *data;
@ -73,7 +73,7 @@ static bool have_wildcard(int num, char_u **file)
static bool have_dollars(int num, char_u **file) static bool have_dollars(int num, char_u **file)
{ {
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
if (vim_strchr(file[i], '$') != NULL) { if (vim_strchr((char *)file[i], '$') != NULL) {
return true; 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. // Don't allow the use of backticks in secure.
if (secure) { if (secure) {
for (i = 0; i < num_pat; i++) { for (i = 0; i < num_pat; i++) {
if (vim_strchr(pat[i], '`') != NULL if (vim_strchr((char *)pat[i], '`') != NULL
&& (check_secure())) { && (check_secure())) {
return FAIL; return FAIL;
} }
@ -1213,7 +1213,7 @@ static void read_input(DynamicBuffer *buf)
dynamic_buffer_ensure(buf, buf->len + len); dynamic_buffer_ensure(buf, buf->len + len);
buf->data[buf->len++] = NUL; buf->data[buf->len++] = NUL;
} else { } 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)); len = s == NULL ? l : (size_t)(s - (lp + written));
dynamic_buffer_ensure(buf, buf->len + len); dynamic_buffer_ensure(buf, buf->len + len);
memcpy(buf->data + buf->len, lp + written, len); memcpy(buf->data + buf->len, lp + written, len);

View File

@ -210,14 +210,12 @@ static void on_signal(SignalWatcher *handle, int signum, void *data)
break; break;
#ifdef SIGUSR1 #ifdef SIGUSR1
case SIGUSR1: case SIGUSR1:
apply_autocmds(EVENT_SIGNAL, (char_u *)"SIGUSR1", curbuf->b_fname, true, apply_autocmds(EVENT_SIGNAL, "SIGUSR1", curbuf->b_fname, true, curbuf);
curbuf);
break; break;
#endif #endif
#ifdef SIGWINCH #ifdef SIGWINCH
case SIGWINCH: case SIGWINCH:
apply_autocmds(EVENT_SIGNAL, (char_u *)"SIGWINCH", curbuf->b_fname, true, apply_autocmds(EVENT_SIGNAL, "SIGWINCH", curbuf->b_fname, true, curbuf);
curbuf);
break; break;
#endif #endif
default: default:

View File

@ -82,7 +82,7 @@ char *stdpaths_get_xdg_var(const XDGVarType idx)
if (env_val != NULL) { if (env_val != NULL) {
ret = xstrdup(env_val); ret = xstrdup(env_val);
} else if (fallback) { } else if (fallback) {
ret = (char *)expand_env_save((char_u *)fallback); ret = expand_env_save((char *)fallback);
} }
return ret; return ret;

View File

@ -525,7 +525,7 @@ bool path_has_wildcard(const char_u *p)
// Windows: // Windows:
const char *wildcards = "?*$[`"; const char *wildcards = "?*$[`";
#endif #endif
if (vim_strchr((char_u *)wildcards, *p) != NULL if (vim_strchr(wildcards, *p) != NULL
|| (p[0] == '~' && p[1] != NUL)) { || (p[0] == '~' && p[1] != NUL)) {
return true; return true;
} }
@ -559,7 +559,7 @@ bool path_has_exp_wildcard(const char_u *p)
#else #else
const char *wildcards = "*?["; // Windows. const char *wildcards = "*?["; // Windows.
#endif #endif
if (vim_strchr((char_u *)wildcards, *p) != NULL) { if (vim_strchr(wildcards, *p) != NULL) {
return true; 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; s = p + 1;
} else if (path_end >= path + wildoff } else if (path_end >= path + wildoff
&& (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL && (vim_strchr("*?[{~$", *path_end) != NULL
#ifndef WIN32 #ifndef WIN32
|| (!p_fic && (flags & EW_ICASE) && mb_isalpha(utf_ptr2char((char *)path_end))) || (!p_fic && (flags & EW_ICASE) && mb_isalpha(utf_ptr2char((char *)path_end)))
#endif #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 // convert the file pattern to a regexp pattern
int starts_with_dot = *s == '.'; 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) { if (pat == NULL) {
xfree(buf); xfree(buf);
return 0; return 0;
@ -949,13 +949,13 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
file_pattern[0] = '*'; file_pattern[0] = '*';
file_pattern[1] = NUL; file_pattern[1] = NUL;
STRCAT(file_pattern, pattern); 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); xfree(file_pattern);
if (pat == NULL) { if (pat == NULL) {
return; return;
} }
regmatch.rm_ic = TRUE; // always ignore case regmatch.rm_ic = true; // always ignore case
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
xfree(pat); xfree(pat);
if (regmatch.regprog == NULL) { if (regmatch.regprog == NULL) {
@ -1153,7 +1153,7 @@ static bool has_env_var(char_u *p)
for (; *p; MB_PTR_ADV(p)) { for (; *p; MB_PTR_ADV(p)) {
if (*p == '\\' && p[1] != NUL) { if (*p == '\\' && p[1] != NUL) {
p++; p++;
} else if (vim_strchr((char_u *)"$", *p) != NULL) { } else if (vim_strchr("$", *p) != NULL) {
return true; return true;
} }
} }
@ -1174,13 +1174,13 @@ static bool has_special_wildchar(char_u *p)
// Allow for escaping. // Allow for escaping.
if (*p == '\\' && p[1] != NUL && p[1] != '\r' && p[1] != '\n') { if (*p == '\\' && p[1] != NUL && p[1] != '\r' && p[1] != '\n') {
p++; 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 }. // A { must be followed by a matching }.
if (*p == '{' && vim_strchr(p, '}') == NULL) { if (*p == '{' && vim_strchr((char *)p, '}') == NULL) {
continue; continue;
} }
// A quote and backtick must be followed by another one. // 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; continue;
} }
return true; return true;
@ -2248,7 +2248,7 @@ int match_suffix(char_u *fname)
char_u *tail = (char_u *)path_tail((char *)fname); char_u *tail = (char_u *)path_tail((char *)fname);
// empty entry: match name without a '.' // empty entry: match name without a '.'
if (vim_strchr(tail, '.') == NULL) { if (vim_strchr((char *)tail, '.') == NULL) {
setsuflen = 1; setsuflen = 1;
break; break;
} }

View File

@ -694,7 +694,7 @@ static int pum_set_selected(int n, int repeat)
if ((pum_array[pum_selected].pum_info != NULL) if ((pum_array[pum_selected].pum_info != NULL)
&& (Rows > 10) && (Rows > 10)
&& (repeat <= 1) && (repeat <= 1)
&& (vim_strchr(p_cot, 'p') != NULL)) { && (vim_strchr((char *)p_cot, 'p') != NULL)) {
win_T *curwin_save = curwin; win_T *curwin_save = curwin;
tabpage_T *curtab_save = curtab; tabpage_T *curtab_save = curtab;
int res = OK; int res = OK;
@ -748,7 +748,7 @@ static int pum_set_selected(int n, int repeat)
linenr_T lnum = 0; linenr_T lnum = 0;
for (p = pum_array[pum_selected].pum_info; *p != NUL;) { 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) { if (e == NULL) {
ml_append(lnum++, (char *)p, 0, false); ml_append(lnum++, (char *)p, 0, false);
break; break;

View File

@ -369,9 +369,9 @@ static char *efmpat_to_regpat(const char *efmpat, char *regpat, efm_T *efminfo,
return NULL; return NULL;
} }
if ((idx && idx < FMT_PATTERN_R if ((idx && idx < FMT_PATTERN_R
&& vim_strchr((char_u *)"DXOPQ", efminfo->prefix) != NULL) && vim_strchr("DXOPQ", efminfo->prefix) != NULL)
|| (idx == FMT_PATTERN_R || (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); semsg(_("E373: Unexpected %%%c in format string"), *efmpat);
return NULL; 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) static const char *efm_analyze_prefix(const char *efmp, efm_T *efminfo)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
if (vim_strchr((char_u *)"+-", *efmp) != NULL) { if (vim_strchr("+-", *efmp) != NULL) {
efminfo->flags = *efmp++; efminfo->flags = *efmp++;
} }
if (vim_strchr((char_u *)"DXAEWINCZGOPQ", *efmp) != NULL) { if (vim_strchr("DXAEWINCZGOPQ", *efmp) != NULL) {
efminfo->prefix = *efmp; efminfo->prefix = *efmp;
} else { } else {
semsg(_("E376: Invalid %%%c in format string prefix"), *efmp); 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) { if (ptr == NULL) {
return FAIL; return FAIL;
} }
} else if (vim_strchr((char_u *)"%\\.^$~[", *efmp) != NULL) { } else if (vim_strchr("%\\.^$~[", *efmp) != NULL) {
*ptr++ = *efmp; // regexp magic characters *ptr++ = *efmp; // regexp magic characters
} else if (*efmp == '#') { } else if (*efmp == '#') {
*ptr++ = '*'; *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 } else { // copy normal character
if (*efmp == '\\' && efmp + 1 < efm + len) { if (*efmp == '\\' && efmp + 1 < efm + len) {
efmp++; efmp++;
} else if (vim_strchr((char_u *)".*^$~[", *efmp) != NULL) { } else if (vim_strchr(".*^$~[", *efmp) != NULL) {
*ptr++ = '\\'; // escape regexp atoms *ptr++ = '\\'; // escape regexp atoms
} }
if (*efmp) { if (*efmp) {
@ -609,7 +609,7 @@ static efm_T *parse_efm_option(char *efm)
if (efm_to_regpat(efm, len, fmt_ptr, fmtstr) == FAIL) { if (efm_to_regpat(efm, len, fmt_ptr, fmtstr) == FAIL) {
goto parse_efm_error; 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; goto parse_efm_error;
} }
// Advance to next part // Advance to next part
@ -659,7 +659,7 @@ static int qf_get_next_str_line(qfstate_T *state)
return QF_END_OF_INPUT; return QF_END_OF_INPUT;
} }
p = (char *)vim_strchr((char_u *)p_str, '\n'); p = vim_strchr(p_str, '\n');
if (p != NULL) { if (p != NULL) {
len = (size_t)(p - p_str) + 1; len = (size_t)(p - p_str) + 1;
} else { } else {
@ -961,16 +961,16 @@ restofline:
fmt_start = fmt_ptr; 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_multiline = true; // start of a multi-line message
qfl->qf_multiignore = false; // reset continuation 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 // continuation of multi-line msg
status = qf_parse_multiline_pfx(idx, qfl, fields); status = qf_parse_multiline_pfx(idx, qfl, fields);
if (status != QF_OK) { if (status != QF_OK) {
return status; return status;
} }
} else if (vim_strchr((char_u *)"OPQ", idx) != NULL) { } else if (vim_strchr("OPQ", idx) != NULL) {
// global file names // global file names
status = qf_parse_file_pfx(idx, fields, qfl, tail); status = qf_parse_file_pfx(idx, fields, qfl, tail);
if (status == QF_MULTISCAN) { 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 // For separate filename patterns (%O, %P and %Q), the specified file
// should exist. // should exist.
if (vim_strchr((char_u *)"OPQ", prefix) != NULL if (vim_strchr("OPQ", prefix) != NULL
&& !os_path_exists((char_u *)fields->namebuf)) { && !os_path_exists((char_u *)fields->namebuf)) {
return QF_FAIL; 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) { if ((idx == 'C' || idx == 'Z') && !qf_multiline) {
return QF_FAIL; return QF_FAIL;
} }
if (vim_strchr((char_u *)"EWIN", idx) != NULL) { if (vim_strchr("EWIN", idx) != NULL) {
fields->type = idx; fields->type = idx;
} else { } else {
fields->type = 0; 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 status = QF_FAIL;
int r; 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; return QF_FAIL;
} }
@ -3102,7 +3102,7 @@ static void qf_list_entry(qfline_T *qfp, int qf_idx, bool cursel)
} else { } else {
if (qfp->qf_fnum != 0 if (qfp->qf_fnum != 0
&& (buf = buflist_findnr(qfp->qf_fnum)) != NULL) { && (buf = buflist_findnr(qfp->qf_fnum)) != NULL) {
fname = (char *)buf->b_fname; fname = buf->b_fname;
if (qfp->qf_type == 1) { // :helpgrep if (qfp->qf_type == 1) { // :helpgrep
fname = path_tail(fname); 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 = buflist_findnr(qfp->qf_fnum)) != NULL
&& errbuf->b_fname != NULL) { && errbuf->b_fname != NULL) {
if (qfp->qf_type == 1) { // :helpgrep if (qfp->qf_type == 1) { // :helpgrep
STRLCPY(IObuff, path_tail((char *)errbuf->b_fname), IOSIZE); STRLCPY(IObuff, path_tail(errbuf->b_fname), IOSIZE);
} else { } else {
// Shorten the file name if not done already. // Shorten the file name if not done already.
// For optimization, do this only for the first entry in a // 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; curbuf->b_p_ma = false;
keep_filetype = true; // don't detect 'filetype' keep_filetype = true; // don't detect 'filetype'
apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL, apply_autocmds(EVENT_BUFREADPOST, "quickfix", NULL, false, curbuf);
false, curbuf); apply_autocmds(EVENT_BUFWINENTER, "quickfix", NULL, false, curbuf);
apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL,
false, curbuf);
keep_filetype = false; keep_filetype = false;
curbuf->b_ro_locked--; curbuf->b_ro_locked--;
@ -4374,7 +4372,7 @@ void ex_make(exarg_T *eap)
} }
char *const au_name = make_get_auname(eap->cmdidx); 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)) { curbuf->b_fname, true, curbuf)) {
if (aborting()) { if (aborting()) {
return; return;
@ -4415,7 +4413,7 @@ void ex_make(exarg_T *eap)
// check for autocommands changing the current quickfix list. // check for autocommands changing the current quickfix list.
unsigned save_qfid = qf_get_curlist(qi)->qf_id; unsigned save_qfid = qf_get_curlist(qi)->qf_id;
if (au_name != NULL) { 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); curbuf);
} }
if (res > 0 && !eap->forceit && qflist_valid(wp, save_qfid)) { 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); au_name = cfile_get_auname(eap->cmdidx);
if (au_name != NULL 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()) { if (aborting()) {
return; return;
} }
@ -5146,7 +5144,7 @@ void ex_cfile(exarg_T *eap)
} }
unsigned save_qfid = qf_get_curlist(qi)->qf_id; unsigned save_qfid = qf_get_curlist(qi)->qf_id;
if (au_name != NULL) { 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 // Jump to the first error for a new list and if autocmds didn't free the
// list. // list.
@ -5196,9 +5194,9 @@ static void vgr_init_regmatch(regmmatch_T *regmatch, char *s)
emsg(_(e_noprevre)); emsg(_(e_noprevre));
return; return;
} }
regmatch->regprog = vim_regcomp(last_search_pat(), RE_MAGIC); regmatch->regprog = vim_regcomp((char *)last_search_pat(), RE_MAGIC);
} else { } else {
regmatch->regprog = vim_regcomp((char_u *)s, RE_MAGIC); regmatch->regprog = vim_regcomp(s, RE_MAGIC);
} }
regmatch->rmm_ic = p_ic; 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! // options!
aco_save_T aco; aco_save_T aco;
aucmd_prepbuf(&aco, buf); 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); do_modelines(OPT_NOWIN);
aucmd_restbuf(&aco); aucmd_restbuf(&aco);
} }
@ -5588,7 +5586,7 @@ theend:
void ex_vimgrep(exarg_T *eap) void ex_vimgrep(exarg_T *eap)
{ {
char *au_name = vgr_get_auname(eap->cmdidx); 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)) { curbuf->b_fname, true, curbuf)) {
if (aborting()) { if (aborting()) {
return; return;
@ -5637,7 +5635,7 @@ void ex_vimgrep(exarg_T *eap)
unsigned save_qfid = qf_get_curlist(qi)->qf_id; unsigned save_qfid = qf_get_curlist(qi)->qf_id;
if (au_name != NULL) { 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 // The QuickFixCmdPost autocmd may free the quickfix list. Check the list
@ -6935,7 +6933,7 @@ void ex_cbuffer(exarg_T *eap)
linenr_T line2; linenr_T line2;
au_name = cbuffer_get_auname(eap->cmdidx); 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)) { curbuf->b_fname, true, curbuf)) {
if (aborting()) { if (aborting()) {
return; return;
@ -6975,8 +6973,7 @@ void ex_cbuffer(exarg_T *eap)
unsigned save_qfid = qf_get_curlist(qi)->qf_id; unsigned save_qfid = qf_get_curlist(qi)->qf_id;
if (au_name != NULL) { if (au_name != NULL) {
const buf_T *const curbuf_old = curbuf; const buf_T *const curbuf_old = curbuf;
apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name, apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, true, curbuf);
curbuf->b_fname, true, curbuf);
if (curbuf != curbuf_old) { if (curbuf != curbuf_old) {
// Autocommands changed buffer, don't jump now, "qi" may // Autocommands changed buffer, don't jump now, "qi" may
// be invalid. // be invalid.
@ -7023,7 +7020,7 @@ void ex_cexpr(exarg_T *eap)
win_T *wp = NULL; win_T *wp = NULL;
au_name = cexpr_get_auname(eap->cmdidx); 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)) { curbuf->b_fname, true, curbuf)) {
if (aborting()) { if (aborting()) {
return; return;
@ -7055,8 +7052,7 @@ void ex_cexpr(exarg_T *eap)
// check for autocommands changing the current quickfix list. // check for autocommands changing the current quickfix list.
unsigned save_qfid = qf_get_curlist(qi)->qf_id; unsigned save_qfid = qf_get_curlist(qi)->qf_id;
if (au_name != NULL) { if (au_name != NULL) {
apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name, apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, true, curbuf);
curbuf->b_fname, true, curbuf);
} }
// Jump to the first error for a new list and if autocmds didn't // Jump to the first error for a new list and if autocmds didn't
// free the list. // free the list.
@ -7220,7 +7216,7 @@ void ex_helpgrep(exarg_T *eap)
default: default:
break; 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)) { curbuf->b_fname, true, curbuf)) {
if (aborting()) { if (aborting()) {
return; return;
@ -7228,8 +7224,8 @@ void ex_helpgrep(exarg_T *eap)
} }
// Make 'cpoptions' empty, the 'l' flag should not be used here. // Make 'cpoptions' empty, the 'l' flag should not be used here.
char *const save_cpo = (char *)p_cpo; char *const save_cpo = p_cpo;
p_cpo = empty_option; p_cpo = (char *)empty_option;
if (is_loclist_cmd(eap->cmdidx)) { if (is_loclist_cmd(eap->cmdidx)) {
qi = hgr_get_ll(&new_qi); qi = hgr_get_ll(&new_qi);
@ -7240,7 +7236,7 @@ void ex_helpgrep(exarg_T *eap)
// Check for a specified language // Check for a specified language
char *const lang = check_help_lang(eap->arg); char *const lang = check_help_lang(eap->arg);
regmatch_T regmatch = { 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, .rm_ic = false,
}; };
if (regmatch.regprog != NULL) { if (regmatch.regprog != NULL) {
@ -7259,16 +7255,15 @@ void ex_helpgrep(exarg_T *eap)
qf_update_buffer(qi, NULL); qf_update_buffer(qi, NULL);
} }
if (p_cpo == empty_option) { if ((char_u *)p_cpo == empty_option) {
p_cpo = (char_u *)save_cpo; p_cpo = save_cpo;
} else { } else {
// Darn, some plugin changed the value. // Darn, some plugin changed the value.
free_string_option((char_u *)save_cpo); free_string_option((char_u *)save_cpo);
} }
if (au_name != NULL) { if (au_name != NULL) {
apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name, apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, true, curbuf);
curbuf->b_fname, true, curbuf);
// When adding a location list to an existing location list stack, // When adding a location list to an existing location list stack,
// if the autocmd made the stack invalid, then just return. // if the autocmd made the stack invalid, then just return.
if (!new_qi && IS_LL_STACK(qi) && qf_find_win_with_loclist(qi) == NULL) { if (!new_qi && IS_LL_STACK(qi) && qf_find_win_with_loclist(qi) == NULL) {

View File

@ -154,8 +154,8 @@ static char_u *reg_prev_sub = NULL;
* \u - Multibyte character code, eg \u20ac * \u - Multibyte character code, eg \u20ac
* \U - Long multibyte character code, eg \U12345678 * \U - Long multibyte character code, eg \U12345678
*/ */
static char_u REGEXP_INRANGE[] = "]^-n\\"; static char REGEXP_INRANGE[] = "]^-n\\";
static char_u REGEXP_ABBR[] = "nrtebdoxuU"; 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 FUNC_ATTR_ALWAYS_INLINE
{ {
if (!rex.reg_ic) { 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 // 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)) { } else if (ASCII_ISLOWER(c)) {
cc = TOUPPER_ASC(c); cc = TOUPPER_ASC(c);
} else { } else {
return vim_strchr(s, c); return (char_u *)vim_strchr((char *)s, c);
} }
char tofind[] = { (char)c, (char)cc, NUL }; 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; no = 0;
} else if ('0' <= *src && *src <= '9') { } else if ('0' <= *src && *src <= '9') {
no = *src++ - '0'; no = *src++ - '0';
} else if (vim_strchr((char_u *)"uUlLeE", *src)) { } else if (vim_strchr("uUlLeE", *src)) {
switch (*src++) { switch (*src++) {
case 'u': case 'u':
func_one = (fptr_T)do_upper; func_one = (fptr_T)do_upper;
@ -2285,10 +2285,10 @@ static char_u regname[][30] = {
* Use vim_regfree() to free the memory. * Use vim_regfree() to free the memory.
* Returns NULL for an error. * 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; regprog_T *prog = NULL;
char_u *expr = expr_arg; char_u *expr = (char_u *)expr_arg;
int save_called_emsg; int save_called_emsg;
regexp_engine = p_re; 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; p_re = BACKTRACKING_ENGINE;
vim_regfree(rmp->regprog); vim_regfree(rmp->regprog);
report_re_switch(pat); report_re_switch(pat);
rmp->regprog = vim_regcomp(pat, re_flags); rmp->regprog = vim_regcomp((char *)pat, re_flags);
if (rmp->regprog != NULL) { if (rmp->regprog != NULL) {
rmp->regprog->re_in_use = true; rmp->regprog->re_in_use = true;
result = rmp->regprog->engine->regexec_nl(rmp, line, col, nl); 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, // checking for \z misuse was already done when compiling for NFA,
// allow all here // allow all here
reg_do_extmatch = REX_ALL; reg_do_extmatch = REX_ALL;
rmp->regprog = vim_regcomp(pat, re_flags); rmp->regprog = vim_regcomp((char *)pat, re_flags);
reg_do_extmatch = 0; reg_do_extmatch = 0;
if (rmp->regprog == NULL) { if (rmp->regprog == NULL) {

View File

@ -1802,7 +1802,7 @@ static char_u *regatom(int *flagp)
case Magic('L'): case Magic('L'):
case Magic('u'): case Magic('u'):
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 (p == NULL) {
EMSG_RET_NULL(_("E63: invalid use of \\_")); 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 // This is used very often, esp. for ":global". Use two versions of
// the loop to avoid overhead of conditions. // the loop to avoid overhead of conditions.
if (!rex.reg_ic) { 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) { if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) {
break; // Found it. break; // Found it.
} }

View File

@ -1892,7 +1892,7 @@ static int nfa_regatom(void)
case Magic('L'): case Magic('L'):
case Magic('u'): case Magic('u'):
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 (p == NULL) {
if (extra == NFA_ADD_NL) { if (extra == NFA_ADD_NL) {
semsg(_(e_ill_char_class), (int64_t)c); semsg(_(e_ill_char_class), (int64_t)c);

View File

@ -650,7 +650,7 @@ bool conceal_cursor_line(const win_T *wp)
} else { } else {
return false; 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'. // 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 if (wp->w_p_cole > 0
&& (wp != curwin || lnum != wp->w_cursor.lnum || conceal_cursor_line(wp)) && (wp != curwin || lnum != wp->w_cursor.lnum || conceal_cursor_line(wp))
&& ((syntax_flags & HL_CONCEAL) != 0 || has_match_conc > 0 || decor_conceal > 0) && ((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; char_attr = conceal_attr;
if (((prev_syntax_id != syntax_seqnr && (syntax_flags & HL_CONCEAL) != 0) if (((prev_syntax_id != syntax_seqnr && (syntax_flags & HL_CONCEAL) != 0)
|| has_match_conc > 1 || decor_conceal > 1) || has_match_conc > 1 || decor_conceal > 1)
@ -6394,7 +6394,7 @@ void get_trans_bufname(buf_T *buf)
if (buf_spname(buf) != NULL) { if (buf_spname(buf) != NULL) {
STRLCPY(NameBuff, buf_spname(buf), MAXPATHL); STRLCPY(NameBuff, buf_spname(buf), MAXPATHL);
} else { } 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); trans_characters(NameBuff, MAXPATHL);
} }

View File

@ -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_ic = ignorecase(pat);
regmatch->rmm_maxcol = 0; 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) { if (regmatch->regprog == NULL) {
return FAIL; 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. * A line offset is not remembered, this is vi compatible.
*/ */
if (spats[0].off.line && vim_strchr(p_cpo, CPO_LINEOFF) != NULL) { 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; 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 // This is just guessing: when 'rightleft' is set, search for a matching
// paren/brace in the other direction. // 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; backwards = !backwards;
} }
@ -2092,7 +2092,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
} else if (raw_string) { } else if (raw_string) {
if (linep[pos.col - 1] == 'R' if (linep[pos.col - 1] == 'R'
&& linep[pos.col] == '"' && 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 // Possible start of raw string. Now that we have the
// delimiter we can check if it ends before where we // delimiter we can check if it ends before where we
// started searching, or before the previously found // 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) * (actually, we skip #\( et al)
*/ */
if (curbuf->b_p_lisp if (curbuf->b_p_lisp
&& vim_strchr((char_u *)"(){}[]", c) != NULL && vim_strchr("(){}[]", c) != NULL
&& pos.col > 1 && pos.col > 1
&& check_prevcol(linep, pos.col, '\\', NULL) && check_prevcol(linep, pos.col, '\\', NULL)
&& check_prevcol(linep, pos.col - 1, '#', 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 const char_u *p = line; // scan from start
// skip Lispish one-line comments // skip Lispish one-line comments
if (curbuf->b_p_lisp) { if (curbuf->b_p_lisp) {
if (vim_strchr(p, ';') != NULL) { // there may be comments if (vim_strchr((char *)p, ';') != NULL) { // there may be comments
bool in_str = false; // inside of string bool in_str = false; // inside of string
while ((p = (char_u *)strpbrk((char *)p, "\";")) != NULL) { while ((p = (char_u *)strpbrk((char *)p, "\";")) != NULL) {
@ -2346,7 +2346,7 @@ int check_linecomment(const char_u *line)
p = NULL; p = NULL;
} }
} else { } 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 *, // Accept a double /, unless it's preceded with * and followed by *,
// because * / / * is an end and start of a C comment. // because * / / * is an end and start of a C comment.
// Only accept the position if it is not inside a string. // 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 // go back to the previous non-white non-punctuation character
bool found_dot = false; bool found_dot = false;
while (c = gchar_pos(&pos), ascii_iswhite(c) while (c = gchar_pos(&pos), ascii_iswhite(c)
|| vim_strchr((char_u *)".!?)]\"'", c) != NULL) { || vim_strchr(".!?)]\"'", c) != NULL) {
tpos = pos; tpos = pos;
if (decl(&tpos) == -1 || (LINEEMPTY(tpos.lnum) && dir == FORWARD)) { if (decl(&tpos) == -1 || (LINEEMPTY(tpos.lnum) && dir == FORWARD)) {
break; break;
@ -2515,11 +2515,11 @@ int findsent(Direction dir, long count)
if (found_dot) { if (found_dot) {
break; break;
} }
if (vim_strchr((char_u *)".!?", c) != NULL) { if (vim_strchr(".!?", c) != NULL) {
found_dot = true; found_dot = true;
} }
if (vim_strchr((char_u *)")]\"'", c) != NULL if (vim_strchr(")]\"'", c) != NULL
&& vim_strchr((char_u *)".!?)]\"'", gchar_pos(&tpos)) == NULL) { && vim_strchr(".!?)]\"'", gchar_pos(&tpos)) == NULL) {
break; break;
} }
decl(&pos); decl(&pos);
@ -2543,7 +2543,7 @@ int findsent(Direction dir, long count)
if ((c = inc(&tpos)) == -1) { if ((c = inc(&tpos)) == -1) {
break; break;
} }
} while (vim_strchr((char_u *)")]\"'", c = gchar_pos(&tpos)) } while (vim_strchr(")]\"'", c = gchar_pos(&tpos))
!= NULL); != NULL);
if (c == -1 || (!cpo_J && (c == ' ' || c == '\t')) || c == NUL if (c == -1 || (!cpo_J && (c == ' ' || c == '\t')) || c == NUL
|| (cpo_J && (c == ' ' && inc(&tpos) >= 0 || (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 start_pos;
pos_T *end_pos; pos_T *end_pos;
pos_T old_start, old_end; pos_T old_start, old_end;
char_u *save_cpo; char *save_cpo;
bool sol = false; // '{' at start of line bool sol = false; // '{' at start of line
old_pos = curwin->w_cursor; 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 // Ignore quotes here. Keep the "M" flag in 'cpo', as that is what the
// user wants. // user wants.
save_cpo = p_cpo; 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) { if ((pos = findmatch(NULL, what)) != NULL) {
while (count-- > 0) { while (count-- > 0) {
if ((pos = findmatch(NULL, what)) == NULL) { 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]; c = line[col];
if (c == NUL) { if (c == NUL) {
return -1; return -1;
} else if (escape != NULL && vim_strchr(escape, c)) { } else if (escape != NULL && vim_strchr((char *)escape, c)) {
col++; col++;
if (line[col] == NUL) { if (line[col] == NUL) {
return -1; 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); col_start -= utf_head_off(line, line + col_start);
n = 0; n = 0;
if (escape != NULL) { 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) { line[col_start - n - 1]) != NULL) {
++n; ++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 *pat;
char_u *new_fname; 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; char_u *prev_fname = NULL;
linenr_T lnum; linenr_T lnum;
int depth; 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); sprintf((char *)pat, whole ? "\\<%.*s\\>" : "%.*s", (int)len, ptr);
// ignore case according to p_ic, p_scs and pat // ignore case according to p_ic, p_scs and pat
regmatch.rm_ic = ignorecase(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); xfree(pat);
if (regmatch.regprog == NULL) { if (regmatch.regprog == NULL) {
goto fpip_end; 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; inc_opt = (*curbuf->b_p_inc == NUL) ? p_inc : curbuf->b_p_inc;
if (*inc_opt != NUL) { 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) { if (incl_regmatch.regprog == NULL) {
goto fpip_end; 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)) { if (type == FIND_DEFINE && (*curbuf->b_p_def != NUL || *p_def != NUL)) {
def_regmatch.regprog = vim_regcomp(*curbuf->b_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) { if (def_regmatch.regprog == NULL) {
goto fpip_end; goto fpip_end;
} }
@ -5410,7 +5411,7 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo
for (;;) { for (;;) {
if (incl_regmatch.regprog != NULL if (incl_regmatch.regprog != NULL
&& vim_regexec(&incl_regmatch, line, (colnr_T)0)) { && 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; ? curbuf->b_ffname : curr_fname;
if (inc_opt != NULL && strstr((char *)inc_opt, "\\zs") != NULL) { 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, 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); dir, cont_s_ipos);
if (add_r == OK) { if (add_r == OK) {
// if dir was BACKWARD then honor it just once // if dir was BACKWARD then honor it just once
@ -5865,8 +5867,8 @@ exit_matched:
--old_files; --old_files;
files[old_files].name = files[depth].name; files[old_files].name = files[depth].name;
files[old_files].matched = files[depth].matched; files[old_files].matched = files[depth].matched;
--depth; depth--;
curr_fname = (depth == -1) ? curbuf->b_fname curr_fname = (depth == -1) ? (char_u *)curbuf->b_fname
: files[depth].name; : files[depth].name;
if (depth < depth_displayed) { if (depth < depth_displayed) {
depth_displayed = depth; depth_displayed = depth;

View File

@ -1815,7 +1815,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
p = skiptowhite(p); p = skiptowhite(p);
} while (*p != NUL); } while (*p != NUL);
p = vim_strchr(last, '='); p = (char_u *)vim_strchr((char *)last, '=');
// :sign define {name} {args}... {last}= // :sign define {name} {args}... {last}=
// | | // | |

View File

@ -1173,7 +1173,7 @@ static bool match_compoundrule(slang_T *slang, char_u *compflags)
} }
// Skip to the next "/", where the next pattern starts. // Skip to the next "/", where the next pattern starts.
p = vim_strchr(p, '/'); p = (char_u *)vim_strchr((char *)p, '/');
if (p == NULL) { if (p == NULL) {
break; break;
} }
@ -1637,7 +1637,7 @@ void spell_cat_line(char_u *buf, char_u *line, int maxlen)
int n; int n;
p = (char_u *)skipwhite((char *)line); 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); 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); r = do_in_runtimepath((char *)fname_enc, 0, spell_load_cb, &sl);
if (r == FAIL && *sl.sl_lang != NUL && round == 1 if (r == FAIL && *sl.sl_lang != NUL && round == 1
&& apply_autocmds(EVENT_SPELLFILEMISSING, lang, && apply_autocmds(EVENT_SPELLFILEMISSING, (char *)lang,
curbuf->b_fname, FALSE, curbuf)) { curbuf->b_fname, false, curbuf)) {
continue; continue;
} }
break; break;
@ -1961,14 +1961,14 @@ int init_syl_tab(slang_T *slang)
int l; int l;
ga_init(&slang->sl_syl_items, sizeof(syl_item_T), 4); 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) { while (p != NULL) {
*p++ = NUL; *p++ = NUL;
if (*p == NUL) { // trailing slash if (*p == NUL) { // trailing slash
break; break;
} }
s = p; s = p;
p = vim_strchr(p, '/'); p = (char_u *)vim_strchr((char *)p, '/');
if (p == NULL) { if (p == NULL) {
l = (int)STRLEN(s); l = (int)STRLEN(s);
} else { } 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? // No recognized syllable item, at least a syllable char then?
c = utf_ptr2char((char *)p); c = utf_ptr2char((char *)p);
len = utfc_ptr2len((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 skip = false; // No, search for next syllable
} else if (!skip) { } else if (!skip) {
++cnt; // Yes, count it ++cnt; // Yes, count it
@ -2105,7 +2105,7 @@ char *did_set_spelllang(win_T *wp)
filename = true; filename = true;
// Locate a region and remove it from the file name. // 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]) if (p != NULL && ASCII_ISALPHA(p[1]) && ASCII_ISALPHA(p[2])
&& !ASCII_ISALPHA(p[3])) { && !ASCII_ISALPHA(p[3])) {
STRLCPY(region_cp, p + 1, 3); STRLCPY(region_cp, p + 1, 3);
@ -2248,7 +2248,7 @@ char *did_set_spelllang(win_T *wp)
STRCPY(lang, "internal wordlist"); STRCPY(lang, "internal wordlist");
} else { } else {
STRLCPY(lang, path_tail((char *)spf_name), MAXWLEN + 1); STRLCPY(lang, path_tail((char *)spf_name), MAXWLEN + 1);
p = vim_strchr(lang, '.'); p = (char_u *)vim_strchr((char *)lang, '.');
if (p != NULL) { if (p != NULL) {
*p = NUL; // truncate at ".encoding.add" *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 if (c < 256
? wp->w_s->b_spell_ismw[c] ? wp->w_s->b_spell_ismw[c]
: (wp->w_s->b_spell_ismw_mb != NULL : (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; s = p + l;
} }
} }
@ -2730,9 +2730,10 @@ static bool spell_iswordp_w(const int *p, const win_T *wp)
{ {
const int *s; const int *s;
if (*p < 256 ? wp->w_s->b_spell_ismw[*p] if (*p <
: (wp->w_s->b_spell_ismw_mb != NULL 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)) { && vim_strchr((char *)wp->w_s->b_spell_ismw_mb,
*p) != NULL)) {
s = p + 1; s = p + 1;
} else { } else {
s = p; 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) { while (!vim_fgets(line, MAXWLEN * 2, fd) && !got_int) {
line_breakcheck(); line_breakcheck();
p = vim_strchr(line, '/'); p = (char_u *)vim_strchr((char *)line, '/');
if (p == NULL) { if (p == NULL) {
continue; // No Tab found, just skip the line. 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 // replace string
ws = smp[n].sm_to_w; ws = smp[n].sm_to_w;
s = smp[n].sm_rules; 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) { if (p0 == 1 && z == 0) {
// rule with '<' is used // rule with '<' is used
if (reslen > 0 && ws != NULL && *ws != NUL if (reslen > 0 && ws != NULL && *ws != NUL

View File

@ -1100,7 +1100,7 @@ static int read_prefcond_section(FILE *fd, slang_T *lp)
buf[0] = '^'; // always match at one position only buf[0] = '^'; // always match at one position only
SPELL_READ_NONNUL_BYTES(buf + 1, (size_t)n, fd,; ); SPELL_READ_NONNUL_BYTES(buf + 1, (size_t)n, fd,; );
buf[n + 1] = NUL; 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; return 0;
@ -1202,7 +1202,7 @@ static int read_sal_section(FILE *fd, slang_T *slang)
int i = 0; int i = 0;
for (; i < ccnt; ++i) { for (; i < ccnt; ++i) {
c = getc(fd); // <salfrom> c = getc(fd); // <salfrom>
if (vim_strchr((char_u *)"0123456789(-<^$", c) != NULL) { if (vim_strchr("0123456789(-<^$", c) != NULL) {
break; break;
} }
*p++ = c; *p++ = c;
@ -1466,7 +1466,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
} }
// Add all flags to "sl_compallflags". // 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)) { && !byte_in_str(slang->sl_compallflags, c)) {
*ap++ = c; *ap++ = c;
*ap = NUL; *ap = NUL;
@ -1521,7 +1521,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
*crp = NUL; *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); xfree(pat);
if (slang->sl_compprog == NULL) { if (slang->sl_compprog == NULL) {
return SP_FORMERROR; 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]); aff_entry->ae_add = getroom_save(spin, items[3]);
// Recognize flags on the affix: abcd/XYZ // 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) { if (aff_entry->ae_flags != NULL) {
*aff_entry->ae_flags++ = NUL; *aff_entry->ae_flags++ = NUL;
aff_process_flags(aff, aff_entry); aff_process_flags(aff, aff_entry);
@ -2484,8 +2484,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
} else { } else {
sprintf((char *)buf, "%s$", items[4]); sprintf((char *)buf, "%s$", items[4]);
} }
aff_entry->ae_prog = vim_regcomp(buf, aff_entry->ae_prog = vim_regcomp((char *)buf, RE_MAGIC + RE_STRING + RE_STRICT);
RE_MAGIC + RE_STRING + RE_STRICT);
if (aff_entry->ae_prog == NULL) { if (aff_entry->ae_prog == NULL) {
smsg(_("Broken condition in %s line %d: %s"), smsg(_("Broken condition in %s line %d: %s"),
fname, lnum, items[4]); fname, lnum, items[4]);
@ -2533,7 +2532,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
sprintf((char *)buf, "^%s", sprintf((char *)buf, "^%s",
aff_entry->ae_cond); aff_entry->ae_cond);
vim_regfree(aff_entry->ae_prog); 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) if ((!GA_EMPTY(&spin->si_map)
&& vim_strchr(spin->si_map.ga_data, c) && vim_strchr(spin->si_map.ga_data, c)
!= NULL) != NULL)
|| vim_strchr(p, c) != NULL) { || vim_strchr((char *)p, c) != NULL) {
smsg(_("Duplicate character in MAP in %s line %d"), smsg(_("Duplicate character in MAP in %s line %d"),
fname, lnum); fname, lnum);
} }
@ -2924,7 +2923,7 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compfla
tp = p + STRLEN(p); tp = p + STRLEN(p);
for (p = compflags; *p != NUL;) { for (p = compflags; *p != NUL;) {
if (vim_strchr((char_u *)"/?*+[]", *p) != NULL) { if (vim_strchr("/?*+[]", *p) != NULL) {
// Copy non-flag characters directly. // Copy non-flag characters directly.
*tp++ = *p++; *tp++ = *p++;
} else { } else {
@ -2947,7 +2946,7 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compfla
do { do {
check_renumber(spin); check_renumber(spin);
id = spin->si_newcompID--; id = spin->si_newcompID--;
} while (vim_strchr((char_u *)"/?*+[]\\-^", id) != NULL); } while (vim_strchr("/?*+[]\\-^", id) != NULL);
ci->ci_newID = id; ci->ci_newID = id;
hash_add(&aff->af_comp, ci->ci_key); 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) { switch (flagtype) {
case AFT_CHAR: case AFT_CHAR:
return vim_strchr(afflist, flag) != NULL; return vim_strchr((char *)afflist, flag) != NULL;
case AFT_CAPLONG: case AFT_CAPLONG:
case AFT_LONG: case AFT_LONG:
@ -3783,7 +3782,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
regionmask = spin->si_region; regionmask = spin->si_region;
// Check for flags and region after a slash. // Check for flags and region after a slash.
p = vim_strchr(line, '/'); p = (char_u *)vim_strchr((char *)line, '/');
if (p != NULL) { if (p != NULL) {
*p++ = NUL; *p++ = NUL;
while (*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) { if (incount <= 0) {
emsg(_(e_invarg)); // need at least output and input names 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")); emsg(_("E751: Output file name must not have region name"));
} else if (incount > MAXREGIONS) { } else if (incount > MAXREGIONS) {
semsg(_("E754: Only up to %d regions supported"), 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 // Find the end of the language name. Exclude the region. If there
// is a path separator remember the start of the tail. // is a path separator remember the start of the tail.
for (lend = curwin->w_s->b_p_spl; *lend != NUL 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)) { if (vim_ispathsep(*lend)) {
aspath = true; aspath = true;
lstart = lend + 1; lstart = lend + 1;
@ -5878,9 +5877,9 @@ static void set_map_str(slang_T *lp, char_u *map)
hashitem_T *hi; hashitem_T *hi;
b = xmalloc(cl + headcl + 2); b = xmalloc(cl + headcl + 2);
utf_char2bytes(c, (char *)b); utf_char2bytes(c, b);
b[cl] = NUL; b[cl] = NUL;
utf_char2bytes(headc, (char *)b + cl + 1); utf_char2bytes(headc, b + cl + 1);
b[cl + 1 + headcl] = NUL; b[cl + 1 + headcl] = NUL;
hash = hash_hash((char_u *)b); hash = hash_hash((char_u *)b);
hi = hash_lookup(&lp->sl_map_hash, (const char *)b, STRLEN(b), hash); hi = hash_lookup(&lp->sl_map_hash, (const char *)b, STRLEN(b), hash);

View File

@ -233,7 +233,7 @@ void may_trigger_modechanged(void)
} }
char curr_mode[MODE_MAX_LENGTH]; 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); get_mode(curr_mode);
if (STRCMP(curr_mode, last_mode) == 0) { if (STRCMP(curr_mode, last_mode) == 0) {
@ -247,7 +247,7 @@ void may_trigger_modechanged(void)
tv_dict_set_keys_readonly(v_event); tv_dict_set_keys_readonly(v_event);
// concatenate modes in format "old_mode:new_mode" // 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); apply_autocmds(EVENT_MODECHANGED, pattern_buf, NULL, false, curbuf);
STRCPY(last_mode, curr_mode); STRCPY(last_mode, curr_mode);

View File

@ -104,8 +104,8 @@ char_u *vim_strsave_escaped_ext(const char_u *string, const char_u *esc_chars, c
p += l - 1; p += l - 1;
continue; continue;
} }
if (vim_strchr(esc_chars, *p) != NULL || (bsl && rem_backslash(p))) { if (vim_strchr((char *)esc_chars, *p) != NULL || (bsl && rem_backslash(p))) {
++length; // count a backslash length++; // count a backslash
} }
++length; // count an ordinary char ++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 p += l - 1; // skip multibyte char
continue; 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++ = cc;
} }
*p2++ = *p; *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 /// @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 /// if it was not found or character is invalid. NUL character is never
/// found, use `strlen()` instead. /// 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 FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{ {
if (c <= 0) { if (c <= 0) {
return NULL; return NULL;
} else if (c < 0x80) { } else if (c < 0x80) {
return (char_u *)strchr((const char *)string, c); return strchr(string, c);
} else { } else {
char u8char[MB_MAXBYTES + 1]; char u8char[MB_MAXBYTES + 1];
const int len = utf_char2bytes(c, u8char); const int len = utf_char2bytes(c, u8char);
u8char[len] = NUL; 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') { if (fmt_spec == 'f' || fmt_spec == 'F') {
tp = tmp + str_arg_l - 1; tp = tmp + str_arg_l - 1;
} else { } else {
tp = (char *)vim_strchr((char_u *)tmp, tp = vim_strchr(tmp, fmt_spec == 'e' ? 'e' : 'E');
fmt_spec == 'e' ? 'e' : 'E');
if (tp) { if (tp) {
// remove superfluous '+' and leading zeroes from exponent // remove superfluous '+' and leading zeroes from exponent
if (tp[1] == '+') { 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 { } else {
// Be consistent: some printf("%e") use 1.0e+12 and some // Be consistent: some printf("%e") use 1.0e+12 and some
// 1.0e+012; remove one zero in the last case. // 1.0e+012; remove one zero in the last case.
char *tp = (char *)vim_strchr((char_u *)tmp, char *tp = vim_strchr(tmp, fmt_spec == 'e' ? 'e' : 'E');
fmt_spec == 'e' ? 'e' : 'E');
if (tp && (tp[1] == '+' || tp[1] == '-') && tp[2] == '0' if (tp && (tp[1] == '+' || tp[1] == '-') && tp[2] == '0'
&& ascii_isdigit(tp[3]) && ascii_isdigit(tp[4])) { && ascii_isdigit(tp[3]) && ascii_isdigit(tp[4])) {
STRMOVE(tp + 2, tp + 3); STRMOVE(tp + 2, tp + 3);

View File

@ -3807,7 +3807,7 @@ static void put_pattern(const char *const s, const int c, const synpat_T *const
msg_putchar(c); msg_putchar(c);
// output the pattern, in between a char that is not in the pattern // 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) { if (sepchars[++i] == NUL) {
i = 0; // no good char found, just use the first one i = 0; // no good char found, just use the first one
break; break;
@ -4393,7 +4393,7 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing)
// 2: Add an entry for each keyword. // 2: Add an entry for each keyword.
for (kw = keyword_copy; --cnt >= 0; kw += STRLEN(kw) + 1) { 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) { if (p != NULL) {
*p = NUL; *p = NUL;
} }
@ -5075,7 +5075,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
char_u *end; char_u *end;
int *p; int *p;
int idx; int idx;
char_u *cpo_save; char *cpo_save;
// need at least three chars // need at least three chars
if (arg == NULL || arg[0] == NUL || arg[1] == NUL || arg[2] == NUL) { 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 // Make 'cpoptions' empty, to avoid the 'l' flag
cpo_save = p_cpo; cpo_save = p_cpo;
p_cpo = (char_u *)""; p_cpo = "";
ci->sp_prog = vim_regcomp(ci->sp_pattern, RE_MAGIC); ci->sp_prog = vim_regcomp((char *)ci->sp_pattern, RE_MAGIC);
p_cpo = cpo_save; p_cpo = cpo_save;
if (ci->sp_prog == NULL) { if (ci->sp_prog == NULL) {
@ -5174,7 +5174,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
int illegal = FALSE; int illegal = FALSE;
int finished = FALSE; int finished = FALSE;
long n; long n;
char_u *cpo_save; char *cpo_save;
if (ends_excmd(*arg_start)) { if (ends_excmd(*arg_start)) {
syn_cmd_list(eap, TRUE); 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 // Make 'cpoptions' empty, to avoid the 'l' flag
cpo_save = p_cpo; cpo_save = p_cpo;
p_cpo = (char_u *)""; p_cpo = "";
curwin->w_s->b_syn_linecont_prog = 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; p_cpo = cpo_save;
syn_clear_time(&curwin->w_s->b_syn_linecont_time); 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; int count = 0;
do { do {
for (end = p; *end && !ascii_iswhite(*end) && *end != ','; end++) {} 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); STRLCPY(name + 1, p, end - p + 1);
if (STRCMP(name + 1, "ALLBUT") == 0 if (STRCMP(name + 1, "ALLBUT") == 0
|| STRCMP(name + 1, "ALL") == 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) { if (skip) {
id = -1; id = -1;
} else { } else {
id = syn_check_cluster(name + 2, (int)(end - p - 1)); id = syn_check_cluster((char_u *)name + 2, (int)(end - p - 1));
} }
} else { } else {
/* /*
* Handle full group name. * Handle full group name.
*/ */
if (strpbrk((char *)name + 1, "\\.*^$~[") == NULL) { if (strpbrk(name + 1, "\\.*^$~[") == NULL) {
id = syn_check_group((char *)(name + 1), (int)(end - p)); id = syn_check_group((name + 1), (int)(end - p));
} else { } else {
// Handle match of regexp with group names. // Handle match of regexp with group names.
*name = '^'; *name = '^';
@ -5669,7 +5669,7 @@ void ex_ownsyntax(exarg_T *eap)
} }
// Apply the "syntax" autocommand event, this finds and loads the syntax file. // 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. // Move value of b:current_syntax to w:current_syntax.
new_value = get_var_value("b:current_syntax"); new_value = get_var_value("b:current_syntax");

View File

@ -1108,10 +1108,8 @@ static void prepare_pats(pat_T *pats, int has_re)
if (pats->head == pats->pat) { if (pats->head == pats->pat) {
pats->headlen = 0; pats->headlen = 0;
} else { } else {
for (pats->headlen = 0; pats->head[pats->headlen] != NUL; for (pats->headlen = 0; pats->head[pats->headlen] != NUL; pats->headlen++) {
++pats->headlen) { if (vim_strchr((p_magic ? ".[~*\\$" : "\\$"), pats->head[pats->headlen]) != NULL) {
if (vim_strchr((char_u *)(p_magic ? ".[~*\\$" : "\\$"),
pats->head[pats->headlen]) != NULL) {
break; break;
} }
} }
@ -1122,7 +1120,7 @@ static void prepare_pats(pat_T *pats, int has_re)
} }
if (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 { } else {
pats->regmatch.regprog = NULL; 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) { if (STRNICMP(s, help_lang, 2) == 0) {
break; break;
} }
++help_pri; help_pri++;
if ((s = vim_strchr(s, ',')) == NULL) { if ((s = (char_u *)vim_strchr((char *)s, ',')) == NULL) {
break; break;
} }
} }
@ -1864,7 +1862,7 @@ parse_line:
// This speeds up tag searching a lot! // This speeds up tag searching a lot!
if (orgpat.headlen) { if (orgpat.headlen) {
tagp.tagname = lbuf; 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) { if (tagp.tagname_end == NULL) {
// Corrupted tag line. // Corrupted tag line.
line_error = true; line_error = true;
@ -1982,7 +1980,7 @@ parse_line:
// Can be a matching tag, isolate the file name and command. // Can be a matching tag, isolate the file name and command.
tagp.fname = tagp.tagname_end + 1; 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; tagp.command = tagp.fname_end + 1;
if (tagp.fname_end == NULL) { if (tagp.fname_end == NULL) {
i = FAIL; 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 // Isolate the tagname, from lbuf up to the first white
tagp->tagname = lbuf; tagp->tagname = lbuf;
p = vim_strchr(lbuf, TAB); p = (char_u *)vim_strchr((char *)lbuf, TAB);
if (p == NULL) { if (p == NULL) {
return FAIL; return FAIL;
} }
@ -2484,7 +2482,7 @@ static int parse_tag_line(char_u *lbuf, tagptrs_T *tagp)
++p; ++p;
} }
tagp->fname = p; tagp->fname = p;
p = vim_strchr(p, TAB); p = (char_u *)vim_strchr((char *)p, TAB);
if (p == NULL) { if (p == NULL) {
return FAIL; return FAIL;
} }
@ -2522,8 +2520,8 @@ static bool test_for_static(tagptrs_T *tagp)
// Check for new style static tag ":...<Tab>file:[<Tab>...]" // Check for new style static tag ":...<Tab>file:[<Tab>...]"
p = tagp->command; p = tagp->command;
while ((p = vim_strchr(p, '\t')) != NULL) { while ((p = (char_u *)vim_strchr((char *)p, '\t')) != NULL) {
++p; p++;
if (STRNCMP(p, "file:", 5) == 0) { if (STRNCMP(p, "file:", 5) == 0) {
return TRUE; return TRUE;
} }
@ -2595,8 +2593,8 @@ static int parse_match(char_u *lbuf, tagptrs_T *tagp)
break; break;
} }
pc = vim_strchr(p, ':'); pc = (char_u *)vim_strchr((char *)p, ':');
pt = vim_strchr(p, '\t'); pt = (char_u *)vim_strchr((char *)p, '\t');
if (pc == NULL || (pt != NULL && pc > pt)) { if (pc == NULL || (pt != NULL && pc > pt)) {
tagp->tagkind = p; tagp->tagkind = p;
} }

View File

@ -344,7 +344,7 @@ void vim_beep(unsigned val)
// When 'debug' contains "beep" produce a message. If we are sourcing // 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 // a script or executing a function give the user a hint where the beep
// comes from. // comes from.
if (vim_strchr(p_debug, 'e') != NULL) { if (vim_strchr((char *)p_debug, 'e') != NULL) {
msg_source(HL_ATTR(HLF_W)); msg_source(HL_ATTR(HLF_W));
msg_attr(_("Beep!"), 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++) { for (char_u *p = p_mouse; *p; p++) {
switch (*p) { switch (*p) {
case 'a': case 'a':
if (vim_strchr((char_u *)MOUSE_A, checkfor) != NULL) { if (vim_strchr(MOUSE_A, checkfor) != NULL) {
has_mouse = true; has_mouse = true;
return; return;
} }

View File

@ -2201,8 +2201,8 @@ void maybe_intro_message(void)
if (buf_is_empty(curbuf) if (buf_is_empty(curbuf)
&& (curbuf->b_fname == NULL) && (curbuf->b_fname == NULL)
&& (firstwin->w_next == NULL) && (firstwin->w_next == NULL)
&& (vim_strchr(p_shm, SHM_INTRO) == NULL)) { && (vim_strchr((char *)p_shm, SHM_INTRO) == NULL)) {
intro_message(FALSE); intro_message(false);
} }
} }

View File

@ -2916,8 +2916,8 @@ static void do_autocmd_winclosed(win_T *win)
return; return;
} }
recursive = true; recursive = true;
char_u winid[NUMBUFLEN]; char winid[NUMBUFLEN];
vim_snprintf((char *)winid, sizeof(winid), "%d", win->handle); vim_snprintf(winid, sizeof(winid), "%d", win->handle);
apply_autocmds(EVENT_WINCLOSED, winid, winid, false, win->w_buffer); apply_autocmds(EVENT_WINCLOSED, winid, winid, false, win->w_buffer);
recursive = false; 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. // When closing the last window in a tab page remove the tab page.
if (tp->tp_firstwin == tp->tp_lastwin) { if (tp->tp_firstwin == tp->tp_lastwin) {
char_u prev_idx[NUMBUFLEN]; char prev_idx[NUMBUFLEN];
if (has_event(EVENT_TABCLOSED)) { 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) { 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_WINNEW, NULL, NULL, false, curbuf);
apply_autocmds(EVENT_WINENTER, 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); apply_autocmds(EVENT_TABENTER, NULL, NULL, false, curbuf);
return OK; return OK;
@ -4890,7 +4890,7 @@ void fix_current_dir(void)
// (unless that was done already) and change to the local directory. // (unless that was done already) and change to the local directory.
if (globaldir == NULL) { if (globaldir == NULL) {
if (cwd[0] != NUL) { if (cwd[0] != NUL) {
globaldir = (char_u *)xstrdup(cwd); globaldir = xstrdup(cwd);
} }
} }
bool dir_differs = pathcmp(new_dir, cwd, -1) != 0; bool dir_differs = pathcmp(new_dir, cwd, -1) != 0;
@ -4909,13 +4909,13 @@ void fix_current_dir(void)
} else if (globaldir != NULL) { } else if (globaldir != NULL) {
// Window doesn't have a local directory and we are not in the global // Window doesn't have a local directory and we are not in the global
// directory: Change to the global directory. // 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) { 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) { if (!p_acd && dir_differs) {
do_autocmd_dirchanged((char *)globaldir, kCdScopeGlobal, kCdCauseWindow, false); do_autocmd_dirchanged(globaldir, kCdScopeGlobal, kCdCauseWindow, false);
} }
} }
XFREE_CLEAR(globaldir); XFREE_CLEAR(globaldir);
@ -5317,8 +5317,8 @@ void may_trigger_winscrolled(void)
|| wp->w_last_leftcol != wp->w_leftcol || wp->w_last_leftcol != wp->w_leftcol
|| wp->w_last_width != wp->w_width || wp->w_last_width != wp->w_width
|| wp->w_last_height != wp->w_height) { || wp->w_last_height != wp->w_height) {
char_u winid[NUMBUFLEN]; char winid[NUMBUFLEN];
vim_snprintf((char *)winid, sizeof(winid), "%d", wp->handle); vim_snprintf(winid, sizeof(winid), "%d", wp->handle);
recursive = true; recursive = true;
apply_autocmds(EVENT_WINSCROLLED, winid, winid, false, wp->w_buffer); 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; len = 0;
while (vim_isfilec(ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ') while (vim_isfilec(ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ')
|| ((options & FNAME_HYP) && path_is_url(ptr + len)) || ((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 // After type:// we also include :, ?, & and = as valid characters, so that
// http://google.com:8080?q=this&that=ok works. // http://google.com:8080?q=this&that=ok works.
if ((ptr[len] >= 'A' && ptr[len] <= 'Z') 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. * If there is trailing punctuation, remove it.
* But don't remove "..", could be a directory name. * 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] != '.') { && ptr[len - 2] != '.') {
--len; --len;
} }