diff options
53 files changed, 531 insertions, 569 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 75666c600c..d51079b515 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -1679,7 +1679,7 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force } else if (fname != NULL && !ends_excmd(*fname)) { autocmd_fname = fname; } else if (buf != NULL) { - autocmd_fname = (char *)buf->b_ffname; + autocmd_fname = buf->b_ffname; } else { autocmd_fname = NULL; } @@ -1711,9 +1711,9 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force fname = (char *)buf->b_p_ft; } else { if (buf->b_sfname != NULL) { - sfname = (char *)vim_strsave(buf->b_sfname); + sfname = xstrdup(buf->b_sfname); } - fname = (char *)buf->b_ffname; + fname = buf->b_ffname; } } if (fname == NULL) { diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index a2ecb69ac0..7bdb905dfa 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -113,7 +113,7 @@ static int read_buffer(int read_stdin, exarg_T *eap, int flags) // the end. This makes it possible to retry when 'fileformat' or // 'fileencoding' was guessed wrong. line_count = curbuf->b_ml.ml_line_count; - retval = readfile(read_stdin ? NULL : (char *)curbuf->b_ffname, + retval = readfile(read_stdin ? NULL : curbuf->b_ffname, read_stdin ? NULL : curbuf->b_fname, line_count, (linenr_T)0, (linenr_T)MAXLNUM, eap, flags | READ_BUFFER, silent); @@ -231,7 +231,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags) } #endif - retval = readfile((char *)curbuf->b_ffname, curbuf->b_fname, + retval = readfile(curbuf->b_ffname, curbuf->b_fname, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, eap, flags | READ_NEW | (read_fifo ? READ_FIFO : 0), silent); #ifdef UNIX @@ -803,8 +803,7 @@ static void free_buffer_stuff(buf_T *buf, int free_flags) // Avoid losing b:changedtick when deleting buffer: clearing variables // implies using clear_tv() on b:changedtick and that sets changedtick to // zero. - hashitem_T *const changedtick_hi = hash_find(&buf->b_vars->dv_hashtab, - (const char_u *)"changedtick"); + hashitem_T *const changedtick_hi = hash_find(&buf->b_vars->dv_hashtab, "changedtick"); assert(changedtick_hi != NULL); hash_remove(&buf->b_vars->dv_hashtab, changedtick_hi); } @@ -814,7 +813,7 @@ static void free_buffer_stuff(buf_T *buf, int free_flags) buf_init_changedtick(buf); } uc_clear(&buf->b_ucmds); // clear local user commands - buf_delete_signs(buf, (char_u *)"*"); // delete any signs + buf_delete_signs(buf, "*"); // delete any signs extmark_free_all(buf); // delete any extmarks map_clear_mode(buf, MAP_ALL_MODES, true, false); // clear local mappings map_clear_mode(buf, MAP_ALL_MODES, true, true); // clear local abbrevs @@ -943,7 +942,7 @@ void handle_swap_exists(bufref_T *old_curbuf) /// @param end_bnr buffer nr or last buffer nr in a range /// /// @return error message or NULL -char *do_bufdel(int command, char_u *arg, int addr_count, int start_bnr, int end_bnr, int forceit) +char *do_bufdel(int command, char *arg, int addr_count, int start_bnr, int end_bnr, int forceit) { int do_current = 0; // delete current buffer? int deleted = 0; // number of buffers deleted @@ -981,17 +980,17 @@ char *do_bufdel(int command, char_u *arg, int addr_count, int start_bnr, int end break; } } else { // addr_count == 1 - arg = (char_u *)skipwhite((char *)arg); + arg = skipwhite(arg); if (*arg == NUL) { break; } if (!ascii_isdigit(*arg)) { - p = (char *)skiptowhite_esc(arg); - bnr = buflist_findpat(arg, (char_u *)p, command == DOBUF_WIPE, false, false); + p = skiptowhite_esc(arg); + bnr = buflist_findpat(arg, p, command == DOBUF_WIPE, false, false); if (bnr < 0) { // failed break; } - arg = (char_u *)p; + arg = p; } else { bnr = getdigits_int(&arg, false, 0); } @@ -1677,10 +1676,10 @@ static inline void buf_init_changedtick(buf_T *const buf) /// @param bufnr /// /// @return pointer to the buffer -buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int flags) +buf_T *buflist_new(char *ffname_arg, char *sfname_arg, linenr_T lnum, int flags) { - char *ffname = (char *)ffname_arg; - char *sfname = (char *)sfname_arg; + char *ffname = ffname_arg; + char *sfname = sfname_arg; buf_T *buf; fname_expand(curbuf, &ffname, &sfname); // will allocate ffname @@ -1747,8 +1746,8 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int fl } if (ffname != NULL) { - buf->b_ffname = (char_u *)ffname; - buf->b_sfname = vim_strsave((char_u *)sfname); + buf->b_ffname = ffname; + buf->b_sfname = xstrdup(sfname); } clear_wininfo(buf); @@ -1797,7 +1796,7 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int fl hash_init(&buf->b_s.b_keywtab); hash_init(&buf->b_s.b_keywtab_ic); - buf->b_fname = (char *)buf->b_sfname; + buf->b_fname = buf->b_sfname; if (!file_id_valid) { buf->file_id_valid = false; } else { @@ -2047,13 +2046,13 @@ void buflist_getfpos(void) /// Find file in buffer list by name (it has to be for the current window). /// /// @return buffer or NULL if not found -buf_T *buflist_findname_exp(char_u *fname) +buf_T *buflist_findname_exp(char *fname) { char *ffname; buf_T *buf = NULL; // First make the name into a full path name - ffname = FullName_save((char *)fname, + ffname = FullName_save(fname, #ifdef UNIX // force expansion, get rid of symbolic links true @@ -2062,7 +2061,7 @@ buf_T *buflist_findname_exp(char_u *fname) #endif ); // NOLINT(whitespace/parens) if (ffname != NULL) { - buf = buflist_findname((char_u *)ffname); + buf = buflist_findname(ffname); xfree(ffname); } return buf; @@ -2073,11 +2072,11 @@ buf_T *buflist_findname_exp(char_u *fname) /// Skips dummy buffers. /// /// @return buffer or NULL if not found -buf_T *buflist_findname(char_u *ffname) +buf_T *buflist_findname(char *ffname) { FileID file_id; - bool file_id_valid = os_fileid((char *)ffname, &file_id); - return buflist_findname_file_id((char *)ffname, &file_id, file_id_valid); + bool file_id_valid = os_fileid(ffname, &file_id); + return buflist_findname_file_id(ffname, &file_id, file_id_valid); } /// Same as buflist_findname(), but pass the FileID structure to avoid @@ -2105,7 +2104,7 @@ static buf_T *buflist_findname_file_id(char *ffname, FileID *file_id, bool file_ /// @param curtab_only find buffers in current tab only /// /// @return fnum of the found buffer or < 0 for error. -int buflist_findpat(const char_u *pattern, const char_u *pattern_end, bool unlisted, bool diffmode, +int buflist_findpat(const char *pattern, const char *pattern_end, bool unlisted, bool diffmode, bool curtab_only) FUNC_ATTR_NONNULL_ARG(1) { @@ -2236,7 +2235,7 @@ static int buf_time_compare(const void *s1, const void *s2) /// For command line expansion of ":buf" and ":sbuf". /// /// @return OK if matches found, FAIL otherwise. -int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options) +int ExpandBufnames(char *pat, int *num_file, char ***file, int options) { int count = 0; int round; @@ -2258,20 +2257,20 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options) STRCPY(patc, "\\(^\\|[\\/]\\)"); STRCPY(patc + 11, pat + 1); } else { - patc = (char *)pat; + patc = pat; } // attempt == 0: try match with '\<', match at start of word // attempt == 1: try match without '\<', match anywhere for (attempt = 0; attempt <= 1; attempt++) { - if (attempt > 0 && (char_u *)patc == pat) { + if (attempt > 0 && patc == pat) { break; // there was no anchor, no need to try again } regmatch_T regmatch; regmatch.regprog = vim_regcomp(patc + attempt * 11, RE_MAGIC); if (regmatch.regprog == NULL) { - if ((char_u *)patc != pat) { + if (patc != pat) { xfree(patc); } return FAIL; @@ -2298,7 +2297,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options) count++; } else { if (options & WILD_HOME_REPLACE) { - p = (char *)home_replace_save(buf, (char_u *)p); + p = home_replace_save(buf, p); } else { p = xstrdup(p); } @@ -2307,7 +2306,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options) matches[count].match = p; count++; } else { - (*file)[count++] = (char_u *)p; + (*file)[count++] = p; } } } @@ -2329,7 +2328,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options) } } - if ((char_u *)patc != pat) { + if (patc != pat) { xfree(patc); } @@ -2341,12 +2340,12 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options) // if the current buffer is first in the list, place it at the end if (matches[0].buf == curbuf) { for (int i = 1; i < count; i++) { - (*file)[i - 1] = (char_u *)matches[i].match; + (*file)[i - 1] = matches[i].match; } - (*file)[count - 1] = (char_u *)matches[0].match; + (*file)[count - 1] = matches[0].match; } else { for (int i = 0; i < count; i++) { - (*file)[i] = (char_u *)matches[i].match; + (*file)[i] = matches[i].match; } } xfree(matches); @@ -2362,9 +2361,9 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options) static char *buflist_match(regmatch_T *rmp, buf_T *buf, bool ignore_case) { // First try the short file name, then the long file name. - char *match = fname_match(rmp, (char *)buf->b_sfname, ignore_case); + char *match = fname_match(rmp, buf->b_sfname, ignore_case); if (match == NULL && rmp->regprog != NULL) { - match = fname_match(rmp, (char *)buf->b_ffname, ignore_case); + match = fname_match(rmp, buf->b_ffname, ignore_case); } return match; } @@ -2382,12 +2381,12 @@ static char *fname_match(regmatch_T *rmp, char *name, bool ignore_case) if (name != NULL) { // Ignore case when 'fileignorecase' or the argument is set. rmp->rm_ic = p_fic || ignore_case; - if (vim_regexec(rmp, (char_u *)name, (colnr_T)0)) { + if (vim_regexec(rmp, name, (colnr_T)0)) { match = name; } else if (rmp->regprog != NULL) { // Replace $(HOME) with '~' and try matching again. - p = (char *)home_replace_save(NULL, (char_u *)name); - if (vim_regexec(rmp, (char_u *)p, (colnr_T)0)) { + p = home_replace_save(NULL, name); + if (vim_regexec(rmp, p, (colnr_T)0)) { match = name; } xfree(p); @@ -2414,16 +2413,14 @@ buf_T *buflist_findnr(int nr) /// @param helptail for help buffers return tail only /// /// @return a pointer to allocated memory, of NULL when failed. -char_u *buflist_nr2name(int n, int fullname, int helptail) +char *buflist_nr2name(int n, int fullname, int helptail) { - buf_T *buf; - - buf = buflist_findnr(n); + buf_T *buf = buflist_findnr(n); if (buf == NULL) { return NULL; } return home_replace_save(helptail ? buf : NULL, - fullname ? buf->b_ffname : (char_u *)buf->b_fname); + fullname ? buf->b_ffname : buf->b_fname); } /// Set the line and column numbers for the given buffer and window @@ -2719,16 +2716,14 @@ void buflist_list(exarg_T *eap) /// Used by insert_reg() and cmdline_paste() for '#' register. /// /// @return FAIL if not found, OK for success. -int buflist_name_nr(int fnum, char_u **fname, linenr_T *lnum) +int buflist_name_nr(int fnum, char **fname, linenr_T *lnum) { - buf_T *buf; - - buf = buflist_findnr(fnum); + buf_T *buf = buflist_findnr(fnum); if (buf == NULL || buf->b_fname == NULL) { return FAIL; } - *fname = (char_u *)buf->b_fname; + *fname = buf->b_fname; *lnum = buflist_findlnum(buf); return OK; @@ -2783,16 +2778,16 @@ int setfname(buf_T *buf, char *ffname_arg, char *sfname_arg, bool message) } sfname = xstrdup(sfname); #ifdef USE_FNAME_CASE - path_fix_case((char_u *)sfname); // set correct case for short file name + path_fix_case(sfname); // set correct case for short file name #endif if (buf->b_sfname != buf->b_ffname) { xfree(buf->b_sfname); } xfree(buf->b_ffname); - buf->b_ffname = (char_u *)ffname; - buf->b_sfname = (char_u *)sfname; + buf->b_ffname = ffname; + buf->b_sfname = sfname; } - buf->b_fname = (char *)buf->b_sfname; + buf->b_fname = buf->b_sfname; if (!file_id_valid) { buf->file_id_valid = false; } else { @@ -2806,22 +2801,20 @@ int setfname(buf_T *buf, char *ffname_arg, char *sfname_arg, bool message) /// Crude way of changing the name of a buffer. Use with care! /// The name should be relative to the current directory. -void buf_set_name(int fnum, char_u *name) +void buf_set_name(int fnum, char *name) { - buf_T *buf; - - buf = buflist_findnr(fnum); + buf_T *buf = buflist_findnr(fnum); if (buf != NULL) { if (buf->b_sfname != buf->b_ffname) { xfree(buf->b_sfname); } xfree(buf->b_ffname); - buf->b_ffname = vim_strsave(name); + buf->b_ffname = xstrdup(name); buf->b_sfname = NULL; // Allocate ffname and expand into full path. Also resolves .lnk // files on Win32. - fname_expand(buf, (char **)&buf->b_ffname, (char **)&buf->b_sfname); - buf->b_fname = (char *)buf->b_sfname; + fname_expand(buf, &buf->b_ffname, &buf->b_sfname); + buf->b_fname = buf->b_sfname; } } @@ -2847,12 +2840,10 @@ void buf_name_changed(buf_T *buf) /// Used by do_one_cmd(), do_write() and do_ecmd(). /// /// @return the buffer. -buf_T *setaltfname(char_u *ffname, char_u *sfname, linenr_T lnum) +buf_T *setaltfname(char *ffname, char *sfname, linenr_T lnum) { - buf_T *buf; - // Create a buffer. 'buflisted' is not set if it's a new buffer - buf = buflist_new(ffname, sfname, lnum, 0); + buf_T *buf = buflist_new(ffname, sfname, lnum, 0); if (buf != NULL && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) { curwin->w_alt_fnum = buf->b_fnum; } @@ -2863,29 +2854,27 @@ buf_T *setaltfname(char_u *ffname, char_u *sfname, linenr_T lnum) /// Return NULL if there isn't any, and give error message if requested. /// /// @param errmsg give error message -char_u *getaltfname(bool errmsg) +char *getaltfname(bool errmsg) { char *fname; linenr_T dummy; - if (buflist_name_nr(0, (char_u **)&fname, &dummy) == FAIL) { + if (buflist_name_nr(0, &fname, &dummy) == FAIL) { if (errmsg) { emsg(_(e_noalt)); } return NULL; } - return (char_u *)fname; + return fname; } /// Add a file name to the buflist and return its number. /// Uses same flags as buflist_new(), except BLN_DUMMY. /// /// Used by qf_init(), main() and doarglist() -int buflist_add(char_u *fname, int flags) +int buflist_add(char *fname, int flags) { - buf_T *buf; - - buf = buflist_new(fname, NULL, (linenr_T)0, flags); + buf_T *buf = buflist_new(fname, NULL, (linenr_T)0, flags); if (buf != NULL) { return buf->b_fnum; } @@ -2919,10 +2908,10 @@ void buflist_altfpos(win_T *win) /// Fname must have a full path (expanded by path_to_absolute()). /// /// @param ffname full path name to check -bool otherfile(char_u *ffname) +bool otherfile(char *ffname) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - return otherfile_buf(curbuf, (char *)ffname, NULL, false); + return otherfile_buf(curbuf, ffname, NULL, false); } /// Check that "ffname" is not the same file as the file loaded in "buf". @@ -3023,7 +3012,7 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate) if (!fullname && curbuf->b_fname != NULL) { name = curbuf->b_fname; } else { - name = (char *)curbuf->b_ffname; + name = curbuf->b_ffname; } home_replace(shorthelp ? curbuf : NULL, name, p, (size_t)(IOSIZE - (p - buffer)), true); @@ -3071,7 +3060,7 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate) n); validate_virtcol(); len = STRLEN(buffer); - col_print((char_u *)buffer + len, IOSIZE - len, + col_print(buffer + len, IOSIZE - len, (int)curwin->w_cursor.col + 1, (int)curwin->w_virtcol + 1); } @@ -3100,12 +3089,12 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate) xfree(buffer); } -void col_print(char_u *buf, size_t buflen, int col, int vcol) +void col_print(char *buf, size_t buflen, int col, int vcol) { if (col == vcol) { - vim_snprintf((char *)buf, buflen, "%d", col); + vim_snprintf(buf, buflen, "%d", col); } else { - vim_snprintf((char *)buf, buflen, "%d-%d", col, vcol); + vim_snprintf(buf, buflen, "%d-%d", col, vcol); } } @@ -3200,7 +3189,7 @@ void maketitle(void) // Get path of file, replace home dir with ~. *buf_p++ = ' '; *buf_p++ = '('; - home_replace(curbuf, (char *)curbuf->b_ffname, buf_p, + home_replace(curbuf, curbuf->b_ffname, buf_p, (SPACE_FOR_DIR - (size_t)(buf_p - buf)), true); #ifdef BACKSLASH_IN_FILENAME // Avoid "c:/name" to be reduced to "c". @@ -3209,7 +3198,7 @@ void maketitle(void) } #endif // Remove the file name. - char *p = (char *)path_tail_with_sep((char_u *)buf_p); + char *p = path_tail_with_sep(buf_p); if (p == buf_p) { // Must be a help buffer. xstrlcpy(buf_p, _("help"), SPACE_FOR_DIR - (size_t)(buf_p - buf)); @@ -3244,7 +3233,7 @@ void maketitle(void) if (maxlen > 0) { // Make it shorter by removing a bit in the middle. if (vim_strsize(buf) > maxlen) { - trunc_string((char_u *)buf, (char_u *)buf, maxlen, sizeof(buf)); + trunc_string(buf, buf, maxlen, sizeof(buf)); } } title_str = buf; @@ -3279,18 +3268,18 @@ void maketitle(void) if (buf_spname(curbuf) != NULL) { buf_p = buf_spname(curbuf); } else { // use file name only in icon - buf_p = path_tail((char *)curbuf->b_ffname); + buf_p = path_tail(curbuf->b_ffname); } *icon_str = NUL; // Truncate name at 100 bytes. len = (int)STRLEN(buf_p); if (len > 100) { len -= 100; - len += mb_tail_off((char_u *)buf_p, (char_u *)buf_p + len) + 1; + len += mb_tail_off(buf_p, buf_p + len) + 1; buf_p += len; } STRCPY(icon_str, buf_p); - trans_characters((char_u *)icon_str, IOSIZE); + trans_characters(icon_str, IOSIZE); } } @@ -3688,7 +3677,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, int use_san // The first digit group is the item's min width if (ascii_isdigit(*fmt_p)) { - minwid = getdigits_int((char_u **)&fmt_p, false, 0); + minwid = getdigits_int(&fmt_p, false, 0); } // User highlight groups override the min width field @@ -3771,7 +3760,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, int use_san if (*fmt_p == '.') { fmt_p++; if (ascii_isdigit(*fmt_p)) { - maxwid = getdigits_int((char_u **)&fmt_p, false, 50); + maxwid = getdigits_int(&fmt_p, false, 50); } } @@ -3824,11 +3813,11 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, int use_san if (buf_spname(wp->w_buffer) != NULL) { STRLCPY(NameBuff, buf_spname(wp->w_buffer), MAXPATHL); } else { - char *t = (opt == STL_FULLPATH) ? (char *)wp->w_buffer->b_ffname + char *t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname : wp->w_buffer->b_fname; home_replace(wp->w_buffer, t, (char *)NameBuff, MAXPATHL, true); } - trans_characters(NameBuff, MAXPATHL); + trans_characters((char *)NameBuff, MAXPATHL); if (opt != STL_FILENAME) { str = (char *)NameBuff; } else { @@ -4708,7 +4697,7 @@ void do_arg_all(int count, int forceit, int keep_tabs) if (i < alist->al_ga.ga_len && (AARGLIST(alist)[i].ae_fnum == buf->b_fnum || path_full_compare(alist_name(&AARGLIST(alist)[i]), - (char *)buf->b_ffname, + buf->b_ffname, true, true) & kEqualFiles)) { int weight = 1; @@ -5576,7 +5565,7 @@ bool buf_contents_changed(buf_T *buf) aucmd_prepbuf(&aco, newbuf); if (ml_open(curbuf) == OK - && readfile((char *)buf->b_ffname, buf->b_fname, + && readfile(buf->b_ffname, buf->b_fname, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, &ea, READ_NEW | READ_DUMMY, false) == OK) { // compare the two files line by line diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index e5142f714e..8c70765d30 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -545,8 +545,8 @@ struct file_buffer { // b_sfname is the name as the user typed it (or NULL). // b_fname is the same as b_sfname, unless ":cd" has been done, // then it is the same as b_ffname (NULL for no name). - char_u *b_ffname; // full path file name, allocated - char_u *b_sfname; // short file name, allocated, may be equal to + char *b_ffname; // full path file name, allocated + char *b_sfname; // short file name, allocated, may be equal to // b_ffname char *b_fname; // current file name, points to b_ffname or // b_sfname @@ -829,7 +829,7 @@ struct file_buffer { int b_start_eol; // last line had eol when it was read int b_start_ffc; // first char of 'ff' when edit started - char_u *b_start_fenc; // 'fileencoding' when edit started or NULL + char *b_start_fenc; // 'fileencoding' when edit started or NULL int b_bad_char; // "++bad=" argument when edit started or 0 int b_start_bomb; // 'bomb' when it was read @@ -855,7 +855,7 @@ struct file_buffer { // are not used! Use the B_SPELL macro to // access b_spell without #ifdef. - char_u *b_prompt_text; // set by prompt_setprompt() + char *b_prompt_text; // set by prompt_setprompt() Callback b_prompt_callback; // set by prompt_setcallback() Callback b_prompt_interrupt; // set by prompt_setinterrupt() int b_prompt_insert; // value for restart_edit when entering @@ -963,8 +963,8 @@ struct tabpage_S { frame_T *(tp_snapshot[SNAP_COUNT]); ///< window layout snapshots ScopeDictDictItem tp_winvar; ///< Variable for "t:" Dictionary. dict_T *tp_vars; ///< Internal variables, local to tab page. - char_u *tp_localdir; ///< Absolute path of local cwd or NULL. - char_u *tp_prevdir; ///< Previous directory. + char *tp_localdir; ///< Absolute path of local cwd or NULL. + char *tp_prevdir; ///< Previous directory. }; /* @@ -1061,7 +1061,7 @@ struct matchitem { matchitem_T *next; int id; ///< match ID int priority; ///< match priority - char_u *pattern; ///< pattern to highlight + char *pattern; ///< pattern to highlight regmmatch_T match; ///< regexp program for pattern posmatch_T pos; ///< position matches match_T hl; ///< struct for doing the actual highlighting @@ -1409,8 +1409,8 @@ struct window_S { // out of range!) int w_arg_idx_invalid; // editing another file than w_arg_idx - char_u *w_localdir; // absolute path of local directory or NULL - char_u *w_prevdir; // previous directory + char *w_localdir; // absolute path of local directory or NULL + char *w_prevdir; // previous directory // Options local to a window. // They are local because they influence the layout of the window or // depend on the window layout. @@ -1424,10 +1424,10 @@ struct window_S { uint32_t w_p_wbr_flags; // flags for 'winbar' uint32_t w_p_fde_flags; // flags for 'foldexpr' uint32_t w_p_fdt_flags; // flags for 'foldtext' - int *w_p_cc_cols; // array of columns to highlight or NULL - char_u w_p_culopt_flags; // flags for cursorline highlighting - long w_p_siso; // 'sidescrolloff' local value - long w_p_so; // 'scrolloff' local value + int *w_p_cc_cols; // array of columns to highlight or NULL + uint8_t w_p_culopt_flags; // flags for cursorline highlighting + long w_p_siso; // 'sidescrolloff' local value + long w_p_so; // 'scrolloff' local value int w_briopt_min; // minimum width for breakindent int w_briopt_shift; // additional shift for breakindent diff --git a/src/nvim/change.c b/src/nvim/change.c index f1273c802e..4568b71fd9 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -1059,7 +1059,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) old_cursor = curwin->w_cursor; ptr = saved_line; if (flags & OPENLINE_DO_COM) { - lead_len = get_leader_len(ptr, NULL, false, true); + lead_len = get_leader_len((char *)ptr, NULL, false, true); } else { lead_len = 0; } @@ -1072,7 +1072,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) newindent = get_indent(); } if (flags & OPENLINE_DO_COM) { - lead_len = get_leader_len(ptr, NULL, false, true); + lead_len = get_leader_len((char *)ptr, NULL, false, true); } else { lead_len = 0; } @@ -1191,14 +1191,14 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) // This may then be inserted in front of the new line. end_comment_pending = NUL; if (flags & OPENLINE_DO_COM) { - lead_len = get_leader_len(saved_line, &lead_flags, dir == BACKWARD, true); + lead_len = get_leader_len((char *)saved_line, (char **)&lead_flags, dir == BACKWARD, true); if (lead_len == 0 && curbuf->b_p_cin && do_cindent && dir == FORWARD && (!has_format_option(FO_NO_OPEN_COMS) || (flags & OPENLINE_FORMAT))) { // Check for a line comment after code. comment_start = check_linecomment(saved_line); if (comment_start != MAXCOL) { - lead_len = get_leader_len(saved_line + comment_start, - &lead_flags, false, true); + lead_len = get_leader_len((char *)saved_line + comment_start, + (char **)&lead_flags, false, true); if (lead_len != 0) { lead_len += comment_start; if (did_do_comment != NULL) { @@ -1238,7 +1238,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) } // find start of middle part - (void)copy_option_part(&p, lead_middle, COM_MAX_LEN, ","); + (void)copy_option_part((char **)&p, (char *)lead_middle, COM_MAX_LEN, ","); require_blank = false; } @@ -1249,7 +1249,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) } p++; } - (void)copy_option_part(&p, lead_middle, COM_MAX_LEN, ","); + (void)copy_option_part((char **)&p, (char *)lead_middle, COM_MAX_LEN, ","); while (*p && p[-1] != ':') { // find end of end flags // Check whether we allow automatic ending of comments @@ -1258,7 +1258,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) } p++; } - size_t n = copy_option_part(&p, lead_end, COM_MAX_LEN, ","); + size_t n = copy_option_part((char **)&p, (char *)lead_end, COM_MAX_LEN, ","); if (end_comment_pending == -1) { // we can set it now end_comment_pending = lead_end[n - 1]; @@ -1377,7 +1377,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) if (*p == COM_RIGHT || *p == COM_LEFT) { c = *p++; } else if (ascii_isdigit(*p) || *p == '-') { - off = getdigits_int(&p, true, 0); + off = getdigits_int((char **)&p, true, 0); } else { p++; } @@ -1881,16 +1881,16 @@ void del_lines(long nlines, bool undo) /// When "flags" is not NULL, it is set to point to the flags of the recognized comment leader. /// "backward" must be true for the "O" command. /// If "include_space" is set, include trailing whitespace while calculating the length. -int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_space) +int get_leader_len(char *line, char **flags, bool backward, bool include_space) { int j; int got_com = false; char part_buf[COM_MAX_LEN]; // buffer for one option part - char_u *string; // pointer to comment string - char_u *list; + char *string; // pointer to comment string + char *list; int middle_match_len = 0; - char_u *prev_list; - char_u *saved_flags = NULL; + char *prev_list; + char *saved_flags = NULL; int result = 0; int i = 0; @@ -1902,15 +1902,15 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa while (line[i] != NUL) { // scan through the 'comments' option for a match int found_one = false; - for (list = curbuf->b_p_com; *list;) { + for (list = (char *)curbuf->b_p_com; *list;) { // Get one option part into part_buf[]. Advance "list" to next // one. Put "string" at start of string. if (!got_com && flags != NULL) { *flags = list; // remember where flags started } prev_list = list; - (void)copy_option_part(&list, (char_u *)part_buf, COM_MAX_LEN, ","); - string = (char_u *)vim_strchr(part_buf, ':'); + (void)copy_option_part(&list, part_buf, COM_MAX_LEN, ","); + string = vim_strchr(part_buf, ':'); if (string == NULL) { // missing ':', ignore this part continue; } @@ -2023,15 +2023,15 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa /// /// When "flags" is not null, it is set to point to the flags describing the /// recognized comment leader. -int get_last_leader_offset(char_u *line, char_u **flags) +int get_last_leader_offset(char *line, char **flags) { int result = -1; int j; int lower_check_bound = 0; - char_u *string; - char_u *com_leader; - char_u *com_flags; - char_u *list; + char *string; + char *com_leader; + char *com_flags; + char *list; char part_buf[COM_MAX_LEN]; // buffer for one option part // Repeat to match several nested comment strings. @@ -2039,13 +2039,13 @@ int get_last_leader_offset(char_u *line, char_u **flags) while (--i >= lower_check_bound) { // scan through the 'comments' option for a match int found_one = false; - for (list = curbuf->b_p_com; *list;) { - char_u *flags_save = list; + for (list = (char *)curbuf->b_p_com; *list;) { + char *flags_save = list; // Get one option part into part_buf[]. Advance list to next one. // put string at start of string. - (void)copy_option_part(&list, (char_u *)part_buf, COM_MAX_LEN, ","); - string = (char_u *)vim_strchr(part_buf, ':'); + (void)copy_option_part(&list, part_buf, COM_MAX_LEN, ","); + string = vim_strchr(part_buf, ':'); if (string == NULL) { // If everything is fine, this cannot actually // happen. continue; @@ -2124,14 +2124,14 @@ int get_last_leader_offset(char_u *line, char_u **flags) } len1 = (int)STRLEN(com_leader); - for (list = curbuf->b_p_com; *list;) { - char_u *flags_save = list; + for (list = (char *)curbuf->b_p_com; *list;) { + char *flags_save = list; - (void)copy_option_part(&list, (char_u *)part_buf2, COM_MAX_LEN, ","); + (void)copy_option_part(&list, part_buf2, COM_MAX_LEN, ","); if (flags_save == com_flags) { continue; } - string = (char_u *)vim_strchr(part_buf2, ':'); + string = vim_strchr(part_buf2, ':'); string++; while (ascii_iswhite(*string)) { string++; diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 885ebca214..028dd70eb2 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -162,7 +162,7 @@ int buf_init_chartab(buf_T *buf, int global) } if (ascii_isdigit(*p)) { - c = getdigits_int((char_u **)&p, true, 0); + c = getdigits_int((char **)&p, true, 0); } else { c = mb_ptr2char_adv(&p); } @@ -172,7 +172,7 @@ int buf_init_chartab(buf_T *buf, int global) p++; if (ascii_isdigit(*p)) { - c2 = getdigits_int((char_u **)&p, true, 0); + c2 = getdigits_int((char **)&p, true, 0); } else { c2 = mb_ptr2char_adv(&p); } @@ -265,7 +265,7 @@ int buf_init_chartab(buf_T *buf, int global) /// /// @param buf /// @param bufsize -void trans_characters(char_u *buf, int bufsize) +void trans_characters(char *buf, int bufsize) { char_u *trs; // translated character int len = (int)STRLEN(buf); // length of string needing translation @@ -274,10 +274,10 @@ void trans_characters(char_u *buf, int bufsize) while (*buf != 0) { int trs_len; // length of trs[] // Assume a multi-byte character doesn't need translation. - if ((trs_len = utfc_ptr2len((char *)buf)) > 1) { + if ((trs_len = utfc_ptr2len(buf)) > 1) { len -= trs_len; } else { - trs = transchar_byte(*buf); + trs = transchar_byte((uint8_t)(*buf)); trs_len = (int)STRLEN(trs); if (trs_len > 1) { @@ -1302,7 +1302,7 @@ char_u *skiptowhite(const char_u *p) /// @param p /// /// @return Pointer to the next whitespace character. -char_u *skiptowhite_esc(char_u *p) +char *skiptowhite_esc(char *p) FUNC_ATTR_PURE { while (*p != ' ' && *p != '\t' && *p != NUL) { @@ -1364,9 +1364,9 @@ intmax_t getdigits(char_u **pp, bool strict, intmax_t def) /// Gets an int number from a string. /// /// @see getdigits -int getdigits_int(char_u **pp, bool strict, int def) +int getdigits_int(char **pp, bool strict, int def) { - intmax_t number = getdigits(pp, strict, def); + intmax_t number = getdigits((char_u **)pp, strict, def); #if SIZEOF_INTMAX_T > SIZEOF_INT if (strict) { assert(number >= INT_MIN && number <= INT_MAX); diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index c7c7e6ae58..62cf60e03b 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -189,7 +189,7 @@ char *parse_shape_opt(int what) if (!ascii_isdigit(*p)) { return N_("E548: digit expected"); } - int n = getdigits_int((char_u **)&p, false, 0); + int n = getdigits_int(&p, false, 0); if (len == 3) { // "ver" or "hor" if (n == 0) { return N_("E549: Illegal percentage"); diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 803427dd17..0eaff06833 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -523,7 +523,7 @@ static int dbg_parsearg(char_u *arg, garray_T *gap) if (bp->dbg_type == DBG_FUNC) { bp->dbg_name = vim_strsave((char_u *)p); } else if (here) { - bp->dbg_name = vim_strsave(curbuf->b_ffname); + bp->dbg_name = vim_strsave((char_u *)curbuf->b_ffname); } else if (bp->dbg_type == DBG_EXPR) { bp->dbg_name = vim_strsave((char_u *)p); bp->dbg_val = eval_expr_no_emsg(bp); diff --git a/src/nvim/diff.c b/src/nvim/diff.c index e4d77cec9c..75021e90d6 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -2143,7 +2143,7 @@ int diffopt_changed(void) diff_flags_new |= DIFF_FILLER; } else if ((STRNCMP(p, "context:", 8) == 0) && ascii_isdigit(p[8])) { p += 8; - diff_context_new = getdigits_int(&p, false, diff_context_new); + diff_context_new = getdigits_int((char **)&p, false, diff_context_new); } else if (STRNCMP(p, "iblank", 6) == 0) { p += 6; diff_flags_new |= DIFF_IBLANK; @@ -2167,7 +2167,7 @@ int diffopt_changed(void) diff_flags_new |= DIFF_VERTICAL; } else if ((STRNCMP(p, "foldcolumn:", 11) == 0) && ascii_isdigit(p[11])) { p += 11; - diff_foldcolumn_new = getdigits_int(&p, false, diff_foldcolumn_new); + diff_foldcolumn_new = getdigits_int((char **)&p, false, diff_foldcolumn_new); } else if (STRNCMP(p, "hiddenoff", 9) == 0) { p += 9; diff_flags_new |= DIFF_HIDDEN_OFF; @@ -2562,7 +2562,7 @@ void ex_diffgetput(exarg_T *eap) // digits only i = (int)atol(eap->arg); } else { - i = buflist_findpat((char_u *)eap->arg, p, false, true, false); + i = buflist_findpat(eap->arg, (char *)p, false, true, false); if (i < 0) { // error message already given diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index cbff15c84a..355900c93f 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1683,7 +1683,7 @@ void putdigraph(char_u *str) emsg(_(e_number_exp)); return; } - int n = getdigits_int(&str, true, 0); + int n = getdigits_int((char **)&str, true, 0); registerdigraph(char1, char2, n); } diff --git a/src/nvim/edit.c b/src/nvim/edit.c index cba2f812e0..d21583e951 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1618,7 +1618,7 @@ char_u *buf_prompt_text(const buf_T *const buf) if (buf->b_prompt_text == NULL) { return (char_u *)"% "; } - return buf->b_prompt_text; + return (char_u *)buf->b_prompt_text; } // Return the effective prompt for the current buffer. @@ -2955,7 +2955,7 @@ static void ins_compl_dictionaries(char_u *dict_start, char_u *pat, int flags, i /* Expand wildcards in the dictionary name, but do not allow * backticks (for security, the 'dict' option may have been set in * a modeline). */ - copy_option_part(&dict, buf, LSIZE, ","); + copy_option_part((char **)&dict, (char *)buf, LSIZE, ","); if (!thesaurus && STRCMP(buf, "spell") == 0) { count = -1; } else if (vim_strchr((char *)buf, '`') != NULL @@ -3020,7 +3020,7 @@ static void ins_compl_files(int count, char_u **files, int thesaurus, int flags, while (!got_int && !compl_interrupted && !vim_fgets(buf, LSIZE, fp)) { ptr = buf; - while (vim_regexec(regmatch, buf, (colnr_T)(ptr - buf))) { + while (vim_regexec(regmatch, (char *)buf, (colnr_T)(ptr - buf))) { ptr = regmatch->startp[0]; if (CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode)) { ptr = find_line_end(ptr); @@ -4223,9 +4223,9 @@ static int ins_compl_get_exp(pos_T *ini) msg_hist_off = true; // reset in msg_trunc_attr() vim_snprintf((char *)IObuff, IOSIZE, _("Scanning: %s"), ins_buf->b_fname == NULL - ? (char_u *)buf_spname(ins_buf) + ? buf_spname(ins_buf) : ins_buf->b_sfname == NULL - ? (char_u *)ins_buf->b_fname + ? ins_buf->b_fname : ins_buf->b_sfname); (void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R)); } else if (*e_cpt == NUL) { @@ -4257,7 +4257,7 @@ static int ins_compl_get_exp(pos_T *ini) } // in any case e_cpt is advanced to the next entry - (void)copy_option_part(&e_cpt, IObuff, IOSIZE, ","); + (void)copy_option_part((char **)&e_cpt, (char *)IObuff, IOSIZE, ","); found_all = true; if (type == -1) { @@ -4313,7 +4313,7 @@ static int ins_compl_get_exp(pos_T *ini) if (find_tags(compl_pattern, &num_matches, &matches, TAG_REGEXP | TAG_NAMES | TAG_NOIC | TAG_INS_COMP | (l_ctrl_x_mode != CTRL_X_NORMAL ? TAG_VERBOSE : 0), - TAG_MANY, curbuf->b_ffname) == OK && num_matches > 0) { + TAG_MANY, (char_u *)curbuf->b_ffname) == OK && num_matches > 0) { ins_compl_add_matches(num_matches, matches, p_ic); } g_tag_at_cursor = false; @@ -4516,7 +4516,8 @@ static int ins_compl_get_exp(pos_T *ini) } } } - if (ins_compl_add_infercase(ptr, len, p_ic, ins_buf == curbuf ? NULL : ins_buf->b_sfname, + if (ins_compl_add_infercase(ptr, len, p_ic, + ins_buf == curbuf ? NULL : (char_u *)ins_buf->b_sfname, 0, cont_s_ipos) != NOTDONE) { found_new_match = OK; break; @@ -5773,21 +5774,18 @@ void insertchar(int c, int flags, int second_indent) // Check whether this character should end a comment. if (did_ai && c == end_comment_pending) { - char_u *line; char_u lead_end[COM_MAX_LEN]; // end-comment string - int i; - /* - * Need to remove existing (middle) comment leader and insert end - * comment leader. First, check what comment leader we can find. - */ - i = get_leader_len(line = get_cursor_line_ptr(), &p, false, true); + // Need to remove existing (middle) comment leader and insert end + // comment leader. First, check what comment leader we can find. + char_u *line = get_cursor_line_ptr(); + int i = get_leader_len((char *)line, (char **)&p, false, true); if (i > 0 && vim_strchr((char *)p, COM_MIDDLE) != NULL) { // Just checking // Skip middle-comment string while (*p && p[-1] != ':') { // find end of middle flags p++; } - int middle_len = (int)copy_option_part(&p, lead_end, COM_MAX_LEN, ","); + int middle_len = (int)copy_option_part((char **)&p, (char *)lead_end, COM_MAX_LEN, ","); // Don't count trailing white space for middle_len while (middle_len > 0 && ascii_iswhite(lead_end[middle_len - 1])) { middle_len--; @@ -5797,7 +5795,7 @@ void insertchar(int c, int flags, int second_indent) while (*p && p[-1] != ':') { // find end of end flags p++; } - int end_len = (int)copy_option_part(&p, lead_end, COM_MAX_LEN, ","); + int end_len = (int)copy_option_part((char **)&p, (char *)lead_end, COM_MAX_LEN, ","); // Skip white space before the cursor i = curwin->w_cursor.col; @@ -5974,12 +5972,12 @@ static void internal_format(int textwidth, int second_indent, int flags, int for // Don't break until after the comment leader if (do_comments) { char_u *line = get_cursor_line_ptr(); - leader_len = get_leader_len(line, NULL, false, true); + leader_len = get_leader_len((char *)line, NULL, false, true); if (leader_len == 0 && curbuf->b_p_cin) { // Check for a line comment after code. int comment_start = check_linecomment(line); if (comment_start != MAXCOL) { - leader_len = get_leader_len(line + comment_start, NULL, false, true); + leader_len = get_leader_len((char *)line + comment_start, NULL, false, true); if (leader_len != 0) { leader_len += comment_start; } @@ -6374,7 +6372,7 @@ void auto_format(bool trailblank, bool prev_line) // With the 'c' flag in 'formatoptions' and 't' missing: only format // comments. if (has_format_option(FO_WRAP_COMS) && !has_format_option(FO_WRAP) - && get_leader_len(old, NULL, false, true) == 0) { + && get_leader_len((char *)old, NULL, false, true) == 0) { return; } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 2ce48479b7..c7173c2078 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -986,7 +986,7 @@ void restore_vimvar(int idx, typval_T *save_tv) vimvars[idx].vv_tv = *save_tv; if (vimvars[idx].vv_type == VAR_UNKNOWN) { - hi = hash_find(&vimvarht, vimvars[idx].vv_di.di_key); + hi = hash_find(&vimvarht, (char *)vimvars[idx].vv_di.di_key); if (HASHITEM_EMPTY(hi)) { internal_error("restore_vimvar()"); } else { @@ -2822,7 +2822,7 @@ void ex_lockvar(exarg_T *eap) if (eap->forceit) { deep = -1; } else if (ascii_isdigit(*arg)) { - deep = getdigits_int((char_u **)&arg, false, -1); + deep = getdigits_int(&arg, false, -1); arg = skipwhite(arg); } @@ -3019,7 +3019,7 @@ int do_unlet(const char *const name, const size_t name_len, const bool forceit) } } - hashitem_T *hi = hash_find(ht, (const char_u *)varname); + hashitem_T *hi = hash_find(ht, varname); if (HASHITEM_EMPTY(hi)) { hi = find_hi_in_scoped_ht(name, &ht); } @@ -9814,7 +9814,7 @@ void func_line_start(void *cookie) if (fp->uf_profiling && sourcing_lnum >= 1 && sourcing_lnum <= fp->uf_lines.ga_len) { - fp->uf_tml_idx = (int)(sourcing_lnum - 1); + fp->uf_tml_idx = sourcing_lnum - 1; // Skip continuation lines. while (fp->uf_tml_idx > 0 && FUNCLINE(fp, fp->uf_tml_idx) == NULL) { fp->uf_tml_idx--; diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 96c6a4704c..8d267f6a9e 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -476,7 +476,7 @@ static buf_T *find_buffer(typval_T *avar) if (avar->v_type == VAR_NUMBER) { buf = buflist_findnr((int)avar->vval.v_number); } else if (avar->v_type == VAR_STRING && avar->vval.v_string != NULL) { - buf = buflist_findname_exp((char_u *)avar->vval.v_string); + buf = buflist_findname_exp(avar->vval.v_string); if (buf == NULL) { /* No full path name match, try a match with a URL or a "nofile" * buffer, these don't use the full path. */ @@ -498,7 +498,7 @@ static void f_bufadd(typval_T *argvars, typval_T *rettv, FunPtr fptr) { char_u *name = (char_u *)tv_get_string(&argvars[0]); - rettv->vval.v_number = buflist_add(*name == NUL ? NULL : name, 0); + rettv->vval.v_number = buflist_add(*name == NUL ? NULL : (char *)name, 0); } /// "bufexists(expr)" function @@ -586,7 +586,7 @@ static void f_bufnr(typval_T *argvars, typval_T *rettv, FunPtr fptr) && tv_get_number_chk(&argvars[1], &error) != 0 && !error && (name = tv_get_string_chk(&argvars[0])) != NULL) { - buf = buflist_new((char_u *)name, NULL, 1, 0); + buf = buflist_new((char *)name, NULL, 1, 0); } if (buf != NULL) { @@ -655,7 +655,7 @@ buf_T *tv_get_buf(typval_T *tv, int curtab_only) save_cpo = p_cpo; p_cpo = ""; - buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name), + buf = buflist_findnr(buflist_findpat((char *)name, (char *)name + STRLEN(name), true, false, curtab_only)); p_magic = save_magic; @@ -2396,7 +2396,7 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) fresult = find_file_in_path_option(first ? (char_u *)fname : NULL, first ? strlen(fname) : 0, 0, first, path, - find_what, curbuf->b_ffname, + find_what, (char_u *)curbuf->b_ffname, (find_what == FINDFILE_DIR ? (char_u *)"" : curbuf->b_p_sua)); @@ -2574,7 +2574,7 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } } - unsigned long count = (unsigned long)(foldend - foldstart + 1); + unsigned long count = (unsigned long)foldend - foldstart + 1; txt = NGETTEXT("+-%s%3ld line: ", "+-%s%3ld lines: ", count); r = xmalloc(STRLEN(txt) + STRLEN(dashes) // for %s @@ -3308,8 +3308,8 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr) [kCdScopeTabpage] = 0, // Number of tab to look at. }; - char_u *cwd = NULL; // Current working directory to print - char_u *from = NULL; // The original string to copy + char *cwd = NULL; // Current working directory to print + char *from = NULL; // The original string to copy tabpage_T *tp = curtab; // The tabpage to look at. win_T *win = curwin; // The window to look at. @@ -3386,13 +3386,13 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr) FALLTHROUGH; case kCdScopeGlobal: if (globaldir) { // `globaldir` is not always set. - from = (char_u *)globaldir; + from = globaldir; break; } FALLTHROUGH; // In global directory, just need to get OS CWD. case kCdScopeInvalid: // If called without any arguments, get OS CWD. - if (os_dirname(cwd, MAXPATHL) == FAIL) { - from = (char_u *)""; // Return empty string on failure. + if (os_dirname((char_u *)cwd, MAXPATHL) == FAIL) { + from = ""; // Return empty string on failure. } } @@ -3400,7 +3400,7 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr) STRLCPY(cwd, from, MAXPATHL); } - rettv->vval.v_string = (char *)vim_strsave(cwd); + rettv->vval.v_string = xstrdup(cwd); #ifdef BACKSLASH_IN_FILENAME slash_adjust(rettv->vval.v_string); #endif @@ -5968,7 +5968,7 @@ static void f_mkdir(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (*path_tail(dir) == NUL) { // Remove trailing slashes. - *path_tail_with_sep((char_u *)dir) = NUL; + *path_tail_with_sep((char *)dir) = NUL; } if (argvars[1].v_type != VAR_UNKNOWN) { @@ -6366,20 +6366,17 @@ static void f_prompt_getprompt(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// "prompt_setprompt({buffer}, {text})" function static void f_prompt_setprompt(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - buf_T *buf; - const char_u *text; - if (check_secure()) { return; } - buf = tv_get_buf(&argvars[0], false); + buf_T *buf = tv_get_buf(&argvars[0], false); if (buf == NULL) { return; } - text = (const char_u *)tv_get_string(&argvars[1]); + const char *text = tv_get_string(&argvars[1]); xfree(buf->b_prompt_text); - buf->b_prompt_text = vim_strsave(text); + buf->b_prompt_text = xstrdup(text); } /// "pum_getpos()" function @@ -7341,7 +7338,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (!has_trailing_pathsep) { q = p + strlen(p); if (after_pathsep(p, q)) { - *path_tail_with_sep((char_u *)p) = NUL; + *path_tail_with_sep(p) = NUL; } } diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 97726da5f4..e19cf411c0 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1434,7 +1434,7 @@ dictitem_T *tv_dict_item_copy(dictitem_T *const di) void tv_dict_item_remove(dict_T *const dict, dictitem_T *const item) FUNC_ATTR_NONNULL_ALL { - hashitem_T *const hi = hash_find(&dict->dv_hashtab, item->di_key); + hashitem_T *const hi = hash_find(&dict->dv_hashtab, (char *)item->di_key); if (HASHITEM_EMPTY(hi)) { semsg(_(e_intern2), "tv_dict_item_remove()"); } else { @@ -1567,7 +1567,7 @@ dictitem_T *tv_dict_find(const dict_T *const d, const char *const key, const ptr return NULL; } hashitem_T *const hi = (len < 0 - ? hash_find(&d->dv_hashtab, (const char_u *)key) + ? hash_find(&d->dv_hashtab, key) : hash_find_len(&d->dv_hashtab, key, (size_t)len)); if (HASHITEM_EMPTY(hi)) { return NULL; diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 8646520ec3..c2579944e4 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -547,9 +547,7 @@ static char_u *fname_trans_sid(const char_u *const name, char_u *const fname_buf /// @return NULL for unknown function. ufunc_T *find_func(const char_u *name) { - hashitem_T *hi; - - hi = hash_find(&func_hashtab, name); + hashitem_T *hi = hash_find(&func_hashtab, (char *)name); if (!HASHITEM_EMPTY(hi)) { return HI2UF(hi); } @@ -724,7 +722,7 @@ static void funccal_unref(funccall_T *fc, ufunc_T *fp, bool force) /// @return true if the entry was deleted, false if it wasn't found. static bool func_remove(ufunc_T *fp) { - hashitem_T *hi = hash_find(&func_hashtab, UF2HIKEY(fp)); + hashitem_T *hi = hash_find(&func_hashtab, (char *)UF2HIKEY(fp)); if (!HASHITEM_EMPTY(hi)) { hash_remove(&func_hashtab, hi); @@ -1045,7 +1043,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett char *s = tofree; char buf[MSG_BUF_LEN]; if (vim_strsize(s) > MSG_BUF_CLEN) { - trunc_string((char_u *)s, (char_u *)buf, MSG_BUF_CLEN, sizeof(buf)); + trunc_string(s, buf, MSG_BUF_CLEN, sizeof(buf)); s = buf; } msg_puts(s); @@ -1159,7 +1157,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett emsg_off--; if (s != NULL) { if (vim_strsize(s) > MSG_BUF_CLEN) { - trunc_string((char_u *)s, (char_u *)buf, MSG_BUF_CLEN, MSG_BUF_LEN); + trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN); s = buf; } smsg(_("%s returning %s"), sourcing_name, s); @@ -1976,7 +1974,7 @@ void ex_function(exarg_T *eap) --todo; fp = HI2UF(hi); if (!isdigit(*fp->uf_name) - && vim_regexec(®match, fp->uf_name, 0)) { + && vim_regexec(®match, (char *)fp->uf_name, 0)) { list_func_head(fp, false, false); } } @@ -2537,7 +2535,7 @@ void ex_function(exarg_T *eap) // insert the new function in the function list STRCPY(fp->uf_name, name); if (overwrite) { - hi = hash_find(&func_hashtab, name); + hi = hash_find(&func_hashtab, (char *)name); hi->hi_key = UF2HIKEY(fp); } else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) { xfree(fp); diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index b5b75b76a9..f97caf0703 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -560,7 +560,7 @@ void ex_sort(exarg_T *eap) start_col = 0; end_col = len; - if (regmatch.regprog != NULL && vim_regexec(®match, (char_u *)s, 0)) { + if (regmatch.regprog != NULL && vim_regexec(®match, s, 0)) { if (sort_rx) { start_col = (colnr_T)(regmatch.startp[0] - (char_u *)s); end_col = (colnr_T)(regmatch.endp[0] - (char_u *)s); @@ -1732,19 +1732,19 @@ int rename_buffer(char *new_fname) * But don't set the alternate file name if the buffer didn't have a * name. */ - fname = (char *)curbuf->b_ffname; - sfname = (char *)curbuf->b_sfname; + fname = curbuf->b_ffname; + sfname = curbuf->b_sfname; xfname = curbuf->b_fname; curbuf->b_ffname = NULL; curbuf->b_sfname = NULL; if (setfname(curbuf, new_fname, NULL, true) == FAIL) { - curbuf->b_ffname = (char_u *)fname; - curbuf->b_sfname = (char_u *)sfname; + curbuf->b_ffname = fname; + curbuf->b_sfname = sfname; return FAIL; } curbuf->b_flags |= BF_NOTEDITED; if (xfname != NULL && *xfname != NUL) { - buf = buflist_new((char_u *)fname, (char_u *)xfname, curwin->w_cursor.lnum, 0); + buf = buflist_new(fname, xfname, curwin->w_cursor.lnum, 0); if (buf != NULL && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) { curwin->w_alt_fnum = buf->b_fnum; } @@ -1842,7 +1842,7 @@ int do_write(exarg_T *eap) if (free_fname != NULL) { ffname = free_fname; } - other = otherfile((char_u *)ffname); + other = otherfile(ffname); } /* @@ -1851,9 +1851,9 @@ int do_write(exarg_T *eap) if (other) { if (vim_strchr(p_cpo, CPO_ALTWRITE) != NULL || eap->cmdidx == CMD_saveas) { - alt_buf = setaltfname((char_u *)ffname, (char_u *)fname, (linenr_T)1); + alt_buf = setaltfname(ffname, fname, (linenr_T)1); } else { - alt_buf = buflist_findname((char_u *)ffname); + alt_buf = buflist_findname(ffname); } if (alt_buf != NULL && alt_buf->b_ml.ml_mfp != NULL) { // Overwriting a file that is loaded in another buffer is not a @@ -1873,7 +1873,7 @@ int do_write(exarg_T *eap) } if (!other) { - ffname = (char *)curbuf->b_ffname; + ffname = curbuf->b_ffname; fname = curbuf->b_fname; // Not writing the whole file is only allowed with '!'. if ((eap->line1 != 1 @@ -1913,12 +1913,12 @@ int do_write(exarg_T *eap) fname = alt_buf->b_fname; alt_buf->b_fname = curbuf->b_fname; curbuf->b_fname = fname; - fname = (char *)alt_buf->b_ffname; + fname = alt_buf->b_ffname; alt_buf->b_ffname = curbuf->b_ffname; - curbuf->b_ffname = (char_u *)fname; - fname = (char *)alt_buf->b_sfname; + curbuf->b_ffname = fname; + fname = alt_buf->b_sfname; alt_buf->b_sfname = curbuf->b_sfname; - curbuf->b_sfname = (char_u *)fname; + curbuf->b_sfname = fname; buf_name_changed(curbuf); apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, curbuf); apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, alt_buf); @@ -1942,7 +1942,7 @@ int do_write(exarg_T *eap) // Autocommands may have changed buffer names, esp. when // 'autochdir' is set. - fname = (char *)curbuf->b_sfname; + fname = curbuf->b_sfname; } name_was_missing = curbuf->b_ffname == NULL; @@ -2031,7 +2031,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int oth } else { dir = xmalloc(MAXPATHL); p = (char *)p_dir; - copy_option_part((char_u **)&p, (char_u *)dir, MAXPATHL, ","); + copy_option_part(&p, dir, MAXPATHL, ","); } swapname = (char *)makeswapname((char_u *)fname, (char_u *)ffname, curbuf, (char_u *)dir); xfree(dir); @@ -2112,7 +2112,7 @@ void do_wqall(exarg_T *eap) semsg(_("E141: No file name for buffer %" PRId64), (int64_t)buf->b_fnum); error++; } else if (check_readonly(&eap->forceit, buf) - || check_overwrite(eap, buf, buf->b_fname, (char *)buf->b_ffname, false) == FAIL) { + || check_overwrite(eap, buf, buf->b_fname, buf->b_ffname, false) == FAIL) { error++; } else { bufref_T bufref; @@ -2155,8 +2155,8 @@ static int check_readonly(int *forceit, buf_T *buf) // Handle a file being readonly when the 'readonly' option is set or when // the file exists and permissions are read-only. if (!*forceit && (buf->b_p_ro - || (os_path_exists(buf->b_ffname) - && !os_file_is_writable((char *)buf->b_ffname)))) { + || (os_path_exists((char_u *)buf->b_ffname) + && !os_file_is_writable(buf->b_ffname)))) { if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && buf->b_fname != NULL) { char buff[DIALOG_MSG_SIZE]; @@ -2218,7 +2218,7 @@ int getfile(int fnum, char *ffname_arg, char *sfname_arg, int setpm, linenr_T ln if (fnum == 0) { // make ffname full path, set sfname fname_expand(curbuf, &ffname, &sfname); - other = otherfile((char_u *)ffname); + other = otherfile(ffname); free_me = ffname; // has been allocated, free() later } else { other = (fnum != curbuf->b_fnum); @@ -2339,7 +2339,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum } #ifdef USE_FNAME_CASE if (sfname != NULL) { - path_fix_case((char_u *)sfname); // set correct case for sfname + path_fix_case(sfname); // set correct case for sfname } #endif @@ -2354,14 +2354,14 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum other_file = false; } else { if (*ffname == NUL) { // re-edit with same file name - ffname = (char *)curbuf->b_ffname; + ffname = curbuf->b_ffname; sfname = curbuf->b_fname; } free_fname = fix_fname(ffname); // may expand to full path name if (free_fname != NULL) { ffname = free_fname; } - other_file = otherfile((char_u *)ffname); + other_file = otherfile(ffname); } } @@ -2384,7 +2384,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum | ((flags & ECMD_FORCEIT) ? CCGD_FORCEIT : 0) | (eap == NULL ? 0 : CCGD_EXCMD))) { if (fnum == 0 && other_file && ffname != NULL) { - (void)setaltfname((char_u *)ffname, (char_u *)sfname, newlnum < 0 ? 0 : newlnum); + (void)setaltfname(ffname, sfname, newlnum < 0 ? 0 : newlnum); } goto theend; } @@ -2441,13 +2441,13 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum // Add BLN_NOCURWIN to avoid a new wininfo items are associated // with the current window. const buf_T *const newbuf - = buflist_new((char_u *)ffname, (char_u *)sfname, tlnum, BLN_LISTED | BLN_NOCURWIN); + = buflist_new(ffname, sfname, tlnum, BLN_LISTED | BLN_NOCURWIN); if (newbuf != NULL && (flags & ECMD_ALTBUF)) { curwin->w_alt_fnum = newbuf->b_fnum; } goto theend; } - buf = buflist_new((char_u *)ffname, (char_u *)sfname, 0L, + buf = buflist_new(ffname, sfname, 0L, BLN_CURBUF | (flags & ECMD_SET_HELP ? 0 : BLN_LISTED)); // Autocmds may change curwin and curbuf. if (oldwin != NULL) { @@ -5388,7 +5388,7 @@ void fix_help_buffer(void) // $VIMRUNTIME. char *p = (char *)p_rtp; while (*p != NUL) { - copy_option_part((char_u **)&p, NameBuff, MAXPATHL, ","); + copy_option_part(&p, (char *)NameBuff, MAXPATHL, ","); char *const rt = vim_getenv("VIMRUNTIME"); if (rt != NULL && path_full_compare(rt, (char *)NameBuff, false, true) != kEqualFiles) { diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 621004103e..9cb6d360df 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -562,7 +562,7 @@ void dialog_changed(buf_T *buf, bool checkall) if (ret == VIM_YES) { if (buf->b_fname != NULL - && check_overwrite(&ea, buf, buf->b_fname, (char *)buf->b_ffname, false) == OK) { + && check_overwrite(&ea, buf, buf->b_fname, buf->b_ffname, false) == OK) { // didn't hit Cancel (void)buf_write_all(buf, false); } @@ -578,8 +578,7 @@ void dialog_changed(buf_T *buf, bool checkall) set_bufref(&bufref, buf2); if (buf2->b_fname != NULL - && check_overwrite(&ea, buf2, buf2->b_fname, - (char *)buf2->b_ffname, false) == OK) { + && check_overwrite(&ea, buf2, buf2->b_fname, buf2->b_ffname, false) == OK) { // didn't hit Cancel (void)buf_write_all(buf2, false); } @@ -786,7 +785,7 @@ int buf_write_all(buf_T *buf, int forceit) int retval; buf_T *old_curbuf = curbuf; - retval = (buf_write(buf, (char *)buf->b_ffname, buf->b_fname, + retval = (buf_write(buf, buf->b_ffname, buf->b_fname, (linenr_T)1, buf->b_ml.ml_line_count, NULL, false, forceit, true, false)); if (curbuf != old_curbuf) { @@ -929,7 +928,7 @@ static int do_arglist(char *str, int what, int after, bool will_edit) didone = false; for (match = 0; match < ARGCOUNT; match++) { - if (vim_regexec(®match, (char_u *)alist_name(&ARGLIST[match]), (colnr_T)0)) { + if (vim_regexec(®match, alist_name(&ARGLIST[match]), (colnr_T)0)) { didone = true; xfree(ARGLIST[match].ae_fname); memmove(ARGLIST + match, ARGLIST + match + 1, @@ -992,7 +991,7 @@ static bool editing_arg_idx(win_T *win) != WARGLIST(win)[win->w_arg_idx].ae_fnum && (win->w_buffer->b_ffname == NULL || !(path_full_compare(alist_name(&WARGLIST(win)[win->w_arg_idx]), - (char *)win->w_buffer->b_ffname, true, + win->w_buffer->b_ffname, true, true) & kEqualFiles)))); } @@ -1011,7 +1010,7 @@ void check_arg_idx(win_T *win) && (win->w_buffer->b_fnum == GARGLIST[GARGCOUNT - 1].ae_fnum || (win->w_buffer->b_ffname != NULL && (path_full_compare(alist_name(&GARGLIST[GARGCOUNT - 1]), - (char *)win->w_buffer->b_ffname, true, true) + win->w_buffer->b_ffname, true, true) & kEqualFiles)))) { arg_had_last = true; } @@ -1138,7 +1137,7 @@ void do_argfile(exarg_T *eap, int argn) other = true; if (buf_hide(curbuf)) { p = fix_fname(alist_name(&ARGLIST[argn])); - other = otherfile((char_u *)p); + other = otherfile(p); xfree(p); } if ((!buf_hide(curbuf) || !other) @@ -1551,7 +1550,7 @@ static void alist_add_list(int count, char **files, int after, bool will_edit) for (int i = 0; i < count; i++) { const int flags = BLN_LISTED | (will_edit ? BLN_CURBUF : 0); ARGLIST[after + i].ae_fname = (char_u *)files[i]; - ARGLIST[after + i].ae_fnum = buflist_add((char_u *)files[i], flags); + ARGLIST[after + i].ae_fnum = buflist_add(files[i], flags); } ALIST(curwin)->al_ga.ga_len += count; if (old_argcount > 0 && curwin->w_arg_idx >= after) { @@ -2265,7 +2264,7 @@ char_u *get_scriptname(LastSet last_set, bool *should_free) } *should_free = true; - return home_replace_save(NULL, (char_u *)sname); + return (char_u *)home_replace_save(NULL, sname); } } } @@ -2494,8 +2493,7 @@ void script_line_start(void) if (si->sn_prof_on && sourcing_lnum >= 1) { // Grow the array before starting the timer, so that the time spent // here isn't counted. - (void)ga_grow(&si->sn_prl_ga, - (int)(sourcing_lnum - si->sn_prl_ga.ga_len)); + (void)ga_grow(&si->sn_prl_ga, sourcing_lnum - si->sn_prl_ga.ga_len); si->sn_prl_idx = sourcing_lnum - 1; while (si->sn_prl_ga.ga_len <= si->sn_prl_idx && si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen) { diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 763aca62ef..99c76fc204 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1621,21 +1621,21 @@ int execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo, bool preview) if (eap->cmdidx == CMD_bdelete || eap->cmdidx == CMD_bwipeout || eap->cmdidx == CMD_bunload) { - p = (char *)skiptowhite_esc((char_u *)eap->arg); + p = skiptowhite_esc(eap->arg); } else { p = eap->arg + STRLEN(eap->arg); while (p > eap->arg && ascii_iswhite(p[-1])) { p--; } } - eap->line2 = buflist_findpat((char_u *)eap->arg, (char_u *)p, (eap->argt & EX_BUFUNL) != 0, + eap->line2 = buflist_findpat(eap->arg, p, (eap->argt & EX_BUFUNL) != 0, false, false); eap->addr_count = 1; eap->arg = skipwhite(p); } else { // If argument positions are specified, just use the first argument - eap->line2 = buflist_findpat((char_u *)eap->args[0], - (char_u *)(eap->args[0] + eap->arglens[0]), + eap->line2 = buflist_findpat(eap->args[0], + eap->args[0] + eap->arglens[0], (eap->argt & EX_BUFUNL) != 0, false, false); eap->addr_count = 1; // Shift each argument by 1 @@ -2281,14 +2281,14 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter */ if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout || ea.cmdidx == CMD_bunload) { - p = (char *)skiptowhite_esc((char_u *)ea.arg); + p = skiptowhite_esc(ea.arg); } else { p = ea.arg + STRLEN(ea.arg); while (p > ea.arg && ascii_iswhite(p[-1])) { p--; } } - ea.line2 = buflist_findpat((char_u *)ea.arg, (char_u *)p, (ea.argt & EX_BUFUNL) != 0, + ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0, false, false); if (ea.line2 < 0) { // failed goto doend; @@ -2623,7 +2623,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, cmdmod_T *cmod, bool } if (ascii_isdigit(*eap->cmd)) { // zero means not set, one is verbose == 0, etc. - cmod->cmod_verbose = atoi((char *)eap->cmd) + 1; + cmod->cmod_verbose = atoi(eap->cmd) + 1; } else { cmod->cmod_verbose = 2; // default: verbose == 1 } @@ -5318,7 +5318,7 @@ static void ex_bunload(exarg_T *eap) : eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE : DOBUF_UNLOAD, - (char_u *)eap->arg, eap->addr_count, (int)eap->line1, (int)eap->line2, + eap->arg, eap->addr_count, (int)eap->line1, (int)eap->line2, eap->forceit); } @@ -7507,7 +7507,7 @@ void alist_set(alist_T *al, int count, char **files, int use_curbuf, int *fnum_l /* May set buffer name of a buffer previously used for the * argument list, so that it's re-used by alist_add. */ if (fnum_list != NULL && i < fnum_len) { - buf_set_name(fnum_list[i], (char_u *)files[i]); + buf_set_name(fnum_list[i], files[i]); } alist_add(al, files[i], use_curbuf ? 2 : 1); @@ -7537,7 +7537,7 @@ void alist_add(alist_T *al, char *fname, int set_fnum) AARGLIST(al)[al->al_ga.ga_len].ae_fname = (char_u *)fname; if (set_fnum > 0) { AARGLIST(al)[al->al_ga.ga_len].ae_fnum = - buflist_add((char_u *)fname, BLN_LISTED | (set_fnum == 2 ? BLN_CURBUF : 0)); + buflist_add(fname, BLN_LISTED | (set_fnum == 2 ? BLN_CURBUF : 0)); } ++al->al_ga.ga_len; } @@ -7627,7 +7627,7 @@ void ex_splitview(exarg_T *eap) if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) { fname = (char *)find_file_in_path((char_u *)eap->arg, STRLEN(eap->arg), - FNAME_MESS, true, curbuf->b_ffname); + FNAME_MESS, true, (char_u *)curbuf->b_ffname); if (fname == NULL) { goto theend; } @@ -7829,14 +7829,14 @@ static void ex_find(exarg_T *eap) linenr_T count; fname = (char *)find_file_in_path((char_u *)eap->arg, STRLEN(eap->arg), - FNAME_MESS, true, curbuf->b_ffname); + FNAME_MESS, true, (char_u *)curbuf->b_ffname); if (eap->addr_count > 0) { // Repeat finding the file "count" times. This matters when it // appears several times in the path. count = eap->line2; while (fname != NULL && --count > 0) { xfree(fname); - fname = (char *)find_file_in_path(NULL, 0, FNAME_MESS, false, curbuf->b_ffname); + fname = (char *)find_file_in_path(NULL, 0, FNAME_MESS, false, (char_u *)curbuf->b_ffname); } } @@ -8087,11 +8087,11 @@ static void ex_read(exarg_T *eap) if (check_fname() == FAIL) { // check for no file name return; } - i = readfile((char *)curbuf->b_ffname, curbuf->b_fname, + i = readfile(curbuf->b_ffname, curbuf->b_fname, eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false); } else { if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) { - (void)setaltfname((char_u *)eap->arg, (char_u *)eap->arg, (linenr_T)1); + (void)setaltfname(eap->arg, eap->arg, (linenr_T)1); } i = readfile(eap->arg, NULL, eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false); @@ -8139,10 +8139,10 @@ static char *get_prevdir(CdScope scope) { switch (scope) { case kCdScopeTabpage: - return (char *)curtab->tp_prevdir; + return curtab->tp_prevdir; break; case kCdScopeWindow: - return (char *)curwin->w_prevdir; + return curwin->w_prevdir; break; default: return prev_dir; @@ -8180,10 +8180,10 @@ static void post_chdir(CdScope scope, bool trigger_dirchanged) XFREE_CLEAR(globaldir); break; case kCdScopeTabpage: - curtab->tp_localdir = (char_u *)xstrdup(cwd); + curtab->tp_localdir = xstrdup(cwd); break; case kCdScopeWindow: - curwin->w_localdir = (char_u *)xstrdup(cwd); + curwin->w_localdir = xstrdup(cwd); break; case kCdScopeInvalid: abort(); @@ -8249,10 +8249,10 @@ bool changedir_func(char *new_dir, CdScope scope) char **pp; switch (scope) { case kCdScopeTabpage: - pp = (char **)&curtab->tp_prevdir; + pp = &curtab->tp_prevdir; break; case kCdScopeWindow: - pp = (char **)&curwin->w_prevdir; + pp = &curwin->w_prevdir; break; default: pp = &prev_dir; @@ -8380,10 +8380,10 @@ static void ex_winsize(exarg_T *eap) semsg(_(e_invarg2), arg); return; } - int w = getdigits_int((char_u **)&arg, false, 10); + int w = getdigits_int(&arg, false, 10); arg = skipwhite(arg); char *p = arg; - int h = getdigits_int((char_u **)&arg, false, 10); + int h = getdigits_int(&arg, false, 10); if (*p != NUL && *arg == NUL) { screen_resize(w, h); } else { @@ -8559,7 +8559,7 @@ static void ex_join(exarg_T *eap) } ++eap->line2; } - do_join((size_t)(eap->line2 - eap->line1 + 1), !eap->forceit, true, true, true); + do_join((size_t)((ssize_t)eap->line2 - eap->line1 + 1), !eap->forceit, true, true, true); beginline(BL_WHITE | BL_FIX); ex_may_print(eap); } @@ -9478,7 +9478,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum if (*s == '<') { // "#<99" uses v:oldfiles. s++; } - i = getdigits_int((char_u **)&s, false, 0); + i = getdigits_int(&s, false, 0); if ((char_u *)s == src + 2 && src[1] == '-') { // just a minus sign, don't skip over it s--; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 1982b2dace..f8c9e1f3ea 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4455,14 +4455,13 @@ static void escape_fname(char_u **pp) */ void tilde_replace(char_u *orig_pat, int num_files, char_u **files) { - int i; - char_u *p; + char *p; if (orig_pat[0] == '~' && vim_ispathsep(orig_pat[1])) { - for (i = 0; i < num_files; ++i) { - p = home_replace_save(NULL, files[i]); + for (int i = 0; i < num_files; i++) { + p = home_replace_save(NULL, (char *)files[i]); xfree(files[i]); - files[i] = p; + files[i] = (char_u *)p; } } } @@ -5164,10 +5163,10 @@ static int ExpandFromContext(expand_T *xp, char_u *pat, int *num_file, char_u ** return OK; } if (xp->xp_context == EXPAND_BUFFERS) { - return ExpandBufnames(pat, num_file, file, options); + return ExpandBufnames((char *)pat, num_file, (char ***)file, options); } if (xp->xp_context == EXPAND_DIFF_BUFFERS) { - return ExpandBufnames(pat, num_file, file, options | BUF_DIFF_FILTER); + return ExpandBufnames((char *)pat, num_file, (char ***)file, options | BUF_DIFF_FILTER); } if (xp->xp_context == EXPAND_TAGS || xp->xp_context == EXPAND_TAGS_LISTFILES) { @@ -5320,8 +5319,8 @@ static void ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, cha if (*str == NUL) { // skip empty strings continue; } - if (vim_regexec(regmatch, str, (colnr_T)0)) { - ++count; + if (vim_regexec(regmatch, (char *)str, (colnr_T)0)) { + count++; } } if (count == 0) { @@ -5341,7 +5340,7 @@ static void ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, cha if (*str == NUL) { // Skip empty strings. continue; } - if (vim_regexec(regmatch, str, (colnr_T)0)) { + if (vim_regexec(regmatch, (char *)str, (colnr_T)0)) { if (escaped) { str = vim_strsave_escaped(str, (char_u *)" \t\\."); } else { @@ -5573,7 +5572,7 @@ static int ExpandUserDefined(expand_T *xp, regmatch_T *regmatch, int *num_file, *e = NUL; const bool skip = xp->xp_pattern[0] - && vim_regexec(regmatch, s, (colnr_T)0) == 0; + && vim_regexec(regmatch, (char *)s, (colnr_T)0) == 0; *e = keep; if (!skip) { GA_APPEND(char_u *, &ga, vim_strnsave(s, (size_t)(e - s))); @@ -5814,7 +5813,7 @@ void globpath(char_u *path, char_u *file, garray_T *ga, int expand_options) // Loop over all entries in {path}. while (*path != NUL) { // Copy one item of the path to buf[] and concatenate the file name. - copy_option_part(&path, buf, MAXPATHL, ","); + copy_option_part((char **)&path, (char *)buf, MAXPATHL, ","); if (STRLEN(buf) + STRLEN(file) + 2 < MAXPATHL) { add_pathsep((char *)buf); STRCAT(buf, file); // NOLINT @@ -6370,7 +6369,7 @@ int del_history_entry(int histype, char_u *str) if (hisptr->hisstr == NULL) { break; } - if (vim_regexec(®match, hisptr->hisstr, (colnr_T)0)) { + if (vim_regexec(®match, (char *)hisptr->hisstr, (colnr_T)0)) { found = true; hist_free_entry(hisptr); } else { @@ -6538,7 +6537,7 @@ void ex_history(exarg_T *eap) snprintf((char *)IObuff, IOSIZE, "%c%6d ", i == idx ? '>' : ' ', hist[i].hisnum); if (vim_strsize((char *)hist[i].hisstr) > Columns - 10) { - trunc_string(hist[i].hisstr, IObuff + STRLEN(IObuff), + trunc_string((char *)hist[i].hisstr, (char *)IObuff + STRLEN(IObuff), Columns - 10, IOSIZE - (int)STRLEN(IObuff)); } else { STRCAT(IObuff, hist[i].hisstr); diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index a02232b402..d18ef3a188 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -248,9 +248,9 @@ static char *ses_get_fname(buf_T *buf, unsigned *flagp) && (ssop_flags & (SSOP_CURDIR | SSOP_SESDIR)) && !p_acd && !did_lcd) { - return (char *)buf->b_sfname; + return buf->b_sfname; } - return (char *)buf->b_ffname; + return buf->b_ffname; } /// Write a buffer name to the session file. @@ -275,7 +275,7 @@ static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp, bool add_eol) static char *ses_escape_fname(char *name, unsigned *flagp) { char *p; - char *sname = (char *)home_replace_save(NULL, (char_u *)name); + char *sname = home_replace_save(NULL, name); // Always SSOP_SLASH: change all backslashes to forward slashes. for (p = sname; *p != NUL; MB_PTR_ADV(p)) { @@ -517,7 +517,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr if (wp->w_localdir != NULL && (flagp != &vop_flags || (*flagp & SSOP_CURDIR))) { if (fputs("lcd ", fd) < 0 - || ses_put_fname(fd, wp->w_localdir, flagp) == FAIL + || ses_put_fname(fd, (char_u *)wp->w_localdir, flagp) == FAIL || fprintf(fd, "\n") < 0) { return FAIL; } @@ -542,7 +542,7 @@ static int makeopens(FILE *fd, char_u *dirnow) int nr; int restore_size = true; win_T *wp; - char_u *sname; + char *sname; win_T *edited_win = NULL; int tabnr; win_T *tab_firstwin; @@ -575,8 +575,8 @@ static int makeopens(FILE *fd, char_u *dirnow) if (ssop_flags & SSOP_SESDIR) { PUTLINE_FAIL("exe \"cd \" . escape(expand(\"<sfile>:p:h\"), ' ')"); } else if (ssop_flags & SSOP_CURDIR) { - sname = home_replace_save(NULL, globaldir != NULL ? (char_u *)globaldir : dirnow); - char *fname_esc = ses_escape_fname((char *)sname, &ssop_flags); + sname = home_replace_save(NULL, globaldir != NULL ? globaldir : (char *)dirnow); + char *fname_esc = ses_escape_fname(sname, &ssop_flags); if (fprintf(fd, "cd %s\n", fname_esc) < 0) { xfree(fname_esc); xfree(sname); @@ -821,7 +821,7 @@ static int makeopens(FILE *fd, char_u *dirnow) // Take care of tab-local working directories if applicable if (tp->tp_localdir) { if (fputs("if exists(':tcd') == 2 | tcd ", fd) < 0 - || ses_put_fname(fd, tp->tp_localdir, &ssop_flags) == FAIL + || ses_put_fname(fd, (char_u *)tp->tp_localdir, &ssop_flags) == FAIL || fputs(" | endif\n", fd) < 0) { return FAIL; } @@ -1001,7 +1001,7 @@ void ex_mkrc(exarg_T *eap) *dirnow = NUL; } if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) { - if (vim_chdirfile((char_u *)fname, kCdCauseOther) == OK) { + if (vim_chdirfile(fname, kCdCauseOther) == OK) { shorten_fnames(true); } } else if (*dirnow != NUL @@ -1075,7 +1075,7 @@ static char *get_view_file(int c) emsg(_(e_noname)); return NULL; } - char *sname = (char *)home_replace_save(NULL, curbuf->b_ffname); + char *sname = home_replace_save(NULL, curbuf->b_ffname); // We want a file name without separators, because we're not going to make // a directory. diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index e327b97fbe..ca276b8a40 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -893,8 +893,7 @@ char_u *vim_findfile(void *search_ctx_arg) break; } assert(MAXPATHL >= len); - copy_option_part(&suf, file_path + len, - MAXPATHL - len, ","); + copy_option_part((char **)&suf, (char *)file_path + len, MAXPATHL - len, ","); } } } else { @@ -1503,7 +1502,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first break; } assert(MAXPATHL >= l); - copy_option_part(&buf, NameBuff + l, MAXPATHL - l, ","); + copy_option_part((char **)&buf, (char *)NameBuff + l, MAXPATHL - l, ","); } } } @@ -1543,7 +1542,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first // copy next path buf[0] = 0; - copy_option_part(&dir, buf, MAXPATHL, " ,"); + copy_option_part((char **)&dir, (char *)buf, MAXPATHL, " ,"); // get the stopdir string r_ptr = vim_findfile_stopdir(buf); @@ -1653,12 +1652,12 @@ void do_autocmd_dirchanged(char *new_dir, CdScope scope, CdCause cause, bool pre /// Caller must call shorten_fnames()! /// /// @return OK or FAIL -int vim_chdirfile(char_u *fname, CdCause cause) +int vim_chdirfile(char *fname, CdCause cause) { char dir[MAXPATHL]; STRLCPY(dir, fname, MAXPATHL); - *path_tail_with_sep((char_u *)dir) = NUL; + *path_tail_with_sep(dir) = NUL; if (os_dirname(NameBuff, sizeof(NameBuff)) != OK) { NameBuff[0] = NUL; @@ -1688,7 +1687,7 @@ int vim_chdirfile(char_u *fname, CdCause cause) int vim_chdir(char_u *new_dir) { char *dir_name = (char *)find_directory_in_path(new_dir, STRLEN(new_dir), - FNAME_MESS, curbuf->b_ffname); + FNAME_MESS, (char_u *)curbuf->b_ffname); if (dir_name == NULL) { return -1; } diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 9ba55befdd..febde53ce2 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -275,10 +275,9 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, // executing nasty autocommands. Also check if "fname" and "sfname" // point to one of these values. old_curbuf = curbuf; - old_b_ffname = (char *)curbuf->b_ffname; + old_b_ffname = curbuf->b_ffname; old_b_fname = curbuf->b_fname; - using_b_ffname = ((char_u *)fname == curbuf->b_ffname) - || ((char_u *)sfname == curbuf->b_ffname); + using_b_ffname = (fname == curbuf->b_ffname) || (sfname == curbuf->b_ffname); 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 @@ -373,7 +372,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, && !S_ISFIFO(perm) // ... or fifo && !S_ISSOCK(perm) // ... or socket #ifdef OPEN_CHR_FILES - && !(S_ISCHR(perm) && is_dev_fd_file((char_u *)fname)) + && !(S_ISCHR(perm) && is_dev_fd_file(fname)) // ... or a character special file named /dev/fd/<n> #endif ) { @@ -466,7 +465,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, // SwapExists autocommand may mess things up if (curbuf != old_curbuf || (using_b_ffname - && ((char_u *)old_b_ffname != curbuf->b_ffname)) + && (old_b_ffname != curbuf->b_ffname)) || (using_b_fname && (old_b_fname != curbuf->b_fname))) { emsg(_(e_auchangedbuf)); @@ -538,7 +537,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, check_need_swap(newfile); if (!read_stdin && (curbuf != old_curbuf - || (using_b_ffname && ((char_u *)old_b_ffname != curbuf->b_ffname)) + || (using_b_ffname && (old_b_ffname != curbuf->b_ffname)) || (using_b_fname && (old_b_fname != curbuf->b_fname)))) { emsg(_(e_auchangedbuf)); if (!read_buffer) { @@ -645,7 +644,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, * (cd for example) if it invalidates fname or sfname. */ if (!read_stdin && (curbuf != old_curbuf - || (using_b_ffname && ((char_u *)old_b_ffname != curbuf->b_ffname)) + || (using_b_ffname && (old_b_ffname != curbuf->b_ffname)) || (using_b_fname && (old_b_fname != curbuf->b_fname)) || (fd = os_open(fname, O_RDONLY, 0)) < 0)) { no_wait_return--; @@ -1974,12 +1973,12 @@ failed: /// Do not accept "/dev/fd/[012]", opening these may hang Vim. /// /// @param fname file name to check -bool is_dev_fd_file(char_u *fname) +bool is_dev_fd_file(char *fname) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { return STRNCMP(fname, "/dev/fd/", 8) == 0 - && ascii_isdigit(fname[8]) - && *skipdigits((char *)fname + 9) == NUL + && ascii_isdigit((uint8_t)fname[8]) + && *skipdigits(fname + 9) == NUL && (fname[9] != NUL || (fname[8] != '0' && fname[8] != '1' && fname[8] != '2')); } @@ -2342,16 +2341,16 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en * Set curbuf to the buffer to be written. * Careful: The autocommands may call buf_write() recursively! */ - if ((char_u *)ffname == buf->b_ffname) { + if (ffname == buf->b_ffname) { buf_ffname = true; } - if ((char_u *)sfname == buf->b_sfname) { + if (sfname == buf->b_sfname) { buf_sfname = true; } - if ((char_u *)fname == buf->b_ffname) { + if (fname == buf->b_ffname) { buf_fname_f = true; } - if ((char_u *)fname == buf->b_sfname) { + if (fname == buf->b_sfname) { buf_fname_s = true; } @@ -2491,16 +2490,16 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en * be kept in fname, ffname and sfname. */ if (buf_ffname) { - ffname = (char *)buf->b_ffname; + ffname = buf->b_ffname; } if (buf_sfname) { - sfname = (char *)buf->b_sfname; + sfname = buf->b_sfname; } if (buf_fname_f) { - fname = (char *)buf->b_ffname; + fname = buf->b_ffname; } if (buf_fname_s) { - fname = (char *)buf->b_sfname; + fname = buf->b_sfname; } } @@ -2762,7 +2761,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en /* * Isolate one directory name, using an entry in 'bdir'. */ - size_t dir_len = copy_option_part((char_u **)&dirp, IObuff, IOSIZE, ","); + size_t dir_len = copy_option_part(&dirp, (char *)IObuff, IOSIZE, ","); p = (char *)IObuff + dir_len; bool trailing_pathseps = after_pathsep((char *)IObuff, p) && p[-1] == p[-2]; if (trailing_pathseps) { @@ -2923,7 +2922,7 @@ nobackup: /* * Isolate one directory name and make the backup file name. */ - size_t dir_len = copy_option_part((char_u **)&dirp, IObuff, IOSIZE, ","); + size_t dir_len = copy_option_part(&dirp, (char *)IObuff, IOSIZE, ","); p = (char *)IObuff + dir_len; bool trailing_pathseps = after_pathsep((char *)IObuff, p) && p[-1] == p[-2]; if (trailing_pathseps) { @@ -4304,24 +4303,24 @@ static int make_bom(char_u *buf, char_u *name) /// name. void shorten_buf_fname(buf_T *buf, char_u *dirname, int force) { - char_u *p; + char *p; if (buf->b_fname != NULL && !bt_nofile(buf) && !path_with_url(buf->b_fname) && (force || buf->b_sfname == NULL - || path_is_absolute(buf->b_sfname))) { + || path_is_absolute((char_u *)buf->b_sfname))) { if (buf->b_sfname != buf->b_ffname) { XFREE_CLEAR(buf->b_sfname); } - p = path_shorten_fname(buf->b_ffname, dirname); + p = (char *)path_shorten_fname((char_u *)buf->b_ffname, dirname); if (p != NULL) { - buf->b_sfname = vim_strsave(p); - buf->b_fname = (char *)buf->b_sfname; + buf->b_sfname = xstrdup(p); + buf->b_fname = buf->b_sfname; } if (p == NULL) { - buf->b_fname = (char *)buf->b_ffname; + buf->b_fname = buf->b_ffname; } } } @@ -4918,7 +4917,7 @@ int buf_check_timestamp(buf_T *buf) bool file_info_ok; if (!(buf->b_flags & BF_NOTEDITED) && buf->b_mtime != 0 - && (!(file_info_ok = os_fileinfo((char *)buf->b_ffname, &file_info)) + && (!(file_info_ok = os_fileinfo(buf->b_ffname, &file_info)) || time_differs(&file_info, buf->b_mtime, buf->b_mtime_ns) || (int)file_info.stat.st_mode != buf->b_orig_mode)) { const long prev_b_mtime = buf->b_mtime; @@ -5016,7 +5015,7 @@ int buf_check_timestamp(buf_T *buf) } } } else if ((buf->b_flags & BF_NEW) && !(buf->b_flags & BF_NEW_W) - && os_path_exists(buf->b_ffname)) { + && os_path_exists((char_u *)buf->b_ffname)) { retval = 1; mesg = _("W13: Warning: File \"%s\" has been created after editing started"); buf->b_flags |= BF_NEW_W; @@ -5024,7 +5023,7 @@ int buf_check_timestamp(buf_T *buf) } if (mesg != NULL) { - path = home_replace_save(buf, (char_u *)buf->b_fname); + path = (char_u *)home_replace_save(buf, buf->b_fname); if (!helpmesg) { mesg2 = ""; } @@ -5169,7 +5168,7 @@ void buf_reload(buf_T *buf, int orig_mode, bool reload_options) if (saved == OK) { curbuf->b_flags |= BF_CHECK_RO; // check for RO again keep_filetype = true; // don't detect 'filetype' - if (readfile((char *)buf->b_ffname, buf->b_fname, (linenr_T)0, (linenr_T)0, + if (readfile(buf->b_ffname, buf->b_fname, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, &ea, flags, false) != OK) { if (!aborting()) { semsg(_("E321: Could not reload \"%s\""), buf->b_fname); @@ -5547,10 +5546,10 @@ bool match_file_pat(char *pattern, regprog_T **prog, char *fname, char *sfname, */ if (regmatch.regprog != NULL && ((allow_dirs - && (vim_regexec(®match, (char_u *)fname, (colnr_T)0) + && (vim_regexec(®match, fname, (colnr_T)0) || (sfname != NULL - && vim_regexec(®match, (char_u *)sfname, (colnr_T)0)))) - || (!allow_dirs && vim_regexec(®match, (char_u *)tail, (colnr_T)0)))) { + && vim_regexec(®match, sfname, (colnr_T)0)))) + || (!allow_dirs && vim_regexec(®match, tail, (colnr_T)0)))) { result = true; } @@ -5586,7 +5585,7 @@ bool match_file_list(char_u *list, char_u *sfname, char_u *ffname) // try all patterns in 'wildignore' p = list; while (*p) { - copy_option_part(&p, buf, ARRAY_SIZE(buf), ","); + copy_option_part((char **)&p, (char *)buf, ARRAY_SIZE(buf), ","); regpat = (char_u *)file_pat_to_reg_pat((char *)buf, NULL, &allow_dirs, false); if (regpat == NULL) { break; diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index b96220d547..a4cf65e816 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -342,7 +342,7 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_ break; } - table[idx].number = getdigits_int(&p, false, 0); + table[idx].number = getdigits_int((char **)&p, false, 0); } table[idx].string = p; @@ -659,7 +659,8 @@ void ex_hardcopy(exarg_T *eap) */ if (mch_print_init(&settings, curbuf->b_fname == NULL ? (char_u *)buf_spname(curbuf) : curbuf->b_sfname == - NULL ? (char_u *)curbuf->b_fname : curbuf->b_sfname, eap->forceit) == FAIL) { + NULL ? (char_u *)curbuf->b_fname : (char_u *)curbuf->b_sfname, + eap->forceit) == FAIL) { return; } diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c index ca6f033c47..95ae7a152c 100644 --- a/src/nvim/hashtab.c +++ b/src/nvim/hashtab.c @@ -85,9 +85,9 @@ void hash_clear_all(hashtab_T *ht, unsigned int off) /// used for that key. /// WARNING: Returned pointer becomes invalid as soon as the hash table /// is changed in any way. -hashitem_T *hash_find(const hashtab_T *const ht, const char_u *const key) +hashitem_T *hash_find(const hashtab_T *const ht, const char *const key) { - return hash_lookup(ht, (const char *)key, STRLEN(key), hash_hash(key)); + return hash_lookup(ht, key, STRLEN(key), hash_hash((char_u *)key)); } /// Like hash_find, but key is not NUL-terminated diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 8a5b4cbf0f..9d60cf9dfe 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -400,7 +400,7 @@ int get_number_indent(linenr_T lnum) // In format_lines() (i.e. not insert mode), fo+=q is needed too... 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((char *)ml_get(lnum), NULL, false, true); } regmatch.regprog = vim_regcomp((char *)curbuf->b_p_flp, RE_MAGIC); @@ -409,7 +409,7 @@ int get_number_indent(linenr_T lnum) // vim_regexec() expects a pointer to a line. This lets us // start matching for the flp beyond any comment leader... - if (vim_regexec(®match, ml_get(lnum) + lead_len, (colnr_T)0)) { + if (vim_regexec(®match, (char *)ml_get(lnum) + lead_len, (colnr_T)0)) { pos.lnum = lnum; pos.col = (colnr_T)(*regmatch.endp - ml_get(lnum)); pos.coladd = 0; @@ -468,7 +468,7 @@ int get_breakindent_win(win_T *wp, char_u *line) if (regmatch.regprog != NULL) { regmatch.rm_ic = false; - if (vim_regexec(®match, line, 0)) { + if (vim_regexec(®match, (char *)line, 0)) { if (wp->w_briopt_list > 0) { bri += wp->w_briopt_list; } else { @@ -769,7 +769,7 @@ static int lisp_match(char_u *p) char_u *word = *curbuf->b_p_lw != NUL ? curbuf->b_p_lw : p_lispwords; while (*word != NUL) { - (void)copy_option_part(&word, buf, LSIZE, ","); + (void)copy_option_part((char **)&word, (char *)buf, LSIZE, ","); len = (int)STRLEN(buf); if ((STRNCMP(buf, p, len) == 0) && (p[len] == ' ')) { diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index cb807dec24..3c74b4bd8d 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -224,7 +224,7 @@ bool cin_is_cinword(const char_u *line) line = (char_u *)skipwhite((char *)line); for (char_u *cinw = curbuf->b_p_cinw; *cinw;) { - size_t len = copy_option_part(&cinw, cinw_buf, cinw_len, ","); + size_t len = copy_option_part((char **)&cinw, (char *)cinw_buf, cinw_len, ","); if (STRNCMP(line, cinw_buf, len) == 0 && (!vim_iswordc(line[len]) || !vim_iswordc(line[len - 1]))) { retval = true; @@ -520,7 +520,7 @@ bool cin_isscopedecl(const char_u *p) bool found = false; for (char_u *cinsd = curbuf->b_p_cinsd; *cinsd;) { - const size_t len = copy_option_part(&cinsd, cinsd_buf, cinsd_len, ","); + const size_t len = copy_option_part((char **)&cinsd, (char *)cinsd_buf, cinsd_len, ","); if (STRNCMP(s, cinsd_buf, len) == 0) { const char_u *skip = cin_skipcomment(s + len); if (*skip == ':' && skip[1] != ':') { @@ -1501,7 +1501,7 @@ retry: if ((trypos = findmatchlimit(NULL, c, 0, ind_maxp_wk)) != NULL) { // check if the ( is in a // comment if ((colnr_T)cin_skip2pos(trypos) > trypos->col) { - ind_maxp_wk = ind_maxparen - (int)(cursor_save.lnum - trypos->lnum); + ind_maxp_wk = ind_maxparen - (cursor_save.lnum - trypos->lnum); if (ind_maxp_wk > 0) { curwin->w_cursor = *trypos; curwin->w_cursor.col = 0; // XXX @@ -1515,7 +1515,7 @@ retry: trypos = &pos_copy; curwin->w_cursor = *trypos; if ((trypos_wk = ind_find_start_CORS(NULL)) != NULL) { // XXX - ind_maxp_wk = ind_maxparen - (int)(cursor_save.lnum - trypos_wk->lnum); + ind_maxp_wk = ind_maxparen - (cursor_save.lnum - trypos_wk->lnum); if (ind_maxp_wk > 0) { curwin->w_cursor = *trypos_wk; goto retry; @@ -1746,7 +1746,7 @@ void parse_cino(buf_T *buf) p++; } char_u *digits_start = p; // remember where the digits start - int n = getdigits_int(&p, true, 0); + int n = getdigits_int((char **)&p, true, 0); divider = 0; if (*p == '.') { // ".5s" means a fraction. fraction = atoi((char *)++p); @@ -2075,7 +2075,7 @@ int get_c_indent(void) } else if (*p == COM_LEFT || *p == COM_RIGHT) { align = *p++; } else if (ascii_isdigit(*p) || *p == '-') { - off = getdigits_int(&p, true, 0); + off = getdigits_int((char **)&p, true, 0); } else { p++; } @@ -2084,7 +2084,7 @@ int get_c_indent(void) if (*p == ':') { p++; } - (void)copy_option_part(&p, (char_u *)lead_end, COM_MAX_LEN, ","); + (void)copy_option_part((char **)&p, lead_end, COM_MAX_LEN, ","); if (what == COM_START) { STRCPY(lead_start, lead_end); lead_start_len = (int)STRLEN(lead_start); diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index b911eb8b59..7afb31d55b 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -55,7 +55,7 @@ static int regex_match(lua_State *lstate, regprog_T **prog, char_u *str) regmatch_T rm; rm.regprog = *prog; rm.rm_ic = false; - bool match = vim_regexec(&rm, str, 0); + bool match = vim_regexec(&rm, (char *)str, 0); *prog = rm.regprog; if (match) { @@ -252,7 +252,7 @@ static int nlua_str_utf_end(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL if (offset < 0 || offset > (intptr_t)s1_len) { return luaL_error(lstate, "index out of range"); } - int tail_offset = mb_tail_off((char_u *)s1, (char_u *)s1 + offset - 1); + int tail_offset = mb_tail_off(s1, s1 + offset - 1); lua_pushinteger(lstate, tail_offset); return 1; } diff --git a/src/nvim/main.c b/src/nvim/main.c index a7e39b7655..db588d4694 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -802,7 +802,7 @@ static void init_locale(void) char localepath[MAXPATHL] = { 0 }; snprintf(localepath, sizeof(localepath), "%s", get_vim_var_str(VV_PROGPATH)); - char *tail = (char *)path_tail_with_sep((char_u *)localepath); + char *tail = path_tail_with_sep(localepath); *tail = NUL; tail = path_tail(localepath); xstrlcpy(tail, "share/locale", @@ -1354,11 +1354,11 @@ scripterror: // Add the file to the global argument list. ga_grow(&global_alist.al_ga, 1); - char_u *p = vim_strsave((char_u *)argv[0]); + char *p = xstrdup(argv[0]); - if (parmp->diff_mode && os_isdir(p) && GARGCOUNT > 0 + if (parmp->diff_mode && os_isdir((char_u *)p) && GARGCOUNT > 0 && !os_isdir((char_u *)alist_name(&GARGLIST[0]))) { - char_u *r = (char_u *)concat_fnames((char *)p, path_tail(alist_name(&GARGLIST[0])), true); + char *r = concat_fnames(p, path_tail(alist_name(&GARGLIST[0])), true); xfree(p); p = r; } @@ -1371,7 +1371,7 @@ scripterror: int alist_fnum_flag = edit_stdin(had_stdin_file, parmp) ? 1 // add buffer nr after exp. : 2; // add buffer number now and use curbuf - alist_add(&global_alist, (char *)p, alist_fnum_flag); + alist_add(&global_alist, p, alist_fnum_flag); } // If there are no more letters after the current "-", go to next argument. diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index ff7a3da5c3..9a4db520a6 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -1266,7 +1266,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file) continue; } - if (vim_regexec(regmatch, p, (colnr_T)0)) { + if (vim_regexec(regmatch, (char *)p, (colnr_T)0)) { if (round == 1) { count++; } else { @@ -1289,7 +1289,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file) for (; mp; mp = mp->m_next) { if (mp->m_mode & expand_mapmodes) { p = translate_mapping(mp->m_keys, CPO_TO_CPO_FLAGS); - if (p != NULL && vim_regexec(regmatch, p, (colnr_T)0)) { + if (p != NULL && vim_regexec(regmatch, (char *)p, (colnr_T)0)) { if (round == 1) { count++; } else { diff --git a/src/nvim/mark.c b/src/nvim/mark.c index effd2186f7..de668458f0 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -690,7 +690,7 @@ static void fname2fnum(xfmark_T *fm) p = path_shorten_fname(NameBuff, IObuff); // buflist_new() will call fmarks_check_names() - (void)buflist_new(NameBuff, p, (linenr_T)1, 0); + (void)buflist_new((char *)NameBuff, (char *)p, (linenr_T)1, 0); } } @@ -701,7 +701,7 @@ static void fname2fnum(xfmark_T *fm) */ void fmarks_check_names(buf_T *buf) { - char_u *name = buf->b_ffname; + char_u *name = (char_u *)buf->b_ffname; int i; if (buf->b_ffname == NULL) { @@ -806,7 +806,7 @@ char_u *fm_getname(fmark_T *fmark, int lead_len) if (fmark->fnum == curbuf->b_fnum) { // current buffer return mark_line(&(fmark->mark), lead_len); } - return buflist_nr2name(fmark->fnum, FALSE, TRUE); + return (char_u *)buflist_nr2name(fmark->fnum, false, true); } /* @@ -1851,7 +1851,7 @@ void get_global_marks(list_T *l) // Marks 'A' to 'Z' and '0' to '9' for (int i = 0; i < NMARKS + EXTRA_MARKS; i++) { if (namedfm[i].fmark.fnum != 0) { - name = (char *)buflist_nr2name(namedfm[i].fmark.fnum, true, true); + name = buflist_nr2name(namedfm[i].fmark.fnum, true, true); } else { name = namedfm[i].fname; } diff --git a/src/nvim/match.c b/src/nvim/match.c index 3aa82527aa..54bd3066ab 100644 --- a/src/nvim/match.c +++ b/src/nvim/match.c @@ -86,7 +86,7 @@ static int match_add(win_T *wp, const char *const grp, const char *const pat, in m = xcalloc(1, sizeof(matchitem_T)); m->id = id; m->priority = prio; - m->pattern = pat == NULL ? NULL: (char_u *)xstrdup(pat); + m->pattern = pat == NULL ? NULL: xstrdup(pat); m->hlg_id = hlg_id; m->match.regprog = regprog; m->match.rmm_ic = false; diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 1032986a02..a9792cf1b9 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1840,8 +1840,9 @@ int mb_off_next(const char_u *base, const char_u *p) /// Return the offset from "p" to the last byte of the character it points /// into. Can start anywhere in a stream of bytes. /// Composing characters are not included. -int mb_tail_off(const char_u *base, const char_u *p) +int mb_tail_off(const char *base, const char *p_in) { + const uint8_t *p = (uint8_t *)p_in; int i; int j; @@ -1853,7 +1854,7 @@ int mb_tail_off(const char_u *base, const char_u *p) for (i = 0; (p[i + 1] & 0xc0) == 0x80; i++) {} // Check for illegal sequence. - for (j = 0; p - j > base; j++) { + for (j = 0; p_in - j > base; j++) { if ((p[-j] & 0xc0) != 0x80) { break; } diff --git a/src/nvim/memline.c b/src/nvim/memline.c index ce47e0add6..1c54035a9e 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -665,7 +665,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf) * First replace home dir path with "~/" with home_replace(). * Then insert the user name to get "~user/". */ - home_replace(NULL, (char *)buf->b_ffname, (char *)b0p->b0_fname, + home_replace(NULL, buf->b_ffname, (char *)b0p->b0_fname, B0_FNAME_SIZE_CRYPT, true); if (b0p->b0_fname[0] == '~') { // If there is no user name or it is too long, don't use "~/" @@ -680,7 +680,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf) } } FileInfo file_info; - if (os_fileinfo((char *)buf->b_ffname, &file_info)) { + if (os_fileinfo(buf->b_ffname, &file_info)) { long_to_char(file_info.stat.st_mtim.tv_sec, b0p->b0_mtime); long_to_char((long)os_fileinfo_inode(&file_info), b0p->b0_ino); buf_store_file_info(buf, &file_info); @@ -708,7 +708,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf) /// not set. static void set_b0_dir_flag(ZERO_BL *b0p, buf_T *buf) { - if (same_directory(buf->b_ml.ml_mfp->mf_fname, buf->b_ffname)) { + if (same_directory(buf->b_ml.ml_mfp->mf_fname, (char_u *)buf->b_ffname)) { b0p->b0_flags |= B0_SAME_DIR; } else { b0p->b0_flags &= ~B0_SAME_DIR; @@ -944,7 +944,7 @@ void ml_recover(bool checkext) if (buf_spname(curbuf) != NULL) { STRLCPY(NameBuff, buf_spname(curbuf), MAXPATHL); } else { - home_replace(NULL, (char *)curbuf->b_ffname, (char *)NameBuff, MAXPATHL, true); + home_replace(NULL, curbuf->b_ffname, (char *)NameBuff, MAXPATHL, true); } smsg(_("Original file \"%s\""), NameBuff); msg_putchar('\n'); @@ -956,7 +956,7 @@ void ml_recover(bool checkext) FileInfo swp_file_info; mtime = char_to_long(b0p->b0_mtime); if (curbuf->b_ffname != NULL - && os_fileinfo((char *)curbuf->b_ffname, &org_file_info) + && os_fileinfo(curbuf->b_ffname, &org_file_info) && ((os_fileinfo((char *)mfp->mf_fname, &swp_file_info) && org_file_info.stat.st_mtim.tv_sec > swp_file_info.stat.st_mtim.tv_sec) @@ -990,7 +990,7 @@ void ml_recover(bool checkext) * 'fileencoding', etc. Ignore errors. The text itself is not used. */ if (curbuf->b_ffname != NULL) { - orig_file_status = readfile((char *)curbuf->b_ffname, NULL, (linenr_T)0, + orig_file_status = readfile(curbuf->b_ffname, NULL, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, NULL, READ_NEW, false); } @@ -1064,7 +1064,7 @@ void ml_recover(bool checkext) */ if (!cannot_open) { line_count = pp->pb_pointer[idx].pe_line_count; - if (readfile((char *)curbuf->b_ffname, NULL, lnum, + if (readfile(curbuf->b_ffname, NULL, lnum, pp->pb_pointer[idx].pe_old_lnum - 1, line_count, NULL, 0, false) != OK) { cannot_open = true; @@ -1305,7 +1305,7 @@ int recover_names(char_u *fname, int list, int nr, char_u **fname_out) // Isolate a directory name from *dirp and put it in dir_name (we know // it is large enough, so use 31000 for length). // Advance dirp to next directory name. - (void)copy_option_part(&dirp, dir_name, 31000, ","); + (void)copy_option_part((char **)&dirp, (char *)dir_name, 31000, ","); if (dir_name[0] == '.' && dir_name[1] == NUL) { // check current dir if (fname == NULL) { @@ -1694,7 +1694,7 @@ void ml_sync_all(int check_file, int check_char, bool do_fsync) * call ml_preserve() to get rid of all negative numbered blocks. */ FileInfo file_info; - if (!os_fileinfo((char *)buf->b_ffname, &file_info) + if (!os_fileinfo(buf->b_ffname, &file_info) || file_info.stat.st_mtim.tv_sec != buf->b_mtime_read || file_info.stat.st_mtim.tv_nsec != buf->b_mtime_read_ns || os_fileinfo_size(&file_info) != buf->b_orig_size) { @@ -3426,12 +3426,12 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_ */ const size_t dir_len = strlen(*dirp) + 1; dir_name = xmalloc(dir_len); - (void)copy_option_part((char_u **)dirp, (char_u *)dir_name, dir_len, ","); + (void)copy_option_part(dirp, dir_name, dir_len, ","); /* * we try different names until we find one that does not exist yet */ - fname = (char *)makeswapname((char_u *)buf_fname, buf->b_ffname, buf, + fname = (char *)makeswapname((char_u *)buf_fname, (char_u *)buf->b_ffname, buf, (char_u *)dir_name); for (;;) { @@ -3479,12 +3479,12 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_ if (b0.b0_flags & B0_SAME_DIR) { if (FNAMECMP(path_tail((char *)buf->b_ffname), path_tail((char *)b0.b0_fname)) != 0 - || !same_directory((char_u *)fname, buf->b_ffname)) { + || !same_directory((char_u *)fname, (char_u *)buf->b_ffname)) { // Symlinks may point to the same file even // when the name differs, need to check the // inode too. expand_env(b0.b0_fname, NameBuff, MAXPATHL); - if (fnamecmp_ino(buf->b_ffname, NameBuff, + if (fnamecmp_ino((char_u *)buf->b_ffname, NameBuff, char_to_long(b0.b0_ino))) { differ = TRUE; } @@ -3493,7 +3493,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_ // The name in the swap file may be // "~user/path/file". Expand it first. expand_env(b0.b0_fname, NameBuff, MAXPATHL); - if (fnamecmp_ino(buf->b_ffname, NameBuff, + if (fnamecmp_ino((char_u *)buf->b_ffname, NameBuff, char_to_long(b0.b0_ino))) { differ = TRUE; } diff --git a/src/nvim/message.c b/src/nvim/message.c index 7da8ccd0cb..6ab0a5d3e6 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -387,7 +387,7 @@ char_u *msg_strtrunc(char_u *s, int force) // composing chars) len = (room + 2) * 18; buf = xmalloc((size_t)len); - trunc_string(s, buf, room, len); + trunc_string((char *)s, (char *)buf, room, len); } } return buf; @@ -395,7 +395,7 @@ char_u *msg_strtrunc(char_u *s, int force) /// Truncate a string "s" to "buf" with cell width "room". /// "s" and "buf" may be equal. -void trunc_string(char_u *s, char_u *buf, int room_in, int buflen) +void trunc_string(char *s, char *buf, int room_in, int buflen) { int room = room_in - 3; // "..." takes 3 chars int half; @@ -423,13 +423,13 @@ void trunc_string(char_u *s, char_u *buf, int room_in, int buflen) buf[e] = NUL; return; } - n = ptr2cells((char *)s + e); + n = ptr2cells(s + e); if (len + n > half) { break; } len += n; buf[e] = s[e]; - for (n = utfc_ptr2len((char *)s + e); --n > 0;) { + for (n = utfc_ptr2len(s + e); --n > 0;) { if (++e == buflen) { break; } @@ -441,9 +441,9 @@ void trunc_string(char_u *s, char_u *buf, int room_in, int buflen) half = i = (int)STRLEN(s); for (;;) { do { - half = half - utf_head_off(s, s + half - 1) - 1; - } while (half > 0 && utf_iscomposing(utf_ptr2char((char *)s + half))); - n = ptr2cells((char *)s + half); + half = half - utf_head_off((char_u *)s, (char_u *)s + half - 1) - 1; + } while (half > 0 && utf_iscomposing(utf_ptr2char(s + half))); + n = ptr2cells(s + half); if (len + n > room || half == 0) { break; } @@ -1477,10 +1477,8 @@ void msg_home_replace_hl(char_u *fname) static void msg_home_replace_attr(char_u *fname, int attr) { - char_u *name; - - name = home_replace_save(NULL, fname); - msg_outtrans_attr(name, attr); + char *name = home_replace_save(NULL, (char *)fname); + msg_outtrans_attr((char_u *)name, attr); xfree(name); } @@ -2329,7 +2327,7 @@ bool message_filtered(char_u *msg) return false; } - bool match = vim_regexec(&cmdmod.cmod_filter_regmatch, msg, (colnr_T)0); + bool match = vim_regexec(&cmdmod.cmod_filter_regmatch, (char *)msg, (colnr_T)0); return cmdmod.cmod_filter_force ? match : !match; } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index beeb49ea66..c7f7b569e7 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3143,7 +3143,7 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_ } break; } - if (get_leader_len(get_cursor_line_ptr(), NULL, false, true) > 0) { + if (get_leader_len((char *)get_cursor_line_ptr(), NULL, false, true) > 0) { // Ignore this line, continue at start of next line. curwin->w_cursor.lnum++; curwin->w_cursor.col = 0; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 639b7fd738..a8198cfce9 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1347,7 +1347,7 @@ bool get_spec_reg(int regname, char_u **argp, bool *allocated, bool errmsg) return true; case '#': // alternate file name - *argp = getaltfname(errmsg); // may give emsg if not set + *argp = (char_u *)getaltfname(errmsg); // may give emsg if not set return true; case '=': // result of expression @@ -1810,10 +1810,8 @@ setmarks: /// Used for deletion. static void mb_adjust_opend(oparg_T *oap) { - char_u *p; - if (oap->inclusive) { - p = ml_get(oap->end.lnum); + char *p = (char *)ml_get(oap->end.lnum); oap->end.col += mb_tail_off(p, p + oap->end.col); } } @@ -3886,12 +3884,12 @@ void ex_display(exarg_T *eap) // display alternate file name if ((arg == NULL || vim_strchr((char *)arg, '%') != NULL) && !got_int) { - char_u *fname; + char *fname; linenr_T dummy; - if (buflist_name_nr(0, &fname, &dummy) != FAIL && !message_filtered(fname)) { + if (buflist_name_nr(0, &fname, &dummy) != FAIL && !message_filtered((char_u *)fname)) { msg_puts("\n c \"# "); - dis_msg(fname, false); + dis_msg((char_u *)fname, false); } } @@ -3950,7 +3948,7 @@ char_u *skip_comment(char_u *line, bool process, bool include_space, bool *is_co { char_u *comment_flags = NULL; int lead_len; - int leader_offset = get_last_leader_offset(line, &comment_flags); + int leader_offset = get_last_leader_offset((char *)line, (char **)&comment_flags); *is_comment = false; if (leader_offset != -1) { @@ -3972,7 +3970,7 @@ char_u *skip_comment(char_u *line, bool process, bool include_space, bool *is_co return line; } - lead_len = get_leader_len(line, &comment_flags, false, include_space); + lead_len = get_leader_len((char *)line, (char **)&comment_flags, false, include_space); if (lead_len == 0) { return line; @@ -4654,7 +4652,7 @@ static int fmt_check_par(linenr_T lnum, int *leader_len, char_u **leader_flags, ptr = ml_get(lnum); if (do_comments) { - *leader_len = get_leader_len(ptr, leader_flags, false, true); + *leader_len = get_leader_len((char *)ptr, (char **)leader_flags, false, true); } else { *leader_len = 0; } @@ -5597,7 +5595,7 @@ void write_reg_contents_ex(int name, const char_u *str, ssize_t len, bool must_a semsg(_(e_nobufnr), (int64_t)num); } } else { - buf = buflist_findnr(buflist_findpat(str, str + STRLEN(str), + buf = buflist_findnr(buflist_findpat((char *)str, (char *)str + STRLEN(str), true, false, false)); } if (buf == NULL) { @@ -5993,9 +5991,9 @@ void cursor_pos_info(dict_T *dict) } else { p = get_cursor_line_ptr(); validate_virtcol(); - col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1, + col_print((char *)buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1, (int)curwin->w_virtcol + 1); - col_print(buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p)); + col_print((char *)buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p)); if (char_count_cursor == byte_count_cursor && char_count == byte_count) { @@ -6961,7 +6959,7 @@ bool prepare_yankreg_from_object(yankreg_T *reg, String regtype, size_t lines) return false; } const char *p = regtype.data + 1; - reg->y_width = getdigits_int((char_u **)&p, false, 1) - 1; + reg->y_width = getdigits_int((char **)&p, false, 1) - 1; if (regtype.size > (size_t)(p - regtype.data)) { return false; } diff --git a/src/nvim/option.c b/src/nvim/option.c index 09a597f7e2..bcaa4bb9b8 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1400,7 +1400,7 @@ int do_set(char *arg, int opt_flags) */ else if (varp == (char_u *)&p_bs && ascii_isdigit(**(char_u **)varp)) { - i = getdigits_int((char_u **)varp, true, 0); + i = getdigits_int((char **)varp, true, 0); switch (i) { case 0: *(char_u **)varp = empty_option; @@ -1435,7 +1435,7 @@ int do_set(char *arg, int opt_flags) else if (varp == (char_u *)&p_ww && ascii_isdigit(*arg)) { *errbuf = NUL; - i = getdigits_int((char_u **)&arg, true, 0); + i = getdigits_int(&arg, true, 0); if (i & 1) { STRLCAT(errbuf, "b,", sizeof(errbuf)); } @@ -1728,7 +1728,7 @@ skip: IObuff[i + ((char_u *)arg - startarg)] = NUL; } // make sure all characters are printable - trans_characters(IObuff, IOSIZE); + trans_characters((char *)IObuff, IOSIZE); no_wait_return++; // wait_return done later emsg((char *)IObuff); // show error highlighted @@ -2941,7 +2941,7 @@ ambw_end: if (*++s == '-') { // ignore a '-' s++; } - wid = getdigits_int(&s, true, 0); + wid = getdigits_int((char **)&s, true, 0); if (wid && *s == '(' && (errmsg = check_stl_option((char *)p_ruf)) == NULL) { ru_wid = wid; } else { @@ -3457,7 +3457,7 @@ char *check_colorcolumn(win_T *wp) if (!ascii_isdigit(*s)) { return e_invarg; } - col = col * getdigits_int(&s, true, 0); + col = col * getdigits_int((char **)&s, true, 0); if (wp->w_buffer->b_p_tw == 0) { goto skip; // 'textwidth' not set, skip this item } @@ -3472,7 +3472,7 @@ char *check_colorcolumn(win_T *wp) goto skip; } } else if (ascii_isdigit(*s)) { - col = getdigits_int(&s, true, 0); + col = getdigits_int((char **)&s, true, 0); } else { return e_invarg; } @@ -5650,7 +5650,7 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, uint6 if (fprintf(fd, "%s %s+=", cmd, name) < 0) { goto fail; } - (void)copy_option_part(&p, part, size, ","); + (void)copy_option_part((char **)&p, (char *)part, size, ","); if (put_escstr(fd, part, 2) == FAIL || put_eol(fd) == FAIL) { goto fail; } @@ -6921,7 +6921,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u *** if (xp->xp_context != EXPAND_BOOL_SETTINGS) { for (match = 0; match < (int)ARRAY_SIZE(names); match++) { - if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) { + if (vim_regexec(regmatch, names[match], (colnr_T)0)) { if (loop == 0) { num_normal++; } else { @@ -6940,10 +6940,10 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u *** continue; } match = false; - if (vim_regexec(regmatch, str, (colnr_T)0) + if (vim_regexec(regmatch, (char *)str, (colnr_T)0) || (options[opt_idx].shortname != NULL && vim_regexec(regmatch, - (char_u *)options[opt_idx].shortname, + options[opt_idx].shortname, (colnr_T)0))) { match = true; } @@ -7460,7 +7460,7 @@ void save_file_ff(buf_T *buf) if (buf->b_start_fenc == NULL || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0) { xfree(buf->b_start_fenc); - buf->b_start_fenc = vim_strsave(buf->b_p_fenc); + buf->b_start_fenc = (char *)vim_strsave(buf->b_p_fenc); } } @@ -7827,10 +7827,10 @@ static bool briopt_check(win_T *wp) if (STRNCMP(p, "shift:", 6) == 0 && ((p[6] == '-' && ascii_isdigit(p[7])) || ascii_isdigit(p[6]))) { p += 6; - bri_shift = getdigits_int(&p, true, 0); + bri_shift = getdigits_int((char **)&p, true, 0); } else if (STRNCMP(p, "min:", 4) == 0 && ascii_isdigit(p[4])) { p += 4; - bri_min = getdigits_int(&p, true, 0); + bri_min = getdigits_int((char **)&p, true, 0); } else if (STRNCMP(p, "sbr", 3) == 0) { p += 3; bri_sbr = true; @@ -7991,10 +7991,10 @@ char_u *skip_to_option_part(const char_u *p) /// @param[in] sep_chars chars that separate the option parts /// /// @return length of `*option` -size_t copy_option_part(char_u **option, char_u *buf, size_t maxlen, char *sep_chars) +size_t copy_option_part(char **option, char *buf, size_t maxlen, char *sep_chars) { size_t len = 0; - char_u *p = *option; + char *p = *option; // skip '.' at start of option part, for 'suffixes' if (*p == '.') { @@ -8015,7 +8015,7 @@ size_t copy_option_part(char_u **option, char_u *buf, size_t maxlen, char *sep_c if (*p != NUL && *p != ',') { // skip non-standard separator p++; } - p = skip_to_option_part(p); // p points to next file name + p = (char *)skip_to_option_part((char_u *)p); // p points to next file name *option = p; return len; diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 2a7f7a221f..9c93057fe7 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -884,7 +884,7 @@ void vim_get_prefix_from_exepath(char *exe_name) // TODO(bfredl): param could have been written as "char exe_name[MAXPATHL]" // but c_grammar.lua does not recognize it (yet). xstrlcpy(exe_name, get_vim_var_str(VV_PROGPATH), MAXPATHL * sizeof(*exe_name)); - char *path_end = (char *)path_tail_with_sep((char_u *)exe_name); + char *path_end = path_tail_with_sep(exe_name); *path_end = '\0'; // remove the trailing "nvim.exe" path_end = path_tail(exe_name); *path_end = '\0'; // remove the trailing "bin/" @@ -1143,15 +1143,16 @@ size_t home_replace(const buf_T *const buf, const char *src, char *const dst, si /// Like home_replace, store the replaced string in allocated memory. /// @param buf When not NULL, check for help files /// @param src Input file name -char_u *home_replace_save(buf_T *buf, char_u *src) FUNC_ATTR_NONNULL_RET +char *home_replace_save(buf_T *buf, char *src) + FUNC_ATTR_NONNULL_RET { size_t len = 3; // space for "~/" and trailing NUL if (src != NULL) { // just in case len += STRLEN(src); } char *dst = xmalloc(len); - home_replace(buf, (char *)src, dst, len, true); - return (char_u *)dst; + home_replace(buf, src, dst, len, true); + return dst; } /// Function given to ExpandGeneric() to obtain an environment variable name. @@ -1189,7 +1190,7 @@ bool os_setenv_append_path(const char *fname) internal_error("os_setenv_append_path()"); return false; } - const char *tail = (char *)path_tail_with_sep((char_u *)fname); + const char *tail = path_tail_with_sep((char *)fname); size_t dirlen = (size_t)(tail - fname); assert(tail >= fname && dirlen + 1 < sizeof(os_buf)); xstrlcpy(os_buf, fname, dirlen + 1); diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 7c5e4f31d7..901a1bc5a6 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -935,7 +935,7 @@ int os_mkdir_recurse(const char *const dir, int32_t mode, char **const failed_di const char *const real_end = e; const char past_head_save = *past_head; while (!os_isdir((char_u *)curdir)) { - e = (char *)path_tail_with_sep((char_u *)curdir); + e = path_tail_with_sep(curdir); if (e <= past_head) { *past_head = NUL; break; diff --git a/src/nvim/path.c b/src/nvim/path.c index f5c662ca88..b22c0a18bd 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -125,14 +125,14 @@ char *path_tail(const char *fname) /// - Pointer to the last path separator of `fname`, if there is any. /// - `fname` if it contains no path separator. /// - Never NULL. -char_u *path_tail_with_sep(char_u *fname) +char *path_tail_with_sep(char *fname) { assert(fname != NULL); // Don't remove the '/' from "c:/file". - char_u *past_head = get_past_head(fname); - char_u *tail = (char_u *)path_tail((char *)fname); - while (tail > past_head && after_pathsep((char *)fname, (char *)tail)) { + char *past_head = (char *)get_past_head((char_u *)fname); + char *tail = path_tail(fname); + while (tail > past_head && after_pathsep(fname, tail)) { tail--; } return tail; @@ -326,11 +326,11 @@ void shorten_dir(char_u *str) */ bool dir_of_file_exists(char_u *fname) { - char_u *p = path_tail_with_sep(fname); - if (p == fname) { + char *p = path_tail_with_sep((char *)fname); + if ((char_u *)p == fname) { return true; } - char_u c = *p; + char c = *p; *p = NUL; bool retval = os_isdir(fname); *p = c; @@ -731,7 +731,7 @@ static size_t do_path_expand(garray_T *gap, const char_u *path, size_t wildoff, || ((flags & EW_DODOT) && name[1] != NUL && (name[1] != '.' || name[2] != NUL))) // -V557 - && ((regmatch.regprog != NULL && vim_regexec(®match, name, 0)) + && ((regmatch.regprog != NULL && vim_regexec(®match, (char *)name, 0)) || ((flags & EW_NOTWILD) && FNAMENCMP(path + (s - buf), name, e - s) == 0))) { STRCPY(s, name); @@ -845,7 +845,7 @@ static void expand_path_option(char_u *curdir, garray_T *gap) char_u *buf = xmalloc(MAXPATHL); while (*path_option != NUL) { - copy_option_part(&path_option, buf, MAXPATHL, " ,"); + copy_option_part((char **)&path_option, (char *)buf, MAXPATHL, " ,"); if (buf[0] == '.' && (buf[1] == NUL || vim_ispathsep(buf[1]))) { /* Relative to current buffer: @@ -854,8 +854,8 @@ static void expand_path_option(char_u *curdir, garray_T *gap) if (curbuf->b_ffname == NULL) { continue; } - char_u *p = (char_u *)path_tail((char *)curbuf->b_ffname); - size_t len = (size_t)(p - curbuf->b_ffname); + char_u *p = (char_u *)path_tail(curbuf->b_ffname); + size_t len = (size_t)(p - (char_u *)curbuf->b_ffname); if (len + STRLEN(buf) >= MAXPATHL) { continue; } @@ -996,7 +996,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern) if (pattern[0] == '*' && pattern[1] == '*' && vim_ispathsep_nocolon(pattern[2]) && path_cutoff != NULL - && vim_regexec(®match, path_cutoff, (colnr_T)0) + && vim_regexec(®match, (char *)path_cutoff, (colnr_T)0) && is_unique(path_cutoff, gap, i)) { sort_again = true; memmove(path, path_cutoff, STRLEN(path_cutoff) + 1); @@ -1005,7 +1005,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern) // unique path. We start at the end of the path. */ pathsep_p = path + len - 1; while (find_previous_pathsep(path, &pathsep_p)) { - if (vim_regexec(®match, pathsep_p + 1, (colnr_T)0) + if (vim_regexec(®match, (char *)pathsep_p + 1, (colnr_T)0) && is_unique(pathsep_p + 1, gap, i) && path_cutoff != NULL && pathsep_p + 1 >= path_cutoff) { sort_again = true; @@ -1877,7 +1877,7 @@ char *fix_fname(const char *fname) fname = xstrdup(fname); # ifdef USE_FNAME_CASE - path_fix_case((char_u *)fname); // set correct case for file name + path_fix_case(fname); // set correct case for file name # endif return (char *)fname; @@ -1889,17 +1889,17 @@ char *fix_fname(const char *fname) /// Only required for file systems where case is ignored and preserved. // TODO(SplinterOfChaos): Could also be used when mounting case-insensitive // file systems. -void path_fix_case(char_u *name) +void path_fix_case(char *name) FUNC_ATTR_NONNULL_ALL { FileInfo file_info; - if (!os_fileinfo_link((char *)name, &file_info)) { + if (!os_fileinfo_link(name, &file_info)) { return; } // Open the directory where the file is located. - char_u *slash = STRRCHR(name, '/'); - char_u *tail; + char *slash = (char *)STRRCHR(name, '/'); + char *tail; Directory dir; bool ok; if (slash == NULL) { @@ -1907,7 +1907,7 @@ void path_fix_case(char_u *name) tail = name; } else { *slash = NUL; - ok = os_scandir(&dir, (char *)name); + ok = os_scandir(&dir, name); *slash = '/'; tail = slash + 1; } @@ -1916,8 +1916,8 @@ void path_fix_case(char_u *name) return; } - char_u *entry; - while ((entry = (char_u *)os_scandir_next(&dir))) { + char *entry; + while ((entry = (char *)os_scandir_next(&dir))) { // Only accept names that differ in case and are the same byte // length. TODO: accept different length name. if (STRICMP(tail, entry) == 0 && STRLEN(tail) == STRLEN(entry)) { @@ -1956,9 +1956,9 @@ int after_pathsep(const char *b, const char *p) */ bool same_directory(char_u *f1, char_u *f2) { - char_u ffname[MAXPATHL]; - char_u *t1; - char_u *t2; + char ffname[MAXPATHL]; + char *t1; + char *t2; // safety check if (f1 == NULL || f2 == NULL) { @@ -1967,8 +1967,8 @@ bool same_directory(char_u *f1, char_u *f2) (void)vim_FullName((char *)f1, (char *)ffname, MAXPATHL, FALSE); t1 = path_tail_with_sep(ffname); - t2 = path_tail_with_sep(f2); - return t1 - ffname == t2 - f2 + t2 = path_tail_with_sep((char *)f2); + return t1 - ffname == (char_u *)t2 - f2 && pathcmp((char *)ffname, (char *)f2, (int)(t1 - ffname)) == 0; } @@ -2246,7 +2246,7 @@ int match_suffix(char_u *fname) size_t fnamelen = STRLEN(fname); size_t setsuflen = 0; for (char_u *setsuf = p_su; *setsuf;) { - setsuflen = copy_option_part(&setsuf, suf_buf, MAXSUFLEN, ".,"); + setsuflen = copy_option_part((char **)&setsuf, (char *)suf_buf, MAXSUFLEN, ".,"); if (setsuflen == 0) { char_u *tail = (char_u *)path_tail((char *)fname); diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index edf964f5dd..2138437b29 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1563,7 +1563,7 @@ static int qf_parse_get_fields(char *linebuf, size_t linelen, efm_T *fmt_ptr, qf // Always ignore case when looking for a matching error. regmatch.rm_ic = true; regmatch.regprog = fmt_ptr->prog; - r = vim_regexec(®match, (char_u *)linebuf, (colnr_T)0); + r = vim_regexec(®match, linebuf, (colnr_T)0); fmt_ptr->prog = regmatch.regprog; if (r) { status = qf_parse_match(linebuf, linelen, fmt_ptr, ®match, fields, @@ -2139,7 +2139,7 @@ static int qf_get_fnum(qf_list_T *qfl, char *directory, char *fname) xfree(ptr); } else { xfree(qf_last_bufname); - buf = buflist_new((char_u *)bufname, NULL, (linenr_T)0, BLN_NOOPT); + buf = buflist_new(bufname, NULL, (linenr_T)0, BLN_NOOPT); qf_last_bufname = (bufname == ptr) ? bufname : xstrdup(bufname); set_bufref(&qf_last_bufref, buf); } @@ -3301,7 +3301,7 @@ static void qf_msg(qf_info_T *qi, int which, char *lead) } STRLCAT(buf, title, IOSIZE); } - trunc_string((char_u *)buf, (char_u *)buf, Columns - 1, IOSIZE); + trunc_string(buf, buf, Columns - 1, IOSIZE); msg(buf); } @@ -4035,7 +4035,7 @@ static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum, const qfli // buffer. if (first_bufline && (errbuf->b_sfname == NULL - || path_is_absolute(errbuf->b_sfname))) { + || path_is_absolute((char_u *)errbuf->b_sfname))) { if (*dirname == NUL) { os_dirname((char_u *)dirname, MAXPATHL); } @@ -5462,7 +5462,7 @@ static int vgr_process_files(win_T *wp, qf_info_T *qi, vgr_args_T *cmd_args, boo vgr_display_fname(fname); } - buf_T *buf = buflist_findname_exp((char_u *)cmd_args->fnames[fi]); + buf_T *buf = buflist_findname_exp(cmd_args->fnames[fi]); bool using_dummy; if (buf == NULL || buf->b_ml.ml_mfp == NULL) { // Remember that a buffer with this name already exists. @@ -6936,8 +6936,7 @@ void ex_cbuffer(exarg_T *eap) qf_title = qf_cmdtitle(*eap->cmdlinep); if (buf->b_sfname) { - vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)", - qf_title, (char *)buf->b_sfname); + vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)", qf_title, buf->b_sfname); qf_title = (char *)IObuff; } @@ -7099,7 +7098,7 @@ static void hgr_search_file(qf_list_T *qfl, char *fname, regmatch_T *p_regmatch) while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) { char *line = (char *)IObuff; - if (vim_regexec(p_regmatch, (char_u *)line, (colnr_T)0)) { + if (vim_regexec(p_regmatch, line, (colnr_T)0)) { int l = (int)STRLEN(line); // remove trailing CR, LF, spaces, etc. @@ -7181,7 +7180,7 @@ static void hgr_search_in_rtp(qf_list_T *qfl, regmatch_T *p_regmatch, const char // Go through all directories in 'runtimepath' char *p = (char *)p_rtp; while (*p != NUL && !got_int) { - copy_option_part((char_u **)&p, NameBuff, MAXPATHL, ","); + copy_option_part(&p, (char *)NameBuff, MAXPATHL, ","); hgr_search_files_in_dir(qfl, (char *)NameBuff, p_regmatch, (char *)lang); } diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 45f2cf0e1d..bb6cbc35bc 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -2516,9 +2516,9 @@ bool vim_regexec_prog(regprog_T **prog, bool ignore_case, char_u *line, colnr_T // Note: "rmp->regprog" may be freed and changed. // Return true if there is a match, false if not. -bool vim_regexec(regmatch_T *rmp, char_u *line, colnr_T col) +bool vim_regexec(regmatch_T *rmp, char *line, colnr_T col) { - return vim_regexec_string(rmp, line, col, false); + return vim_regexec_string(rmp, (char_u *)line, col, false); } // Like vim_regexec(), but consider a "\n" in "line" to be a line break. diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 28d85b54bd..045cee2439 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -93,7 +93,7 @@ int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback, char_u *rtp = rtp_copy; while (*rtp != NUL && ((flags & DIP_ALL) || !did_one)) { // Copy the path from 'runtimepath' to buf[]. - copy_option_part(&rtp, buf, MAXPATHL, ","); + copy_option_part((char **)&rtp, (char *)buf, MAXPATHL, ","); size_t buflen = STRLEN(buf); // Skip after or non-after directories. @@ -118,8 +118,7 @@ int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback, while (*np != NUL && ((flags & DIP_ALL) || !did_one)) { // Append the pattern from "name" to buf[]. assert(MAXPATHL >= (tail - buf)); - copy_option_part(&np, tail, (size_t)(MAXPATHL - (tail - buf)), - "\t "); + copy_option_part((char **)&np, (char *)tail, (size_t)(MAXPATHL - (tail - buf)), "\t "); if (p_verbose > 10) { verbose_enter(); @@ -252,8 +251,7 @@ int do_in_cached_path(char_u *name, int flags, DoInRuntimepathCB callback, void while (*np != NUL && ((flags & DIP_ALL) || !did_one)) { // Append the pattern from "name" to buf[]. assert(MAXPATHL >= (tail - buf)); - copy_option_part(&np, tail, (size_t)(MAXPATHL - (tail - buf)), - "\t "); + copy_option_part((char **)&np, (char *)tail, (size_t)(MAXPATHL - (tail - buf)), "\t "); if (p_verbose > 10) { verbose_enter(); @@ -513,7 +511,7 @@ RuntimeSearchPath runtime_search_path_build(void) static char_u buf[MAXPATHL]; for (char *entry = (char *)p_pp; *entry != NUL;) { char *cur_entry = entry; - copy_option_part((char_u **)&entry, buf, MAXPATHL, ","); + copy_option_part(&entry, (char *)buf, MAXPATHL, ","); String the_entry = { .data = cur_entry, .size = STRLEN(buf) }; @@ -524,7 +522,7 @@ RuntimeSearchPath runtime_search_path_build(void) char *rtp_entry; for (rtp_entry = (char *)p_rtp; *rtp_entry != NUL;) { char *cur_entry = rtp_entry; - copy_option_part((char_u **)&rtp_entry, buf, MAXPATHL, ","); + copy_option_part(&rtp_entry, (char *)buf, MAXPATHL, ","); size_t buflen = STRLEN(buf); if (path_is_after(buf, buflen)) { @@ -558,7 +556,7 @@ RuntimeSearchPath runtime_search_path_build(void) // "after" dirs in rtp for (; *rtp_entry != NUL;) { - copy_option_part((char_u **)&rtp_entry, buf, MAXPATHL, ","); + copy_option_part(&rtp_entry, (char *)buf, MAXPATHL, ","); expand_rtp_entry(&search_path, &rtp_used, (char *)buf, path_is_after(buf, STRLEN(buf))); } @@ -700,7 +698,7 @@ static int add_pack_dir_to_rtp(char_u *fname, bool is_pack) for (const char *entry = (const char *)p_rtp; *entry != NUL;) { const char *cur_entry = entry; - copy_option_part((char_u **)&entry, buf, MAXPATHL, ","); + copy_option_part((char **)&entry, (char *)buf, MAXPATHL, ","); if (insp == NULL) { add_pathsep((char *)buf); char *const rtp_ffname = fix_fname((char *)buf); @@ -849,7 +847,7 @@ static void add_pack_plugin(bool opt, char_u *fname, void *cookie) const char *p = (const char *)p_rtp; while (*p != NUL) { - copy_option_part((char_u **)&p, (char_u *)buf, MAXPATHL, ","); + copy_option_part((char **)&p, buf, MAXPATHL, ","); if (path_fnamecmp(buf, (char *)fname) == 0) { found = true; break; diff --git a/src/nvim/screen.c b/src/nvim/screen.c index c2a88bb4a6..32e2d515e1 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -4845,7 +4845,7 @@ void win_redr_status_matches(expand_T *xp, int num_matches, char_u **matches, in clen = len; i = first_match; - while ((long)(clen + status_match_len(xp, L_MATCH(i)) + 2) < Columns) { + while (clen + status_match_len(xp, L_MATCH(i)) + 2 < Columns) { if (i == match) { selstart = buf + len; selstart_col = clen; @@ -6412,7 +6412,7 @@ void get_trans_bufname(buf_T *buf) } else { home_replace(buf, buf->b_fname, (char *)NameBuff, MAXPATHL, true); } - trans_characters(NameBuff, MAXPATHL); + trans_characters((char *)NameBuff, MAXPATHL); } /* @@ -6613,7 +6613,7 @@ static void win_redr_ruler(win_T *wp, bool always) (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) ? (int64_t)0L : (int64_t)wp->w_cursor.lnum); size_t len = STRLEN(buffer); - col_print((char_u *)buffer + len, RULER_BUF_LEN - len, + col_print(buffer + len, RULER_BUF_LEN - len, empty_line ? 0 : (int)wp->w_cursor.col + 1, (int)virtcol + 1); diff --git a/src/nvim/search.c b/src/nvim/search.c index 2a248a53e7..15e8bd9e13 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -5406,9 +5406,9 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo for (;;) { if (incl_regmatch.regprog != NULL - && vim_regexec(&incl_regmatch, line, (colnr_T)0)) { + && vim_regexec(&incl_regmatch, (char *)line, (colnr_T)0)) { char_u *p_fname = (curr_fname == (char_u *)curbuf->b_fname) - ? curbuf->b_ffname : curr_fname; + ? (char_u *)curbuf->b_ffname : curr_fname; if (inc_opt != NULL && strstr((char *)inc_opt, "\\zs") != NULL) { // Use text from '\zs' to '\ze' (or end) of 'include'. @@ -5586,12 +5586,10 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo search_line: define_matched = false; if (def_regmatch.regprog != NULL - && vim_regexec(&def_regmatch, line, (colnr_T)0)) { - /* - * Pattern must be first identifier after 'define', so skip - * to that position before checking for match of pattern. Also - * don't let it match beyond the end of this identifier. - */ + && vim_regexec(&def_regmatch, (char *)line, (colnr_T)0)) { + // Pattern must be first identifier after 'define', so skip + // to that position before checking for match of pattern. Also + // don't let it match beyond the end of this identifier. p = def_regmatch.endp[0]; while (*p && !vim_iswordc(*p)) { p++; @@ -5618,7 +5616,7 @@ search_line: matched = false; } } else if (regmatch.regprog != NULL - && vim_regexec(®match, line, (colnr_T)(p - line))) { + && vim_regexec(®match, (char *)line, (colnr_T)(p - line))) { matched = true; startp = regmatch.startp[0]; // Check if the line is not a comment line (unless we are @@ -5627,7 +5625,7 @@ search_line: if (skip_comments) { if ((*line != '#' || STRNCMP(skipwhite((char *)line + 1), "define", 6) != 0) - && get_leader_len(line, NULL, false, true)) { + && get_leader_len((char *)line, NULL, false, true)) { matched = false; } diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 834355f2b7..6e80b550d8 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -1328,8 +1328,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags) char *const sfname = (char *)path_try_shorten_fname((char_u *)cur_entry.data.buffer_list.buffers[i].fname); buf_T *const buf = - buflist_new((char_u *)cur_entry.data.buffer_list.buffers[i].fname, (char_u *)sfname, 0, - BLN_LISTED); + buflist_new(cur_entry.data.buffer_list.buffers[i].fname, sfname, 0, BLN_LISTED); if (buf != NULL) { fmarkv_T view = INIT_FMARKV; RESET_FMARK(&buf->b_last_cursor, @@ -2307,7 +2306,7 @@ static inline ShadaEntry shada_get_buflist(khash_t(bufset) *const removable_bufs } buflist_entry.data.buffer_list.buffers[i] = (struct buffer_list_buffer) { .pos = buf->b_last_cursor.mark, - .fname = (char *)buf->b_ffname, + .fname = buf->b_ffname, .additional_data = buf->additional_data, }; i++; @@ -2445,7 +2444,7 @@ static inline void replace_numbered_mark(WriteMergerState *const wms, const size static inline void find_removable_bufs(khash_t(bufset) *removable_bufs) { FOR_ALL_BUFFERS(buf) { - if (buf->b_ffname != NULL && shada_removable((char *)buf->b_ffname)) { + if (buf->b_ffname != NULL && shada_removable(buf->b_ffname)) { int kh_ret; (void)kh_put(bufset, removable_bufs, (uintptr_t)buf, &kh_ret); } @@ -2804,7 +2803,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, ShaDaReadDef .mark = curwin->w_cursor, .name = '0', .additional_data = NULL, - .fname = (char *)curbuf->b_ffname, + .fname = curbuf->b_ffname, } } }, @@ -2998,7 +2997,7 @@ shada_write_file_open: {} } if (nomerge) { shada_write_file_nomerge: {} - char *const tail = (char *)path_tail_with_sep((char_u *)fname); + char *const tail = path_tail_with_sep(fname); if (tail != fname) { const char tail_save = *tail; *tail = NUL; @@ -3974,9 +3973,9 @@ static bool shada_removable(const char *name) char part[MAXPATHL + 1]; bool retval = false; - char *new_name = (char *)home_replace_save(NULL, (char_u *)name); + char *new_name = home_replace_save(NULL, (char *)name); for (p = (char *)p_shada; *p;) { - (void)copy_option_part((char_u **)&p, (char_u *)part, ARRAY_SIZE(part), ", "); + (void)copy_option_part(&p, part, ARRAY_SIZE(part), ", "); if (part[0] == 'r') { home_replace(NULL, part + 1, (char *)NameBuff, MAXPATHL, true); size_t n = STRLEN(NameBuff); @@ -4026,8 +4025,7 @@ static inline size_t shada_init_jumps(PossiblyFreedShadaEntry *jumps, continue; } const char *const fname = - (char *)(fm.fmark.fnum == - 0 ? (fm.fname == NULL ? NULL : (char_u *)fm.fname) : buf ? buf->b_ffname : NULL); + (fm.fmark.fnum == 0 ? (fm.fname == NULL ? NULL : fm.fname) : buf ? buf->b_ffname : NULL); if (fname == NULL) { continue; } diff --git a/src/nvim/sign.c b/src/nvim/sign.c index 940cd1d274..9a4b304d6c 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -100,10 +100,9 @@ static signgroup_T *sign_group_ref(const char_u *groupname) /// removed, then remove the group. static void sign_group_unref(char_u *groupname) { - hashitem_T *hi; signgroup_T *group; - hi = hash_find(&sg_table, groupname); + hashitem_T *hi = hash_find(&sg_table, (char *)groupname); if (!HASHITEM_EMPTY(hi)) { group = HI2SG(hi); group->sg_refcount--; @@ -136,7 +135,7 @@ static int sign_group_get_next_signid(buf_T *buf, const char_u *groupname) int found = false; if (groupname != NULL) { - hi = hash_find(&sg_table, groupname); + hi = hash_find(&sg_table, (char *)groupname); if (HASHITEM_EMPTY(hi)) { return id; } @@ -647,7 +646,7 @@ static int buf_findsign_id(buf_T *buf, linenr_T lnum, char_u *groupname) } /// Delete signs in buffer "buf". -void buf_delete_signs(buf_T *buf, char_u *group) +void buf_delete_signs(buf_T *buf, char *group) { sign_entry_T *sign; sign_entry_T **lastp; // pointer to pointer to current sign @@ -662,7 +661,7 @@ void buf_delete_signs(buf_T *buf, char_u *group) lastp = &buf->b_signlist; for (sign = buf->b_signlist; sign != NULL; sign = next) { next = sign->se_next; - if (sign_in_group(sign, group)) { + if (sign_in_group(sign, (char_u *)group)) { *lastp = next; if (next != NULL) { next->se_prev = sign->se_prev; @@ -1086,7 +1085,7 @@ static int sign_unplace(int sign_id, char_u *sign_group, buf_T *buf, linenr_T at if (sign_id == 0) { // Delete all the signs in the specified buffer redraw_buf_later(buf, NOT_VALID); - buf_delete_signs(buf, sign_group); + buf_delete_signs(buf, (char *)sign_group); } else { linenr_T lnum; @@ -1173,7 +1172,7 @@ static void sign_define_cmd(char_u *sign_name, char_u *cmdline) if (*arg == NUL) { break; } - p = skiptowhite_esc(arg); + p = (char_u *)skiptowhite_esc((char *)arg); if (STRNCMP(arg, "icon=", 5) == 0) { arg += 5; XFREE_CLEAR(icon); @@ -1273,7 +1272,7 @@ static void sign_unplace_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int i // :sign unplace * group=* FOR_ALL_BUFFERS(cbuf) { if (cbuf->b_signlist != NULL) { - buf_delete_signs(cbuf, group); + buf_delete_signs(cbuf, (char *)group); } } } @@ -1341,7 +1340,7 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si // first arg could be placed sign id arg1 = arg; if (ascii_isdigit(*arg)) { - *signid = getdigits_int(&arg, true, 0); + *signid = getdigits_int((char **)&arg, true, 0); if (!ascii_iswhite(*arg) && *arg != NUL) { *signid = -1; arg = arg1; @@ -1388,12 +1387,12 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si } else if (STRNCMP(arg, "file=", 5) == 0) { arg += 5; filename = arg; - *buf = buflist_findname_exp(arg); + *buf = buflist_findname_exp((char *)arg); break; } else if (STRNCMP(arg, "buffer=", 7) == 0) { arg += 7; filename = arg; - *buf = buflist_findnr(getdigits_int(&arg, true, 0)); + *buf = buflist_findnr(getdigits_int((char **)&arg, true, 0)); if (*skipwhite((char *)arg) != NUL) { emsg(_(e_trailing)); } diff --git a/src/nvim/spell.c b/src/nvim/spell.c index e4805f3c4a..304fd30b36 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -504,7 +504,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou // Check for end of sentence. regmatch.regprog = wp->w_s->b_cap_prog; regmatch.rm_ic = false; - int r = vim_regexec(®match, ptr, 0); + int r = vim_regexec(®match, (char *)ptr, 0); wp->w_s->b_cap_prog = regmatch.regprog; if (r) { *capcol = (int)(regmatch.endp[0] - ptr); @@ -1908,12 +1908,11 @@ void count_common_word(slang_T *lp, char_u *word, int len, int count) /// @param split word was split, less bonus static int score_wordcount_adj(slang_T *slang, int score, char_u *word, bool split) { - hashitem_T *hi; wordcount_T *wc; int bonus; int newscore; - hi = hash_find(&slang->sl_wordcount, word); + hashitem_T *hi = hash_find(&slang->sl_wordcount, (char *)word); if (!HASHITEM_EMPTY(hi)) { wc = HI2WC(hi); if (wc->wc_count < SCORE_THRES2) { @@ -2083,7 +2082,7 @@ char *did_set_spelllang(win_T *wp) // Loop over comma separated language names. for (splp = spl_copy; *splp != NUL;) { // Get one language name. - copy_option_part(&splp, lang, MAXWLEN, ","); + copy_option_part((char **)&splp, (char *)lang, MAXWLEN, ","); region = NULL; len = (int)STRLEN(lang); @@ -2215,7 +2214,7 @@ char *did_set_spelllang(win_T *wp) int_wordlist_spl(spf_name); } else { // One entry in 'spellfile'. - copy_option_part(&spf, spf_name, MAXPATHL - 5, ","); + copy_option_part((char **)&spf, (char *)spf_name, MAXPATHL - 5, ","); STRCAT(spf_name, ".spl"); // If it was already found above then skip it. @@ -2805,12 +2804,12 @@ int spell_check_sps(void) sps_limit = 9999; for (p = p_sps; *p != NUL;) { - copy_option_part(&p, buf, MAXPATHL, ","); + copy_option_part((char **)&p, (char *)buf, MAXPATHL, ","); f = 0; if (ascii_isdigit(*buf)) { s = buf; - sps_limit = getdigits_int(&s, true, 0); + sps_limit = getdigits_int((char **)&s, true, 0); if (*s != NUL && !ascii_isdigit(*s)) { f = -1; } @@ -3121,7 +3120,7 @@ static bool check_need_cap(linenr_T lnum, colnr_T col) if (p == line || spell_iswordp_nmw(p, curwin)) { break; } - if (vim_regexec(®match, p, 0) + if (vim_regexec(®match, (char *)p, 0) && regmatch.endp[0] == line + endcol) { need_cap = true; break; @@ -3328,7 +3327,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma // Loop over the items in 'spellsuggest'. for (p = sps_copy; *p != NUL;) { - copy_option_part(&p, buf, MAXPATHL, ","); + copy_option_part((char **)&p, (char *)buf, MAXPATHL, ","); if (STRNCMP(buf, "expr:", 5) == 0) { // Evaluate an expression. Skip this when called recursively, @@ -4034,8 +4033,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so break; } if ((sp->ts_complen == sp->ts_compsplit - && WAS_BANNED(su, preword + sp->ts_prewordlen)) - || WAS_BANNED(su, preword)) { + && WAS_BANNED(su, (char *)preword + sp->ts_prewordlen)) + || WAS_BANNED(su, (char *)preword)) { if (slang->sl_compprog == NULL) { break; } @@ -5661,7 +5660,7 @@ static bool similar_chars(slang_T *slang, int c1, int c2) if (c1 >= 256) { buf[utf_char2bytes(c1, (char *)buf)] = 0; - hi = hash_find(&slang->sl_map_hash, (char_u *)buf); + hi = hash_find(&slang->sl_map_hash, buf); if (HASHITEM_EMPTY(hi)) { m1 = 0; } else { @@ -5676,7 +5675,7 @@ static bool similar_chars(slang_T *slang, int c1, int c2) if (c2 >= 256) { buf[utf_char2bytes(c2, (char *)buf)] = 0; - hi = hash_find(&slang->sl_map_hash, (char_u *)buf); + hi = hash_find(&slang->sl_map_hash, buf); if (HASHITEM_EMPTY(hi)) { m2 = 0; } else { @@ -7144,7 +7143,7 @@ static void dump_word(slang_T *slang, char_u *word, char_u *pat, Direction *dir, hashitem_T *hi; // Include the word count for ":spelldump!". - hi = hash_find(&slang->sl_wordcount, tw); + hi = hash_find(&slang->sl_wordcount, (char *)tw); if (!HASHITEM_EMPTY(hi)) { vim_snprintf((char *)IObuff, IOSIZE, "%s\t%d", tw, HI2WC(hi)->wc_count); diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 423ed04176..a532c106ef 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -2351,7 +2351,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) // "S" flag on all but the last block, thus we check for that // and store it in ah_follows. STRLCPY(key, items[1], AH_KEY_LEN); - hi = hash_find(tp, key); + hi = hash_find(tp, (char *)key); if (!HASHITEM_EMPTY(hi)) { cur_aff = HI2AH(hi); if (cur_aff->ah_combine != (*items[2] == 'Y')) { @@ -2688,9 +2688,8 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) } else if (STRCMP(items[0], "COMMON") == 0) { int i; - for (i = 1; i < itemcnt; ++i) { - if (HASHITEM_EMPTY(hash_find(&spin->si_commonwords, - items[i]))) { + for (i = 1; i < itemcnt; i++) { + if (HASHITEM_EMPTY(hash_find(&spin->si_commonwords, (char *)items[i]))) { p = vim_strsave(items[i]); hash_add(&spin->si_commonwords, p); } @@ -2872,7 +2871,7 @@ static unsigned get_affitem(int flagtype, char_u **pp) ++*pp; // always advance, avoid getting stuck return 0; } - res = getdigits_int(pp, true, 0); + res = getdigits_int((char **)pp, true, 0); if (res == 0) { res = ZERO_FLAG; } @@ -2932,7 +2931,7 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compfla // Find the flag in the hashtable. If it was used before, use // the existing ID. Otherwise add a new entry. STRLCPY(key, prevp, p - prevp + 1); - hi = hash_find(&aff->af_comp, key); + hi = hash_find(&aff->af_comp, (char *)key); if (!HASHITEM_EMPTY(hi)) { id = HI2CI(hi)->ci_newID; } else { @@ -2997,7 +2996,7 @@ static bool flag_in_afflist(int flagtype, char_u *afflist, unsigned flag) case AFT_NUM: for (p = afflist; *p != NUL;) { - int digits = getdigits_int(&p, true, 0); + int digits = getdigits_int((char **)&p, true, 0); assert(digits >= 0); n = (unsigned int)digits; if (n == 0) { @@ -3359,7 +3358,7 @@ static int get_pfxlist(afffile_T *affile, char_u *afflist, char_u *store_afflist // A flag is a postponed prefix flag if it appears in "af_pref" // and its ID is not zero. STRLCPY(key, prevp, p - prevp + 1); - hi = hash_find(&affile->af_pref, key); + hi = hash_find(&affile->af_pref, (char *)key); if (!HASHITEM_EMPTY(hi)) { id = HI2AH(hi)->ah_newID; if (id != 0) { @@ -3392,7 +3391,7 @@ static void get_compflags(afffile_T *affile, char_u *afflist, char_u *store_affl if (get_affitem(affile->af_flagtype, &p) != 0) { // A flag is a compound flag if it appears in "af_comp". STRLCPY(key, prevp, p - prevp + 1); - hi = hash_find(&affile->af_comp, key); + hi = hash_find(&affile->af_comp, (char *)key); if (!HASHITEM_EMPTY(hi)) { store_afflist[cnt++] = HI2CI(hi)->ci_newID; } @@ -5563,8 +5562,8 @@ void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo } fnamebuf = xmalloc(MAXPATHL); - for (spf = curwin->w_s->b_p_spf, i = 1; *spf != NUL; ++i) { - copy_option_part(&spf, fnamebuf, MAXPATHL, ","); + for (spf = curwin->w_s->b_p_spf, i = 1; *spf != NUL; i++) { + copy_option_part((char **)&spf, (char *)fnamebuf, MAXPATHL, ","); if (i == idx) { break; } @@ -5576,7 +5575,7 @@ void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo } // Check that the user isn't editing the .add file somewhere. - buf = buflist_findname_exp(fnamebuf); + buf = buflist_findname_exp((char *)fnamebuf); if (buf != NULL && buf->b_ml.ml_mfp == NULL) { buf = NULL; } @@ -5638,7 +5637,8 @@ void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo // file. We may need to create the "spell" directory first. We // already checked the runtime directory is writable in // init_spellfile(). - if (!dir_of_file_exists(fname) && (p = path_tail_with_sep(fname)) != fname) { + if (!dir_of_file_exists(fname) + && (p = (char_u *)path_tail_with_sep((char *)fname)) != fname) { int c = *p; // The directory doesn't exist. Try creating it and opening @@ -5716,7 +5716,7 @@ static void init_spellfile(void) lstart - curbuf->b_s.b_p_spl); } else { // Copy the path from 'runtimepath' to buf[]. - copy_option_part(&rtp, buf, MAXPATHL, ","); + copy_option_part((char **)&rtp, (char *)buf, MAXPATHL, ","); } if (os_file_is_writable((char *)buf) == 2) { // Use the first language name from 'spelllang' and the diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 9615423765..43dbeccf01 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -3005,7 +3005,7 @@ static int check_keyword_id(char_u *const line, const int startcol, int *const e /// Accept a keyword at other levels only if it is in the contains list. static keyentry_T *match_keyword(char_u *keyword, hashtab_T *ht, stateitem_T *cur_si) { - hashitem_T *hi = hash_find(ht, keyword); + hashitem_T *hi = hash_find(ht, (char *)keyword); if (!HASHITEM_EMPTY(hi)) { for (keyentry_T *kp = HI2KE(hi); kp != NULL; kp = kp->ke_next) { if (current_next_list != 0 @@ -5123,7 +5123,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci) ci->sp_off_flags |= (1 << idx); if (idx == SPO_LC_OFF) { // lc=99 end += 3; - *p = getdigits_int(&end, true, 0); + *p = getdigits_int((char **)&end, true, 0); // "lc=" offset automatically sets "ms=" offset if (!(ci->sp_off_flags & (1 << SPO_MS_OFF))) { @@ -5134,10 +5134,10 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci) end += 4; if (*end == '+') { end++; - *p = getdigits_int(&end, true, 0); // positive offset + *p = getdigits_int((char **)&end, true, 0); // positive offset } else if (*end == '-') { end++; - *p = -getdigits_int(&end, true, 0); // negative offset + *p = -getdigits_int((char **)&end, true, 0); // negative offset } } if (*end != ',') { @@ -5382,7 +5382,7 @@ static int get_id_list(char_u **const arg, const int keylen, int16_t **const lis regmatch.rm_ic = TRUE; id = 0; for (int i = highlight_num_groups(); --i >= 0;) { - if (vim_regexec(®match, highlight_group_name(i), (colnr_T)0)) { + if (vim_regexec(®match, (char *)highlight_group_name(i), (colnr_T)0)) { if (round == 2) { // Got more items than expected; can happen // when adding items that match: diff --git a/src/nvim/tag.c b/src/nvim/tag.c index bb884ffb3a..5b62d11bc9 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -167,7 +167,7 @@ bool do_tag(char_u *tag, int type, int count, int forceit, int verbose) char_u **new_matches; int use_tagstack; int skip_msg = false; - char_u *buf_ffname = curbuf->b_ffname; // name for priority computation + char_u *buf_ffname = (char_u *)curbuf->b_ffname; // name for priority computation int use_tfu = 1; // remember the matches for the last used tag @@ -423,7 +423,7 @@ bool do_tag(char_u *tag, int type, int count, int forceit, int verbose) buf_T *buf = buflist_findnr(cur_fnum); if (buf != NULL) { - buf_ffname = buf->b_ffname; + buf_ffname = (char_u *)buf->b_ffname; } } @@ -2031,14 +2031,13 @@ parse_line: cc = *tagp.tagname_end; *tagp.tagname_end = NUL; - match = vim_regexec(&orgpat.regmatch, tagp.tagname, (colnr_T)0); + match = vim_regexec(&orgpat.regmatch, (char *)tagp.tagname, (colnr_T)0); if (match) { matchoff = (int)(orgpat.regmatch.startp[0] - tagp.tagname); if (orgpat.regmatch.rm_ic) { - orgpat.regmatch.rm_ic = FALSE; - match_no_ic = vim_regexec(&orgpat.regmatch, tagp.tagname, - (colnr_T)0); - orgpat.regmatch.rm_ic = TRUE; + orgpat.regmatch.rm_ic = false; + match_no_ic = vim_regexec(&orgpat.regmatch, (char *)tagp.tagname, (colnr_T)0); + orgpat.regmatch.rm_ic = true; } } *tagp.tagname_end = (char_u)cc; @@ -2423,7 +2422,7 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf) * Copy next file name into buf. */ buf[0] = NUL; - (void)copy_option_part(&tnp->tn_np, buf, MAXPATHL - 1, " ,"); + (void)copy_option_part((char **)&tnp->tn_np, (char *)buf, MAXPATHL - 1, " ,"); r_ptr = vim_findfile_stopdir(buf); // move the filename one char forward and truncate the @@ -2436,7 +2435,7 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf) r_ptr, 100, FALSE, // don't free visited list FINDFILE_FILE, // we search for a file - tnp->tn_search_ctx, TRUE, curbuf->b_ffname); + tnp->tn_search_ctx, true, (char_u *)curbuf->b_ffname); if (tnp->tn_search_ctx != NULL) { tnp->tn_did_filefind_init = TRUE; } @@ -2749,7 +2748,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help) // If it was a CTRL-W CTRL-] command split window now. For ":tab tag" // open a new tab page. if (postponed_split && (swb_flags & (SWB_USEOPEN | SWB_USETAB))) { - buf_T *const existing_buf = buflist_findname_exp(fname); + buf_T *const existing_buf = buflist_findname_exp((char *)fname); if (existing_buf != NULL) { const win_T *wp = NULL; @@ -3112,11 +3111,11 @@ int expand_tags(int tagnames, char_u *pat, int *num_file, char_u ***file) if (pat[0] == '/') { ret = find_tags(pat + 1, num_file, file, TAG_REGEXP | extra_flag | TAG_VERBOSE | TAG_NO_TAGFUNC, - TAG_MANY, curbuf->b_ffname); + TAG_MANY, (char_u *)curbuf->b_ffname); } else { ret = find_tags(pat, num_file, file, TAG_REGEXP | extra_flag | TAG_VERBOSE | TAG_NO_TAGFUNC | TAG_NOIC, - TAG_MANY, curbuf->b_ffname); + TAG_MANY, (char_u *)curbuf->b_ffname); } if (ret == OK && !tagnames) { // Reorganize the tags for display and matching as strings of: diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 85517a71a4..be49048aec 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -228,7 +228,7 @@ Terminal *terminal_open(buf_T *buf, TerminalOptions opts) set_option_value("wrap", false, NULL, OPT_LOCAL); set_option_value("list", false, NULL, OPT_LOCAL); if (buf->b_ffname != NULL) { - buf_set_term_title(buf, (char *)buf->b_ffname); + buf_set_term_title(buf, buf->b_ffname); } RESET_BINDING(curwin); // Reset cursor in current window. diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 078cb6a210..135c46203f 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -693,8 +693,7 @@ char *u_get_undo_file_name(const char *const buf_ffname, const bool reading) // When not reading use the first directory that exists or ".". dirp = (char *)p_udir; while (*dirp != NUL) { - size_t dir_len = copy_option_part((char_u **)&dirp, (char_u *)dir_name, - MAXPATHL, ","); + size_t dir_len = copy_option_part(&dirp, dir_name, MAXPATHL, ","); if (dir_len == 1 && dir_name[0] == '.') { // Use same directory as the ffname, // "dir/name" -> "dir/.name.un~" @@ -1186,7 +1185,7 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf, bufinfo_T bi; if (name == NULL) { - file_name = u_get_undo_file_name((char *)buf->b_ffname, false); + file_name = u_get_undo_file_name(buf->b_ffname, false); if (file_name == NULL) { if (p_verbose > 0) { verbose_enter(); @@ -1291,7 +1290,7 @@ void u_write_undo(const char *const name, const bool forceit, buf_T *const buf, FileInfo file_info_old; FileInfo file_info_new; if (buf->b_ffname != NULL - && os_fileinfo((char *)buf->b_ffname, &file_info_old) + && os_fileinfo(buf->b_ffname, &file_info_old) && os_fileinfo(file_name, &file_info_new) && file_info_old.stat.st_gid != file_info_new.stat.st_gid && os_fchown(fd, (uv_uid_t)-1, (uv_gid_t)file_info_old.stat.st_gid)) { @@ -1370,10 +1369,8 @@ write_error: #ifdef HAVE_ACL if (buf->b_ffname != NULL) { - vim_acl_T acl; - // For systems that support ACL: get the ACL from the original file. - acl = mch_get_acl(buf->b_ffname); + vim_acl_T acl = mch_get_acl((char_u *)buf->b_ffname); mch_set_acl((char_u *)file_name, acl); mch_free_acl(acl); } @@ -1398,7 +1395,7 @@ void u_read_undo(char *name, const char_u *hash, const char_u *orig_name FUNC_AT char *file_name; if (name == NULL) { - file_name = u_get_undo_file_name((char *)curbuf->b_ffname, true); + file_name = u_get_undo_file_name(curbuf->b_ffname, true); if (file_name == NULL) { return; } diff --git a/src/nvim/window.c b/src/nvim/window.c index 38597b8b77..ee0d19b1fe 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1554,9 +1554,9 @@ static void win_init(win_T *newp, win_T *oldp, int flags) copy_loclist_stack(oldp, newp); } newp->w_localdir = (oldp->w_localdir == NULL) - ? NULL : vim_strsave(oldp->w_localdir); + ? NULL : xstrdup(oldp->w_localdir); newp->w_prevdir = (oldp->w_prevdir == NULL) - ? NULL : vim_strsave(oldp->w_prevdir); + ? NULL : xstrdup(oldp->w_prevdir); // copy tagstack and folds for (i = 0; i < oldp->w_tagstacklen; i++) { @@ -4076,7 +4076,7 @@ int win_new_tabpage(int after, char_u *filename) } newtp->tp_localdir = old_curtab->tp_localdir - ? vim_strsave(old_curtab->tp_localdir) : NULL; + ? xstrdup(old_curtab->tp_localdir) : NULL; curtab = newtp; @@ -4899,8 +4899,7 @@ static void win_enter_ext(win_T *const wp, const int flags) void fix_current_dir(void) { // New directory is either the local directory of the window, tab or NULL. - char *new_dir = (char *)(curwin->w_localdir - ? curwin->w_localdir : curtab->tp_localdir); + char *new_dir = curwin->w_localdir ? curwin->w_localdir : curtab->tp_localdir; char cwd[MAXPATHL]; if (os_dirname((char_u *)cwd, MAXPATHL) != OK) { cwd[0] = NUL; @@ -6484,7 +6483,7 @@ char_u *grab_file_name(long count, linenr_T *file_lnum) *file_lnum = getdigits_long(&p, false, 0); } - return find_file_name_in_path(ptr, len, options, count, curbuf->b_ffname); + return find_file_name_in_path(ptr, len, options, count, (char_u *)curbuf->b_ffname); } return file_name_at_cursor(options | FNAME_HYP, count, file_lnum); } @@ -6505,7 +6504,7 @@ char_u *grab_file_name(long count, linenr_T *file_lnum) char_u *file_name_at_cursor(int options, long count, linenr_T *file_lnum) { return file_name_in_line(get_cursor_line_ptr(), - curwin->w_cursor.col, options, count, curbuf->b_ffname, + curwin->w_cursor.col, options, count, (char_u *)curbuf->b_ffname, file_lnum); } |